From 8faee5c9f67e9a5389754f90ded6983e669aae15 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 26 Apr 2019 17:24:00 -0700 Subject: [Keyboard] Update Gergo to use newer Ergodox Matrix code (#5703) * [Keyboard] Update Gergo to use newer Ergodox Matrix code And update layout macros to be correct * Almost forgot the json file * Remove board specific defines for i2c timeout --- keyboards/gergo/gergo.c | 16 +-- keyboards/gergo/gergo.h | 18 +-- keyboards/gergo/i2cmaster.h | 178 ----------------------- keyboards/gergo/info.json | 42 +++--- keyboards/gergo/keymaps/default/config.h | 3 + keyboards/gergo/keymaps/default/keymap.c | 75 ++++------ keyboards/gergo/keymaps/drashna/keymap.c | 119 +++++++++++++++ keyboards/gergo/keymaps/drashna/rules.mk | 0 keyboards/gergo/keymaps/germ/config.h | 3 + keyboards/gergo/keymaps/germ/keymap.c | 75 ++++------ keyboards/gergo/matrix.c | 239 +++++++++++++------------------ keyboards/gergo/rules.mk | 2 + 12 files changed, 317 insertions(+), 453 deletions(-) delete mode 100644 keyboards/gergo/i2cmaster.h create mode 100644 keyboards/gergo/keymaps/default/config.h create mode 100644 keyboards/gergo/keymaps/drashna/keymap.c create mode 100644 keyboards/gergo/keymaps/drashna/rules.mk create mode 100644 keyboards/gergo/keymaps/germ/config.h (limited to 'keyboards') diff --git a/keyboards/gergo/gergo.c b/keyboards/gergo/gergo.c index cc0bef391..fab8d0f44 100644 --- a/keyboards/gergo/gergo.c +++ b/keyboards/gergo/gergo.c @@ -43,20 +43,20 @@ uint8_t init_mcp23018(void) { // - unused : input : 1 // - input : input : 1 // - driving : output : 0 - mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(IODIRA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b10000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(IODIRA, I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b10000000, I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); if (mcp23018_status) goto out; i2c_stop(); // set pull-up // - unused : on : 1 // - input : on : 1 // - driving : off : 0 - mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(GPPUA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b10000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; - mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(GPPUA, I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b10000000, I2C_TIMEOUT); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); if (mcp23018_status) goto out; out: i2c_stop(); diff --git a/keyboards/gergo/gergo.h b/keyboards/gergo/gergo.h index 0292c512a..1370325f2 100644 --- a/keyboards/gergo/gergo.h +++ b/keyboards/gergo/gergo.h @@ -1,14 +1,14 @@ #pragma once -#include + +#include "quantum.h" #include #include -#include "quantum.h" #include "i2c_master.h" -#include "matrix.h" +#include extern i2c_status_t mcp23018_status; -#define ERGODOX_EZ_I2C_TIMEOUT 1000 +#define I2C_TIMEOUT 1000 #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) #define CPU_16MHz 0x00 @@ -26,18 +26,14 @@ extern i2c_status_t mcp23018_status; #define OLATA 0x14 // output latch register #define OLATB 0x15 -void init_ergodox(void); uint8_t init_mcp23018(void); /* ---------- LEFT HAND ----------- ---------- RIGHT HAND ---------- */ -#define LAYOUT_GERGO( \ +#define LAYOUT_gergo( \ L00,L01,L02,L03,L04,L05, R00,R01,R02,R03,R04,R05, \ L10,L11,L12,L13,L14,L15,L16, R10,R11,R12,R13,R14,R15,R16, \ - L20,L21,L22,L23,L24,L25,L26, R20,R21,R22,R23,R24,R25,R26, \ - L31,L32, R33,R34, \ - L30, R30, \ - L33,L34, R31,R32) \ - \ + L20,L21,L22,L23,L24,L25,L26,L30, R30,R20,R21,R22,R23,R24,R25,R26, \ + L31,L32,L33,L34, R31,R32,R33,R34) \ /* matrix positions */ \ { \ { KC_NO, L16, L26, L30}, \ diff --git a/keyboards/gergo/i2cmaster.h b/keyboards/gergo/i2cmaster.h deleted file mode 100644 index 72e050849..000000000 --- a/keyboards/gergo/i2cmaster.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef _I2CMASTER_H -#define _I2CMASTER_H 1 -/************************************************************************* -* Title: C include file for the I2C master interface -* (i2cmaster.S or twimaster.c) -* Author: Peter Fleury http://jump.to/fleury -* File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $ -* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3 -* Target: any AVR device -* Usage: see Doxygen manual -**************************************************************************/ - -#ifdef DOXYGEN -/** - @defgroup pfleury_ic2master I2C Master library - @code #include @endcode - - @brief I2C (TWI) Master Software Library - - Basic routines for communicating with I2C slave devices. This single master - implementation is limited to one bus master on the I2C bus. - - This I2c library is implemented as a compact assembler software implementation of the I2C protocol - which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c). - Since the API for these two implementations is exactly the same, an application can be linked either against the - software I2C implementation or the hardware I2C implementation. - - Use 4.7k pull-up resistor on the SDA and SCL pin. - - Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module - i2cmaster.S to your target when using the software I2C implementation ! - - Adjust the CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion. - - @note - The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted - to GNU assembler and AVR-GCC C call interface. - Replaced the incorrect quarter period delays found in AVR300 with - half period delays. - - @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury - - @par API Usage Example - The following code shows typical usage of this library, see example test_i2cmaster.c - - @code - - #include - - - #define Dev24C02 0xA2 // device address of EEPROM 24C02, see datasheet - - int main(void) - { - unsigned char ret; - - i2c_init(); // initialize I2C library - - // write 0x75 to EEPROM address 5 (Byte Write) - i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode - i2c_write(0x05); // write address = 5 - i2c_write(0x75); // write value 0x75 to EEPROM - i2c_stop(); // set stop conditon = release bus - - - // read previously written value back from EEPROM address 5 - i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode - - i2c_write(0x05); // write address = 5 - i2c_rep_start(Dev24C02+I2C_READ); // set device address and read mode - - ret = i2c_readNak(); // read one byte from EEPROM - i2c_stop(); - - for(;;); - } - @endcode - -*/ -#endif /* DOXYGEN */ - -/**@{*/ - -#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 -#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" -#endif - -#include - -/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */ -#define I2C_READ 1 - -/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */ -#define I2C_WRITE 0 - - -/** - @brief initialize the I2C master interace. Need to be called only once - @param void - @return none - */ -void i2c_init(void); - - -/** - @brief Terminates the data transfer and releases the I2C bus - @param void - @return none - */ -void i2c_stop(void); - - -/** - @brief Issues a start condition and sends address and transfer direction - - @param addr address and transfer direction of I2C device - @retval 0 device accessible - @retval 1 failed to access device - */ -unsigned char i2c_start(unsigned char addr); - - -/** - @brief Issues a repeated start condition and sends address and transfer direction - - @param addr address and transfer direction of I2C device - @retval 0 device accessible - @retval 1 failed to access device - */ -unsigned char i2c_rep_start(unsigned char addr); - - -/** - @brief Issues a start condition and sends address and transfer direction - - If device is busy, use ack polling to wait until device ready - @param addr address and transfer direction of I2C device - @return none - */ -void i2c_start_wait(unsigned char addr); - - -/** - @brief Send one byte to I2C device - @param data byte to be transfered - @retval 0 write successful - @retval 1 write failed - */ -unsigned char i2c_write(unsigned char data); - - -/** - @brief read one byte from the I2C device, request more data from device - @return byte read from I2C device - */ -unsigned char i2c_readAck(void); - -/** - @brief read one byte from the I2C device, read is followed by a stop condition - @return byte read from I2C device - */ -unsigned char i2c_readNak(void); - -/** - @brief read one byte from the I2C device - - Implemented as a macro, which calls either i2c_readAck or i2c_readNak - - @param ack 1 send ack, request more data from device
- 0 send nak, read is followed by a stop condition - @return byte read from I2C device - */ -unsigned char i2c_read(unsigned char ack); -#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); - - -/**@}*/ -#endif diff --git a/keyboards/gergo/info.json b/keyboards/gergo/info.json index cacbda423..586b9c908 100644 --- a/keyboards/gergo/info.json +++ b/keyboards/gergo/info.json @@ -5,7 +5,7 @@ "keyboard_name": "Gergo", "url": "http://gboards.ca", "layouts": { - "LAYOUT_GERGO": { + "LAYOUT_gergo": { "layout": [ { "label": "L00", @@ -180,6 +180,16 @@ "x": 6.5, "y": 1.75 }, + { + "label": "L30", + "x": 8.25, + "y": 2.75 + }, + { + "label": "R30", + "x": 10.25, + "y": 2.75 + }, { "h": 1.5, "label": "R20", @@ -227,26 +237,6 @@ "x": 6, "y": 3.63 }, - { - "label": "R33", - "x": 12.5, - "y": 3.63 - }, - { - "label": "R34", - "x": 13.75, - "y": 3.25 - }, - { - "label": "L30", - "x": 8.25, - "y": 2.75 - }, - { - "label": "R30", - "x": 10.25, - "y": 2.75 - }, { "h": 2, "label": "L33", @@ -270,6 +260,16 @@ "label": "R32", "x": 11.25, "y": 3.75 + }, + { + "label": "R33", + "x": 12.5, + "y": 3.63 + }, + { + "label": "R34", + "x": 13.75, + "y": 3.25 } ] } diff --git a/keyboards/gergo/keymaps/default/config.h b/keyboards/gergo/keymaps/default/config.h new file mode 100644 index 000000000..6393d46f1 --- /dev/null +++ b/keyboards/gergo/keymaps/default/config.h @@ -0,0 +1,3 @@ +#pragma once + +#define IGNORE_MOD_TAP_INTERRUPT diff --git a/keyboards/gergo/keymaps/default/keymap.c b/keyboards/gergo/keymaps/default/keymap.c index fabd945fe..8e26223f1 100644 --- a/keyboards/gergo/keymaps/default/keymap.c +++ b/keyboards/gergo/keymaps/default/keymap.c @@ -1,4 +1,4 @@ -/* Good on you for modifying your layout! if you don't have +/* Good on you for modifying your layout! if you don't have * time to read the QMK docs, a list of keycodes can be found at * * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md @@ -8,7 +8,6 @@ #include QMK_KEYBOARD_H -#define IGNORE_MOD_TAP_INTERRUPT #define BASE 0 // default layer #define SYMB 1 // symbols #define NUMB 2 // numbers/motion @@ -41,15 +40,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | | | | | | * `--------------' `--------------' */ -[BASE] = LAYOUT_GERGO( -LT(NUMB, KC_ESC), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_PIPE, -MT(MOD_LCTL, KC_BSPC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_BTN2, KC_TRNS, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, -KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, - - MT(MOD_LGUI, KC_DEL), MT(MOD_LALT, KC_ENT), KC_TAB, KC_BSPC, - - KC_BTN3, KC_PGDN, - LT(SYMB, KC_SPC), LT(NUMB, KC_ESC), LT(SYMB, KC_ENT), LT(NUMB, KC_SPC)), +[BASE] = LAYOUT_gergo( + LT(NUMB, KC_ESC), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_PIPE, + MT(MOD_LCTL, KC_BSPC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_BTN2, KC_TRNS, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BTN3, KC_PGDN, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, + MT(MOD_LGUI, KC_DEL), MT(MOD_LALT, KC_ENT), LT(SYMB, KC_SPC), LT(NUMB, KC_ESC), LT(SYMB, KC_ENT), LT(NUMB, KC_SPC), KC_TAB, KC_BSPC + ), /* Keymap 1: Symbols layer * * ,-------------------------------------------. ,-------------------------------------------. @@ -70,14 +66,12 @@ KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BSP * | | | | | | * `--------------' `--------------' */ -[SYMB] = LAYOUT_GERGO( -KC_TRNS, KC_EXLM, KC_AT, KC_LCBR,KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS, -KC_TRNS, KC_HASH, KC_DLR, KC_LPRN,KC_RPRN, KC_GRV, KC_TRNS, KC_TRNS, KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_PERC, KC_QUOT, -KC_TRNS, KC_PERC, KC_CIRC,KC_LBRC,KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, - - KC_TRNS, KC_TRNS, KC_PGUP, KC_DEL, - KC_TRNS, KC_TRNS, - KC_SCLN, KC_EQL, KC_EQL, KC_SCLN), +[SYMB] = LAYOUT_gergo( + KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS, + KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, KC_TRNS, KC_TRNS, KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_PERC, KC_QUOT, + KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, + KC_TRNS, KC_TRNS, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, KC_PGUP, KC_DEL + ), /* Keymap 2: Pad/Function layer * * ,-------------------------------------------. ,-------------------------------------------. @@ -98,17 +92,15 @@ KC_TRNS, KC_PERC, KC_CIRC,KC_LBRC,KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_ * | | | | | | * `--------------' `--------------' */ -[NUMB] = LAYOUT_GERGO( -KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, -KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLD, KC_VOLU, -KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_MPLY, KC_MNXT, - - KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS, - KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +[NUMB] = LAYOUT_gergo( + KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLD, KC_VOLU, + KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_MPLY, KC_MNXT, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), }; -/* Keymap template +/* Keymap template * * ,-------------------------------------------. ,-------------------------------------------. * | | | | | | | | | | | | | | @@ -127,25 +119,10 @@ KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, K * | | | | | | * | | | | | | * `--------------' `--------------' -[SYMB] = LAYOUT_GERGO( -KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, -KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, -KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), +[SYMB] = LAYOUT_gergo( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ) */ - -// Runs just one time when the keyboard initializes. -void matrix_init_user(void) { - -}; - -// Runs constantly in the background, in a loop. -void matrix_scan_user(void) { - //uint8_t layer = biton32(layer_state); - biton32(layer_state); -}; - - diff --git a/keyboards/gergo/keymaps/drashna/keymap.c b/keyboards/gergo/keymaps/drashna/keymap.c new file mode 100644 index 000000000..a882ff72d --- /dev/null +++ b/keyboards/gergo/keymaps/drashna/keymap.c @@ -0,0 +1,119 @@ +/* Good on you for modifying your layout! if you don't have + * time to read the QMK docs, a list of keycodes can be found at + * + * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md + * + * There's also a template for adding new layers at the bottom of this file! + */ + +#include QMK_KEYBOARD_H +#include "drashna.h" + +// Blank template at the bottom + +enum customKeycodes { + URL = 1 +}; + +#define LAYOUT_gergo_wrapper(...) LAYOUT_gergo(__VA_ARGS__) +#define LAYOUT_gergo_base( \ + K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \ + K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \ + K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A \ + ) \ + LAYOUT_gergo_wrapper( \ + KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_PIPE, \ + KC_TAB, ALT_T(K11), K12, K13, K14, K15, _______, _______, K16, K17, K18, K19, K1A, RGUI_T(KC_QUOT), \ + OS_LSFT, CTL_T(K21), K22, K23, K24, K25, _______, _______, _______, _______, K26, K27, K28, K29, CTL_T(K2A), OS_RSFT, \ + _______, _______, KC_SPC, LT(_LOWER, KC_BSPC), LT(_RAISE, KC_DEL), KC_ENT, _______, _______ \ + ) + +#define LAYOUT_gergo_base_wrapper(...) LAYOUT_gergo_base(__VA_ARGS__) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT_gergo_base_wrapper( + _________________QWERTY_L1_________________, _________________QWERTY_R1_________________, + _________________QWERTY_L2_________________, _________________QWERTY_R2_________________, + _________________QWERTY_L3_________________, _________________QWERTY_R3_________________ + ), + [_COLEMAK] = LAYOUT_gergo_base_wrapper( + _________________COLEMAK_L1________________, _________________COLEMAK_R1________________, + _________________COLEMAK_L2________________, _________________COLEMAK_R2________________, + _________________COLEMAK_L3________________, _________________COLEMAK_R3________________ + ), + + [_DVORAK] = LAYOUT_gergo_base_wrapper( + _________________DVORAK_L1_________________, _________________DVORAK_R1_________________, + _________________DVORAK_L2_________________, _________________DVORAK_R2_________________, + _________________DVORAK_L3_________________, _________________DVORAK_R3_________________ + ), + + [_WORKMAN] = LAYOUT_gergo_base_wrapper( + _________________WORKMAN_L1________________, _________________WORKMAN_R1________________, + _________________WORKMAN_L2________________, _________________WORKMAN_R2________________, + _________________WORKMAN_L3________________, _________________WORKMAN_R3________________ + ), + + [_NORMAN] = LAYOUT_gergo_base_wrapper( + _________________NORMAN_L1_________________, _________________NORMAN_L1_________________, + _________________NORMAN_L2_________________, _________________NORMAN_R2_________________, + _________________NORMAN_L3_________________, _________________NORMAN_R3_________________ + ), + + [_MALTRON] = LAYOUT_gergo_base_wrapper( + _________________MALTRON_L1________________, _________________MALTRON_R1________________, + _________________MALTRON_L2________________, _________________MALTRON_R2________________, + _________________MALTRON_L3________________, _________________MALTRON_R3________________ + ), + + [_EUCALYN] = LAYOUT_gergo_base_wrapper( + _________________EUCALYN_L1________________, _________________EUCALYN_R1________________, + _________________EUCALYN_L2________________, _________________EUCALYN_R2________________, + _________________EUCALYN_L3________________, _________________EUCALYN_R3________________ + ), + + [_CARPLAX] = LAYOUT_gergo_base_wrapper( + _____________CARPLAX_QFMLWY_L1_____________, _____________CARPLAX_QFMLWY_R1_____________, + _____________CARPLAX_QFMLWY_L2_____________, _____________CARPLAX_QFMLWY_R2_____________, + _____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________ + ), + + [_MODS] = LAYOUT_gergo_wrapper( + _______, ___________________BLANK___________________, ___________________BLANK___________________, _______, + _______, ___________________BLANK___________________, _______, _______, ___________________BLANK___________________, _______, + KC_LSFT, ___________________BLANK___________________, _______, _______, _______, _______, ___________________BLANK___________________, KC_RSFT, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + [_LOWER] = LAYOUT_gergo_wrapper( + KC_F12, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_F11, + _______, _________________LOWER_L2__________________, _______, _______, _________________LOWER_R2__________________, KC_PIPE, + _______, _________________LOWER_L3__________________, _______, _______, _______, _______, _________________LOWER_R3__________________, _______, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_RAISE] = LAYOUT_gergo_wrapper( + _______, _________________RAISE_L1__________________, _________________RAISE_R1__________________, _______, + _______, _________________RAISE_L2__________________, _______, _______, _________________RAISE_R2__________________, KC_BSLS, + _______, _________________RAISE_L3__________________, _______, _______, _______, _______, _________________RAISE_R3__________________, _______, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + + [_ADJUST] = LAYOUT_gergo_wrapper( + KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET, + VRSN, _________________ADJUST_L2_________________, _______, KC_NUKE, _________________ADJUST_R2_________________, EEP_RST, + _______, _________________ADJUST_L3_________________, _______, _______, _______, _______, _________________ADJUST_R3_________________, TG_MODS, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + +}; + +/* Keymap template + + [SYMB] = LAYOUT_gergo_wrapper( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + + */ diff --git a/keyboards/gergo/keymaps/drashna/rules.mk b/keyboards/gergo/keymaps/drashna/rules.mk new file mode 100644 index 000000000..e69de29bb diff --git a/keyboards/gergo/keymaps/germ/config.h b/keyboards/gergo/keymaps/germ/config.h new file mode 100644 index 000000000..6393d46f1 --- /dev/null +++ b/keyboards/gergo/keymaps/germ/config.h @@ -0,0 +1,3 @@ +#pragma once + +#define IGNORE_MOD_TAP_INTERRUPT diff --git a/keyboards/gergo/keymaps/germ/keymap.c b/keyboards/gergo/keymaps/germ/keymap.c index fabd945fe..8e26223f1 100644 --- a/keyboards/gergo/keymaps/germ/keymap.c +++ b/keyboards/gergo/keymaps/germ/keymap.c @@ -1,4 +1,4 @@ -/* Good on you for modifying your layout! if you don't have +/* Good on you for modifying your layout! if you don't have * time to read the QMK docs, a list of keycodes can be found at * * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md @@ -8,7 +8,6 @@ #include QMK_KEYBOARD_H -#define IGNORE_MOD_TAP_INTERRUPT #define BASE 0 // default layer #define SYMB 1 // symbols #define NUMB 2 // numbers/motion @@ -41,15 +40,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * | | | | | | * `--------------' `--------------' */ -[BASE] = LAYOUT_GERGO( -LT(NUMB, KC_ESC), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_PIPE, -MT(MOD_LCTL, KC_BSPC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_BTN2, KC_TRNS, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, -KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, - - MT(MOD_LGUI, KC_DEL), MT(MOD_LALT, KC_ENT), KC_TAB, KC_BSPC, - - KC_BTN3, KC_PGDN, - LT(SYMB, KC_SPC), LT(NUMB, KC_ESC), LT(SYMB, KC_ENT), LT(NUMB, KC_SPC)), +[BASE] = LAYOUT_gergo( + LT(NUMB, KC_ESC), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_PIPE, + MT(MOD_LCTL, KC_BSPC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_BTN2, KC_TRNS, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BTN3, KC_PGDN, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, + MT(MOD_LGUI, KC_DEL), MT(MOD_LALT, KC_ENT), LT(SYMB, KC_SPC), LT(NUMB, KC_ESC), LT(SYMB, KC_ENT), LT(NUMB, KC_SPC), KC_TAB, KC_BSPC + ), /* Keymap 1: Symbols layer * * ,-------------------------------------------. ,-------------------------------------------. @@ -70,14 +66,12 @@ KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BSP * | | | | | | * `--------------' `--------------' */ -[SYMB] = LAYOUT_GERGO( -KC_TRNS, KC_EXLM, KC_AT, KC_LCBR,KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS, -KC_TRNS, KC_HASH, KC_DLR, KC_LPRN,KC_RPRN, KC_GRV, KC_TRNS, KC_TRNS, KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_PERC, KC_QUOT, -KC_TRNS, KC_PERC, KC_CIRC,KC_LBRC,KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, - - KC_TRNS, KC_TRNS, KC_PGUP, KC_DEL, - KC_TRNS, KC_TRNS, - KC_SCLN, KC_EQL, KC_EQL, KC_SCLN), +[SYMB] = LAYOUT_gergo( + KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS, + KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, KC_TRNS, KC_TRNS, KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_PERC, KC_QUOT, + KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_SLSH, KC_MINS, + KC_TRNS, KC_TRNS, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, KC_PGUP, KC_DEL + ), /* Keymap 2: Pad/Function layer * * ,-------------------------------------------. ,-------------------------------------------. @@ -98,17 +92,15 @@ KC_TRNS, KC_PERC, KC_CIRC,KC_LBRC,KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_ * | | | | | | * `--------------' `--------------' */ -[NUMB] = LAYOUT_GERGO( -KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, -KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLD, KC_VOLU, -KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_MPLY, KC_MNXT, - - KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS, - KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) +[NUMB] = LAYOUT_gergo( + KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_VOLD, KC_VOLU, + KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_MPLY, KC_MNXT, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), }; -/* Keymap template +/* Keymap template * * ,-------------------------------------------. ,-------------------------------------------. * | | | | | | | | | | | | | | @@ -127,25 +119,10 @@ KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, K * | | | | | | * | | | | | | * `--------------' `--------------' -[SYMB] = LAYOUT_GERGO( -KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, -KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, -KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), +[SYMB] = LAYOUT_gergo( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ) */ - -// Runs just one time when the keyboard initializes. -void matrix_init_user(void) { - -}; - -// Runs constantly in the background, in a loop. -void matrix_scan_user(void) { - //uint8_t layer = biton32(layer_state); - biton32(layer_state); -}; - - diff --git a/keyboards/gergo/matrix.c b/keyboards/gergo/matrix.c index 9886ecf15..aa1dc4842 100644 --- a/keyboards/gergo/matrix.c +++ b/keyboards/gergo/matrix.c @@ -29,10 +29,11 @@ along with this program. If not, see . #include "print.h" #include "debug.h" #include "util.h" +#include "debounce.h" #include "pointing_device.h" #include QMK_KEYBOARD_H #ifdef DEBUG_MATRIX_SCAN_RATE -#include "timer.h" +# include "timer.h" #endif #ifdef BALLER @@ -117,12 +118,11 @@ static matrix_row_t raw_matrix[MATRIX_ROWS]; // Debouncing: store for each key the number of scans until it's eligible to // change. When scanning the matrix, ignore any changes in keys that have // already changed in the last DEBOUNCE scans. -static uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS]; static matrix_row_t read_cols(uint8_t row); -static void init_cols(void); -static void unselect_rows(void); -static void select_row(uint8_t row); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); static void enableInterrupts(void); static uint8_t mcp23018_reset_loop; @@ -134,11 +134,9 @@ uint32_t matrix_scan_count; #endif -__attribute__ ((weak)) -void matrix_init_user(void) {} +__attribute__ ((weak)) void matrix_init_user(void) {} -__attribute__ ((weak)) -void matrix_scan_user(void) {} +__attribute__ ((weak)) void matrix_scan_user(void) {} __attribute__ ((weak)) void matrix_init_kb(void) { @@ -150,39 +148,28 @@ void matrix_scan_kb(void) { matrix_scan_user(); } -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} +inline uint8_t matrix_rows(void) { return MATRIX_ROWS; } -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} +inline uint8_t matrix_cols(void) { return MATRIX_COLS; } -void matrix_init(void) -{ +void matrix_init(void) { // initialize row and col mcp23018_status = init_mcp23018(); unselect_rows(); init_cols(); - // initialize matrix state: all keys off - for (uint8_t i=0; i < MATRIX_ROWS; i++) { - matrix[i] = 0; - raw_matrix[i] = 0; - for (uint8_t j=0; j < MATRIX_COLS; ++j) { - debounce_matrix[i * MATRIX_COLS + j] = 0; - } - } + // initialize matrix state: all keys off + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + raw_matrix[i] = 0; + } #ifdef DEBUG_MATRIX_SCAN_RATE - matrix_timer = timer_read32(); + matrix_timer = timer_read32(); matrix_scan_count = 0; #endif + debounce_init(MATRIX_ROWS); matrix_init_quantum(); } @@ -198,130 +185,120 @@ void matrix_power_up(void) { } #ifdef DEBUG_MATRIX_SCAN_RATE - matrix_timer = timer_read32(); + matrix_timer = timer_read32(); matrix_scan_count = 0; #endif } -// Returns a matrix_row_t whose bits are set if the corresponding key should be -// eligible to change in this scan. -matrix_row_t debounce_mask(matrix_row_t rawcols, uint8_t row) { - matrix_row_t result = 0; - matrix_row_t change = rawcols ^ raw_matrix[row]; - raw_matrix[row] = rawcols; - for (uint8_t i = 0; i < MATRIX_COLS; ++i) { - if (debounce_matrix[row * MATRIX_COLS + i]) { - --debounce_matrix[row * MATRIX_COLS + i]; - } else { - result |= (1 << i); - } - if (change & (1 << i)) { - debounce_matrix[row * MATRIX_COLS + i] = DEBOUNCE; - } +// Reads and stores a row, returning +// whether a change occurred. +static inline bool store_raw_matrix_row(uint8_t index) { + matrix_row_t temp = read_cols(index); + if (raw_matrix[index] != temp) { + raw_matrix[index] = temp; + return true; } - return result; + return false; } -matrix_row_t debounce_read_cols(uint8_t row) { - // Read the row without debouncing filtering and store it for later usage. - matrix_row_t cols = read_cols(row); - // Get the Debounce mask. - matrix_row_t mask = debounce_mask(cols, row); - // debounce the row and return the result. - return (cols & mask) | (matrix[row] & ~mask);; -} -uint8_t matrix_scan(void) -{ - // TODO: Find what is trashing interrupts - enableInterrupts(); - // First we handle the mouse inputs - #ifdef BALLER - uint8_t pBtn = PINE & TRKBTN; +uint8_t matrix_scan(void) { + // TODO: Find what is trashing interrupts + enableInterrupts(); + + // First we handle the mouse inputs +#ifdef BALLER + uint8_t pBtn = PINE & TRKBTN; - #ifdef DEBUG_BALLER - // Compare to previous, mod report - if (tbUpCnt + tbDnCnt + tbLtCnt + tbRtCnt != 0) - xprintf("U: %d D: %d L: %d R: %d B: %d\n", tbUpCnt, tbDnCnt, tbLtCnt, tbRtCnt, (trkBtnState >> 6)); - #endif + #ifdef DEBUG_BALLER + // Compare to previous, mod report + if (tbUpCnt + tbDnCnt + tbLtCnt + tbRtCnt != 0) + xprintf("U: %d D: %d L: %d R: %d B: %d\n", tbUpCnt, tbDnCnt, tbLtCnt, tbRtCnt, (trkBtnState >> 6)); + #endif - // Modify the report - report_mouse_t pRprt = pointing_device_get_report(); + // Modify the report + report_mouse_t pRprt = pointing_device_get_report(); - // Scroll by default, move on layer - if (layer_state == 0) { + // Scroll by default, move on layer + if (layer_state == 0) { pRprt.h += tbLtCnt * SCROLLSTEP; tbLtCnt = 0; pRprt.h -= tbRtCnt * SCROLLSTEP; tbRtCnt = 0; pRprt.v -= tbUpCnt * SCROLLSTEP; tbUpCnt = 0; pRprt.v += tbDnCnt * SCROLLSTEP; tbDnCnt = 0; - } else { + } else { pRprt.x -= tbLtCnt * TRKSTEP * (layer_state - 1); tbLtCnt = 0; pRprt.x += tbRtCnt * TRKSTEP * (layer_state - 1); tbRtCnt = 0; pRprt.y -= tbUpCnt * TRKSTEP * (layer_state - 1); tbUpCnt = 0; pRprt.y += tbDnCnt * TRKSTEP * (layer_state - 1); tbDnCnt = 0; - } + } - #ifdef DEBUG_BALLER - if (pRprt.x != 0 || pRprt.y != 0) - xprintf("X: %d Y: %d\n", pRprt.x, pRprt.y); - #endif - - if ((pBtn != trkBtnState) && ((pBtn >> 6) == 0)) pRprt.buttons |= MOUSE_BTN1; - if ((pBtn != trkBtnState) && ((pBtn >> 6) == 1)) pRprt.buttons &= ~MOUSE_BTN1; - - // Save state, push update - if (pRprt.x != 0 || pRprt.y != 0 || pRprt.h != 0 || pRprt.v != 0 || (trkBtnState != pBtn)) - pointing_device_set_report(pRprt); - - trkBtnState = pBtn; - #endif - - // Then the keyboard - if (mcp23018_status) { // if there was an error - if (++mcp23018_reset_loop == 0) { - // if (++mcp23018_reset_loop >= 1300) { - // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans - // this will be approx bit more frequent than once per second - print("trying to reset mcp23018\n"); - mcp23018_status = init_mcp23018(); - if (mcp23018_status) { - print("left side not responding\n"); - } else { - print("left side attached\n"); - } - } - } +#ifdef DEBUG_BALLER + if (pRprt.x != 0 || pRprt.y != 0) + xprintf("X: %d Y: %d\n", pRprt.x, pRprt.y); +#endif + + if ((pBtn != trkBtnState) && ((pBtn >> 6) == 0)) pRprt.buttons |= MOUSE_BTN1; + if ((pBtn != trkBtnState) && ((pBtn >> 6) == 1)) pRprt.buttons &= ~MOUSE_BTN1; + + // Save state, push update + if (pRprt.x != 0 || pRprt.y != 0 || pRprt.h != 0 || pRprt.v != 0 || (trkBtnState != pBtn)) + pointing_device_set_report(pRprt); + + trkBtnState = pBtn; +#endif + + // Then the keyboard + if (mcp23018_status) { // if there was an error + if (++mcp23018_reset_loop == 0) { + // if (++mcp23018_reset_loop >= 1300) { + // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans + // this will be approx bit more frequent than once per second + print("trying to reset mcp23018\n"); + mcp23018_status = init_mcp23018(); + if (mcp23018_status) { + print("left side not responding\n"); + } else { + print("left side attached\n"); + } + } + } #ifdef DEBUG_MATRIX_SCAN_RATE matrix_scan_count++; + uint32_t timer_now = timer_read32(); - if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { + if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { print("matrix scan frequency: "); pdec(matrix_scan_count); print("\n"); - matrix_timer = timer_now; + matrix_timer = timer_now; matrix_scan_count = 0; } #endif + + bool changed = false; for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { - select_row(i); - // and select on left hand - select_row(i + MATRIX_ROWS_PER_SIDE); + // select rows from left and right hands + uint8_t left_index = i; + uint8_t right_index = i + MATRIX_ROWS_PER_SIDE; + select_row(left_index); + select_row(right_index); + // we don't need a 30us delay anymore, because selecting a // left-hand row requires more than 30us for i2c. - // grab cols from left hand - matrix[i] = debounce_read_cols(i); - // grab cols from right hand - matrix[i + MATRIX_ROWS_PER_SIDE] = debounce_read_cols(i + MATRIX_ROWS_PER_SIDE); + changed |= store_raw_matrix_row(left_index); + changed |= store_raw_matrix_row(right_index); unselect_rows(); } + debounce(raw_matrix, matrix, MATRIX_ROWS, changed); matrix_scan_quantum(); + enableInterrupts(); #ifdef DEBUG_MATRIX @@ -338,20 +315,11 @@ bool matrix_is_modified(void) // deprecated and evidently not called. return true; } -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & ((matrix_row_t)1<