diff options
Diffstat (limited to 'keyboards/helix')
-rw-r--r-- | keyboards/helix/rev2/keymaps/froggy/keymap.c | 122 |
1 files changed, 101 insertions, 21 deletions
diff --git a/keyboards/helix/rev2/keymaps/froggy/keymap.c b/keyboards/helix/rev2/keymaps/froggy/keymap.c index 5ac927af3e..81a28dfa5d 100644 --- a/keyboards/helix/rev2/keymaps/froggy/keymap.c +++ b/keyboards/helix/rev2/keymaps/froggy/keymap.c @@ -81,7 +81,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| * | Shift| Y | S | N | I | U |Space | | | | | | | | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| - * | Ctrl | Alt | win | Sym | Num | OPT | Ent | | | | | | | | + * | Ctrl | Alt | Gui | Sym | Num | OPT | Ent | | | | | | | | * `-------------------------------------------------------------------------------------------------' */ [_BASE] = LAYOUT( \ @@ -256,8 +256,31 @@ void register_delay_code(uint8_t layer){ } } +#ifdef RGBLIGHT_ENABLE +struct keybuf { + char col, row; + char frame; +}; +struct keybuf keybufs[256]; +unsigned char keybuf_begin, keybuf_end; + +int col, row; +#endif + bool process_record_user(uint16_t keycode, keyrecord_t *record) { + #ifdef RGBLIGHT_ENABLE + col = record->event.key.col; + row = record->event.key.row; + if (record->event.pressed && ((row < 5 && is_master) || (row >= 5 && !is_master))) { + int end = keybuf_end; + keybufs[end].col = col; + keybufs[end].row = row % 5; + keybufs[end].frame = 0; + keybuf_end ++; + } + #endif + if(tap_timer&&keycode!=OPT_TAP_SP){ tapping_key = true; } @@ -475,6 +498,61 @@ void music_scale_user(void) #define L_NFNLAYER 192 #define L_MOUSECURSOR 256 +// LED Effect +#ifdef RGBLIGHT_ENABLE +unsigned char rgb[7][5][3]; +void led_ripple_effect(char r, char g, char b) { + static int scan_count = -10; + static int keys[] = { 6, 6, 6, 7, 7 }; + static int keys_sum[] = { 0, 6, 12, 18, 25 }; + + if (scan_count == -1) { + rgblight_enable_noeeprom(); + rgblight_mode(0); + } else if (scan_count >= 0 && scan_count < 5) { + for (unsigned char c=keybuf_begin; c!=keybuf_end; c++) { + int i = c; + // FIXME: + + int y = scan_count; + int dist_y = abs(y - keybufs[i].row); + for (int x=0; x<keys[y]; x++) { + int dist = abs(x - keybufs[i].col) + dist_y; + if (dist <= keybufs[i].frame) { + int elevation = MAX(0, (8 + dist - keybufs[i].frame)) << 2; + if (elevation) { + if ((rgb[x][y][0] != 255) && r) { rgb[x][y][0] = MIN(255, elevation + rgb[x][y][0]); } + if ((rgb[x][y][1] != 255) && g) { rgb[x][y][1] = MIN(255, elevation + rgb[x][y][1]); } + if ((rgb[x][y][2] != 255) && b) { rgb[x][y][2] = MIN(255, elevation + rgb[x][y][2]); } + } + } + } + } + } else if (scan_count == 5) { + for (unsigned char c=keybuf_begin; c!=keybuf_end; c++) { + int i = c; + if (keybufs[i].frame < 18) { + keybufs[i].frame ++; + } else { + keybuf_begin ++; + } + } + } else if (scan_count >= 6 && scan_count <= 10) { + int y = scan_count - 6; + for (int x=0; x<keys[y]; x++) { + int at = keys_sum[y] + ((y & 1) ? x : (keys[y] - x - 1)); + led[at].r = rgb[x][y][0]; + led[at].g = rgb[x][y][1]; + led[at].b = rgb[x][y][2]; + } + rgblight_set(); + } else if (scan_count == 11) { + memset(rgb, 0, sizeof(rgb)); + } + scan_count++; + if (scan_count >= 12) { scan_count = 0; } +} +#endif uint8_t layer_state_old; @@ -494,42 +572,44 @@ void matrix_scan_user(void) { if(layer_state_old != layer_state){ switch (layer_state) { case L_BASE: - #ifdef RGBLIGHT_ENABLE - if (!RGBAnimation){ - rgblight_sethsv(187,255,255); - rgblight_mode(1); - }else{ - rgblight_mode(RGB_current_mode); - } - #endif break; case L_OPT: register_delay_code(_OPT); break; case L_NUM: register_delay_code(_NUM); - #ifdef RGBLIGHT_ENABLE - rgblight_sethsv(25,255,255); - rgblight_mode(1); - #endif break; case L_SYM: register_delay_code(_SYM); - #ifdef RGBLIGHT_ENABLE - rgblight_sethsv(96,255,255); - rgblight_mode(1); - #endif break; case L_FUNC: register_delay_code(_FUNC); - #ifdef RGBLIGHT_ENABLE - rgblight_sethsv(331,255,255); - rgblight_mode(1); - #endif break; } layer_state_old = layer_state; } + + #ifdef RGBLIGHT_ENABLE + if(!RGBAnimation){ + switch (layer_state) { + case L_BASE: + led_ripple_effect(0,112,127); + break; + case L_OPT: + led_ripple_effect(127,0,100); + break; + case L_NUM: + led_ripple_effect(127,23,0); + break; + case L_SYM: + led_ripple_effect(0,127,0); + break; + case L_FUNC: + led_ripple_effect(127,0,61); + break; + } + } + #endif } //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h |