aboutsummaryrefslogtreecommitdiff
path: root/keyboards/helix/rev3_5rows
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2021-09-16 18:47:47 +0900
committerGitHub <noreply@github.com>2021-09-16 18:47:47 +0900
commit85a0c494ffde3dfa555bbe32bb083eec85b9ca72 (patch)
treeb845ecae039c676d9c88ca87c9493da90bd7b454 /keyboards/helix/rev3_5rows
parent13b93c212da202d210ba28657f1b1c3e06d56655 (diff)
downloadqmk_firmware-85a0c494ffde3dfa555bbe32bb083eec85b9ca72.tar.gz
qmk_firmware-85a0c494ffde3dfa555bbe32bb083eec85b9ca72.zip
[Keymap] Update Helix:five_rows OLED code (#14427)
* Stop using snprintf() in keymaps/five_rows/oled_display.c. The binary size becomes 1350 bytes smaller. make HELIX=verbose,core-oled helix/rev2/sc:five_rows (104 bytes over) -> (95%, 1256 bytes free) make helix/rev3_5rows:five_rows (528 bytes over) -> (97%, 830 bytes free) * add matrix scan rate display to OLED for keymaps/five_rows * add matrix_output_unselect_delay.c to helix keymaps/five_rows * add GPLv2 header * apply review comment
Diffstat (limited to 'keyboards/helix/rev3_5rows')
-rw-r--r--keyboards/helix/rev3_5rows/keymaps/five_rows/config.h6
-rw-r--r--keyboards/helix/rev3_5rows/keymaps/five_rows/matrix_output_unselect_delay.c31
-rw-r--r--keyboards/helix/rev3_5rows/keymaps/five_rows/oled_display.c92
-rw-r--r--keyboards/helix/rev3_5rows/keymaps/five_rows/rules.mk13
4 files changed, 128 insertions, 14 deletions
diff --git a/keyboards/helix/rev3_5rows/keymaps/five_rows/config.h b/keyboards/helix/rev3_5rows/keymaps/five_rows/config.h
index b9961f5c4..e1c124f41 100644
--- a/keyboards/helix/rev3_5rows/keymaps/five_rows/config.h
+++ b/keyboards/helix/rev3_5rows/keymaps/five_rows/config.h
@@ -29,7 +29,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29 see tmk_core/common/action_tapping.c */ 29 see tmk_core/common/action_tapping.c */
30 30
31#undef OLED_UPDATE_INTERVAL 31#undef OLED_UPDATE_INTERVAL
32#define OLED_UPDATE_INTERVAL 50 32#ifdef DEBUG_MATRIX_SCAN_RATE
33# define OLED_UPDATE_INTERVAL 500
34#else
35# define OLED_UPDATE_INTERVAL 50
36#endif
33 37
34// place overrides here 38// place overrides here
35 39
diff --git a/keyboards/helix/rev3_5rows/keymaps/five_rows/matrix_output_unselect_delay.c b/keyboards/helix/rev3_5rows/keymaps/five_rows/matrix_output_unselect_delay.c
new file mode 100644
index 000000000..a093afe0a
--- /dev/null
+++ b/keyboards/helix/rev3_5rows/keymaps/five_rows/matrix_output_unselect_delay.c
@@ -0,0 +1,31 @@
1/* Copyright 2021 mtei
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include QMK_KEYBOARD_H
18
19void matrix_output_unselect_delay(uint8_t line, bool key_pressed) {
20 /* If none of the keys are pressed,
21 * there is no need to wait for time for the next line. */
22 if (key_pressed) {
23# ifdef MATRIX_IO_DELAY
24# if MATRIX_IO_DELAY > 0
25 wait_us(MATRIX_IO_DELAY);
26# endif
27# else
28 wait_us(30);
29# endif
30 }
31}
diff --git a/keyboards/helix/rev3_5rows/keymaps/five_rows/oled_display.c b/keyboards/helix/rev3_5rows/keymaps/five_rows/oled_display.c
index 090e8aaec..fcbd81c9b 100644
--- a/keyboards/helix/rev3_5rows/keymaps/five_rows/oled_display.c
+++ b/keyboards/helix/rev3_5rows/keymaps/five_rows/oled_display.c
@@ -64,6 +64,55 @@ void matrix_update(struct CharacterMatrix *dest,
64} 64}
65# endif 65# endif
66 66
67static char *sprint_decimal(char *buf, int data) {
68 if (data > 9) {
69 buf = sprint_decimal(buf, data/10);
70 }
71 *buf++ = "0123456789"[data%10];
72 *buf = '\0';
73 return buf;
74}
75
76static char *sprint_hex(char *buf, uint32_t data) {
77 if (data > 0xf) {
78 buf = sprint_hex(buf, data/0x10);
79 }
80 *buf++ = "0123456789abcdef"[data & 0xf];
81 *buf = '\0';
82 return buf;
83}
84
85char *sprints(char *buf, char *src) {
86 while (*src) {
87 *buf++ = *src++;
88 }
89 *buf = '\0';
90 return buf;
91}
92
93char *sprintx(char *buf, char *leadstr, uint32_t data) {
94 buf = sprints(buf, leadstr);
95 buf = sprint_hex(buf, data);
96 return buf;
97}
98
99char *sprintd(char *buf, char *leadstr, int data) {
100 buf = sprints(buf, leadstr);
101 buf = sprint_decimal(buf, data);
102 return buf;
103}
104
105char *sprint2d(char *buf, char *leadstr, int data) {
106 buf = sprints(buf, leadstr);
107 if (data > 99) {
108 return sprint_decimal(buf, data);
109 }
110 if (data < 10) {
111 *buf++ = ' ';
112 }
113 return sprint_decimal(buf, data);
114}
115
67# ifdef SSD1306OLED 116# ifdef SSD1306OLED
68static void render_logo(struct CharacterMatrix *matrix) { 117static void render_logo(struct CharacterMatrix *matrix) {
69# else 118# else
@@ -76,20 +125,35 @@ static void render_logo(void) {
76 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4, 125 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,
77 0}; 126 0};
78 oled_write_P(helix_logo, false); 127 oled_write_P(helix_logo, false);
79# ifdef RGBLIGHT_ENABLE
80 char buf[30]; 128 char buf[30];
129 char *bufp;
130# ifdef RGBLIGHT_ENABLE
81 if (RGBLIGHT_MODES > 1 && rgblight_is_enabled()) { 131 if (RGBLIGHT_MODES > 1 && rgblight_is_enabled()) {
82 snprintf(buf, sizeof(buf), " LED %2d: %d,%d,%d ", 132 bufp = sprint2d(buf, " LED ", rgblight_get_mode());
83 rgblight_get_mode(), 133# ifdef DEBUG_MATRIX_SCAN_RATE
84 rgblight_get_hue()/RGBLIGHT_HUE_STEP, 134 bufp = sprintd(bufp, " scan:", get_matrix_scan_rate());
85 rgblight_get_sat()/RGBLIGHT_SAT_STEP, 135# else
86 rgblight_get_val()/RGBLIGHT_VAL_STEP); 136 bufp = sprintd(bufp, ": ", rgblight_get_hue()/RGBLIGHT_HUE_STEP);
137 bufp = sprintd(bufp, ",", rgblight_get_sat()/RGBLIGHT_SAT_STEP);
138 bufp = sprintd(bufp, ",", rgblight_get_val()/RGBLIGHT_VAL_STEP);
139 bufp = sprints(bufp, " ");
140# endif
87 oled_write(buf, false); 141 oled_write(buf, false);
88# ifndef SSD1306OLED 142# ifndef SSD1306OLED
89 } else { 143 } else {
144# ifdef DEBUG_MATRIX_SCAN_RATE
145 bufp = sprintd(buf, " scan:", get_matrix_scan_rate());
146 oled_write(buf, false);
147# endif
90 oled_write_P( PSTR("\n"), false); 148 oled_write_P( PSTR("\n"), false);
91# endif 149# endif
92 } 150 }
151# else
152# ifdef DEBUG_MATRIX_SCAN_RATE
153 bufp = sprintd(buf, " scan:", get_matrix_scan_rate());
154 bufp = sprints(bufp, " ");
155 oled_write(buf, false);
156# endif
93# endif 157# endif
94} 158}
95 159
@@ -142,6 +206,11 @@ void render_status(void) {
142 int name_num; 206 int name_num;
143 uint32_t lstate; 207 uint32_t lstate;
144 oled_write_P(layer_names[current_default_layer], false); 208 oled_write_P(layer_names[current_default_layer], false);
209# ifdef DEBUG_MATRIX_SCAN_RATE
210 char buf[16];
211 sprintd(buf, " scan:", get_matrix_scan_rate());
212 oled_write(buf, false);
213# endif
145 oled_write_P(PSTR("\n"), false); 214 oled_write_P(PSTR("\n"), false);
146 for (lstate = layer_state, name_num = 0; 215 for (lstate = layer_state, name_num = 0;
147 lstate && name_num < sizeof(layer_names)/sizeof(char *); 216 lstate && name_num < sizeof(layer_names)/sizeof(char *);
@@ -152,14 +221,13 @@ void render_status(void) {
152 } 221 }
153 } 222 }
154 } 223 }
224 oled_write_P(PSTR("\n"), false);
155 225
156 // Host Keyboard LED Status 226 // Host Keyboard LED Status
157 char led[40]; 227 led_t led_state = host_keyboard_led_state();
158 snprintf(led, sizeof(led), "\n%s %s %s", 228 oled_write_P(led_state.num_lock ? PSTR("NUMLOCK ") : PSTR(" "), false);
159 (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", 229 oled_write_P(led_state.caps_lock ? PSTR("CAPS ") : PSTR(" "), false);
160 (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", 230 oled_write_P(led_state.scroll_lock ? PSTR("SCLK ") : PSTR(" "), false);
161 (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " ");
162 oled_write(led, false);
163} 231}
164 232
165# ifdef SSD1306OLED 233# ifdef SSD1306OLED
diff --git a/keyboards/helix/rev3_5rows/keymaps/five_rows/rules.mk b/keyboards/helix/rev3_5rows/keymaps/five_rows/rules.mk
index d10972bbd..b0cca7912 100644
--- a/keyboards/helix/rev3_5rows/keymaps/five_rows/rules.mk
+++ b/keyboards/helix/rev3_5rows/keymaps/five_rows/rules.mk
@@ -14,9 +14,11 @@ ENCODER_ENABLE = no
14LTO_ENABLE = no # if firmware size over limit, try this option 14LTO_ENABLE = no # if firmware size over limit, try this option
15LED_ANIMATIONS = yes 15LED_ANIMATIONS = yes
16 16
17CUSTOM_DELAY = yes
18
17ifneq ($(strip $(HELIX)),) 19ifneq ($(strip $(HELIX)),)
18 define KEYMAP_OPTION_PARSE 20 define KEYMAP_OPTION_PARSE
19 # parse 'dispoff', 'consle', 'back', 'oled', 'no-ani', 'mini-ani', 'lto', 'no-lto', 'no-enc', 'scan' 21 # parse 'dispoff', 'consle', 'back', 'oled', 'no-ani', 'mini-ani', 'lto', 'no-lto', 'no-enc', 'scan', 'scan-api'
20 $(if $(SHOW_PARCE),$(info parse .$1.)) #debug 22 $(if $(SHOW_PARCE),$(info parse .$1.)) #debug
21 ifeq ($(strip $1),dispoff) 23 ifeq ($(strip $1),dispoff)
22 OLED_ENABLE = no 24 OLED_ENABLE = no
@@ -63,6 +65,11 @@ ifneq ($(strip $(HELIX)),)
63 # see docs/newbs_testing_debugging.md 65 # see docs/newbs_testing_debugging.md
64 DEBUG_MATRIX_SCAN_RATE_ENABLE = yes 66 DEBUG_MATRIX_SCAN_RATE_ENABLE = yes
65 endif 67 endif
68 ifeq ($(strip $1),scan-api)
69 # use DEBUG_MATRIX_SCAN_RATE
70 # see docs/newbs_testing_debugging.md
71 DEBUG_MATRIX_SCAN_RATE_ENABLE = api
72 endif
66 endef # end of KEYMAP_OPTION_PARSE 73 endef # end of KEYMAP_OPTION_PARSE
67 74
68 COMMA=, 75 COMMA=,
@@ -80,6 +87,10 @@ ifeq ($(strip $(LED_ANIMATIONS)), mini)
80 OPT_DEFS += -DLED_ANIMATIONS_LEVEL=1 87 OPT_DEFS += -DLED_ANIMATIONS_LEVEL=1
81endif 88endif
82 89
90ifeq ($(strip $(CUSTOM_DELAY)),yes)
91 SRC += matrix_output_unselect_delay.c
92endif
93
83ifeq ($(strip $(DEBUG_CONFIG)), yes) 94ifeq ($(strip $(DEBUG_CONFIG)), yes)
84 OPT_DEFS += -DDEBUG_CONFIG 95 OPT_DEFS += -DDEBUG_CONFIG
85endif 96endif