From 4b13ebb996e1c4997e6deb1fa3b3227db5fa9661 Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Tue, 7 Apr 2020 20:11:31 +0900 Subject: [PATCH 1/6] dipsw test on helix/rev2/sc/back:five_rows --- .../helix/rev2/keymaps/five_rows/config.h | 3 + .../helix/rev2/keymaps/five_rows/keymap.c | 90 +++++++++++++++++++ .../helix/rev2/keymaps/five_rows/rules.mk | 3 + 3 files changed, 96 insertions(+) diff --git a/keyboards/helix/rev2/keymaps/five_rows/config.h b/keyboards/helix/rev2/keymaps/five_rows/config.h index 538859bc3c5d..30848162cbf4 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/config.h +++ b/keyboards/helix/rev2/keymaps/five_rows/config.h @@ -27,6 +27,9 @@ along with this program. If not, see . /* when TAPPING_TERM >= 500 same effect PERMISSIVE_HOLD. see tmk_core/common/action_tapping.c */ +//#define DIP_SWITCH_PINS { B5, B6 } +#define DIP_SWITCH_PINS { B5, B6, B5, B6 } + // place overrides here // If you need more program area, try select and reduce rgblight modes to use. diff --git a/keyboards/helix/rev2/keymaps/five_rows/keymap.c b/keyboards/helix/rev2/keymaps/five_rows/keymap.c index eb73881c6ba9..616a32482f9d 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/keymap.c +++ b/keyboards/helix/rev2/keymaps/five_rows/keymap.c @@ -1,4 +1,5 @@ #include QMK_KEYBOARD_H +#include #include "bootloader.h" #ifdef PROTOCOL_LUFA #include "lufa.h" @@ -13,6 +14,7 @@ #ifdef CONSOLE_ENABLE #include #endif +#include "timer.h" extern keymap_config_t keymap_config; @@ -332,8 +334,14 @@ uint32_t default_layer_state_set_kb(uint32_t state) { return state; } +void dump_pbuf(void); void update_base_layer(int base) { + uprintf("layer\n"); + dump_pbuf(); + dip_switch_read(true); + uprintf("call dip_switch_read(true)\n"); + dump_pbuf(); if( current_default_layer != base ) { eeconfig_update_default_layer(1UL< 0 ) { + uprintf(" dump_pbuf %d\n", pbuf_count); + for( uint8_t i = 0; i < pbuf_count; i++ ) { + uprintf(" %06d : ", pbuf[i].timer); + __xprintf(pbuf[i].fmt, pbuf[i].arg1, pbuf[i].arg2); + } + pbuf_count = 0; + if( pbuf_overflow ) { + uprintf(" pbuf overflow \n"); + pbuf_overflow = false; + } + } +#endif +} + +void dip_switch_update_user(uint8_t index, bool active) { + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("dip_switch_update_user(%d,%d)\n"); + pbuf[pbuf_count].arg1 = index; + pbuf[pbuf_count].arg2 = active; + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } +} + +void dip_switch_update_mask_user(uint32_t state) { + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("dip_switch_update_mask_user(0b%b)\n"); + pbuf[pbuf_count].arg1 = state; + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } +} + +void keyboard_pre_init_user(void) +{ + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("keyboard_pre_init_user()\n"); + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } +} + +void keyboard_post_init_user(void) +{ + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("keyboard_post_init_user()\n"); + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } +} diff --git a/keyboards/helix/rev2/keymaps/five_rows/rules.mk b/keyboards/helix/rev2/keymaps/five_rows/rules.mk index fb564b6e0424..0303d49aeaf5 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/rules.mk +++ b/keyboards/helix/rev2/keymaps/five_rows/rules.mk @@ -30,6 +30,9 @@ ifneq ($(strip $(HELIX)),) endif endif +CONSOLE_ENABLE = yes +DIP_SWITCH_ENABLE = yes + # convert Helix-specific options (that represent combinations of standard options) # into QMK standard options. include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) From 7bc8d033bc1742d06fc9a76c0fe43416ff1ba194 Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Wed, 8 Apr 2020 19:01:03 +0900 Subject: [PATCH 2/6] bug fix quantum/dip_switch.c --- quantum/dip_switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index ab74222d1008..81d5a42d0324 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c @@ -52,7 +52,7 @@ void dip_switch_read(bool forced) { for (uint8_t i = 0; i < NUMBER_OF_DIP_SWITCHES; i++) { dip_switch_state[i] = !readPin(dip_switch_pad[i]); dip_switch_mask |= dip_switch_state[i] << i; - if (last_dip_switch_state[i] ^ dip_switch_state[i] || forced) { + if (last_dip_switch_state[i] != dip_switch_state[i] || forced) { has_dip_state_changed = true; dip_switch_update_kb(i, dip_switch_state[i]); } @@ -60,5 +60,5 @@ void dip_switch_read(bool forced) { if (has_dip_state_changed) { dip_switch_update_mask_kb(dip_switch_mask); } - memcpy(last_dip_switch_state, dip_switch_state, sizeof(&dip_switch_state)); + memcpy(last_dip_switch_state, dip_switch_state, sizeof(dip_switch_state)); } From 582cea6e1d2a7fa3601f6195cd0343ddeb1d05dd Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Wed, 8 Apr 2020 19:01:17 +0900 Subject: [PATCH 3/6] test end. remove test code. Revert "dipsw test on helix/rev2/sc/back:five_rows" This reverts commit 4b13ebb996e1c4997e6deb1fa3b3227db5fa9661. --- .../helix/rev2/keymaps/five_rows/config.h | 3 - .../helix/rev2/keymaps/five_rows/keymap.c | 90 ------------------- .../helix/rev2/keymaps/five_rows/rules.mk | 3 - 3 files changed, 96 deletions(-) diff --git a/keyboards/helix/rev2/keymaps/five_rows/config.h b/keyboards/helix/rev2/keymaps/five_rows/config.h index 30848162cbf4..538859bc3c5d 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/config.h +++ b/keyboards/helix/rev2/keymaps/five_rows/config.h @@ -27,9 +27,6 @@ along with this program. If not, see . /* when TAPPING_TERM >= 500 same effect PERMISSIVE_HOLD. see tmk_core/common/action_tapping.c */ -//#define DIP_SWITCH_PINS { B5, B6 } -#define DIP_SWITCH_PINS { B5, B6, B5, B6 } - // place overrides here // If you need more program area, try select and reduce rgblight modes to use. diff --git a/keyboards/helix/rev2/keymaps/five_rows/keymap.c b/keyboards/helix/rev2/keymaps/five_rows/keymap.c index 616a32482f9d..eb73881c6ba9 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/keymap.c +++ b/keyboards/helix/rev2/keymaps/five_rows/keymap.c @@ -1,5 +1,4 @@ #include QMK_KEYBOARD_H -#include #include "bootloader.h" #ifdef PROTOCOL_LUFA #include "lufa.h" @@ -14,7 +13,6 @@ #ifdef CONSOLE_ENABLE #include #endif -#include "timer.h" extern keymap_config_t keymap_config; @@ -334,14 +332,8 @@ uint32_t default_layer_state_set_kb(uint32_t state) { return state; } -void dump_pbuf(void); void update_base_layer(int base) { - uprintf("layer\n"); - dump_pbuf(); - dip_switch_read(true); - uprintf("call dip_switch_read(true)\n"); - dump_pbuf(); if( current_default_layer != base ) { eeconfig_update_default_layer(1UL< 0 ) { - uprintf(" dump_pbuf %d\n", pbuf_count); - for( uint8_t i = 0; i < pbuf_count; i++ ) { - uprintf(" %06d : ", pbuf[i].timer); - __xprintf(pbuf[i].fmt, pbuf[i].arg1, pbuf[i].arg2); - } - pbuf_count = 0; - if( pbuf_overflow ) { - uprintf(" pbuf overflow \n"); - pbuf_overflow = false; - } - } -#endif -} - -void dip_switch_update_user(uint8_t index, bool active) { - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("dip_switch_update_user(%d,%d)\n"); - pbuf[pbuf_count].arg1 = index; - pbuf[pbuf_count].arg2 = active; - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } -} - -void dip_switch_update_mask_user(uint32_t state) { - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("dip_switch_update_mask_user(0b%b)\n"); - pbuf[pbuf_count].arg1 = state; - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } -} - -void keyboard_pre_init_user(void) -{ - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("keyboard_pre_init_user()\n"); - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } -} - -void keyboard_post_init_user(void) -{ - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("keyboard_post_init_user()\n"); - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } -} diff --git a/keyboards/helix/rev2/keymaps/five_rows/rules.mk b/keyboards/helix/rev2/keymaps/five_rows/rules.mk index 0303d49aeaf5..fb564b6e0424 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/rules.mk +++ b/keyboards/helix/rev2/keymaps/five_rows/rules.mk @@ -30,9 +30,6 @@ ifneq ($(strip $(HELIX)),) endif endif -CONSOLE_ENABLE = yes -DIP_SWITCH_ENABLE = yes - # convert Helix-specific options (that represent combinations of standard options) # into QMK standard options. include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) From bf99ace095528ad65c531229bcf5ece037dda595 Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Tue, 7 Apr 2020 20:11:31 +0900 Subject: [PATCH 4/6] dipsw test on helix/rev2/sc/back:five_rows --- .../helix/rev2/keymaps/five_rows/config.h | 3 + .../helix/rev2/keymaps/five_rows/keymap.c | 102 +++++++++++++++++- .../helix/rev2/keymaps/five_rows/rules.mk | 3 + 3 files changed, 107 insertions(+), 1 deletion(-) diff --git a/keyboards/helix/rev2/keymaps/five_rows/config.h b/keyboards/helix/rev2/keymaps/five_rows/config.h index 538859bc3c5d..30848162cbf4 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/config.h +++ b/keyboards/helix/rev2/keymaps/five_rows/config.h @@ -27,6 +27,9 @@ along with this program. If not, see . /* when TAPPING_TERM >= 500 same effect PERMISSIVE_HOLD. see tmk_core/common/action_tapping.c */ +//#define DIP_SWITCH_PINS { B5, B6 } +#define DIP_SWITCH_PINS { B5, B6, B5, B6 } + // place overrides here // If you need more program area, try select and reduce rgblight modes to use. diff --git a/keyboards/helix/rev2/keymaps/five_rows/keymap.c b/keyboards/helix/rev2/keymaps/five_rows/keymap.c index eb73881c6ba9..b8c4602af651 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/keymap.c +++ b/keyboards/helix/rev2/keymaps/five_rows/keymap.c @@ -1,4 +1,5 @@ #include QMK_KEYBOARD_H +#include #include "bootloader.h" #ifdef PROTOCOL_LUFA #include "lufa.h" @@ -13,6 +14,7 @@ #ifdef CONSOLE_ENABLE #include #endif +#include "timer.h" extern keymap_config_t keymap_config; @@ -332,8 +334,13 @@ uint32_t default_layer_state_set_kb(uint32_t state) { return state; } +void dump_pbuf(void); void update_base_layer(int base) { + uprintf("layer\n"); + dump_pbuf(); + uprintf("call dip_switch_read(true)\n"); + dip_switch_read(true); if( current_default_layer != base ) { eeconfig_update_default_layer(1UL< 0 ) { + if (pbuf_count > 1) + uprintf(" %06d : dump_pbuf %d\n", timer_read(), pbuf_count); + for( uint8_t i = 0; i < pbuf_count; i++ ) { + uprintf(" %06d : ", pbuf[i].timer); + __xprintf(pbuf[i].fmt, pbuf[i].arg1, pbuf[i].arg2); + } + pbuf_count = 0; + if( pbuf_overflow ) { + uprintf(" pbuf overflow \n"); + pbuf_overflow = false; + } + } +#endif +} + +void matrix_scan_user(void) { + if( pbuf_wait ) { + if( pbuf_timer == 0 ) { + /* the first scan. */ + pbuf_timer = timer_read(); + } + if( timer_elapsed(pbuf_timer) < 2000 ) { + return; + } + pbuf_wait = false; + dump_pbuf(); + } +} + +void dip_switch_update_user(uint8_t index, bool active) { + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("dip_switch_update_user(%d,%d)\n"); + pbuf[pbuf_count].arg1 = index; + pbuf[pbuf_count].arg2 = active; + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } + dump_pbuf(); +} + +void dip_switch_update_mask_user(uint32_t state) { + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("dip_switch_update_mask_user(0b%b)\n"); + pbuf[pbuf_count].arg1 = state; + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } + dump_pbuf(); +} + +void keyboard_pre_init_user(void) +{ + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("keyboard_pre_init_user()\n"); + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } +} + +void keyboard_post_init_user(void) +{ + if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { + pbuf[pbuf_count].fmt = PSTR("keyboard_post_init_user()\n"); + pbuf[pbuf_count].timer = timer_read(); + pbuf_count++; + } else { + pbuf_overflow = true; + } +} diff --git a/keyboards/helix/rev2/keymaps/five_rows/rules.mk b/keyboards/helix/rev2/keymaps/five_rows/rules.mk index fb564b6e0424..0303d49aeaf5 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/rules.mk +++ b/keyboards/helix/rev2/keymaps/five_rows/rules.mk @@ -30,6 +30,9 @@ ifneq ($(strip $(HELIX)),) endif endif +CONSOLE_ENABLE = yes +DIP_SWITCH_ENABLE = yes + # convert Helix-specific options (that represent combinations of standard options) # into QMK standard options. include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) From 8420245f7a240314b515323dbd3820fcb58c2504 Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Fri, 10 Apr 2020 02:19:45 +0900 Subject: [PATCH 5/6] update quantum/dip_switch.c --- quantum/dip_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/dip_switch.c b/quantum/dip_switch.c index 81d5a42d0324..66c166ce45d2 100644 --- a/quantum/dip_switch.c +++ b/quantum/dip_switch.c @@ -59,6 +59,6 @@ void dip_switch_read(bool forced) { } if (has_dip_state_changed) { dip_switch_update_mask_kb(dip_switch_mask); + memcpy(last_dip_switch_state, dip_switch_state, sizeof(dip_switch_state)); } - memcpy(last_dip_switch_state, dip_switch_state, sizeof(dip_switch_state)); } From 7789a9ffa28dda98647c7ff5c0b0d226ee361e3d Mon Sep 17 00:00:00 2001 From: mtei <2170248+mtei@users.noreply.github.com> Date: Fri, 10 Apr 2020 02:21:03 +0900 Subject: [PATCH 6/6] test end. remove test code. Revert "dipsw test on helix/rev2/sc/back:five_rows" This reverts commit bf99ace095528ad65c531229bcf5ece037dda595. --- .../helix/rev2/keymaps/five_rows/config.h | 3 - .../helix/rev2/keymaps/five_rows/keymap.c | 102 +----------------- .../helix/rev2/keymaps/five_rows/rules.mk | 3 - 3 files changed, 1 insertion(+), 107 deletions(-) diff --git a/keyboards/helix/rev2/keymaps/five_rows/config.h b/keyboards/helix/rev2/keymaps/five_rows/config.h index 30848162cbf4..538859bc3c5d 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/config.h +++ b/keyboards/helix/rev2/keymaps/five_rows/config.h @@ -27,9 +27,6 @@ along with this program. If not, see . /* when TAPPING_TERM >= 500 same effect PERMISSIVE_HOLD. see tmk_core/common/action_tapping.c */ -//#define DIP_SWITCH_PINS { B5, B6 } -#define DIP_SWITCH_PINS { B5, B6, B5, B6 } - // place overrides here // If you need more program area, try select and reduce rgblight modes to use. diff --git a/keyboards/helix/rev2/keymaps/five_rows/keymap.c b/keyboards/helix/rev2/keymaps/five_rows/keymap.c index b8c4602af651..eb73881c6ba9 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/keymap.c +++ b/keyboards/helix/rev2/keymaps/five_rows/keymap.c @@ -1,5 +1,4 @@ #include QMK_KEYBOARD_H -#include #include "bootloader.h" #ifdef PROTOCOL_LUFA #include "lufa.h" @@ -14,7 +13,6 @@ #ifdef CONSOLE_ENABLE #include #endif -#include "timer.h" extern keymap_config_t keymap_config; @@ -334,13 +332,8 @@ uint32_t default_layer_state_set_kb(uint32_t state) { return state; } -void dump_pbuf(void); void update_base_layer(int base) { - uprintf("layer\n"); - dump_pbuf(); - uprintf("call dip_switch_read(true)\n"); - dip_switch_read(true); if( current_default_layer != base ) { eeconfig_update_default_layer(1UL< 0 ) { - if (pbuf_count > 1) - uprintf(" %06d : dump_pbuf %d\n", timer_read(), pbuf_count); - for( uint8_t i = 0; i < pbuf_count; i++ ) { - uprintf(" %06d : ", pbuf[i].timer); - __xprintf(pbuf[i].fmt, pbuf[i].arg1, pbuf[i].arg2); - } - pbuf_count = 0; - if( pbuf_overflow ) { - uprintf(" pbuf overflow \n"); - pbuf_overflow = false; - } - } -#endif -} - -void matrix_scan_user(void) { - if( pbuf_wait ) { - if( pbuf_timer == 0 ) { - /* the first scan. */ - pbuf_timer = timer_read(); - } - if( timer_elapsed(pbuf_timer) < 2000 ) { - return; - } - pbuf_wait = false; - dump_pbuf(); - } -} - -void dip_switch_update_user(uint8_t index, bool active) { - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("dip_switch_update_user(%d,%d)\n"); - pbuf[pbuf_count].arg1 = index; - pbuf[pbuf_count].arg2 = active; - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } - dump_pbuf(); -} - -void dip_switch_update_mask_user(uint32_t state) { - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("dip_switch_update_mask_user(0b%b)\n"); - pbuf[pbuf_count].arg1 = state; - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } - dump_pbuf(); -} - -void keyboard_pre_init_user(void) -{ - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("keyboard_pre_init_user()\n"); - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } -} - -void keyboard_post_init_user(void) -{ - if( pbuf_count < sizeof(pbuf)/sizeof(pbuf[0]) ) { - pbuf[pbuf_count].fmt = PSTR("keyboard_post_init_user()\n"); - pbuf[pbuf_count].timer = timer_read(); - pbuf_count++; - } else { - pbuf_overflow = true; - } -} diff --git a/keyboards/helix/rev2/keymaps/five_rows/rules.mk b/keyboards/helix/rev2/keymaps/five_rows/rules.mk index 0303d49aeaf5..fb564b6e0424 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/rules.mk +++ b/keyboards/helix/rev2/keymaps/five_rows/rules.mk @@ -30,9 +30,6 @@ ifneq ($(strip $(HELIX)),) endif endif -CONSOLE_ENABLE = yes -DIP_SWITCH_ENABLE = yes - # convert Helix-specific options (that represent combinations of standard options) # into QMK standard options. include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))