diff options
Diffstat (limited to 'keyboards/lily58/keymaps/default/keymap.c')
| -rw-r--r-- | keyboards/lily58/keymaps/default/keymap.c | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/keyboards/lily58/keymaps/default/keymap.c b/keyboards/lily58/keymaps/default/keymap.c index f36248e12..f0fbaa8b0 100644 --- a/keyboards/lily58/keymaps/default/keymap.c +++ b/keyboards/lily58/keymaps/default/keymap.c | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | #include "ssd1306.h" | 8 | #include "ssd1306.h" |
| 9 | #endif | 9 | #endif |
| 10 | 10 | ||
| 11 | |||
| 12 | |||
| 13 | #ifdef RGBLIGHT_ENABLE | 11 | #ifdef RGBLIGHT_ENABLE |
| 14 | //Following line allows macro to read current RGB settings | 12 | //Following line allows macro to read current RGB settings |
| 15 | extern rgblight_config_t rgblight_config; | 13 | extern rgblight_config_t rgblight_config; |
| @@ -135,16 +133,18 @@ void matrix_init_user(void) { | |||
| 135 | #ifdef RGBLIGHT_ENABLE | 133 | #ifdef RGBLIGHT_ENABLE |
| 136 | RGB_current_mode = rgblight_config.mode; | 134 | RGB_current_mode = rgblight_config.mode; |
| 137 | #endif | 135 | #endif |
| 138 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | ||
| 139 | #ifdef SSD1306OLED | ||
| 140 | iota_gfx_init(!has_usb()); // turns on the display | ||
| 141 | #endif | ||
| 142 | } | 136 | } |
| 143 | 137 | ||
| 144 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | 138 | //SSD1306 OLED update loop, make sure to enable OLED_DRIVER_ENABLE=yes in rules.mk |
| 145 | #ifdef SSD1306OLED | 139 | #ifdef OLED_DRIVER_ENABLE |
| 146 | 140 | ||
| 147 | // When add source files to SRC in rules.mk, you can use functions. | 141 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { |
| 142 | if (!is_keyboard_master()) | ||
| 143 | return OLED_ROTATION_180; // flips the display 180 degrees if offhand | ||
| 144 | return rotation; | ||
| 145 | } | ||
| 146 | |||
| 147 | // When you add source files to SRC in rules.mk, you can use functions. | ||
| 148 | const char *read_layer_state(void); | 148 | const char *read_layer_state(void); |
| 149 | const char *read_logo(void); | 149 | const char *read_logo(void); |
| 150 | void set_keylog(uint16_t keycode, keyrecord_t *record); | 150 | void set_keylog(uint16_t keycode, keyrecord_t *record); |
| @@ -156,42 +156,24 @@ const char *read_keylogs(void); | |||
| 156 | // void set_timelog(void); | 156 | // void set_timelog(void); |
| 157 | // const char *read_timelog(void); | 157 | // const char *read_timelog(void); |
| 158 | 158 | ||
| 159 | void matrix_scan_user(void) { | 159 | void oled_task_user(void) { |
| 160 | iota_gfx_task(); | 160 | if (is_keyboard_master()) { |
| 161 | } | ||
| 162 | |||
| 163 | void matrix_render_user(struct CharacterMatrix *matrix) { | ||
| 164 | if (is_master) { | ||
| 165 | // If you want to change the display of OLED, you need to change here | 161 | // If you want to change the display of OLED, you need to change here |
| 166 | matrix_write_ln(matrix, read_layer_state()); | 162 | oled_write_ln(read_layer_state(), false); |
| 167 | matrix_write_ln(matrix, read_keylog()); | 163 | oled_write_ln(read_keylog(), false); |
| 168 | matrix_write_ln(matrix, read_keylogs()); | 164 | oled_write_ln(read_keylogs(), false); |
| 169 | //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); | 165 | //oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false); |
| 170 | //matrix_write_ln(matrix, read_host_led_state()); | 166 | //oled_write_ln(read_host_led_state(), false); |
| 171 | //matrix_write_ln(matrix, read_timelog()); | 167 | //oled_write_ln(read_timelog(), false); |
| 172 | } else { | 168 | } else { |
| 173 | matrix_write(matrix, read_logo()); | 169 | oled_write(read_logo(), false); |
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { | ||
| 178 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
| 179 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
| 180 | dest->dirty = true; | ||
| 181 | } | 170 | } |
| 182 | } | 171 | } |
| 183 | 172 | #endif // OLED_DRIVER_ENABLE | |
| 184 | void iota_gfx_task_user(void) { | ||
| 185 | struct CharacterMatrix matrix; | ||
| 186 | matrix_clear(&matrix); | ||
| 187 | matrix_render_user(&matrix); | ||
| 188 | matrix_update(&display, &matrix); | ||
| 189 | } | ||
| 190 | #endif//SSD1306OLED | ||
| 191 | 173 | ||
| 192 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 174 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 193 | if (record->event.pressed) { | 175 | if (record->event.pressed) { |
| 194 | #ifdef SSD1306OLED | 176 | #ifdef OLED_DRIVER_ENABLE |
| 195 | set_keylog(keycode, record); | 177 | set_keylog(keycode, record); |
| 196 | #endif | 178 | #endif |
| 197 | // set_timelog(); | 179 | // set_timelog(); |
