aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-04-26 17:24:00 -0700
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-04-26 17:24:00 -0700
commit8faee5c9f67e9a5389754f90ded6983e669aae15 (patch)
tree1e3a1eb1a65e01a0c22aaafaeccc1fd657ce7a4b
parentffd10d41168a7bf3eb2631490c61fb7a552fa6a6 (diff)
downloadqmk_firmware-8faee5c9f67e9a5389754f90ded6983e669aae15.tar.gz
qmk_firmware-8faee5c9f67e9a5389754f90ded6983e669aae15.zip
[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
-rw-r--r--keyboards/gergo/gergo.c16
-rw-r--r--keyboards/gergo/gergo.h18
-rw-r--r--keyboards/gergo/i2cmaster.h178
-rw-r--r--keyboards/gergo/info.json42
-rw-r--r--keyboards/gergo/keymaps/default/config.h3
-rw-r--r--keyboards/gergo/keymaps/default/keymap.c75
-rw-r--r--keyboards/gergo/keymaps/drashna/keymap.c119
-rw-r--r--keyboards/gergo/keymaps/drashna/rules.mk0
-rw-r--r--keyboards/gergo/keymaps/germ/config.h3
-rw-r--r--keyboards/gergo/keymaps/germ/keymap.c75
-rw-r--r--keyboards/gergo/matrix.c239
-rw-r--r--keyboards/gergo/rules.mk2
12 files changed, 317 insertions, 453 deletions
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) {
43 // - unused : input : 1 43 // - unused : input : 1
44 // - input : input : 1 44 // - input : input : 1
45 // - driving : output : 0 45 // - driving : output : 0
46 mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 46 mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
47 mcp23018_status = i2c_write(IODIRA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 47 mcp23018_status = i2c_write(IODIRA, I2C_TIMEOUT); if (mcp23018_status) goto out;
48 mcp23018_status = i2c_write(0b10000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 48 mcp23018_status = i2c_write(0b10000000, I2C_TIMEOUT); if (mcp23018_status) goto out;
49 mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 49 mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); if (mcp23018_status) goto out;
50 i2c_stop(); 50 i2c_stop();
51 51
52 // set pull-up 52 // set pull-up
53 // - unused : on : 1 53 // - unused : on : 1
54 // - input : on : 1 54 // - input : on : 1
55 // - driving : off : 0 55 // - driving : off : 0
56 mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 56 mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
57 mcp23018_status = i2c_write(GPPUA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 57 mcp23018_status = i2c_write(GPPUA, I2C_TIMEOUT); if (mcp23018_status) goto out;
58 mcp23018_status = i2c_write(0b10000000, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 58 mcp23018_status = i2c_write(0b10000000, I2C_TIMEOUT); if (mcp23018_status) goto out;
59 mcp23018_status = i2c_write(0b11111111, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 59 mcp23018_status = i2c_write(0b11111111, I2C_TIMEOUT); if (mcp23018_status) goto out;
60 60
61out: 61out:
62 i2c_stop(); 62 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 @@
1#pragma once 1#pragma once
2#include <util/delay.h> 2
3#include "quantum.h"
3#include <stdint.h> 4#include <stdint.h>
4#include <stdbool.h> 5#include <stdbool.h>
5#include "quantum.h"
6#include "i2c_master.h" 6#include "i2c_master.h"
7#include "matrix.h" 7#include <util/delay.h>
8 8
9 9
10extern i2c_status_t mcp23018_status; 10extern i2c_status_t mcp23018_status;
11#define ERGODOX_EZ_I2C_TIMEOUT 1000 11#define I2C_TIMEOUT 1000
12#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) 12#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
13#define CPU_16MHz 0x00 13#define CPU_16MHz 0x00
14 14
@@ -26,18 +26,14 @@ extern i2c_status_t mcp23018_status;
26#define OLATA 0x14 // output latch register 26#define OLATA 0x14 // output latch register
27#define OLATB 0x15 27#define OLATB 0x15
28 28
29void init_ergodox(void);
30uint8_t init_mcp23018(void); 29uint8_t init_mcp23018(void);
31 30
32/* ---------- LEFT HAND ----------- ---------- RIGHT HAND ---------- */ 31/* ---------- LEFT HAND ----------- ---------- RIGHT HAND ---------- */
33#define LAYOUT_GERGO( \ 32#define LAYOUT_gergo( \
34 L00,L01,L02,L03,L04,L05, R00,R01,R02,R03,R04,R05, \ 33 L00,L01,L02,L03,L04,L05, R00,R01,R02,R03,R04,R05, \
35 L10,L11,L12,L13,L14,L15,L16, R10,R11,R12,R13,R14,R15,R16, \ 34 L10,L11,L12,L13,L14,L15,L16, R10,R11,R12,R13,R14,R15,R16, \
36 L20,L21,L22,L23,L24,L25,L26, R20,R21,R22,R23,R24,R25,R26, \ 35 L20,L21,L22,L23,L24,L25,L26,L30, R30,R20,R21,R22,R23,R24,R25,R26, \
37 L31,L32, R33,R34, \ 36 L31,L32,L33,L34, R31,R32,R33,R34) \
38 L30, R30, \
39 L33,L34, R31,R32) \
40 \
41 /* matrix positions */ \ 37 /* matrix positions */ \
42 { \ 38 { \
43 { KC_NO, L16, L26, L30}, \ 39 { 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 @@
1#ifndef _I2CMASTER_H
2#define _I2CMASTER_H 1
3/*************************************************************************
4* Title: C include file for the I2C master interface
5* (i2cmaster.S or twimaster.c)
6* Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
7* File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $
8* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3
9* Target: any AVR device
10* Usage: see Doxygen manual
11**************************************************************************/
12
13#ifdef DOXYGEN
14/**
15 @defgroup pfleury_ic2master I2C Master library
16 @code #include <i2cmaster.h> @endcode
17
18 @brief I2C (TWI) Master Software Library
19
20 Basic routines for communicating with I2C slave devices. This single master
21 implementation is limited to one bus master on the I2C bus.
22
23 This I2c library is implemented as a compact assembler software implementation of the I2C protocol
24 which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c).
25 Since the API for these two implementations is exactly the same, an application can be linked either against the
26 software I2C implementation or the hardware I2C implementation.
27
28 Use 4.7k pull-up resistor on the SDA and SCL pin.
29
30 Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module
31 i2cmaster.S to your target when using the software I2C implementation !
32
33 Adjust the CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion.
34
35 @note
36 The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted
37 to GNU assembler and AVR-GCC C call interface.
38 Replaced the incorrect quarter period delays found in AVR300 with
39 half period delays.
40
41 @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
42
43 @par API Usage Example
44 The following code shows typical usage of this library, see example test_i2cmaster.c
45
46 @code
47
48 #include <i2cmaster.h>
49
50
51 #define Dev24C02 0xA2 // device address of EEPROM 24C02, see datasheet
52
53 int main(void)
54 {
55 unsigned char ret;
56
57 i2c_init(); // initialize I2C library
58
59 // write 0x75 to EEPROM address 5 (Byte Write)
60 i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode
61 i2c_write(0x05); // write address = 5
62 i2c_write(0x75); // write value 0x75 to EEPROM
63 i2c_stop(); // set stop conditon = release bus
64
65
66 // read previously written value back from EEPROM address 5
67 i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode
68
69 i2c_write(0x05); // write address = 5
70 i2c_rep_start(Dev24C02+I2C_READ); // set device address and read mode
71
72 ret = i2c_readNak(); // read one byte from EEPROM
73 i2c_stop();
74
75 for(;;);
76 }
77 @endcode
78
79*/
80#endif /* DOXYGEN */
81
82/**@{*/
83
84#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304
85#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !"
86#endif
87
88#include <avr/io.h>
89
90/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */
91#define I2C_READ 1
92
93/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */
94#define I2C_WRITE 0
95
96
97/**
98 @brief initialize the I2C master interace. Need to be called only once
99 @param void
100 @return none
101 */
102void i2c_init(void);
103
104
105/**
106 @brief Terminates the data transfer and releases the I2C bus
107 @param void
108 @return none
109 */
110void i2c_stop(void);
111
112
113/**
114 @brief Issues a start condition and sends address and transfer direction
115
116 @param addr address and transfer direction of I2C device
117 @retval 0 device accessible
118 @retval 1 failed to access device
119 */
120unsigned char i2c_start(unsigned char addr);
121
122
123/**
124 @brief Issues a repeated start condition and sends address and transfer direction
125
126 @param addr address and transfer direction of I2C device
127 @retval 0 device accessible
128 @retval 1 failed to access device
129 */
130unsigned char i2c_rep_start(unsigned char addr);
131
132
133/**
134 @brief Issues a start condition and sends address and transfer direction
135
136 If device is busy, use ack polling to wait until device ready
137 @param addr address and transfer direction of I2C device
138 @return none
139 */
140void i2c_start_wait(unsigned char addr);
141
142
143/**
144 @brief Send one byte to I2C device
145 @param data byte to be transfered
146 @retval 0 write successful
147 @retval 1 write failed
148 */
149unsigned char i2c_write(unsigned char data);
150
151
152/**
153 @brief read one byte from the I2C device, request more data from device
154 @return byte read from I2C device
155 */
156unsigned char i2c_readAck(void);
157
158/**
159 @brief read one byte from the I2C device, read is followed by a stop condition
160 @return byte read from I2C device
161 */
162unsigned char i2c_readNak(void);
163
164/**
165 @brief read one byte from the I2C device
166
167 Implemented as a macro, which calls either i2c_readAck or i2c_readNak
168
169 @param ack 1 send ack, request more data from device<br>
170 0 send nak, read is followed by a stop condition
171 @return byte read from I2C device
172 */
173unsigned char i2c_read(unsigned char ack);
174#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
175
176
177/**@}*/
178#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 @@
5 "keyboard_name": "Gergo", 5 "keyboard_name": "Gergo",
6 "url": "http://gboards.ca", 6 "url": "http://gboards.ca",
7 "layouts": { 7 "layouts": {
8 "LAYOUT_GERGO": { 8 "LAYOUT_gergo": {
9 "layout": [ 9 "layout": [
10 { 10 {
11 "label": "L00", 11 "label": "L00",
@@ -181,6 +181,16 @@
181 "y": 1.75 181 "y": 1.75
182 }, 182 },
183 { 183 {
184 "label": "L30",
185 "x": 8.25,
186 "y": 2.75
187 },
188 {
189 "label": "R30",
190 "x": 10.25,
191 "y": 2.75
192 },
193 {
184 "h": 1.5, 194 "h": 1.5,
185 "label": "R20", 195 "label": "R20",
186 "x": 12, 196 "x": 12,
@@ -228,26 +238,6 @@
228 "y": 3.63 238 "y": 3.63
229 }, 239 },
230 { 240 {
231 "label": "R33",
232 "x": 12.5,
233 "y": 3.63
234 },
235 {
236 "label": "R34",
237 "x": 13.75,
238 "y": 3.25
239 },
240 {
241 "label": "L30",
242 "x": 8.25,
243 "y": 2.75
244 },
245 {
246 "label": "R30",
247 "x": 10.25,
248 "y": 2.75
249 },
250 {
251 "h": 2, 241 "h": 2,
252 "label": "L33", 242 "label": "L33",
253 "x": 7.25, 243 "x": 7.25,
@@ -270,6 +260,16 @@
270 "label": "R32", 260 "label": "R32",
271 "x": 11.25, 261 "x": 11.25,
272 "y": 3.75 262 "y": 3.75
263 },
264 {
265 "label": "R33",
266 "x": 12.5,
267 "y": 3.63
268 },
269 {
270 "label": "R34",
271 "x": 13.75,
272 "y": 3.25
273 } 273 }
274 ] 274 ]
275 } 275 }
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 @@
1#pragma once
2
3#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 @@
1/* Good on you for modifying your layout! if you don't have 1/* Good on you for modifying your layout! if you don't have
2 * time to read the QMK docs, a list of keycodes can be found at 2 * time to read the QMK docs, a list of keycodes can be found at
3 * 3 *
4 * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md 4 * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md
@@ -8,7 +8,6 @@
8 8
9#include QMK_KEYBOARD_H 9#include QMK_KEYBOARD_H
10 10
11#define IGNORE_MOD_TAP_INTERRUPT
12#define BASE 0 // default layer 11#define BASE 0 // default layer
13#define SYMB 1 // symbols 12#define SYMB 1 // symbols
14#define NUMB 2 // numbers/motion 13#define NUMB 2 // numbers/motion
@@ -41,15 +40,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
41 * | | | | | | 40 * | | | | | |
42 * `--------------' `--------------' 41 * `--------------' `--------------'
43 */ 42 */
44[BASE] = LAYOUT_GERGO( 43[BASE] = LAYOUT_gergo(
45LT(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, 44 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,
46MT(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, 45 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,
47KC_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, 46 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,
48 47 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
49 MT(MOD_LGUI, KC_DEL), MT(MOD_LALT, KC_ENT), KC_TAB, KC_BSPC, 48 ),
50
51 KC_BTN3, KC_PGDN,
52 LT(SYMB, KC_SPC), LT(NUMB, KC_ESC), LT(SYMB, KC_ENT), LT(NUMB, KC_SPC)),
53/* Keymap 1: Symbols layer 49/* Keymap 1: Symbols layer
54 * 50 *
55 * ,-------------------------------------------. ,-------------------------------------------. 51 * ,-------------------------------------------. ,-------------------------------------------.
@@ -70,14 +66,12 @@ KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BSP
70 * | | | | | | 66 * | | | | | |
71 * `--------------' `--------------' 67 * `--------------' `--------------'
72 */ 68 */
73[SYMB] = LAYOUT_GERGO( 69[SYMB] = LAYOUT_gergo(
74KC_TRNS, KC_EXLM, KC_AT, KC_LCBR,KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS, 70 KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS,
75KC_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, 71 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,
76KC_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, 72 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,
77 73 KC_TRNS, KC_TRNS, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, KC_PGUP, KC_DEL
78 KC_TRNS, KC_TRNS, KC_PGUP, KC_DEL, 74 ),
79 KC_TRNS, KC_TRNS,
80 KC_SCLN, KC_EQL, KC_EQL, KC_SCLN),
81/* Keymap 2: Pad/Function layer 75/* Keymap 2: Pad/Function layer
82 * 76 *
83 * ,-------------------------------------------. ,-------------------------------------------. 77 * ,-------------------------------------------. ,-------------------------------------------.
@@ -98,17 +92,15 @@ KC_TRNS, KC_PERC, KC_CIRC,KC_LBRC,KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_
98 * | | | | | | 92 * | | | | | |
99 * `--------------' `--------------' 93 * `--------------' `--------------'
100 */ 94 */
101[NUMB] = LAYOUT_GERGO( 95[NUMB] = LAYOUT_gergo(
102KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, 96 KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS,
103KC_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, 97 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,
104KC_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, 98 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,
105 99 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
106 KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS, 100 ),
107 KC_TRNS, KC_TRNS,
108 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
109}; 101};
110 102
111/* Keymap template 103/* Keymap template
112 * 104 *
113 * ,-------------------------------------------. ,-------------------------------------------. 105 * ,-------------------------------------------. ,-------------------------------------------.
114 * | | | | | | | | | | | | | | 106 * | | | | | | | | | | | | | |
@@ -127,25 +119,10 @@ KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, K
127 * | | | | | | 119 * | | | | | |
128 * | | | | | | 120 * | | | | | |
129 * `--------------' `--------------' 121 * `--------------' `--------------'
130[SYMB] = LAYOUT_GERGO( 122[SYMB] = LAYOUT_gergo(
131KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 123 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
132KC_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, 124 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,
133KC_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, 125 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,
134 126 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
135 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 127 )
136 KC_TRNS, KC_TRNS,
137 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
138 */ 128 */
139
140// Runs just one time when the keyboard initializes.
141void matrix_init_user(void) {
142
143};
144
145// Runs constantly in the background, in a loop.
146void matrix_scan_user(void) {
147 //uint8_t layer = biton32(layer_state);
148 biton32(layer_state);
149};
150
151
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 @@
1/* Good on you for modifying your layout! if you don't have
2 * time to read the QMK docs, a list of keycodes can be found at
3 *
4 * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md
5 *
6 * There's also a template for adding new layers at the bottom of this file!
7 */
8
9#include QMK_KEYBOARD_H
10#include "drashna.h"
11
12// Blank template at the bottom
13
14enum customKeycodes {
15 URL = 1
16};
17
18#define LAYOUT_gergo_wrapper(...) LAYOUT_gergo(__VA_ARGS__)
19#define LAYOUT_gergo_base( \
20 K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, \
21 K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, \
22 K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A \
23 ) \
24 LAYOUT_gergo_wrapper( \
25 KC_ESC, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, KC_PIPE, \
26 KC_TAB, ALT_T(K11), K12, K13, K14, K15, _______, _______, K16, K17, K18, K19, K1A, RGUI_T(KC_QUOT), \
27 OS_LSFT, CTL_T(K21), K22, K23, K24, K25, _______, _______, _______, _______, K26, K27, K28, K29, CTL_T(K2A), OS_RSFT, \
28 _______, _______, KC_SPC, LT(_LOWER, KC_BSPC), LT(_RAISE, KC_DEL), KC_ENT, _______, _______ \
29 )
30
31#define LAYOUT_gergo_base_wrapper(...) LAYOUT_gergo_base(__VA_ARGS__)
32
33const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
34 [_QWERTY] = LAYOUT_gergo_base_wrapper(
35 _________________QWERTY_L1_________________, _________________QWERTY_R1_________________,
36 _________________QWERTY_L2_________________, _________________QWERTY_R2_________________,
37 _________________QWERTY_L3_________________, _________________QWERTY_R3_________________
38 ),
39 [_COLEMAK] = LAYOUT_gergo_base_wrapper(
40 _________________COLEMAK_L1________________, _________________COLEMAK_R1________________,
41 _________________COLEMAK_L2________________, _________________COLEMAK_R2________________,
42 _________________COLEMAK_L3________________, _________________COLEMAK_R3________________
43 ),
44
45 [_DVORAK] = LAYOUT_gergo_base_wrapper(
46 _________________DVORAK_L1_________________, _________________DVORAK_R1_________________,
47 _________________DVORAK_L2_________________, _________________DVORAK_R2_________________,
48 _________________DVORAK_L3_________________, _________________DVORAK_R3_________________
49 ),
50
51 [_WORKMAN] = LAYOUT_gergo_base_wrapper(
52 _________________WORKMAN_L1________________, _________________WORKMAN_R1________________,
53 _________________WORKMAN_L2________________, _________________WORKMAN_R2________________,
54 _________________WORKMAN_L3________________, _________________WORKMAN_R3________________
55 ),
56
57 [_NORMAN] = LAYOUT_gergo_base_wrapper(
58 _________________NORMAN_L1_________________, _________________NORMAN_L1_________________,
59 _________________NORMAN_L2_________________, _________________NORMAN_R2_________________,
60 _________________NORMAN_L3_________________, _________________NORMAN_R3_________________
61 ),
62
63 [_MALTRON] = LAYOUT_gergo_base_wrapper(
64 _________________MALTRON_L1________________, _________________MALTRON_R1________________,
65 _________________MALTRON_L2________________, _________________MALTRON_R2________________,
66 _________________MALTRON_L3________________, _________________MALTRON_R3________________
67 ),
68
69 [_EUCALYN] = LAYOUT_gergo_base_wrapper(
70 _________________EUCALYN_L1________________, _________________EUCALYN_R1________________,
71 _________________EUCALYN_L2________________, _________________EUCALYN_R2________________,
72 _________________EUCALYN_L3________________, _________________EUCALYN_R3________________
73 ),
74
75 [_CARPLAX] = LAYOUT_gergo_base_wrapper(
76 _____________CARPLAX_QFMLWY_L1_____________, _____________CARPLAX_QFMLWY_R1_____________,
77 _____________CARPLAX_QFMLWY_L2_____________, _____________CARPLAX_QFMLWY_R2_____________,
78 _____________CARPLAX_QFMLWY_L3_____________, _____________CARPLAX_QFMLWY_R3_____________
79 ),
80
81 [_MODS] = LAYOUT_gergo_wrapper(
82 _______, ___________________BLANK___________________, ___________________BLANK___________________, _______,
83 _______, ___________________BLANK___________________, _______, _______, ___________________BLANK___________________, _______,
84 KC_LSFT, ___________________BLANK___________________, _______, _______, _______, _______, ___________________BLANK___________________, KC_RSFT,
85 _______, _______, _______, _______, _______, _______, _______, _______
86 ),
87 [_LOWER] = LAYOUT_gergo_wrapper(
88 KC_F12, _________________LOWER_L1__________________, _________________LOWER_R1__________________, KC_F11,
89 _______, _________________LOWER_L2__________________, _______, _______, _________________LOWER_R2__________________, KC_PIPE,
90 _______, _________________LOWER_L3__________________, _______, _______, _______, _______, _________________LOWER_R3__________________, _______,
91 _______, _______, _______, _______, _______, _______, _______, _______
92 ),
93
94 [_RAISE] = LAYOUT_gergo_wrapper(
95 _______, _________________RAISE_L1__________________, _________________RAISE_R1__________________, _______,
96 _______, _________________RAISE_L2__________________, _______, _______, _________________RAISE_R2__________________, KC_BSLS,
97 _______, _________________RAISE_L3__________________, _______, _______, _______, _______, _________________RAISE_R3__________________, _______,
98 _______, _______, _______, _______, _______, _______, _______, _______
99 ),
100
101 [_ADJUST] = LAYOUT_gergo_wrapper(
102 KC_MAKE, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, KC_RESET,
103 VRSN, _________________ADJUST_L2_________________, _______, KC_NUKE, _________________ADJUST_R2_________________, EEP_RST,
104 _______, _________________ADJUST_L3_________________, _______, _______, _______, _______, _________________ADJUST_R3_________________, TG_MODS,
105 _______, _______, _______, _______, _______, _______, _______, _______
106 ),
107
108};
109
110/* Keymap template
111
112 [SYMB] = LAYOUT_gergo_wrapper(
113 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
114 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
115 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
116 _______, _______, _______, _______, _______, _______, _______, _______
117 ),
118
119 */
diff --git a/keyboards/gergo/keymaps/drashna/rules.mk b/keyboards/gergo/keymaps/drashna/rules.mk
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/keyboards/gergo/keymaps/drashna/rules.mk
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 @@
1#pragma once
2
3#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 @@
1/* Good on you for modifying your layout! if you don't have 1/* Good on you for modifying your layout! if you don't have
2 * time to read the QMK docs, a list of keycodes can be found at 2 * time to read the QMK docs, a list of keycodes can be found at
3 * 3 *
4 * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md 4 * https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md
@@ -8,7 +8,6 @@
8 8
9#include QMK_KEYBOARD_H 9#include QMK_KEYBOARD_H
10 10
11#define IGNORE_MOD_TAP_INTERRUPT
12#define BASE 0 // default layer 11#define BASE 0 // default layer
13#define SYMB 1 // symbols 12#define SYMB 1 // symbols
14#define NUMB 2 // numbers/motion 13#define NUMB 2 // numbers/motion
@@ -41,15 +40,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
41 * | | | | | | 40 * | | | | | |
42 * `--------------' `--------------' 41 * `--------------' `--------------'
43 */ 42 */
44[BASE] = LAYOUT_GERGO( 43[BASE] = LAYOUT_gergo(
45LT(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, 44 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,
46MT(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, 45 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,
47KC_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, 46 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,
48 47 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
49 MT(MOD_LGUI, KC_DEL), MT(MOD_LALT, KC_ENT), KC_TAB, KC_BSPC, 48 ),
50
51 KC_BTN3, KC_PGDN,
52 LT(SYMB, KC_SPC), LT(NUMB, KC_ESC), LT(SYMB, KC_ENT), LT(NUMB, KC_SPC)),
53/* Keymap 1: Symbols layer 49/* Keymap 1: Symbols layer
54 * 50 *
55 * ,-------------------------------------------. ,-------------------------------------------. 51 * ,-------------------------------------------. ,-------------------------------------------.
@@ -70,14 +66,12 @@ KC_RSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_BTN1, KC_BSP
70 * | | | | | | 66 * | | | | | |
71 * `--------------' `--------------' 67 * `--------------' `--------------'
72 */ 68 */
73[SYMB] = LAYOUT_GERGO( 69[SYMB] = LAYOUT_gergo(
74KC_TRNS, KC_EXLM, KC_AT, KC_LCBR,KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS, 70 KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSLS,
75KC_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, 71 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,
76KC_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, 72 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,
77 73 KC_TRNS, KC_TRNS, KC_SCLN, KC_EQL, KC_EQL, KC_SCLN, KC_PGUP, KC_DEL
78 KC_TRNS, KC_TRNS, KC_PGUP, KC_DEL, 74 ),
79 KC_TRNS, KC_TRNS,
80 KC_SCLN, KC_EQL, KC_EQL, KC_SCLN),
81/* Keymap 2: Pad/Function layer 75/* Keymap 2: Pad/Function layer
82 * 76 *
83 * ,-------------------------------------------. ,-------------------------------------------. 77 * ,-------------------------------------------. ,-------------------------------------------.
@@ -98,17 +92,15 @@ KC_TRNS, KC_PERC, KC_CIRC,KC_LBRC,KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_
98 * | | | | | | 92 * | | | | | |
99 * `--------------' `--------------' 93 * `--------------' `--------------'
100 */ 94 */
101[NUMB] = LAYOUT_GERGO( 95[NUMB] = LAYOUT_gergo(
102KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, 96 KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS,
103KC_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, 97 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,
104KC_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, 98 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,
105 99 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
106 KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS, 100 ),
107 KC_TRNS, KC_TRNS,
108 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS)
109}; 101};
110 102
111/* Keymap template 103/* Keymap template
112 * 104 *
113 * ,-------------------------------------------. ,-------------------------------------------. 105 * ,-------------------------------------------. ,-------------------------------------------.
114 * | | | | | | | | | | | | | | 106 * | | | | | | | | | | | | | |
@@ -127,25 +119,10 @@ KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, K
127 * | | | | | | 119 * | | | | | |
128 * | | | | | | 120 * | | | | | |
129 * `--------------' `--------------' 121 * `--------------' `--------------'
130[SYMB] = LAYOUT_GERGO( 122[SYMB] = LAYOUT_gergo(
131KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 123 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
132KC_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, 124 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,
133KC_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, 125 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,
134 126 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
135 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, 127 )
136 KC_TRNS, KC_TRNS,
137 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
138 */ 128 */
139
140// Runs just one time when the keyboard initializes.
141void matrix_init_user(void) {
142
143};
144
145// Runs constantly in the background, in a loop.
146void matrix_scan_user(void) {
147 //uint8_t layer = biton32(layer_state);
148 biton32(layer_state);
149};
150
151
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 <http://www.gnu.org/licenses/>.
29#include "print.h" 29#include "print.h"
30#include "debug.h" 30#include "debug.h"
31#include "util.h" 31#include "util.h"
32#include "debounce.h"
32#include "pointing_device.h" 33#include "pointing_device.h"
33#include QMK_KEYBOARD_H 34#include QMK_KEYBOARD_H
34#ifdef DEBUG_MATRIX_SCAN_RATE 35#ifdef DEBUG_MATRIX_SCAN_RATE
35#include "timer.h" 36# include "timer.h"
36#endif 37#endif
37 38
38#ifdef BALLER 39#ifdef BALLER
@@ -117,12 +118,11 @@ static matrix_row_t raw_matrix[MATRIX_ROWS];
117// Debouncing: store for each key the number of scans until it's eligible to 118// Debouncing: store for each key the number of scans until it's eligible to
118// change. When scanning the matrix, ignore any changes in keys that have 119// change. When scanning the matrix, ignore any changes in keys that have
119// already changed in the last DEBOUNCE scans. 120// already changed in the last DEBOUNCE scans.
120static uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS];
121 121
122static matrix_row_t read_cols(uint8_t row); 122static matrix_row_t read_cols(uint8_t row);
123static void init_cols(void); 123static void init_cols(void);
124static void unselect_rows(void); 124static void unselect_rows(void);
125static void select_row(uint8_t row); 125static void select_row(uint8_t row);
126static void enableInterrupts(void); 126static void enableInterrupts(void);
127 127
128static uint8_t mcp23018_reset_loop; 128static uint8_t mcp23018_reset_loop;
@@ -134,11 +134,9 @@ uint32_t matrix_scan_count;
134#endif 134#endif
135 135
136 136
137__attribute__ ((weak)) 137__attribute__ ((weak)) void matrix_init_user(void) {}
138void matrix_init_user(void) {}
139 138
140__attribute__ ((weak)) 139__attribute__ ((weak)) void matrix_scan_user(void) {}
141void matrix_scan_user(void) {}
142 140
143__attribute__ ((weak)) 141__attribute__ ((weak))
144void matrix_init_kb(void) { 142void matrix_init_kb(void) {
@@ -150,39 +148,28 @@ void matrix_scan_kb(void) {
150 matrix_scan_user(); 148 matrix_scan_user();
151} 149}
152 150
153inline 151inline uint8_t matrix_rows(void) { return MATRIX_ROWS; }
154uint8_t matrix_rows(void)
155{
156 return MATRIX_ROWS;
157}
158 152
159inline 153inline uint8_t matrix_cols(void) { return MATRIX_COLS; }
160uint8_t matrix_cols(void)
161{
162 return MATRIX_COLS;
163}
164 154
165 155
166void matrix_init(void) 156void matrix_init(void) {
167{
168 // initialize row and col 157 // initialize row and col
169 mcp23018_status = init_mcp23018(); 158 mcp23018_status = init_mcp23018();
170 unselect_rows(); 159 unselect_rows();
171 init_cols(); 160 init_cols();
172 161
173 // initialize matrix state: all keys off 162 // initialize matrix state: all keys off
174 for (uint8_t i=0; i < MATRIX_ROWS; i++) { 163 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
175 matrix[i] = 0; 164 matrix[i] = 0;
176 raw_matrix[i] = 0; 165 raw_matrix[i] = 0;
177 for (uint8_t j=0; j < MATRIX_COLS; ++j) { 166 }
178 debounce_matrix[i * MATRIX_COLS + j] = 0;
179 }
180 }
181 167
182#ifdef DEBUG_MATRIX_SCAN_RATE 168#ifdef DEBUG_MATRIX_SCAN_RATE
183 matrix_timer = timer_read32(); 169 matrix_timer = timer_read32();
184 matrix_scan_count = 0; 170 matrix_scan_count = 0;
185#endif 171#endif
172 debounce_init(MATRIX_ROWS);
186 matrix_init_quantum(); 173 matrix_init_quantum();
187} 174}
188 175
@@ -198,130 +185,120 @@ void matrix_power_up(void) {
198 } 185 }
199 186
200#ifdef DEBUG_MATRIX_SCAN_RATE 187#ifdef DEBUG_MATRIX_SCAN_RATE
201 matrix_timer = timer_read32(); 188 matrix_timer = timer_read32();
202 matrix_scan_count = 0; 189 matrix_scan_count = 0;
203#endif 190#endif
204 191
205} 192}
206 193
207// Returns a matrix_row_t whose bits are set if the corresponding key should be 194// Reads and stores a row, returning
208// eligible to change in this scan. 195// whether a change occurred.
209matrix_row_t debounce_mask(matrix_row_t rawcols, uint8_t row) { 196static inline bool store_raw_matrix_row(uint8_t index) {
210 matrix_row_t result = 0; 197 matrix_row_t temp = read_cols(index);
211 matrix_row_t change = rawcols ^ raw_matrix[row]; 198 if (raw_matrix[index] != temp) {
212 raw_matrix[row] = rawcols; 199 raw_matrix[index] = temp;
213 for (uint8_t i = 0; i < MATRIX_COLS; ++i) { 200 return true;
214 if (debounce_matrix[row * MATRIX_COLS + i]) {
215 --debounce_matrix[row * MATRIX_COLS + i];
216 } else {
217 result |= (1 << i);
218 }
219 if (change & (1 << i)) {
220 debounce_matrix[row * MATRIX_COLS + i] = DEBOUNCE;
221 }
222 } 201 }
223 return result; 202 return false;
224} 203}
225 204
226matrix_row_t debounce_read_cols(uint8_t row) {
227 // Read the row without debouncing filtering and store it for later usage.
228 matrix_row_t cols = read_cols(row);
229 // Get the Debounce mask.
230 matrix_row_t mask = debounce_mask(cols, row);
231 // debounce the row and return the result.
232 return (cols & mask) | (matrix[row] & ~mask);;
233}
234 205
235uint8_t matrix_scan(void)
236{
237 // TODO: Find what is trashing interrupts
238 enableInterrupts();
239 206
240 // First we handle the mouse inputs 207uint8_t matrix_scan(void) {
241 #ifdef BALLER 208 // TODO: Find what is trashing interrupts
242 uint8_t pBtn = PINE & TRKBTN; 209 enableInterrupts();
210
211 // First we handle the mouse inputs
212#ifdef BALLER
213 uint8_t pBtn = PINE & TRKBTN;
243 214
244 #ifdef DEBUG_BALLER 215 #ifdef DEBUG_BALLER
245 // Compare to previous, mod report 216 // Compare to previous, mod report
246 if (tbUpCnt + tbDnCnt + tbLtCnt + tbRtCnt != 0) 217 if (tbUpCnt + tbDnCnt + tbLtCnt + tbRtCnt != 0)
247 xprintf("U: %d D: %d L: %d R: %d B: %d\n", tbUpCnt, tbDnCnt, tbLtCnt, tbRtCnt, (trkBtnState >> 6)); 218 xprintf("U: %d D: %d L: %d R: %d B: %d\n", tbUpCnt, tbDnCnt, tbLtCnt, tbRtCnt, (trkBtnState >> 6));
248 #endif 219 #endif
249 220
250 // Modify the report 221 // Modify the report
251 report_mouse_t pRprt = pointing_device_get_report(); 222 report_mouse_t pRprt = pointing_device_get_report();
252 223
253 // Scroll by default, move on layer 224 // Scroll by default, move on layer
254 if (layer_state == 0) { 225 if (layer_state == 0) {
255 pRprt.h += tbLtCnt * SCROLLSTEP; tbLtCnt = 0; 226 pRprt.h += tbLtCnt * SCROLLSTEP; tbLtCnt = 0;
256 pRprt.h -= tbRtCnt * SCROLLSTEP; tbRtCnt = 0; 227 pRprt.h -= tbRtCnt * SCROLLSTEP; tbRtCnt = 0;
257 pRprt.v -= tbUpCnt * SCROLLSTEP; tbUpCnt = 0; 228 pRprt.v -= tbUpCnt * SCROLLSTEP; tbUpCnt = 0;
258 pRprt.v += tbDnCnt * SCROLLSTEP; tbDnCnt = 0; 229 pRprt.v += tbDnCnt * SCROLLSTEP; tbDnCnt = 0;
259 } else { 230 } else {
260 pRprt.x -= tbLtCnt * TRKSTEP * (layer_state - 1); tbLtCnt = 0; 231 pRprt.x -= tbLtCnt * TRKSTEP * (layer_state - 1); tbLtCnt = 0;
261 pRprt.x += tbRtCnt * TRKSTEP * (layer_state - 1); tbRtCnt = 0; 232 pRprt.x += tbRtCnt * TRKSTEP * (layer_state - 1); tbRtCnt = 0;
262 pRprt.y -= tbUpCnt * TRKSTEP * (layer_state - 1); tbUpCnt = 0; 233 pRprt.y -= tbUpCnt * TRKSTEP * (layer_state - 1); tbUpCnt = 0;
263 pRprt.y += tbDnCnt * TRKSTEP * (layer_state - 1); tbDnCnt = 0; 234 pRprt.y += tbDnCnt * TRKSTEP * (layer_state - 1); tbDnCnt = 0;
264 } 235 }
265 236
266 #ifdef DEBUG_BALLER 237#ifdef DEBUG_BALLER
267 if (pRprt.x != 0 || pRprt.y != 0) 238 if (pRprt.x != 0 || pRprt.y != 0)
268 xprintf("X: %d Y: %d\n", pRprt.x, pRprt.y); 239 xprintf("X: %d Y: %d\n", pRprt.x, pRprt.y);
269 #endif 240#endif
270 241
271 if ((pBtn != trkBtnState) && ((pBtn >> 6) == 0)) pRprt.buttons |= MOUSE_BTN1; 242 if ((pBtn != trkBtnState) && ((pBtn >> 6) == 0)) pRprt.buttons |= MOUSE_BTN1;
272 if ((pBtn != trkBtnState) && ((pBtn >> 6) == 1)) pRprt.buttons &= ~MOUSE_BTN1; 243 if ((pBtn != trkBtnState) && ((pBtn >> 6) == 1)) pRprt.buttons &= ~MOUSE_BTN1;
273 244
274 // Save state, push update 245 // Save state, push update
275 if (pRprt.x != 0 || pRprt.y != 0 || pRprt.h != 0 || pRprt.v != 0 || (trkBtnState != pBtn)) 246 if (pRprt.x != 0 || pRprt.y != 0 || pRprt.h != 0 || pRprt.v != 0 || (trkBtnState != pBtn))
276 pointing_device_set_report(pRprt); 247 pointing_device_set_report(pRprt);
277 248
278 trkBtnState = pBtn; 249 trkBtnState = pBtn;
279 #endif 250#endif
280 251
281 // Then the keyboard 252 // Then the keyboard
282 if (mcp23018_status) { // if there was an error 253 if (mcp23018_status) { // if there was an error
283 if (++mcp23018_reset_loop == 0) { 254 if (++mcp23018_reset_loop == 0) {
284 // if (++mcp23018_reset_loop >= 1300) { 255 // if (++mcp23018_reset_loop >= 1300) {
285 // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans 256 // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans
286 // this will be approx bit more frequent than once per second 257 // this will be approx bit more frequent than once per second
287 print("trying to reset mcp23018\n"); 258 print("trying to reset mcp23018\n");
288 mcp23018_status = init_mcp23018(); 259 mcp23018_status = init_mcp23018();
289 if (mcp23018_status) { 260 if (mcp23018_status) {
290 print("left side not responding\n"); 261 print("left side not responding\n");
291 } else { 262 } else {
292 print("left side attached\n"); 263 print("left side attached\n");
293 } 264 }
294 } 265 }
295 } 266 }
296 267
297#ifdef DEBUG_MATRIX_SCAN_RATE 268#ifdef DEBUG_MATRIX_SCAN_RATE
298 matrix_scan_count++; 269 matrix_scan_count++;
270
299 uint32_t timer_now = timer_read32(); 271 uint32_t timer_now = timer_read32();
300 if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { 272 if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) {
301 print("matrix scan frequency: "); 273 print("matrix scan frequency: ");
302 pdec(matrix_scan_count); 274 pdec(matrix_scan_count);
303 print("\n"); 275 print("\n");
304 276
305 matrix_timer = timer_now; 277 matrix_timer = timer_now;
306 matrix_scan_count = 0; 278 matrix_scan_count = 0;
307 } 279 }
308#endif 280#endif
281
282 bool changed = false;
309 for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { 283 for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) {
310 select_row(i); 284 // select rows from left and right hands
311 // and select on left hand 285 uint8_t left_index = i;
312 select_row(i + MATRIX_ROWS_PER_SIDE); 286 uint8_t right_index = i + MATRIX_ROWS_PER_SIDE;
287 select_row(left_index);
288 select_row(right_index);
289
313 // we don't need a 30us delay anymore, because selecting a 290 // we don't need a 30us delay anymore, because selecting a
314 // left-hand row requires more than 30us for i2c. 291 // left-hand row requires more than 30us for i2c.
315 292
316 // grab cols from left hand 293 changed |= store_raw_matrix_row(left_index);
317 matrix[i] = debounce_read_cols(i); 294 changed |= store_raw_matrix_row(right_index);
318 // grab cols from right hand
319 matrix[i + MATRIX_ROWS_PER_SIDE] = debounce_read_cols(i + MATRIX_ROWS_PER_SIDE);
320 295
321 unselect_rows(); 296 unselect_rows();
322 } 297 }
323 298
299 debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
324 matrix_scan_quantum(); 300 matrix_scan_quantum();
301
325 enableInterrupts(); 302 enableInterrupts();
326 303
327#ifdef DEBUG_MATRIX 304#ifdef DEBUG_MATRIX
@@ -338,20 +315,11 @@ bool matrix_is_modified(void) // deprecated and evidently not called.
338 return true; 315 return true;
339} 316}
340 317
341inline 318inline bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & ((matrix_row_t)1 << col)); }
342bool matrix_is_on(uint8_t row, uint8_t col)
343{
344 return (matrix[row] & ((matrix_row_t)1<<col));
345}
346 319
347inline 320inline matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; }
348matrix_row_t matrix_get_row(uint8_t row)
349{
350 return matrix[row];
351}
352 321
353void matrix_print(void) 322void matrix_print(void) {
354{
355 print("\nr/c 0123456789ABCDEF\n"); 323 print("\nr/c 0123456789ABCDEF\n");
356 for (uint8_t row = 0; row < MATRIX_ROWS; row++) { 324 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
357 phex(row); print(": "); 325 phex(row); print(": ");
@@ -360,8 +328,7 @@ void matrix_print(void)
360 } 328 }
361} 329}
362 330
363uint8_t matrix_key_count(void) 331uint8_t matrix_key_count(void) {
364{
365 uint8_t count = 0; 332 uint8_t count = 0;
366 for (uint8_t i = 0; i < MATRIX_ROWS; i++) { 333 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
367 count += bitpop16(matrix[i]); 334 count += bitpop16(matrix[i]);
@@ -370,8 +337,7 @@ uint8_t matrix_key_count(void)
370} 337}
371 338
372// Remember this means ROWS 339// Remember this means ROWS
373static void init_cols(void) 340static void init_cols(void) {
374{
375 // init on mcp23018 341 // init on mcp23018
376 // not needed, already done as part of init_mcp23018() 342 // not needed, already done as part of init_mcp23018()
377 343
@@ -380,17 +346,16 @@ static void init_cols(void)
380 PORTF |= FMASK; 346 PORTF |= FMASK;
381} 347}
382 348
383static matrix_row_t read_cols(uint8_t row) 349static matrix_row_t read_cols(uint8_t row) {
384{
385 if (row < 7) { 350 if (row < 7) {
386 if (mcp23018_status) { // if there was an error 351 if (mcp23018_status) { // if there was an error
387 return 0; 352 return 0;
388 } else { 353 } else {
389 uint8_t data = 0; 354 uint8_t data = 0;
390 mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 355 mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
391 mcp23018_status = i2c_write(GPIOB, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 356 mcp23018_status = i2c_write(GPIOB, I2C_TIMEOUT); if (mcp23018_status) goto out;
392 mcp23018_status = i2c_start(I2C_ADDR_READ, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 357 mcp23018_status = i2c_start(I2C_ADDR_READ, I2C_TIMEOUT); if (mcp23018_status) goto out;
393 mcp23018_status = i2c_read_nack(ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status < 0) goto out; 358 mcp23018_status = i2c_read_nack(I2C_TIMEOUT); if (mcp23018_status < 0) goto out;
394 data = ~((uint8_t)mcp23018_status); 359 data = ~((uint8_t)mcp23018_status);
395 mcp23018_status = I2C_STATUS_SUCCESS; 360 mcp23018_status = I2C_STATUS_SUCCESS;
396 out: 361 out:
@@ -440,9 +405,9 @@ static void select_row(uint8_t row)
440 // select on mcp23018 405 // select on mcp23018
441 if (mcp23018_status) { // do nothing on error 406 if (mcp23018_status) { // do nothing on error
442 } else { // set active row low : 0 // set other rows hi-Z : 1 407 } else { // set active row low : 0 // set other rows hi-Z : 1
443 mcp23018_status = i2c_start(I2C_ADDR_WRITE, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 408 mcp23018_status = i2c_start(I2C_ADDR_WRITE, I2C_TIMEOUT); if (mcp23018_status) goto out;
444 mcp23018_status = i2c_write(GPIOA, ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 409 mcp23018_status = i2c_write(GPIOA, I2C_TIMEOUT); if (mcp23018_status) goto out;
445 mcp23018_status = i2c_write(0xFF & ~(1<<row), ERGODOX_EZ_I2C_TIMEOUT); if (mcp23018_status) goto out; 410 mcp23018_status = i2c_write(0xFF & ~(1<<row), I2C_TIMEOUT); if (mcp23018_status) goto out;
446 out: 411 out:
447 i2c_stop(); 412 i2c_stop();
448 } 413 }
diff --git a/keyboards/gergo/rules.mk b/keyboards/gergo/rules.mk
index aadc1c2ce..2ce9e01e6 100644
--- a/keyboards/gergo/rules.mk
+++ b/keyboards/gergo/rules.mk
@@ -18,3 +18,5 @@ POINTING_DEVICE_ENABLE = yes
18EXTRAKEY_ENABLE = yes 18EXTRAKEY_ENABLE = yes
19CONSOLE_ENABLE = yes 19CONSOLE_ENABLE = yes
20COMMAND_ENABLE = yes 20COMMAND_ENABLE = yes
21
22DEBOUNCE_TYPE = eager_pr