]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/helix/rev2/keymaps/froggy/keymap.c
Remove redundant KC_TRNS and KC_NO fillers in remaining keymaps (#5154)
[qmk_firmware.git] / keyboards / helix / rev2 / keymaps / froggy / keymap.c
1 #include QMK_KEYBOARD_H
2 #include "bootloader.h"
3 #ifdef PROTOCOL_LUFA
4 #include "lufa.h"
5 #include "split_util.h"
6 #endif
7 #ifdef AUDIO_ENABLE
8   #include "audio.h"
9 #endif
10 #ifdef SSD1306OLED
11   #include "ssd1306.h"
12 #endif
13
14 extern keymap_config_t keymap_config;
15
16 #ifdef RGBLIGHT_ENABLE
17 //Following line allows macro to read current RGB settings
18 extern rgblight_config_t rgblight_config;
19 #endif
20
21 extern uint8_t is_master;
22
23 #define DELAY_TIME  75
24 static uint16_t key_timer;
25 static uint16_t tap_timer;
26 static uint16_t delay_registered_code;
27 static uint8_t delay_mat_row;
28 static uint8_t delay_mat_col;
29 static bool delay_key_stat;
30 static bool delay_key_pressed;
31 static bool tapping_key;
32
33 // Each layer gets a name for readability, which is then used in the keymap matrix below.
34 // The underscores don't mean anything - you can have a layer called STUFF or any other name.
35 // Layer names don't all need to be of the same length, obviously, and you can also skip them
36 // entirely and just use numbers.
37 #define _BASE 0
38 #define _OPT 1
39 #define _FUNC 2
40 #define _SYM 3
41 #define _NUM 4
42
43 bool RGBAnimation = false; //Flag for LED Layer color Refresh.
44
45 enum custom_keycodes {
46   QWERTY = SAFE_RANGE,
47   EISU,
48   KANA,
49   RGBRST,
50   RGBOFF,
51   RGB1,
52   RGB2,
53   RGB3,
54   OPT_TAP_SP,
55   DESKTOP,
56   MAC,
57   WIN,
58 };
59
60 enum macro_keycodes {
61   KC_SAMPLEMACRO,
62 };
63
64 //Macros
65 #define M_SAMPLE M(KC_SAMPLEMACRO)
66
67 #if HELIX_ROWS == 5
68 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
69
70   /* Base
71    * ,-----------------------------------------.             ,-----------------------------------------.
72    * |  C+z |   ;  |   [  |   (  |   <  |   {  |             |      |      |      |      |      |      |
73    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
74    * | KANA |   P  |   K  |   R  |   A  |   F  |             |      |      |      |      |      |      |
75    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
76    * |  BS  |   D  |   T  |   H  |   E  |   O  |             |      |      |      |      |      |      |
77    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
78    * | Shift|   Y  |   S  |   N  |   I  |   U  |Space |      |      |      |      |      |      |      |
79    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
80    * | Ctrl | Alt  | Gui  | Sym  | Num  | OPT  | Ent  |      |      |      |      |      |      |      |
81    * `-------------------------------------------------------------------------------------------------'
82    */
83   [_BASE] = LAYOUT( \
84       LCTL(KC_Z),    KC_SCLN,       KC_LBRC,       KC_LPRN,   KC_LT,     KC_LCBR,                                _______,  _______,  _______,  _______,  _______,  _______, \
85       KANA,          KC_P,          KC_K,          KC_R,      KC_A,      KC_F,                                   _______,  _______,  _______,  _______,  _______,  _______, \
86       KC_BSPC,       KC_D,          KC_T,          KC_H,      KC_E,      KC_O,                                   _______,  _______,  _______,  _______,  _______,  _______, \
87       OSM(MOD_LSFT), KC_Y,          KC_S,          KC_N,      KC_I,      KC_U,       KC_SPC, _______,  _______,  _______,  _______,  _______,  _______,  _______, \
88       OSM(MOD_LCTL), OSM(MOD_LALT), OSM(MOD_LGUI), MO(_SYM),  MO(_NUM),  OPT_TAP_SP, KC_ENT, _______,  _______,  _______,  _______,  _______,  _______,  _______ \
89       ),
90
91   /* Opt
92    * ,-----------------------------------------.             ,-----------------------------------------.
93    * |  Esc |  :   |  ]   |  )   |  >   |  }   |             |      |      |      |      |      |      |
94    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
95    * |  EISU|   J  |   M  |   B  |   '  |  Tab |             |      |      |      |      |      |      |
96    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
97    * |   .  |   V  |   C  |   L  |   Z  |  Q   |             |      |      |      |      |      |      |
98    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
99    * |      |   X  |   G  |   W  |   -  |  Del | Esc  |      |      |      |      |      |      |      |
100    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
101    * |      |      |      |   ,  | DTOP |      |      |      |      |      |      |      |      |      |
102    * `-------------------------------------------------------------------------------------------------'
103    */
104   [_OPT] = LAYOUT( \
105       KC_ESC,  KC_COLN,KC_RBRC, KC_RPRN,KC_GT,     KC_RCBR,                   _______,  _______,  _______,  _______,  _______,  _______, \
106       EISU,    KC_J,   KC_M,    KC_B,   KC_QUOT,   KC_TAB,                    _______,  _______,  _______,  _______,  _______,  _______, \
107       KC_DOT,  KC_V,   KC_C,    KC_L,   KC_Z,      KC_Q,                      _______,  _______,  _______,  _______,  _______,  _______, \
108       _______, KC_X,   KC_G,    KC_W,   KC_MINUS,  KC_DEL,  KC_ESC,  _______, _______,  _______,  _______,  _______,  _______,  _______, \
109       _______, _______,_______, KC_COMM,DESKTOP,   _______, _______, _______, _______,  _______,  _______,  _______,  _______,  _______ \
110       ),
111
112   /* Func
113    * ,-----------------------------------------.             ,-----------------------------------------.
114    * |RGBRST|  Hue |      |  RST |  Mac |  Win |             |      |      |      |      |      |      |
115    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
116    * | RGB1 | VAL+ |  F7  |  F8  |  F9  |      |             |      |      |      |      |      |      |
117    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
118    * | RGB2 | VAL- |  F4  |  F5  |  F6  | F12  |             |      |      |      |      |      |      |
119    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
120    * | RGB3 |  F10 |  F1  |  F2  |  F3  | F11  |      |      |      |      |      |      |      |      |
121    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
122    * |RGBOFF|      |      |      |      |      |      |      |      |      |      |      |      |      |
123    * `-------------------------------------------------------------------------------------------------'
124    */
125   [_FUNC] = LAYOUT( \
126       RGBRST,RGB_HUI, _______, RESET,   MAC,     WIN,                         _______,  _______,  _______,  _______,  _______,  _______, \
127       RGB1,  RGB_VAI, KC_F7,   KC_F8,   KC_F9,   _______,                     _______,  _______,  _______,  _______,  _______,  _______, \
128       RGB2,  RGB_VAD, KC_F4,   KC_F5,   KC_F6,   KC_F12,                      _______,  _______,  _______,  _______,  _______,  _______, \
129       RGB3,  KC_F10,  KC_F1,   KC_F2,   KC_F3,   KC_F11,   _______,  _______, _______,  _______,  _______,  _______,  _______,  _______, \
130       RGBOFF,_______, _______, _______, _______, _______,  _______,  _______, _______,  _______,  _______,  _______,  _______,  _______ \
131       ),
132
133   /* Sym
134    * ,-----------------------------------------.             ,-----------------------------------------.
135    * |  Ins |  GRV |      |  PU  |  PD  |   ^  |             |      |      |      |      |      |      |
136    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
137    * |      |   \  |   #  |   =  |   ?  |   %  |             |      |      |      |      |      |      |
138    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
139    * |      |   $  |  upA |   @  |   !  |   |  |             |      |      |      |      |      |      |
140    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
141    * |  CL  |  <-  |  dwA |  ->  |   _  |   &  |      |      |      |      |      |      |      |      |
142    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
143    * |      |      |  PS  |      |   ~  |      |      |      |      |      |      |      |      |      |
144    * `-------------------------------------------------------------------------------------------------'
145    */
146   [_SYM] = LAYOUT( \
147       KC_INS,  KC_GRV,  _______, KC_PGUP, KC_PGDN, KC_CIRC,                   _______,  _______,  _______,  _______,  _______,  _______, \
148       _______, KC_BSLS, KC_HASH, KC_EQL,  KC_QUES, KC_PERC,                   _______,  _______,  _______,  _______,  _______,  _______, \
149       _______, KC_DLR,  KC_UP,   KC_AT,   KC_EXLM, KC_PIPE,                   _______,  _______,  _______,  _______,  _______,  _______, \
150       KC_CAPS, KC_LEFT, KC_DOWN, KC_RIGHT,KC_UNDS, KC_AMPR, _______, _______, _______,  _______,  _______,  _______,  _______,  _______, \
151       _______, _______, KC_PSCR, _______, KC_TILD, _______, _______, _______, _______,  _______,  _______,  _______,  _______,  _______ \
152       ),
153
154   /* Raise
155    * ,-----------------------------------------.             ,-----------------------------------------.
156    * |      |      | Func | home |  End |      |             |      |      |      |      |      |      |
157    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
158    * |      |   *  |  7   |  8   |  9   |  -   |             |      |      |      |      |      |      |
159    * |------+------+------+------+------+------|             |------+------+------+------+------+------|
160    * |  .   |   /  |  4   |  5   |  6   |  +   |             |      |      |      |      |      |      |
161    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
162    * |  LN  |  0   |  1   |  2   |  3   |C+S+F1|      |      |      |      |      |      |      |      |
163    * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
164    * |      |      |      |  ,   |      |      |      |      |      |      |      |      |      |      |
165    * `-------------------------------------------------------------------------------------------------'
166    */
167   [_NUM] = LAYOUT( \
168       _______,  _______, OSL(_FUNC), KC_HOME, KC_END,  _______,                          _______,  _______,  _______,  _______,  _______,  _______, \
169       _______,  KC_ASTR, KC_P7,      KC_P8,   KC_P9,   KC_MINS,                          _______,  _______,  _______,  _______,  _______,  _______, \
170       KC_PDOT,  KC_SLSH, KC_P4,      KC_P5,   KC_P6,   KC_PLUS,                          _______,  _______,  _______,  _______,  _______,  _______, \
171       KC_NLCK,  KC_P0,   KC_P1,      KC_P2,   KC_P3,   LCTL(S(KC_F1)), _______, _______, _______,  _______,  _______,  _______,  _______,  _______, \
172       _______,  _______, KC_PDOT,    KC_COMM, _______, _______,        _______, _______, _______,  _______,  _______,  _______,  _______,  _______ \
173       )
174 };
175 #else
176 #error "undefined keymaps"
177 #endif
178
179
180 #ifdef AUDIO_ENABLE
181
182 float tone_qwerty[][2]     = SONG(QWERTY_SOUND);
183 float tone_dvorak[][2]     = SONG(DVORAK_SOUND);
184 float tone_colemak[][2]    = SONG(COLEMAK_SOUND);
185 float tone_plover[][2]     = SONG(PLOVER_SOUND);
186 float tone_plover_gb[][2]  = SONG(PLOVER_GOODBYE_SOUND);
187 float music_scale[][2]     = SONG(MUSIC_SCALE_SOUND);
188 #endif
189
190 // define variables for reactive RGB
191 //bool TOG_STATUS = false;
192 int RGB_current_mode;
193
194 void persistent_default_layer_set(uint16_t default_layer) {
195   eeconfig_update_default_layer(default_layer);
196   default_layer_set(default_layer);
197 }
198
199 bool find_mairix(uint16_t keycode, uint8_t *row, uint8_t *col){
200   for(uint8_t i=0; i<MATRIX_ROWS; i++){
201     for(uint8_t j=0; j<MATRIX_COLS; j++){
202       if( pgm_read_word(&(keymaps[_BASE][i][j]))==keycode){
203         *row = i;
204         *col = j;
205         return true;
206       }
207     }
208   }
209   return false;
210 }
211
212 void unregister_delay_code(void){
213   if(delay_registered_code){
214     unregister_code(delay_registered_code);
215     if (delay_registered_code & QK_LSFT){
216       unregister_code(KC_LSFT);
217     }
218     if (delay_registered_code & QK_LCTL){
219       unregister_code(KC_LCTL);
220     }
221     if (delay_registered_code & QK_LALT){
222       unregister_code(KC_LALT);
223     }
224     if (delay_registered_code & QK_LGUI){
225       unregister_code(KC_LGUI);
226     }
227     delay_registered_code=0;
228   }
229 }
230
231 void register_delay_code(uint8_t layer){
232   if(delay_key_stat){
233     unregister_delay_code();
234
235     uint16_t code = pgm_read_word(&(keymaps[layer][delay_mat_row][delay_mat_col]));
236     if (code & QK_LSFT){
237       register_code(KC_LSFT);
238     }
239     if (code & QK_LCTL){
240       register_code(KC_LCTL);
241     }
242     if (code & QK_LALT){
243       register_code(KC_LALT);
244     }
245     if (code & QK_LGUI){
246       register_code(KC_LGUI);
247     }
248     register_code(code);
249     delay_registered_code = code;
250     delay_key_stat = false;
251     tapping_key = true;
252   }
253 }
254
255 #ifdef RGBLIGHT_ENABLE
256 struct keybuf {
257   char col, row;
258   char frame;
259 };
260 struct keybuf keybufs[256];
261 unsigned char keybuf_begin, keybuf_end;
262
263 int col, row;
264 #endif
265
266 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
267
268   #ifdef RGBLIGHT_ENABLE
269     col = record->event.key.col;
270     row = record->event.key.row;
271     if (record->event.pressed && ((row < 5 && is_master) || (row >= 5 && !is_master))) {
272       int end = keybuf_end;
273       keybufs[end].col = col;
274       keybufs[end].row = row % 5;
275       keybufs[end].frame = 0;
276       keybuf_end ++;
277     }
278   #endif
279
280   if(tap_timer&&keycode!=OPT_TAP_SP){
281     tapping_key = true;
282   }
283
284   if(keycode==delay_registered_code){
285       if (!record->event.pressed){
286         unregister_delay_code();
287       }
288   }
289
290   switch (keycode) {
291     case KC_SCLN:
292     case KC_LBRC:
293     case KC_LPRN:
294     case KC_LT:
295     case KC_LCBR:
296     case KC_P:
297     case KC_K:
298     case KC_R:
299     case KC_A:
300     case KC_F:
301     case KC_BSPC:
302     case KC_D:
303     case KC_T:
304     case KC_H:
305     case KC_E:
306     case KC_O:
307     case KC_Y:
308     case KC_S:
309     case KC_N:
310     case KC_I:
311     case KC_U:
312     case LCTL(KC_Z):
313     case KC_SPC:
314       if (record->event.pressed) {
315         register_delay_code(_BASE);
316         if(find_mairix(keycode, &delay_mat_row, &delay_mat_col)){
317           key_timer = timer_read();
318           delay_key_stat = true;
319           delay_key_pressed = true;
320         }
321       }else{
322         delay_key_pressed = false;
323       }
324       return false;
325       break;
326     case OPT_TAP_SP:
327       if (record->event.pressed) {
328         tapping_key = false;
329         register_delay_code(_OPT);
330         layer_on(_OPT);
331         tap_timer = timer_read();
332       }else{
333         layer_off(_OPT);
334         if(tapping_key==false && timer_elapsed(tap_timer) < TAPPING_TERM){
335           SEND_STRING(" ");
336         }
337         tap_timer = 0;
338       }
339       return false;
340       break;
341    case EISU:
342       if (record->event.pressed) {
343         if(keymap_config.swap_lalt_lgui==false){
344           register_code(KC_LANG2);
345         }else{
346           SEND_STRING(SS_LALT("`"));
347         }
348       } else {
349         unregister_code(KC_LANG2);
350       }
351       return false;
352       break;
353     case KANA:
354       if (record->event.pressed) {
355         if(keymap_config.swap_lalt_lgui==false){
356           register_code(KC_LANG1);
357         }else{
358           SEND_STRING(SS_LALT("`"));
359         }
360       } else {
361         unregister_code(KC_LANG1);
362       }
363       return false;
364       break;
365     case DESKTOP:
366       if (record->event.pressed) {
367         if(keymap_config.swap_lalt_lgui==false){
368           register_code(KC_F11);
369         }else{
370           SEND_STRING(SS_LGUI("d"));
371         }
372       } else {
373         unregister_code(KC_F11);
374       }
375       return false;
376       break;
377     case RGBRST:
378       #ifdef RGBLIGHT_ENABLE
379         if (record->event.pressed) {
380           eeconfig_update_rgblight_default();
381           rgblight_enable();
382           RGB_current_mode = rgblight_config.mode;
383           RGBAnimation = false;
384         }
385       #endif
386       break;
387     case RGBOFF:
388       #ifdef RGBLIGHT_ENABLE
389         if (record->event.pressed) {
390           rgblight_disable();
391         }
392       #endif
393       break;
394     case RGB1:
395       #ifdef RGBLIGHT_ENABLE
396         if (record->event.pressed) {
397           RGBAnimation = true;
398           rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD);
399           RGB_current_mode = rgblight_config.mode;
400         }
401       #endif
402       break;
403     case RGB2:
404       #ifdef RGBLIGHT_ENABLE
405         if (record->event.pressed) {
406           RGBAnimation = true;
407           rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL + 1);
408           RGB_current_mode = rgblight_config.mode;
409         }
410       #endif
411       break;
412     case RGB3:
413       #ifdef RGBLIGHT_ENABLE
414         if (record->event.pressed) {
415           RGBAnimation = true;
416           rgblight_mode(RGBLIGHT_MODE_KNIGHT);
417           RGB_current_mode = rgblight_config.mode;
418         }
419       #endif
420       break;
421     case MAC:
422       if (record->event.pressed) {
423         keymap_config.swap_lalt_lgui = false;
424         keymap_config.swap_ralt_rgui = false;
425         #ifdef AUDIO_ENABLE
426           PLAY_SONG(ag_norm_song);
427         #endif
428       }
429       break;
430     case WIN:
431       if (record->event.pressed) {
432         keymap_config.swap_lalt_lgui = true;
433         keymap_config.swap_ralt_rgui = true;
434         #ifdef AUDIO_ENABLE
435           PLAY_SONG(ag_swap_song);
436         #endif
437       }
438       break;
439     }
440   return true;
441 }
442
443
444 //keyboard start-up code. Runs once when the firmware starts up.
445 void matrix_init_user(void) {
446     #ifdef AUDIO_ENABLE
447         startup_user();
448     #endif
449     #ifdef RGBLIGHT_ENABLE
450       RGB_current_mode = rgblight_config.mode;
451     #endif
452     //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
453     #ifdef SSD1306OLED
454         iota_gfx_init(!has_usb());   // turns on the display
455     #endif
456 }
457
458
459 #ifdef AUDIO_ENABLE
460
461 void startup_user()
462 {
463     _delay_ms(20); // gets rid of tick
464 }
465
466 void shutdown_user()
467 {
468     _delay_ms(150);
469     stop_all_notes();
470 }
471
472 void music_on_user(void)
473 {
474     music_scale_user();
475 }
476
477 void music_scale_user(void)
478 {
479     PLAY_SONG(music_scale);
480 }
481
482 #endif
483
484
485 //assign the right code to your layers for OLED display
486 #define L_BASE 0
487 #define L_OPT 2
488 #define L_FUNC 4
489 #define L_SYM 8
490 #define L_NUM 16
491 #define L_FNLAYER 64
492 #define L_NUMLAY 128
493 #define L_NLOWER 136
494 #define L_NFNLAYER 192
495 #define L_MOUSECURSOR 256
496
497 // LED Effect
498 #ifdef RGBLIGHT_ENABLE
499 unsigned char rgb[7][5][3];
500 void led_ripple_effect(char r, char g, char b) {
501     static int scan_count = -10;
502     static int keys[] = { 6, 6, 6, 7, 7 };
503     static int keys_sum[] = { 0, 6, 12, 18, 25 };
504
505     if (scan_count == -1) {
506       rgblight_enable_noeeprom();
507       rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
508     } else if (scan_count >= 0 && scan_count < 5) {
509       for (unsigned char c=keybuf_begin; c!=keybuf_end; c++) {
510         int i = c;
511         // FIXME:
512
513         int y = scan_count;
514         int dist_y = abs(y - keybufs[i].row);
515         for (int x=0; x<keys[y]; x++) {
516           int dist = abs(x - keybufs[i].col) + dist_y;
517           if (dist <= keybufs[i].frame) {
518             int elevation = MAX(0, (8 + dist - keybufs[i].frame)) << 2;
519             if (elevation) {
520               if ((rgb[x][y][0] != 255) && r) { rgb[x][y][0] = MIN(255, elevation + rgb[x][y][0]); }
521               if ((rgb[x][y][1] != 255) && g) { rgb[x][y][1] = MIN(255, elevation + rgb[x][y][1]); }
522               if ((rgb[x][y][2] != 255) && b) { rgb[x][y][2] = MIN(255, elevation + rgb[x][y][2]); }
523             }
524           }
525         }
526       }
527     } else if (scan_count == 5) {
528       for (unsigned char c=keybuf_begin; c!=keybuf_end; c++) {
529         int i = c;
530         if (keybufs[i].frame < 18) {
531           keybufs[i].frame ++;
532         } else {
533           keybuf_begin ++;
534         }
535       }
536     } else if (scan_count >= 6 && scan_count <= 10) {
537       int y = scan_count - 6;
538       for (int x=0; x<keys[y]; x++) {
539         int at = keys_sum[y] + ((y & 1) ? x : (keys[y] - x - 1));
540         led[at].r = rgb[x][y][0];
541         led[at].g = rgb[x][y][1];
542         led[at].b = rgb[x][y][2];
543       }
544       rgblight_set();
545     } else if (scan_count == 11) {
546       memset(rgb, 0, sizeof(rgb));
547     }
548     scan_count++;
549     if (scan_count >= 12) { scan_count = 0; }
550 }
551 #endif
552
553 uint8_t layer_state_old;
554
555 //runs every scan cycle (a lot)
556 void matrix_scan_user(void) {
557   #ifdef SSD1306OLED
558     iota_gfx_task();  // this is what updates the display continuously
559   #endif
560
561   if(delay_key_stat && (timer_elapsed(key_timer) > DELAY_TIME)){
562     register_delay_code(_BASE);
563     if(!delay_key_pressed){
564       unregister_delay_code();
565     }
566   }
567
568   if(layer_state_old != layer_state){
569     switch (layer_state) {
570       case L_BASE:
571         break;
572       case L_OPT:
573         register_delay_code(_OPT);
574         break;
575       case L_NUM:
576         register_delay_code(_NUM);
577         break;
578       case L_SYM:
579         register_delay_code(_SYM);
580         break;
581       case L_FUNC:
582         register_delay_code(_FUNC);
583         break;
584     }
585     layer_state_old = layer_state;
586   }
587
588   #ifdef RGBLIGHT_ENABLE
589     if(!RGBAnimation){
590       switch (layer_state) {
591         case L_BASE:
592           #ifdef RGBLED_BACK
593             led_ripple_effect(0,112,127);
594           #else
595             rgblight_setrgb(0,112,127);
596           #endif
597           break;
598         case L_OPT:
599           #ifdef RGBLED_BACK
600             led_ripple_effect(127,0,100);
601           #else
602             rgblight_setrgb(127,0,100);
603           #endif
604           break;
605         case L_NUM:
606           #ifdef RGBLED_BACK
607             led_ripple_effect(127,23,0);
608           #else
609             rgblight_setrgb(127,23,0);
610           #endif
611           break;
612         case L_SYM:
613           #ifdef RGBLED_BACK
614             led_ripple_effect(0,127,0);
615           #else
616             rgblight_setrgb(0,127,0);
617           #endif
618           break;
619         case L_FUNC:
620           #ifdef RGBLED_BACK
621             led_ripple_effect(127,0,61);
622           #else
623             rgblight_setrgb(127,0,61);
624           #endif
625           break;
626         }
627     }
628   #endif
629 }
630
631 //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
632 #ifdef SSD1306OLED
633
634 void matrix_update(struct CharacterMatrix *dest,
635                           const struct CharacterMatrix *source) {
636   if (memcmp(dest->display, source->display, sizeof(dest->display))) {
637     memcpy(dest->display, source->display, sizeof(dest->display));
638     dest->dirty = true;
639   }
640 }
641
642 // Render to OLED
643 void render_status(struct CharacterMatrix *matrix) {
644
645   // froggy logo
646   static char logo[4][1][17]=
647   {
648     {
649       {0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0}
650     },
651     {
652       {0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,0}
653     },
654     {
655       {0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,0}
656     },
657     {
658       {0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0}
659     }
660   };
661
662   static char indctr[8][2][4]=
663   {
664     // white icon
665     {
666       {0x60,0x61,0x62,0},
667       {0x63,0x64,0}
668     },
669     {
670       {0x80,0x81,0x82,0},
671       {0x83,0x84,0}
672     },
673     {
674       {0xa0,0xa1,0xa2,0},
675       {0xa3,0xa4,0}
676     },
677     {
678       {0xc0,0xc1,0xc2,0},
679       {0xc3,0xc4,0}
680     },
681     // Black icon
682     {
683       {0x75,0x76,0x77,0},
684       {0x78,0x79,0}
685     },
686     {
687       {0x95,0x96,0x97,0},
688       {0x98,0x99,0}
689     },
690     {
691       {0xb5,0xb6,0xb7,0},
692       {0xb8,0xb9,0}
693     },
694     {
695       {0xd5,0xd6,0xd7,0},
696       {0xd8,0xd9,0}
697     },
698   };
699
700   int rown = 0;
701   int rowf = 0;
702   int rowa = 0;
703   int rows = 0;
704
705   //Set Indicator icon
706   if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 4; } else { rown = 0; }
707   if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowa = 4; } else { rowa = 0; }
708   if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) { rows = 4; } else { rows = 0; }
709   if (layer_state == L_FUNC) { rowf = 4; }
710
711   matrix_write(matrix, indctr[rown]  [0]);
712   matrix_write(matrix, indctr[rowf]  [1]);
713   matrix_write(matrix, logo  [0]     [0]);
714   matrix_write(matrix, indctr[rown+1][0]);
715   matrix_write(matrix, indctr[rowf+1][1]);
716   matrix_write(matrix, logo  [1]     [0]);
717   matrix_write(matrix, indctr[rowa+2][0]);
718   matrix_write(matrix, indctr[rows+2][1]);
719   matrix_write(matrix, logo  [2]     [0]);
720   matrix_write(matrix, indctr[rowa+3][0]);
721   matrix_write(matrix, indctr[rows+3][1]);
722   matrix_write(matrix, logo  [3]     [0]);
723
724 }
725
726 void iota_gfx_task_user(void) {
727   struct CharacterMatrix matrix;
728
729 #if DEBUG_TO_SCREEN
730   if (debug_enable) {
731     return;
732   }
733 #endif
734
735   matrix_clear(&matrix);
736   if(is_master){
737     render_status(&matrix);
738   }
739   matrix_update(&display, &matrix);
740 }
741
742 #endif