aboutsummaryrefslogtreecommitdiff
path: root/keyboards/sixkeyboard
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-03-22 14:24:04 -0400
committerJack Humbert <jack.humb@gmail.com>2017-06-30 16:33:49 -0400
commit753809eed7873205baa6692d928d9c255308d22b (patch)
treefea3ecf011cce00a11497f6032cbe69be48080ef /keyboards/sixkeyboard
parentb476d65b9cc2b25031c6f8143fd6a59a7d5ee6b7 (diff)
downloadqmk_firmware-753809eed7873205baa6692d928d9c255308d22b.tar.gz
qmk_firmware-753809eed7873205baa6692d928d9c255308d22b.zip
adds debouncing to sixkeyboard
Diffstat (limited to 'keyboards/sixkeyboard')
-rw-r--r--keyboards/sixkeyboard/config.h4
-rw-r--r--keyboards/sixkeyboard/keymaps/default/keymap.c10
-rw-r--r--keyboards/sixkeyboard/matrix.c38
3 files changed, 31 insertions, 21 deletions
diff --git a/keyboards/sixkeyboard/config.h b/keyboards/sixkeyboard/config.h
index bf58bb2b7..4ce25c670 100644
--- a/keyboards/sixkeyboard/config.h
+++ b/keyboards/sixkeyboard/config.h
@@ -107,8 +107,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
107 107
108/* disable action features */ 108/* disable action features */
109//#define NO_ACTION_LAYER 109//#define NO_ACTION_LAYER
110//#define NO_ACTION_TAPPING 110#define NO_ACTION_TAPPING
111//#define NO_ACTION_ONESHOT 111#define NO_ACTION_ONESHOT
112//#define NO_ACTION_MACRO 112//#define NO_ACTION_MACRO
113//#define NO_ACTION_FUNCTION 113//#define NO_ACTION_FUNCTION
114 114
diff --git a/keyboards/sixkeyboard/keymaps/default/keymap.c b/keyboards/sixkeyboard/keymaps/default/keymap.c
index 641ed790e..74ce6f036 100644
--- a/keyboards/sixkeyboard/keymaps/default/keymap.c
+++ b/keyboards/sixkeyboard/keymaps/default/keymap.c
@@ -17,16 +17,6 @@ const uint16_t PROGMEM fn_actions[] = {
17 17
18const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) 18const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
19{ 19{
20 // MACRODOWN only works in this function
21 switch(id) {
22 case 0:
23 if (record->event.pressed) {
24 register_code(KC_RSFT);
25 } else {
26 unregister_code(KC_RSFT);
27 }
28 break;
29 }
30 return MACRO_NONE; 20 return MACRO_NONE;
31}; 21};
32 22
diff --git a/keyboards/sixkeyboard/matrix.c b/keyboards/sixkeyboard/matrix.c
index ed1b70e28..37cc68a21 100644
--- a/keyboards/sixkeyboard/matrix.c
+++ b/keyboards/sixkeyboard/matrix.c
@@ -37,6 +37,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
37 37
38/* matrix state(1:on, 0:off) */ 38/* matrix state(1:on, 0:off) */
39static matrix_row_t matrix[MATRIX_ROWS]; 39static matrix_row_t matrix[MATRIX_ROWS];
40static matrix_row_t matrix_stage[MATRIX_ROWS];
41static matrix_row_t matrix_debouncing[MATRIX_ROWS];
42
43static uint16_t debouncing_time;
44static bool debouncing = false;
40 45
41__attribute__ ((weak)) 46__attribute__ ((weak))
42void matrix_init_kb(void) { 47void matrix_init_kb(void) {
@@ -78,14 +83,35 @@ void matrix_init(void)
78 DDRD &= ~(1<<6 | 1<<4 | 1<<1); 83 DDRD &= ~(1<<6 | 1<<4 | 1<<1);
79 PORTD |= (1<<6 | 1<<4 | 1<<1); 84 PORTD |= (1<<6 | 1<<4 | 1<<1);
80 85
81 matrix_init_kb(); 86 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
87 matrix[i] = 0;
88 matrix_debouncing[i] = 0;
89 matrix_stage[i] = 0;
90 }
91
92 matrix_init_quantum();
82 93
83} 94}
84 95
85uint8_t matrix_scan(void) 96uint8_t matrix_scan(void)
86{ 97{
87 matrix[0] = (PINC&(1<<7) ? 0 : (1<<0)) | (PINB&(1<<7) ? 0 : (1<<1)) | (PINB&(1<<5) ? 0 : (1<<2)); 98 matrix_stage[0] = (PINC&(1<<7) ? 0 : (1<<0)) | (PINB&(1<<7) ? 0 : (1<<1)) | (PINB&(1<<5) ? 0 : (1<<2));
88 matrix[1] = (PIND&(1<<6) ? 0 : (1<<0)) | (PIND&(1<<1) ? 0 : (1<<1)) | (PIND&(1<<4) ? 0 : (1<<2)); 99 matrix_stage[1] = (PIND&(1<<6) ? 0 : (1<<0)) | (PIND&(1<<1) ? 0 : (1<<1)) | (PIND&(1<<4) ? 0 : (1<<2));
100
101 if (memcmp(matrix_debouncing, matrix_stage, sizeof(matrix)) != 0) {
102 debouncing = true;
103 debouncing_time = timer_read();
104 }
105
106 matrix_debouncing[0] = matrix_stage[0];
107 matrix_debouncing[1] = matrix_stage[1];
108
109 if (debouncing && (timer_elapsed(debouncing_time) > 20)) {
110 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
111 matrix[i] = matrix_debouncing[i];
112 }
113 debouncing = false;
114 }
89 115
90 matrix_scan_quantum(); 116 matrix_scan_quantum();
91 117
@@ -111,12 +137,6 @@ matrix_row_t matrix_get_row(uint8_t row)
111 137
112void matrix_print(void) 138void matrix_print(void)
113{ 139{
114 print("\nr/c 0123456789ABCDEF\n");
115 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
116 phex(row); print(": ");
117 pbin_reverse16(matrix_get_row(row));
118 print("\n");
119 }
120} 140}
121 141
122uint8_t matrix_key_count(void) 142uint8_t matrix_key_count(void)