diff options
Diffstat (limited to 'keyboards/sol/keymaps/default/keymap.c')
| -rw-r--r-- | keyboards/sol/keymaps/default/keymap.c | 145 |
1 files changed, 54 insertions, 91 deletions
diff --git a/keyboards/sol/keymaps/default/keymap.c b/keyboards/sol/keymaps/default/keymap.c index 799507f66..1742fc597 100644 --- a/keyboards/sol/keymaps/default/keymap.c +++ b/keyboards/sol/keymaps/default/keymap.c | |||
| @@ -4,9 +4,6 @@ | |||
| 4 | #include "lufa.h" | 4 | #include "lufa.h" |
| 5 | #include "split_util.h" | 5 | #include "split_util.h" |
| 6 | #endif | 6 | #endif |
| 7 | #ifdef SSD1306OLED | ||
| 8 | #include "common/ssd1306.h" | ||
| 9 | #endif | ||
| 10 | 7 | ||
| 11 | extern keymap_config_t keymap_config; | 8 | extern keymap_config_t keymap_config; |
| 12 | 9 | ||
| @@ -248,115 +245,81 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 248 | } | 245 | } |
| 249 | 246 | ||
| 250 | void matrix_init_user(void) { | 247 | void matrix_init_user(void) { |
| 251 | #ifdef RGBLIGHT_ENABLE | 248 | #ifdef RGBLIGHT_ENABLE |
| 252 | RGB_current_mode = rgblight_config.mode; | 249 | RGB_current_mode = rgblight_config.mode; |
| 253 | #endif | 250 | #endif |
| 254 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | ||
| 255 | #ifdef SSD1306OLED | ||
| 256 | iota_gfx_init(!has_usb()); // turns on the display | ||
| 257 | #endif | ||
| 258 | } | 251 | } |
| 259 | 252 | ||
| 260 | 253 | ||
| 261 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | 254 | // OLED Driver Logic |
| 262 | #ifdef SSD1306OLED | 255 | #ifdef OLED_DRIVER_ENABLE |
| 263 | 256 | ||
| 264 | // hook point for 'led_test' keymap | 257 | uint8_t oled_init_user(uint8_t rotation) { |
| 265 | // 'default' keymap's led_test_init() is empty function, do nothing | 258 | if (!has_usb()) |
| 266 | // 'led_test' keymap's led_test_init() force rgblight_mode_noeeprom(35); | 259 | return OLED_ROTATION_180; // flip 180 for offhand |
| 267 | __attribute__ ((weak)) | 260 | return rotation; |
| 268 | void led_test_init(void) {} | ||
| 269 | |||
| 270 | void matrix_scan_user(void) { | ||
| 271 | led_test_init(); | ||
| 272 | iota_gfx_task(); // this is what updates the display continuously | ||
| 273 | } | 261 | } |
| 274 | 262 | ||
| 275 | void matrix_update(struct CharacterMatrix *dest, | 263 | static void render_logo(void) { |
| 276 | const struct CharacterMatrix *source) { | 264 | static const char PROGMEM sol_logo[] = { |
| 277 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | 265 | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, |
| 278 | memcpy(dest->display, source->display, sizeof(dest->display)); | 266 | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, |
| 279 | dest->dirty = true; | 267 | 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0}; |
| 280 | } | 268 | |
| 269 | oled_write_P(sol_logo, false); | ||
| 281 | } | 270 | } |
| 282 | 271 | ||
| 283 | //assign the right code to your layers for OLED display | 272 | //assign the right code to your layers for OLED display |
| 284 | #define L_BASE 0 | 273 | #define L_BASE 0 |
| 285 | #define L_FN (1<<_FN) | 274 | #define L_FN (1<<_FN) |
| 286 | #define L_ADJ (1<<_ADJ) | 275 | #define L_ADJ (1<<_ADJ) |
| 276 | #define L_ADJ_TRI (L_ADJ|L_FN) | ||
| 287 | 277 | ||
| 288 | static void render_logo(struct CharacterMatrix *matrix) { | 278 | static void render_status(void) { |
| 289 | |||
| 290 | static char logo[]={ | ||
| 291 | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, | ||
| 292 | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, | ||
| 293 | 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4, | ||
| 294 | 0}; | ||
| 295 | matrix_write(matrix, logo); | ||
| 296 | //matrix_write_P(&matrix, PSTR(" Split keyboard kit")); | ||
| 297 | } | ||
| 298 | |||
| 299 | |||
| 300 | |||
| 301 | void render_status(struct CharacterMatrix *matrix) { | ||
| 302 | |||
| 303 | // Render to mode icon | 279 | // Render to mode icon |
| 304 | static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}}; | 280 | static const char PROGMEM mode_logo[4][4] = { |
| 305 | if(keymap_config.swap_lalt_lgui==false){ | 281 | {0x95,0x96,0x0a,0}, |
| 306 | matrix_write(matrix, logo[0][0]); | 282 | {0xb5,0xb6,0x0a,0}, |
| 307 | matrix_write_P(matrix, PSTR("\n")); | 283 | {0x97,0x98,0x0a,0}, |
| 308 | matrix_write(matrix, logo[0][1]); | 284 | {0xb7,0xb8,0x0a,0} }; |
| 309 | }else{ | 285 | |
| 310 | matrix_write(matrix, logo[1][0]); | 286 | if (keymap_config.swap_lalt_lgui != false) { |
| 311 | matrix_write_P(matrix, PSTR("\n")); | 287 | oled_write_P(mode_logo[0], false); |
| 312 | matrix_write(matrix, logo[1][1]); | 288 | oled_write_P(mode_logo[1], false); |
| 289 | } else { | ||
| 290 | oled_write_P(mode_logo[2], false); | ||
| 291 | oled_write_P(mode_logo[3], false); | ||
| 313 | } | 292 | } |
| 314 | 293 | ||
| 315 | // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below | 294 | // Define layers here, Have not worked out how to have text displayed for each layer. Copy down the number you see and add a case for it below |
| 316 | char buf[40]; | 295 | oled_write_P(PSTR("Layer: "), false); |
| 317 | snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); | 296 | switch (layer_state) { |
| 318 | matrix_write_P(matrix, PSTR("\nLayer: ")); | 297 | case L_BASE: |
| 319 | switch (layer_state) { | 298 | oled_write_P(PSTR("Default\n"), false); |
| 320 | case L_BASE: | 299 | break; |
| 321 | matrix_write_P(matrix, PSTR("Default")); | 300 | case L_FN: |
| 322 | break; | 301 | oled_write_P(PSTR("FN \n"), false); |
| 323 | case L_FN: | 302 | break; |
| 324 | matrix_write_P(matrix, PSTR("FN")); | 303 | case L_ADJ: |
| 325 | break; | 304 | case L_ADJ_TRI: |
| 326 | case L_ADJ: | 305 | oled_write_P(PSTR("ADJ \n"), false); |
| 327 | case L_ADJ_TRI: | 306 | break; |
| 328 | matrix_write_P(matrix, PSTR("ADJ")); | 307 | default: |
| 329 | break; | 308 | oled_write_P(PSTR("UNDEF \n"), false); |
| 330 | default: | 309 | } |
| 331 | matrix_write(matrix, buf); | ||
| 332 | } | ||
| 333 | 310 | ||
| 334 | // Host Keyboard LED Status | 311 | // Host Keyboard LED Status |
| 335 | char led[40]; | 312 | uint8_t led_usb_state = host_keyboard_leds(); |
| 336 | snprintf(led, sizeof(led), "\n%s %s %s", | 313 | oled_write_P(led_usb_state & (1<<USB_LED_NUM_LOCK) ? PSTR("NUMLOCK ") : PSTR(" "), false); |
| 337 | (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", | 314 | oled_write_P(led_usb_state & (1<<USB_LED_CAPS_LOCK) ? PSTR("CAPS ") : PSTR(" "), false); |
| 338 | (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", | 315 | oled_write_P(led_usb_state & (1<<USB_LED_SCROLL_LOCK) ? PSTR("SCLK ") : PSTR(" "), false); |
| 339 | (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); | ||
| 340 | matrix_write(matrix, led); | ||
| 341 | } | 316 | } |
| 342 | 317 | ||
| 343 | 318 | void oled_task_user(void) { | |
| 344 | void iota_gfx_task_user(void) { | 319 | if (is_master) |
| 345 | struct CharacterMatrix matrix; | 320 | render_status(); |
| 346 | 321 | else | |
| 347 | #if DEBUG_TO_SCREEN | 322 | render_logo(); |
| 348 | if (debug_enable) { | ||
| 349 | return; | ||
| 350 | } | ||
| 351 | #endif | ||
| 352 | |||
| 353 | matrix_clear(&matrix); | ||
| 354 | if(is_master){ | ||
| 355 | render_status(&matrix); | ||
| 356 | }else{ | ||
| 357 | render_logo(&matrix); | ||
| 358 | } | ||
| 359 | matrix_update(&display, &matrix); | ||
| 360 | } | 323 | } |
| 361 | 324 | ||
| 362 | #endif | 325 | #endif |
