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