From b3d80d4af011be30e6cdf55230d27e20a34b31a1 Mon Sep 17 00:00:00 2001 From: MakotoKurauchi Date: Thu, 16 Aug 2018 01:30:34 +0900 Subject: Keymap: Helix : Update froggy keymap (#3652) * led ripple effect * fix key name --- keyboards/helix/rev2/keymaps/froggy/keymap.c | 122 ++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 21 deletions(-) (limited to 'keyboards') 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= 6 && scan_count <= 10) { + int y = scan_count - 6; + for (int x=0; x= 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 -- cgit v1.2.3