diff options
| author | marksard <38324387+marksard@users.noreply.github.com> | 2018-08-23 01:51:37 +0900 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-08-22 09:51:37 -0700 |
| commit | 6076ed85be111f0e88c7049aa3d2e69eed5005a1 (patch) | |
| tree | da704f8828a63245ea2333c883462b2f96591212 | |
| parent | 9d27d5544365b988575ca3face308d30feb40c86 (diff) | |
| download | qmk_firmware-6076ed85be111f0e88c7049aa3d2e69eed5005a1.tar.gz qmk_firmware-6076ed85be111f0e88c7049aa3d2e69eed5005a1.zip | |
Keyboard: Partial refactor of the crkbd code (#3600)
* Add display to LED-parameters function
* Improvement of update timing for OLED display (Need TWI_Init)
| -rw-r--r-- | keyboards/crkbd/keymaps/default/config.h | 6 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/default/keymap.c | 33 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/default/rules.mk | 13 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/lib/host_led_state_reader.c | 16 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/lib/keylogger.c | 46 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/lib/layer_state_reader.c | 38 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/lib/logo_reader.c | 13 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/lib/mode_icon_reader.c | 12 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/lib/rgb_state_reader.c | 15 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/lib/timelogger.c | 13 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/like_jis/keymap.c | 59 | ||||
| -rw-r--r-- | keyboards/crkbd/keymaps/like_jis/rules.mk | 9 |
12 files changed, 159 insertions, 114 deletions
diff --git a/keyboards/crkbd/keymaps/default/config.h b/keyboards/crkbd/keymaps/default/config.h index 15aeb098b..8d25f7cbc 100644 --- a/keyboards/crkbd/keymaps/default/config.h +++ b/keyboards/crkbd/keymaps/default/config.h | |||
| @@ -18,10 +18,7 @@ You should have received a copy of the GNU General Public License | |||
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #ifndef CONFIG_USER_H | 21 | #pragma once |
| 22 | #define CONFIG_USER_H | ||
| 23 | |||
| 24 | #include "../../config.h" | ||
| 25 | 22 | ||
| 26 | /* Use I2C or Serial */ | 23 | /* Use I2C or Serial */ |
| 27 | 24 | ||
| @@ -50,4 +47,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 50 | #define RGBLIGHT_HUE_STEP 10 | 47 | #define RGBLIGHT_HUE_STEP 10 |
| 51 | #define RGBLIGHT_SAT_STEP 17 | 48 | #define RGBLIGHT_SAT_STEP 17 |
| 52 | #define RGBLIGHT_VAL_STEP 17 | 49 | #define RGBLIGHT_VAL_STEP 17 |
| 53 | #endif | ||
diff --git a/keyboards/crkbd/keymaps/default/keymap.c b/keyboards/crkbd/keymaps/default/keymap.c index ac3b7215c..87661d345 100644 --- a/keyboards/crkbd/keymaps/default/keymap.c +++ b/keyboards/crkbd/keymaps/default/keymap.c | |||
| @@ -1,24 +1,14 @@ | |||
| 1 | #include "crkbd.h" | 1 | #include QMK_KEYBOARD_H |
| 2 | #include "bootloader.h" | 2 | #include "bootloader.h" |
| 3 | #include "action_layer.h" | ||
| 4 | #include "action_util.h" | ||
| 5 | #include "eeconfig.h" | ||
| 6 | #ifdef PROTOCOL_LUFA | 3 | #ifdef PROTOCOL_LUFA |
| 7 | #include "lufa.h" | 4 | #include "lufa.h" |
| 8 | #include "split_util.h" | 5 | #include "split_util.h" |
| 9 | #endif | 6 | #endif |
| 10 | #include "LUFA/Drivers/Peripheral/TWI.h" | ||
| 11 | #ifdef SSD1306OLED | 7 | #ifdef SSD1306OLED |
| 8 | #include "LUFA/Drivers/Peripheral/TWI.h" | ||
| 12 | #include "ssd1306.h" | 9 | #include "ssd1306.h" |
| 13 | #endif | 10 | #endif |
| 14 | 11 | ||
| 15 | #include "../lib/mode_icon_reader.c" | ||
| 16 | #include "../lib/layer_state_reader.c" | ||
| 17 | #include "../lib/host_led_state_reader.c" | ||
| 18 | #include "../lib/logo_reader.c" | ||
| 19 | #include "../lib/keylogger.c" | ||
| 20 | #include "../lib/timelogger.c" | ||
| 21 | |||
| 22 | extern keymap_config_t keymap_config; | 12 | extern keymap_config_t keymap_config; |
| 23 | 13 | ||
| 24 | #ifdef RGBLIGHT_ENABLE | 14 | #ifdef RGBLIGHT_ENABLE |
| @@ -148,12 +138,25 @@ void matrix_init_user(void) { | |||
| 148 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | 138 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h |
| 149 | #ifdef SSD1306OLED | 139 | #ifdef SSD1306OLED |
| 150 | 140 | ||
| 141 | // When add source files to SRC in rules.mk, you can use functions. | ||
| 142 | const char *read_layer_state(void); | ||
| 143 | const char *read_logo(void); | ||
| 144 | void set_keylog(uint16_t keycode, keyrecord_t *record); | ||
| 145 | const char *read_keylog(void); | ||
| 146 | const char *read_keylogs(void); | ||
| 147 | |||
| 148 | // const char *read_mode_icon(bool swap); | ||
| 149 | // const char *read_host_led_state(void); | ||
| 150 | // void set_timelog(void); | ||
| 151 | // const char *read_timelog(void); | ||
| 152 | |||
| 151 | void matrix_scan_user(void) { | 153 | void matrix_scan_user(void) { |
| 152 | iota_gfx_task(); | 154 | iota_gfx_task(); |
| 153 | } | 155 | } |
| 154 | 156 | ||
| 155 | void matrix_render_user(struct CharacterMatrix *matrix) { | 157 | void matrix_render_user(struct CharacterMatrix *matrix) { |
| 156 | if (is_master) { | 158 | if (is_master) { |
| 159 | // If you want to change the display of OLED, you need to change here | ||
| 157 | matrix_write_ln(matrix, read_layer_state()); | 160 | matrix_write_ln(matrix, read_layer_state()); |
| 158 | matrix_write_ln(matrix, read_keylog()); | 161 | matrix_write_ln(matrix, read_keylog()); |
| 159 | matrix_write_ln(matrix, read_keylogs()); | 162 | matrix_write_ln(matrix, read_keylogs()); |
| @@ -182,7 +185,7 @@ void iota_gfx_task_user(void) { | |||
| 182 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 185 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 183 | if (record->event.pressed) { | 186 | if (record->event.pressed) { |
| 184 | set_keylog(keycode, record); | 187 | set_keylog(keycode, record); |
| 185 | set_timelog(); | 188 | // set_timelog(); |
| 186 | } | 189 | } |
| 187 | 190 | ||
| 188 | switch (keycode) { | 191 | switch (keycode) { |
diff --git a/keyboards/crkbd/keymaps/default/rules.mk b/keyboards/crkbd/keymaps/default/rules.mk index 33ddd82a4..6570e2f5c 100644 --- a/keyboards/crkbd/keymaps/default/rules.mk +++ b/keyboards/crkbd/keymaps/default/rules.mk | |||
| @@ -15,11 +15,16 @@ AUDIO_ENABLE = no # Audio output on port C6 | |||
| 15 | UNICODE_ENABLE = no # Unicode | 15 | UNICODE_ENABLE = no # Unicode |
| 16 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 16 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 17 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | 17 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. |
| 18 | ONEHAND_ENABLE = no # Enable one-hand typing | 18 | SWAP_HANDS_ENABLE = no # Enable one-hand typing |
| 19 | 19 | ||
| 20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 22 | 22 | ||
| 23 | ifndef QUANTUM_DIR | 23 | # If you want to change the display of OLED, you need to change here |
| 24 | include ../../../../Makefile | 24 | SRC += ../lib/rgb_state_reader.c \ |
| 25 | endif | 25 | ../lib/layer_state_reader.c \ |
| 26 | ../lib/logo_reader.c \ | ||
| 27 | ../lib/keylogger.c \ | ||
| 28 | # ../lib/mode_icon_reader.c \ | ||
| 29 | # ../lib/host_led_state_reader.c \ | ||
| 30 | # ../lib/timelogger.c \ | ||
diff --git a/keyboards/crkbd/keymaps/lib/host_led_state_reader.c b/keyboards/crkbd/keymaps/lib/host_led_state_reader.c index c19af11f8..41ac55dc2 100644 --- a/keyboards/crkbd/keymaps/lib/host_led_state_reader.c +++ b/keyboards/crkbd/keymaps/lib/host_led_state_reader.c | |||
| @@ -1,13 +1,15 @@ | |||
| 1 | #include <stdio.h> | ||
| 1 | #include "crkbd.h" | 2 | #include "crkbd.h" |
| 2 | 3 | ||
| 3 | char host_led_state[40]; | 4 | char host_led_state_str[24]; |
| 4 | 5 | ||
| 5 | char *read_host_led_state(void) | 6 | const char *read_host_led_state(void) |
| 6 | { | 7 | { |
| 7 | snprintf(host_led_state, sizeof(host_led_state), "\n%s %s %s", | 8 | uint8_t leds = host_keyboard_leds(); |
| 8 | (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", | 9 | snprintf(host_led_state_str, sizeof(host_led_state_str), "NL:%s CL:%s SL:%s", |
| 9 | (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) ? "CAPS" : " ", | 10 | (leds & (1 << USB_LED_NUM_LOCK)) ? "on" : "- ", |
| 10 | (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); | 11 | (leds & (1 << USB_LED_CAPS_LOCK)) ? "on" : "- ", |
| 12 | (leds & (1 << USB_LED_SCROLL_LOCK)) ? "on" : "- "); | ||
| 11 | 13 | ||
| 12 | return host_led_state; | 14 | return host_led_state_str; |
| 13 | } | 15 | } |
diff --git a/keyboards/crkbd/keymaps/lib/keylogger.c b/keyboards/crkbd/keymaps/lib/keylogger.c index ee14ff033..8f2a8ce3c 100644 --- a/keyboards/crkbd/keymaps/lib/keylogger.c +++ b/keyboards/crkbd/keymaps/lib/keylogger.c | |||
| @@ -1,10 +1,11 @@ | |||
| 1 | #include <stdio.h> | ||
| 1 | #include "crkbd.h" | 2 | #include "crkbd.h" |
| 2 | 3 | ||
| 3 | char keylog[40] = {}; | 4 | char keylog_str[24] = {}; |
| 4 | char keylogs[21] = {}; | 5 | char keylogs_str[21] = {}; |
| 5 | int keylogs_idx = 0; | 6 | int keylogs_str_idx = 0; |
| 6 | 7 | ||
| 7 | char code_to_name[60] = { | 8 | const char code_to_name[60] = { |
| 8 | ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', | 9 | ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', |
| 9 | 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', | 10 | 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', |
| 10 | 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', | 11 | 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', |
| @@ -12,38 +13,33 @@ char code_to_name[60] = { | |||
| 12 | 'R', 'E', 'B', 'T', ' ', ' ', ' ', ' ', ' ', ' ', | 13 | 'R', 'E', 'B', 'T', ' ', ' ', ' ', ' ', ' ', ' ', |
| 13 | ' ', ';', '\'', ' ', ',', '.', '/', ' ', ' ', ' '}; | 14 | ' ', ';', '\'', ' ', ',', '.', '/', ' ', ' ', ' '}; |
| 14 | 15 | ||
| 15 | void set_keylog(uint16_t keycode, keyrecord_t *record) | 16 | void set_keylog(uint16_t keycode, keyrecord_t *record) { |
| 16 | { | ||
| 17 | char name = ' '; | 17 | char name = ' '; |
| 18 | if (keycode < 60) | 18 | if (keycode < 60) { |
| 19 | { | ||
| 20 | name = code_to_name[keycode]; | 19 | name = code_to_name[keycode]; |
| 21 | } | 20 | } |
| 22 | 21 | ||
| 23 | // update keylog | 22 | // update keylog |
| 24 | snprintf(keylog, sizeof(keylog), "%dx%d, k%2d : %c", | 23 | snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c", |
| 25 | record->event.key.row, | 24 | record->event.key.row, record->event.key.col, |
| 26 | record->event.key.col, | 25 | keycode, name); |
| 27 | keycode, | ||
| 28 | name); | ||
| 29 | 26 | ||
| 30 | // update keylogs | 27 | // update keylogs |
| 31 | if (keylogs_idx == sizeof(keylogs) - 1) | 28 | if (keylogs_str_idx == sizeof(keylogs_str) - 1) { |
| 32 | { | 29 | keylogs_str_idx = 0; |
| 33 | keylogs_idx = 0; | 30 | for (int i = 0; i < sizeof(keylogs_str) - 1; i++) { |
| 34 | for (int i = 0; i < sizeof(keylogs) - 1; i++) | 31 | keylogs_str[i] = ' '; |
| 35 | { | ||
| 36 | keylogs[i] = ' '; | ||
| 37 | } | 32 | } |
| 38 | } | 33 | } |
| 39 | keylogs[keylogs_idx] = name; | 34 | |
| 40 | keylogs_idx++; | 35 | keylogs_str[keylogs_str_idx] = name; |
| 36 | keylogs_str_idx++; | ||
| 41 | } | 37 | } |
| 42 | 38 | ||
| 43 | char *read_keylog(void) { | 39 | const char *read_keylog(void) { |
| 44 | return keylog; | 40 | return keylog_str; |
| 45 | } | 41 | } |
| 46 | 42 | ||
| 47 | char *read_keylogs(void) { | 43 | const char *read_keylogs(void) { |
| 48 | return keylogs; | 44 | return keylogs_str; |
| 49 | } | 45 | } |
diff --git a/keyboards/crkbd/keymaps/lib/layer_state_reader.c b/keyboards/crkbd/keymaps/lib/layer_state_reader.c index f79720d6f..eddb71337 100644 --- a/keyboards/crkbd/keymaps/lib/layer_state_reader.c +++ b/keyboards/crkbd/keymaps/lib/layer_state_reader.c | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | |||
| 2 | #include QMK_KEYBOARD_H | ||
| 3 | #include <stdio.h> | ||
| 1 | #include "crkbd.h" | 4 | #include "crkbd.h" |
| 2 | 5 | ||
| 3 | #define L_BASE 0 | 6 | #define L_BASE 0 |
| @@ -6,27 +9,26 @@ | |||
| 6 | #define L_ADJUST 65536 | 9 | #define L_ADJUST 65536 |
| 7 | #define L_ADJUST_TRI 65560 | 10 | #define L_ADJUST_TRI 65560 |
| 8 | 11 | ||
| 9 | char layer_state_str[40]; | 12 | char layer_state_str[24]; |
| 10 | 13 | ||
| 11 | char *read_layer_state(void) | 14 | const char *read_layer_state(void) { |
| 12 | { | ||
| 13 | switch (layer_state) | 15 | switch (layer_state) |
| 14 | { | 16 | { |
| 15 | case L_BASE: | 17 | case L_BASE: |
| 16 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Default"); | 18 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Default"); |
| 17 | break; | 19 | break; |
| 18 | case L_RAISE: | 20 | case L_RAISE: |
| 19 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Raise"); | 21 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Raise"); |
| 20 | break; | 22 | break; |
| 21 | case L_LOWER: | 23 | case L_LOWER: |
| 22 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Lower"); | 24 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Lower"); |
| 23 | break; | 25 | break; |
| 24 | case L_ADJUST: | 26 | case L_ADJUST: |
| 25 | case L_ADJUST_TRI: | 27 | case L_ADJUST_TRI: |
| 26 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Adjust"); | 28 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Adjust"); |
| 27 | break; | 29 | break; |
| 28 | default: | 30 | default: |
| 29 | snprintf(layer_state_str,sizeof(layer_state_str), "Layer: Undef-%ld", layer_state); | 31 | snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Undef-%ld", layer_state); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | return layer_state_str; | 34 | return layer_state_str; |
diff --git a/keyboards/crkbd/keymaps/lib/logo_reader.c b/keyboards/crkbd/keymaps/lib/logo_reader.c index 46de17bfe..1bc1503a6 100644 --- a/keyboards/crkbd/keymaps/lib/logo_reader.c +++ b/keyboards/crkbd/keymaps/lib/logo_reader.c | |||
| @@ -1,12 +1,11 @@ | |||
| 1 | #include "crkbd.h" | 1 | #include "crkbd.h" |
| 2 | 2 | ||
| 3 | char *read_logo(void) | 3 | const char *read_logo(void) { |
| 4 | { | 4 | static char logo[] = { |
| 5 | static char logo[]={ | 5 | 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, |
| 6 | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, | 6 | 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, |
| 7 | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, | 7 | 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, |
| 8 | 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4, | 8 | 0}; |
| 9 | 0}; | ||
| 10 | 9 | ||
| 11 | return logo; | 10 | return logo; |
| 12 | } | 11 | } |
diff --git a/keyboards/crkbd/keymaps/lib/mode_icon_reader.c b/keyboards/crkbd/keymaps/lib/mode_icon_reader.c index cb3d8adb1..04c226506 100644 --- a/keyboards/crkbd/keymaps/lib/mode_icon_reader.c +++ b/keyboards/crkbd/keymaps/lib/mode_icon_reader.c | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | #include <stdio.h> | ||
| 1 | #include "crkbd.h" | 2 | #include "crkbd.h" |
| 2 | 3 | ||
| 3 | char mode_icon[40]; | 4 | char mode_icon[24]; |
| 4 | 5 | ||
| 5 | char *read_mode_icon(bool swap) | 6 | const char *read_mode_icon(bool swap) { |
| 6 | { | 7 | static char logo[][2][3] = {{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}}; |
| 7 | static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}}; | 8 | if (swap == false) { |
| 8 | if(swap == false){ | ||
| 9 | snprintf(mode_icon, sizeof(mode_icon), "%s\n%s", logo[0][0], logo[0][1]); | 9 | snprintf(mode_icon, sizeof(mode_icon), "%s\n%s", logo[0][0], logo[0][1]); |
| 10 | }else{ | 10 | } else { |
| 11 | snprintf(mode_icon, sizeof(mode_icon), "%s\n%s", logo[1][0], logo[1][1]); | 11 | snprintf(mode_icon, sizeof(mode_icon), "%s\n%s", logo[1][0], logo[1][1]); |
| 12 | } | 12 | } |
| 13 | 13 | ||
diff --git a/keyboards/crkbd/keymaps/lib/rgb_state_reader.c b/keyboards/crkbd/keymaps/lib/rgb_state_reader.c new file mode 100644 index 000000000..e0efe2e52 --- /dev/null +++ b/keyboards/crkbd/keymaps/lib/rgb_state_reader.c | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #ifdef RGBLIGHT_ENABLE | ||
| 2 | |||
| 3 | #include QMK_KEYBOARD_H | ||
| 4 | #include <stdio.h> | ||
| 5 | |||
| 6 | extern rgblight_config_t rgblight_config; | ||
| 7 | char rbf_info_str[24]; | ||
| 8 | const char *read_rgb_info(void) { | ||
| 9 | |||
| 10 | snprintf(rbf_info_str, sizeof(rbf_info_str), "%s %2d h%3d s%3d v%3d", | ||
| 11 | rgblight_config.enable ? "on" : "- ", rgblight_config.mode, | ||
| 12 | rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 13 | return rbf_info_str; | ||
| 14 | } | ||
| 15 | #endif | ||
diff --git a/keyboards/crkbd/keymaps/lib/timelogger.c b/keyboards/crkbd/keymaps/lib/timelogger.c index 0e22bafe7..69828a3a0 100644 --- a/keyboards/crkbd/keymaps/lib/timelogger.c +++ b/keyboards/crkbd/keymaps/lib/timelogger.c | |||
| @@ -1,17 +1,16 @@ | |||
| 1 | #include <stdio.h> | ||
| 1 | #include "crkbd.h" | 2 | #include "crkbd.h" |
| 2 | 3 | ||
| 3 | char timelog[40] = {}; | 4 | char timelog_str[24] = {}; |
| 4 | int last_time = 0; | 5 | int last_time = 0; |
| 5 | int elapsed_time = 0; | 6 | int elapsed_time = 0; |
| 6 | 7 | ||
| 7 | void set_timelog(void) | 8 | void set_timelog(void) { |
| 8 | { | ||
| 9 | elapsed_time = timer_elapsed(last_time); | 9 | elapsed_time = timer_elapsed(last_time); |
| 10 | last_time = timer_read(); | 10 | last_time = timer_read(); |
| 11 | snprintf(timelog, sizeof(timelog), "lt:%5d, et:%5d", last_time, elapsed_time); | 11 | snprintf(timelog_str, sizeof(timelog_str), "lt:%5d, et:%5d", last_time, elapsed_time); |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | char *read_timelog(void) | 14 | const char *read_timelog(void) { |
| 15 | { | 15 | return timelog_str; |
| 16 | return timelog; | ||
| 17 | } | 16 | } |
diff --git a/keyboards/crkbd/keymaps/like_jis/keymap.c b/keyboards/crkbd/keymaps/like_jis/keymap.c index 0dd9c1550..31b5230b1 100644 --- a/keyboards/crkbd/keymaps/like_jis/keymap.c +++ b/keyboards/crkbd/keymaps/like_jis/keymap.c | |||
| @@ -5,16 +5,10 @@ | |||
| 5 | #include "split_util.h" | 5 | #include "split_util.h" |
| 6 | #endif | 6 | #endif |
| 7 | #ifdef SSD1306OLED | 7 | #ifdef SSD1306OLED |
| 8 | #include "LUFA/Drivers/Peripheral/TWI.h" | ||
| 8 | #include "ssd1306.h" | 9 | #include "ssd1306.h" |
| 9 | #endif | 10 | #endif |
| 10 | 11 | ||
| 11 | #include "../lib/mode_icon_reader.c" | ||
| 12 | #include "../lib/layer_state_reader.c" | ||
| 13 | #include "../lib/host_led_state_reader.c" | ||
| 14 | #include "../lib/logo_reader.c" | ||
| 15 | #include "../lib/keylogger.c" | ||
| 16 | #include "../lib/timelogger.c" | ||
| 17 | |||
| 18 | extern keymap_config_t keymap_config; | 12 | extern keymap_config_t keymap_config; |
| 19 | 13 | ||
| 20 | #ifdef RGBLIGHT_ENABLE | 14 | #ifdef RGBLIGHT_ENABLE |
| @@ -84,7 +78,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 84 | //|------+------+------+------+------+------| |------+------+------+------+------+------| | 78 | //|------+------+------+------+------+------| |------+------+------+------+------+------| |
| 85 | _____, F11, F12, XXXXX, KANJI, ENT, XXXXX, XXXXX, COMM, DOT, SLSH, RO,\ | 79 | _____, F11, F12, XXXXX, KANJI, ENT, XXXXX, XXXXX, COMM, DOT, SLSH, RO,\ |
| 86 | //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------| | 80 | //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------| |
| 87 | _____, _____, DEL, XXXXX, _____, APP \ | 81 | _____, _____, DEL, _____, _____, APP \ |
| 88 | //`--------------------' `--------------------' | 82 | //`--------------------' `--------------------' |
| 89 | ), | 83 | ), |
| 90 | 84 | ||
| @@ -96,19 +90,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 96 | //|------+------+------+------+------+------| |------+------+------+------+------+------| | 90 | //|------+------+------+------+------+------| |------+------+------+------+------+------| |
| 97 | _____, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, 0, 1, 2, 3, DOT, XXXXX,\ | 91 | _____, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, 0, 1, 2, 3, DOT, XXXXX,\ |
| 98 | //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------| | 92 | //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------| |
| 99 | _____, _____, XXXXX, XXXXX, _____, LALT \ | 93 | _____, _____, BSPC, _____, _____, LALT \ |
| 100 | //`--------------------' `--------------------' | 94 | //`--------------------' `--------------------' |
| 101 | ), | 95 | ), |
| 102 | 96 | ||
| 103 | [_ADJUST] = LAYOUT_kc( \ | 97 | [_ADJUST] = LAYOUT_kc( \ |
| 104 | //,-----------------------------------------. ,-----------------------------------------. | 98 | //,-----------------------------------------. ,-----------------------------------------. |
| 105 | RST, LRST, KNRM, KSWP, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX,\ | 99 | _____, RST, LRST, KNRM, KSWP,XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX,\ |
| 106 | //|------+------+------+------+------+------| |------+------+------+------+------+------| | 100 | //|------+-------+------+------+------+-----| |------+------+------+------+------+------| |
| 107 | LTOG, LHUI, LSAI, LVAI, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, PGUP, XXXXX,\ | 101 | _____, LTOG, LHUI, LSAI, LVAI,XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, PGUP, XXXXX,\ |
| 108 | //|------+------+------+------+------+------| |------+------+------+------+------+------| | 102 | //|------+-------+------+------+------+-----| |------+------+------+------+------+------| |
| 109 | LSMOD, LHUD, LSAD, LVAD, XXXXX, XXXXX, XXXXX, XXXXX, XXXXX, HOME, PGDN, END,\ | 103 | _____, LSMOD, LHUD, LSAD, LVAD,XXXXX, XXXXX, XXXXX, XXXXX, HOME, PGDN, END,\ |
| 110 | //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------| | 104 | //|------+------+------+------+------+------+------| |------+------+------+------+------+------+------| |
| 111 | _____, _____, XXXXX, XXXXX, _____, XXXXX \ | 105 | _____, _____, XXXXX, _____, _____, XXXXX \ |
| 112 | //`--------------------' `--------------------' | 106 | //`--------------------' `--------------------' |
| 113 | ) | 107 | ) |
| 114 | }; | 108 | }; |
| @@ -130,6 +124,7 @@ void matrix_init_user(void) { | |||
| 130 | #endif | 124 | #endif |
| 131 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | 125 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h |
| 132 | #ifdef SSD1306OLED | 126 | #ifdef SSD1306OLED |
| 127 | TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); | ||
| 133 | iota_gfx_init(!has_usb()); // turns on the display | 128 | iota_gfx_init(!has_usb()); // turns on the display |
| 134 | #endif | 129 | #endif |
| 135 | } | 130 | } |
| @@ -137,18 +132,42 @@ void matrix_init_user(void) { | |||
| 137 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | 132 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h |
| 138 | #ifdef SSD1306OLED | 133 | #ifdef SSD1306OLED |
| 139 | 134 | ||
| 135 | |||
| 136 | // When add source files to SRC in rules.mk, you can use functions. | ||
| 137 | const char *read_layer_state(void); | ||
| 138 | const char *read_logo(void); | ||
| 139 | void set_keylog(uint16_t keycode, keyrecord_t *record); | ||
| 140 | const char *read_keylog(void); | ||
| 141 | const char *read_keylogs(void); | ||
| 142 | |||
| 143 | // const char *read_mode_icon(bool swap); | ||
| 144 | // const char *read_host_led_state(void); | ||
| 145 | // void set_timelog(void); | ||
| 146 | // const char *read_timelog(void); | ||
| 147 | |||
| 148 | #ifdef RGBLIGHT_ENABLE | ||
| 149 | const char *read_rgb_info(void); | ||
| 150 | #define RENDER_RGB_INFO(m) matrix_write_ln(m, (const char*)read_rgb_info()) | ||
| 151 | #else | ||
| 152 | #define RENDER_RGB_INFO(m) | ||
| 153 | #endif | ||
| 154 | |||
| 155 | |||
| 140 | void matrix_scan_user(void) { | 156 | void matrix_scan_user(void) { |
| 141 | iota_gfx_task(); | 157 | iota_gfx_task(); |
| 142 | } | 158 | } |
| 143 | 159 | ||
| 144 | inline void matrix_render_user(struct CharacterMatrix *matrix) { | 160 | inline void matrix_render_user(struct CharacterMatrix *matrix) { |
| 145 | if (is_master) { | 161 | if (is_master) { |
| 162 | // If you want to change the display of OLED, you need to change here | ||
| 146 | matrix_write_ln(matrix, read_layer_state()); | 163 | matrix_write_ln(matrix, read_layer_state()); |
| 147 | matrix_write_ln(matrix, read_keylog()); | 164 | matrix_write_ln(matrix, read_keylog()); |
| 148 | matrix_write_ln(matrix, read_keylogs()); | 165 | RENDER_RGB_INFO(matrix); |
| 149 | //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); | 166 | // matrix_write_ln(matrix, read_keylogs()); |
| 150 | //matrix_write_ln(matrix, read_host_led_state()); | 167 | // matrix_write_ln(matrix, read_host_led_state()); |
| 151 | //matrix_write_ln(matrix, read_timelog()); | 168 | |
| 169 | // matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); | ||
| 170 | // matrix_write_ln(matrix, read_timelog()); | ||
| 152 | } else { | 171 | } else { |
| 153 | matrix_write(matrix, read_logo()); | 172 | matrix_write(matrix, read_logo()); |
| 154 | } | 173 | } |
| @@ -174,7 +193,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 174 | #ifdef SSD1306OLED | 193 | #ifdef SSD1306OLED |
| 175 | if (record->event.pressed) { | 194 | if (record->event.pressed) { |
| 176 | set_keylog(keycode, record); | 195 | set_keylog(keycode, record); |
| 177 | set_timelog(); | 196 | // set_timelog(); |
| 178 | } | 197 | } |
| 179 | #endif | 198 | #endif |
| 180 | 199 | ||
diff --git a/keyboards/crkbd/keymaps/like_jis/rules.mk b/keyboards/crkbd/keymaps/like_jis/rules.mk index 3f1bd9108..6570e2f5c 100644 --- a/keyboards/crkbd/keymaps/like_jis/rules.mk +++ b/keyboards/crkbd/keymaps/like_jis/rules.mk | |||
| @@ -19,3 +19,12 @@ SWAP_HANDS_ENABLE = no # Enable one-hand typing | |||
| 19 | 19 | ||
| 20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 22 | |||
| 23 | # If you want to change the display of OLED, you need to change here | ||
| 24 | SRC += ../lib/rgb_state_reader.c \ | ||
| 25 | ../lib/layer_state_reader.c \ | ||
| 26 | ../lib/logo_reader.c \ | ||
| 27 | ../lib/keylogger.c \ | ||
| 28 | # ../lib/mode_icon_reader.c \ | ||
| 29 | # ../lib/host_led_state_reader.c \ | ||
| 30 | # ../lib/timelogger.c \ | ||
