diff options
| author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2018-03-17 05:28:07 +0900 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2018-03-16 16:28:07 -0400 |
| commit | 3d1801e63a03779df5b47076b5b129b41d5f8891 (patch) | |
| tree | ccfd9d4db55451491ddaa8ef3b6c3c7674197c5c | |
| parent | ea070950e7c5f21ec1c24df53acdef5608b703b3 (diff) | |
| download | qmk_firmware-3d1801e63a03779df5b47076b5b129b41d5f8891.tar.gz qmk_firmware-3d1801e63a03779df5b47076b5b129b41d5f8891.zip | |
Helix keyboard led test as a keymap (#2513)
* duplicate keyboards/helix/rev2/keymaps/default to keyboards/helix/rev2/keymaps/led_test
* OLED & RGB LED on
* duplicate quantum/rgblight.[ch] to keyboards/helix/rev2/keymaps/led_test
* rgblight.c modify for RGB test
| -rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/config.h | 97 | ||||
| -rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/keymap.c | 616 | ||||
| -rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/rgblight.c | 666 | ||||
| -rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/rgblight.h | 148 | ||||
| -rw-r--r-- | keyboards/helix/rev2/keymaps/led_test/rules.mk | 38 |
5 files changed, 1565 insertions, 0 deletions
diff --git a/keyboards/helix/rev2/keymaps/led_test/config.h b/keyboards/helix/rev2/keymaps/led_test/config.h new file mode 100644 index 000000000..fa16b87f0 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/led_test/config.h | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | /* | ||
| 2 | This is the c configuration file for the keymap | ||
| 3 | |||
| 4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 5 | Copyright 2015 Jack Humbert | ||
| 6 | |||
| 7 | This program is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 2 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | This program is distributed in the hope that it will be useful, | ||
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef CONFIG_USER_H | ||
| 22 | #define CONFIG_USER_H | ||
| 23 | |||
| 24 | #include "../../config.h" | ||
| 25 | |||
| 26 | /* Use I2C or Serial */ | ||
| 27 | |||
| 28 | #define USE_I2C | ||
| 29 | #define USE_SERIAL | ||
| 30 | //#define USE_MATRIX_I2C | ||
| 31 | |||
| 32 | /* Select hand configuration */ | ||
| 33 | |||
| 34 | #define MASTER_LEFT | ||
| 35 | // #define MASTER_RIGHT | ||
| 36 | // #define EE_HANDS | ||
| 37 | |||
| 38 | // Helix keyboard OLED support | ||
| 39 | #define SSD1306OLED | ||
| 40 | |||
| 41 | /* Select rows configuration */ | ||
| 42 | // Rows are 4 or 5 | ||
| 43 | #define HELIX_ROWS 5 | ||
| 44 | |||
| 45 | /* key matrix size */ | ||
| 46 | // Rows are doubled-up | ||
| 47 | #if HELIX_ROWS == 4 | ||
| 48 | #define MATRIX_ROWS 8 | ||
| 49 | #define MATRIX_COLS 7 | ||
| 50 | #define MATRIX_ROW_PINS { D4, C6, D7, E6 } | ||
| 51 | #elif HELIX_ROWS == 5 | ||
| 52 | #define MATRIX_ROWS 10 | ||
| 53 | #define MATRIX_COLS 7 | ||
| 54 | #define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 } | ||
| 55 | #else | ||
| 56 | #error "expected HELIX_ROWS 4 or 5" | ||
| 57 | #endif | ||
| 58 | |||
| 59 | #define USE_SERIAL_PD2 | ||
| 60 | |||
| 61 | #define PREVENT_STUCK_MODIFIERS | ||
| 62 | #define TAPPING_FORCE_HOLD | ||
| 63 | #define TAPPING_TERM 100 | ||
| 64 | |||
| 65 | |||
| 66 | #undef RGBLED_NUM | ||
| 67 | #define RGBLIGHT_ANIMATIONS | ||
| 68 | // Helix keyboard : see ./rules.mk: RGBLIGHT_ENABLE = yes or no | ||
| 69 | // Helix keyboard : RGBLED_NUM 6 or 32 | ||
| 70 | #define RGBLED_NUM 32 | ||
| 71 | #if RGBLED_NUM <= 6 | ||
| 72 | #define RGBLIGHT_LIMIT_VAL 255 | ||
| 73 | #else | ||
| 74 | #if HELIX_ROWS == 5 | ||
| 75 | #define RGBLIGHT_LIMIT_VAL 120 | ||
| 76 | #else | ||
| 77 | #define RGBLIGHT_LIMIT_VAL 130 | ||
| 78 | #endif | ||
| 79 | #endif | ||
| 80 | #define RGBLIGHT_HUE_STEP 10 | ||
| 81 | #define RGBLIGHT_SAT_STEP 17 | ||
| 82 | #define RGBLIGHT_VAL_STEP 17 | ||
| 83 | #endif | ||
| 84 | |||
| 85 | #ifdef RGBLIGHT_ENABLE | ||
| 86 | // USB_MAX_POWER_CONSUMPTION value for Helix keyboard | ||
| 87 | // 120 RGBoff, OLEDoff | ||
| 88 | // 120 OLED | ||
| 89 | // 330 RGB 6 | ||
| 90 | // 300 RGB 32 | ||
| 91 | // 310 OLED & RGB 32 | ||
| 92 | #define USB_MAX_POWER_CONSUMPTION 330 | ||
| 93 | #else | ||
| 94 | // fix iPhone and iPad power adapter issue | ||
| 95 | // iOS device need lessthan 100 | ||
| 96 | #define USB_MAX_POWER_CONSUMPTION 100 | ||
| 97 | #endif | ||
diff --git a/keyboards/helix/rev2/keymaps/led_test/keymap.c b/keyboards/helix/rev2/keymaps/led_test/keymap.c new file mode 100644 index 000000000..b8a9baee3 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/led_test/keymap.c | |||
| @@ -0,0 +1,616 @@ | |||
| 1 | #include "helix.h" | ||
| 2 | #include "bootloader.h" | ||
| 3 | #include "action_layer.h" | ||
| 4 | #include "eeconfig.h" | ||
| 5 | #ifdef PROTOCOL_LUFA | ||
| 6 | #include "lufa.h" | ||
| 7 | #include "split_util.h" | ||
| 8 | #endif | ||
| 9 | #include "LUFA/Drivers/Peripheral/TWI.h" | ||
| 10 | #ifdef AUDIO_ENABLE | ||
| 11 | #include "audio.h" | ||
| 12 | #endif | ||
| 13 | #ifdef SSD1306OLED | ||
| 14 | #include "ssd1306.h" | ||
| 15 | #endif | ||
| 16 | |||
| 17 | extern keymap_config_t keymap_config; | ||
| 18 | |||
| 19 | #ifdef RGBLIGHT_ENABLE | ||
| 20 | //Following line allows macro to read current RGB settings | ||
| 21 | extern rgblight_config_t rgblight_config; | ||
| 22 | #endif | ||
| 23 | |||
| 24 | extern uint8_t is_master; | ||
| 25 | |||
| 26 | // Each layer gets a name for readability, which is then used in the keymap matrix below. | ||
| 27 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | ||
| 28 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | ||
| 29 | // entirely and just use numbers. | ||
| 30 | #define _QWERTY 0 | ||
| 31 | #define _COLEMAK 1 | ||
| 32 | #define _DVORAK 2 | ||
| 33 | #define _LOWER 3 | ||
| 34 | #define _RAISE 4 | ||
| 35 | #define _ADJUST 16 | ||
| 36 | |||
| 37 | enum custom_keycodes { | ||
| 38 | QWERTY = SAFE_RANGE, | ||
| 39 | COLEMAK, | ||
| 40 | DVORAK, | ||
| 41 | LOWER, | ||
| 42 | RAISE, | ||
| 43 | ADJUST, | ||
| 44 | BACKLIT, | ||
| 45 | EISU, | ||
| 46 | KANA, | ||
| 47 | RGBRST | ||
| 48 | }; | ||
| 49 | |||
| 50 | enum macro_keycodes { | ||
| 51 | KC_SAMPLEMACRO, | ||
| 52 | }; | ||
| 53 | |||
| 54 | |||
| 55 | // Fillers to make layering more clear | ||
| 56 | #define _______ KC_TRNS | ||
| 57 | #define XXXXXXX KC_NO | ||
| 58 | //Macros | ||
| 59 | #define M_SAMPLE M(KC_SAMPLEMACRO) | ||
| 60 | |||
| 61 | #if HELIX_ROWS == 5 | ||
| 62 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 63 | |||
| 64 | /* Qwerty | ||
| 65 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 66 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
| 67 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 68 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp | | ||
| 69 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 70 | * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' | | ||
| 71 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 72 | * | Shift| Z | X | C | V | B | [ | ] | N | M | , | . | / |Enter | | ||
| 73 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 74 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
| 75 | * `-------------------------------------------------------------------------------------------------' | ||
| 76 | */ | ||
| 77 | [_QWERTY] = KEYMAP( \ | ||
| 78 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
| 79 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
| 80 | KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
| 81 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
| 82 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 83 | ), | ||
| 84 | |||
| 85 | /* Colemak | ||
| 86 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 87 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
| 88 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 89 | * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp | | ||
| 90 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 91 | * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' | | ||
| 92 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 93 | * | Shift| Z | X | C | V | B | [ | ] | K | M | , | . | / |Enter | | ||
| 94 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 95 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
| 96 | * `-------------------------------------------------------------------------------------------------' | ||
| 97 | */ | ||
| 98 | [_COLEMAK] = KEYMAP( \ | ||
| 99 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
| 100 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \ | ||
| 101 | KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
| 102 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
| 103 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 104 | ), | ||
| 105 | |||
| 106 | /* Dvorak | ||
| 107 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 108 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
| 109 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 110 | * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del | | ||
| 111 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 112 | * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / | | ||
| 113 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 114 | * | Shift| ; | Q | J | K | X | [ | ] | B | M | W | V | Z |Enter | | ||
| 115 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 116 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
| 117 | * `-------------------------------------------------------------------------------------------------' | ||
| 118 | */ | ||
| 119 | [_DVORAK] = KEYMAP( \ | ||
| 120 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
| 121 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \ | ||
| 122 | KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
| 123 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_LBRC, KC_RBRC, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
| 124 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 125 | ), | ||
| 126 | |||
| 127 | /* Lower | ||
| 128 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 129 | * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
| 130 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 131 | * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
| 132 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 133 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | | | ||
| 134 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 135 | * | | F7 | F8 | F9 | F10 | F11 | ( | ) | F12 | | | Home | End | | | ||
| 136 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 137 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 138 | * `-------------------------------------------------------------------------------------------------' | ||
| 139 | */ | ||
| 140 | [_LOWER] = KEYMAP( \ | ||
| 141 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ | ||
| 142 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ | ||
| 143 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
| 144 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_LPRN, KC_RPRN, KC_F12, _______, _______, KC_HOME, KC_END, _______, \ | ||
| 145 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 146 | ), | ||
| 147 | |||
| 148 | /* Raise | ||
| 149 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 150 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Bksp | | ||
| 151 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 152 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
| 153 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 154 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ | | ||
| 155 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 156 | * | | F7 | F8 | F9 | F10 | F11 | | | F12 | | |PageDn|PageUp| | | ||
| 157 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 158 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 159 | * `-------------------------------------------------------------------------------------------------' | ||
| 160 | */ | ||
| 161 | [_RAISE] = KEYMAP( \ | ||
| 162 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
| 163 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
| 164 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
| 165 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \ | ||
| 166 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 167 | ), | ||
| 168 | |||
| 169 | /* Adjust (Lower + Raise) | ||
| 170 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 171 | * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | | ||
| 172 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 173 | * | | Reset|RGBRST| | | | | | | | | | Del | | ||
| 174 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 175 | * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | | | ||
| 176 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 177 | * | | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ | | ||
| 178 | * |------+------+------+------+------+------+------+------+------+------+------+------+------+------| | ||
| 179 | * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- | | ||
| 180 | * `-------------------------------------------------------------------------------------------------' | ||
| 181 | */ | ||
| 182 | [_ADJUST] = KEYMAP( \ | ||
| 183 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ | ||
| 184 | _______, RESET, RGBRST, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
| 185 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
| 186 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \ | ||
| 187 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \ | ||
| 188 | ) | ||
| 189 | }; | ||
| 190 | |||
| 191 | #elif HELIX_ROWS == 4 | ||
| 192 | |||
| 193 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 194 | |||
| 195 | /* Qwerty | ||
| 196 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 197 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp | | ||
| 198 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 199 | * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' | | ||
| 200 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 201 | * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter | | ||
| 202 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
| 203 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
| 204 | * `-------------------------------------------------------------------------------------------------' | ||
| 205 | */ | ||
| 206 | [_QWERTY] = KEYMAP( \ | ||
| 207 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \ | ||
| 208 | KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \ | ||
| 209 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
| 210 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 211 | ), | ||
| 212 | |||
| 213 | /* Colemak | ||
| 214 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 215 | * | Tab | Q | W | F | P | G | | J | L | U | Y | ; | Bksp | | ||
| 216 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 217 | * | Ctrl | A | R | S | T | D | | H | N | E | I | O | ' | | ||
| 218 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 219 | * | Shift| Z | X | C | V | B | | K | M | , | . | / |Enter | | ||
| 220 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
| 221 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
| 222 | * `-------------------------------------------------------------------------------------------------' | ||
| 223 | */ | ||
| 224 | [_COLEMAK] = KEYMAP( \ | ||
| 225 | KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \ | ||
| 226 | KC_LCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \ | ||
| 227 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \ | ||
| 228 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 229 | ), | ||
| 230 | |||
| 231 | /* Dvorak | ||
| 232 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 233 | * | Tab | ' | , | . | P | Y | | F | G | C | R | L | Del | | ||
| 234 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 235 | * | Ctrl | A | O | E | U | I | | D | H | T | N | S | / | | ||
| 236 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 237 | * | Shift| ; | Q | J | K | X | | B | M | W | V | Z |Enter | | ||
| 238 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
| 239 | * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right | | ||
| 240 | * `-------------------------------------------------------------------------------------------------' | ||
| 241 | */ | ||
| 242 | [_DVORAK] = KEYMAP( \ | ||
| 243 | KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \ | ||
| 244 | KC_LCTL, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \ | ||
| 245 | KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \ | ||
| 246 | ADJUST, KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | ||
| 247 | ), | ||
| 248 | |||
| 249 | /* Lower | ||
| 250 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 251 | * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | ||
| 252 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 253 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | | | ||
| 254 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 255 | * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | Home | End | | | ||
| 256 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
| 257 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 258 | * `-------------------------------------------------------------------------------------------------' | ||
| 259 | */ | ||
| 260 | [_LOWER] = KEYMAP( \ | ||
| 261 | KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \ | ||
| 262 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \ | ||
| 263 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_HOME, KC_END, _______, \ | ||
| 264 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 265 | ), | ||
| 266 | |||
| 267 | /* Raise | ||
| 268 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 269 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del | | ||
| 270 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 271 | * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ | | ||
| 272 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 273 | * | | F7 | F8 | F9 | F10 | F11 | | F12 | | |PageDn|PageUp| | | ||
| 274 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
| 275 | * | | | | | | | | | | | Next | Vol- | Vol+ | Play | | ||
| 276 | * `-------------------------------------------------------------------------------------------------' | ||
| 277 | */ | ||
| 278 | [_RAISE] = KEYMAP( \ | ||
| 279 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \ | ||
| 280 | _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \ | ||
| 281 | _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \ | ||
| 282 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \ | ||
| 283 | ), | ||
| 284 | |||
| 285 | /* Adjust (Lower + Raise) | ||
| 286 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 287 | * | | Reset| | | | | | | | | | | Del | | ||
| 288 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 289 | * | | | |Aud on|Audoff| Mac | | Win |Qwerty|Colemk|Dvorak| | | | ||
| 290 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 291 | * | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ | | ||
| 292 | * |------+------+------+------+------+------+-------------+------+------+------+------+------+------| | ||
| 293 | * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- | | ||
| 294 | * `-------------------------------------------------------------------------------------------------' | ||
| 295 | */ | ||
| 296 | [_ADJUST] = KEYMAP( \ | ||
| 297 | _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \ | ||
| 298 | _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \ | ||
| 299 | _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \ | ||
| 300 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SMOD,RGB_HUD, RGB_SAD, RGB_VAD \ | ||
| 301 | ) | ||
| 302 | }; | ||
| 303 | |||
| 304 | #else | ||
| 305 | #error "undefined keymaps" | ||
| 306 | #endif | ||
| 307 | |||
| 308 | |||
| 309 | #ifdef AUDIO_ENABLE | ||
| 310 | |||
| 311 | float tone_qwerty[][2] = SONG(QWERTY_SOUND); | ||
| 312 | float tone_dvorak[][2] = SONG(DVORAK_SOUND); | ||
| 313 | float tone_colemak[][2] = SONG(COLEMAK_SOUND); | ||
| 314 | float tone_plover[][2] = SONG(PLOVER_SOUND); | ||
| 315 | float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); | ||
| 316 | float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); | ||
| 317 | #endif | ||
| 318 | |||
| 319 | // define variables for reactive RGB | ||
| 320 | bool TOG_STATUS = false; | ||
| 321 | int RGB_current_mode; | ||
| 322 | |||
| 323 | void persistent_default_layer_set(uint16_t default_layer) { | ||
| 324 | eeconfig_update_default_layer(default_layer); | ||
| 325 | default_layer_set(default_layer); | ||
| 326 | } | ||
| 327 | |||
| 328 | // Setting ADJUST layer RGB back to default | ||
| 329 | void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { | ||
| 330 | if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { | ||
| 331 | #ifdef RGBLIGHT_ENABLE | ||
| 332 | //rgblight_mode(RGB_current_mode); | ||
| 333 | #endif | ||
| 334 | layer_on(layer3); | ||
| 335 | } else { | ||
| 336 | layer_off(layer3); | ||
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 341 | switch (keycode) { | ||
| 342 | case QWERTY: | ||
| 343 | if (record->event.pressed) { | ||
| 344 | #ifdef AUDIO_ENABLE | ||
| 345 | PLAY_SONG(tone_qwerty); | ||
| 346 | #endif | ||
| 347 | persistent_default_layer_set(1UL<<_QWERTY); | ||
| 348 | } | ||
| 349 | return false; | ||
| 350 | break; | ||
| 351 | case COLEMAK: | ||
| 352 | if (record->event.pressed) { | ||
| 353 | #ifdef AUDIO_ENABLE | ||
| 354 | PLAY_SONG(tone_colemak); | ||
| 355 | #endif | ||
| 356 | persistent_default_layer_set(1UL<<_COLEMAK); | ||
| 357 | } | ||
| 358 | return false; | ||
| 359 | break; | ||
| 360 | case DVORAK: | ||
| 361 | if (record->event.pressed) { | ||
| 362 | #ifdef AUDIO_ENABLE | ||
| 363 | PLAY_SONG(tone_dvorak); | ||
| 364 | #endif | ||
| 365 | persistent_default_layer_set(1UL<<_DVORAK); | ||
| 366 | } | ||
| 367 | return false; | ||
| 368 | break; | ||
| 369 | case LOWER: | ||
| 370 | if (record->event.pressed) { | ||
| 371 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
| 372 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
| 373 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
| 374 | } else { | ||
| 375 | TOG_STATUS = !TOG_STATUS; | ||
| 376 | #ifdef RGBLIGHT_ENABLE | ||
| 377 | //rgblight_mode(16); | ||
| 378 | #endif | ||
| 379 | } | ||
| 380 | layer_on(_LOWER); | ||
| 381 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 382 | } else { | ||
| 383 | #ifdef RGBLIGHT_ENABLE | ||
| 384 | //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
| 385 | #endif | ||
| 386 | TOG_STATUS = false; | ||
| 387 | layer_off(_LOWER); | ||
| 388 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 389 | } | ||
| 390 | return false; | ||
| 391 | break; | ||
| 392 | case RAISE: | ||
| 393 | if (record->event.pressed) { | ||
| 394 | //not sure how to have keyboard check mode and set it to a variable, so my work around | ||
| 395 | //uses another variable that would be set to true after the first time a reactive key is pressed. | ||
| 396 | if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false | ||
| 397 | } else { | ||
| 398 | TOG_STATUS = !TOG_STATUS; | ||
| 399 | #ifdef RGBLIGHT_ENABLE | ||
| 400 | //rgblight_mode(15); | ||
| 401 | #endif | ||
| 402 | } | ||
| 403 | layer_on(_RAISE); | ||
| 404 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 405 | } else { | ||
| 406 | #ifdef RGBLIGHT_ENABLE | ||
| 407 | //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change | ||
| 408 | #endif | ||
| 409 | layer_off(_RAISE); | ||
| 410 | TOG_STATUS = false; | ||
| 411 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 412 | } | ||
| 413 | return false; | ||
| 414 | break; | ||
| 415 | case ADJUST: | ||
| 416 | if (record->event.pressed) { | ||
| 417 | layer_on(_ADJUST); | ||
| 418 | } else { | ||
| 419 | layer_off(_ADJUST); | ||
| 420 | } | ||
| 421 | return false; | ||
| 422 | break; | ||
| 423 | //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released | ||
| 424 | case RGB_MOD: | ||
| 425 | #ifdef RGBLIGHT_ENABLE | ||
| 426 | if (record->event.pressed) { | ||
| 427 | rgblight_mode(RGB_current_mode); | ||
| 428 | rgblight_step(); | ||
| 429 | RGB_current_mode = rgblight_config.mode; | ||
| 430 | } | ||
| 431 | #endif | ||
| 432 | return false; | ||
| 433 | break; | ||
| 434 | case EISU: | ||
| 435 | if (record->event.pressed) { | ||
| 436 | if(keymap_config.swap_lalt_lgui==false){ | ||
| 437 | register_code(KC_LANG2); | ||
| 438 | }else{ | ||
| 439 | SEND_STRING(SS_LALT("`")); | ||
| 440 | } | ||
| 441 | } else { | ||
| 442 | unregister_code(KC_LANG2); | ||
| 443 | } | ||
| 444 | return false; | ||
| 445 | break; | ||
| 446 | case KANA: | ||
| 447 | if (record->event.pressed) { | ||
| 448 | if(keymap_config.swap_lalt_lgui==false){ | ||
| 449 | register_code(KC_LANG1); | ||
| 450 | }else{ | ||
| 451 | SEND_STRING(SS_LALT("`")); | ||
| 452 | } | ||
| 453 | } else { | ||
| 454 | unregister_code(KC_LANG1); | ||
| 455 | } | ||
| 456 | return false; | ||
| 457 | break; | ||
| 458 | case RGBRST: | ||
| 459 | #ifdef RGBLIGHT_ENABLE | ||
| 460 | if (record->event.pressed) { | ||
| 461 | eeconfig_update_rgblight_default(); | ||
| 462 | rgblight_enable(); | ||
| 463 | RGB_current_mode = rgblight_config.mode; | ||
| 464 | } | ||
| 465 | #endif | ||
| 466 | break; | ||
| 467 | } | ||
| 468 | return true; | ||
| 469 | } | ||
| 470 | |||
| 471 | void matrix_init_user(void) { | ||
| 472 | #ifdef AUDIO_ENABLE | ||
| 473 | startup_user(); | ||
| 474 | #endif | ||
| 475 | #ifdef RGBLIGHT_ENABLE | ||
| 476 | RGB_current_mode = rgblight_config.mode; | ||
| 477 | #endif | ||
| 478 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | ||
| 479 | #ifdef SSD1306OLED | ||
| 480 | TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 800000)); | ||
| 481 | iota_gfx_init(!has_usb()); // turns on the display | ||
| 482 | #endif | ||
| 483 | } | ||
| 484 | |||
| 485 | |||
| 486 | #ifdef AUDIO_ENABLE | ||
| 487 | |||
| 488 | void startup_user() | ||
| 489 | { | ||
| 490 | _delay_ms(20); // gets rid of tick | ||
| 491 | } | ||
| 492 | |||
| 493 | void shutdown_user() | ||
| 494 | { | ||
| 495 | _delay_ms(150); | ||
| 496 | stop_all_notes(); | ||
| 497 | } | ||
| 498 | |||
| 499 | void music_on_user(void) | ||
| 500 | { | ||
| 501 | music_scale_user(); | ||
| 502 | } | ||
| 503 | |||
| 504 | void music_scale_user(void) | ||
| 505 | { | ||
| 506 | PLAY_SONG(music_scale); | ||
| 507 | } | ||
| 508 | |||
| 509 | #endif | ||
| 510 | |||
| 511 | |||
| 512 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | ||
| 513 | #ifdef SSD1306OLED | ||
| 514 | |||
| 515 | void matrix_scan_user(void) { | ||
| 516 | iota_gfx_task(); // this is what updates the display continuously | ||
| 517 | } | ||
| 518 | |||
| 519 | void matrix_update(struct CharacterMatrix *dest, | ||
| 520 | const struct CharacterMatrix *source) { | ||
| 521 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
| 522 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
| 523 | dest->dirty = true; | ||
| 524 | } | ||
| 525 | } | ||
| 526 | |||
| 527 | //assign the right code to your layers for OLED display | ||
| 528 | #define L_BASE 0 | ||
| 529 | #define L_LOWER 8 | ||
| 530 | #define L_RAISE 16 | ||
| 531 | #define L_FNLAYER 64 | ||
| 532 | #define L_NUMLAY 128 | ||
| 533 | #define L_NLOWER 136 | ||
| 534 | #define L_NFNLAYER 192 | ||
| 535 | #define L_MOUSECURSOR 256 | ||
| 536 | #define L_ADJUST 65536 | ||
| 537 | #define L_ADJUST_TRI 65560 | ||
| 538 | |||
| 539 | static void render_logo(struct CharacterMatrix *matrix) { | ||
| 540 | |||
| 541 | static char logo[]={ | ||
| 542 | 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94, | ||
| 543 | 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4, | ||
| 544 | 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4, | ||
| 545 | 0}; | ||
| 546 | matrix_write(matrix, logo); | ||
| 547 | //matrix_write_P(&matrix, PSTR(" Split keyboard kit")); | ||
| 548 | } | ||
| 549 | |||
| 550 | |||
| 551 | |||
| 552 | void render_status(struct CharacterMatrix *matrix) { | ||
| 553 | |||
| 554 | // Render to mode icon | ||
| 555 | static char logo[][2][3]={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}}; | ||
| 556 | if(keymap_config.swap_lalt_lgui==false){ | ||
| 557 | matrix_write(matrix, logo[0][0]); | ||
| 558 | matrix_write_P(matrix, PSTR("\n")); | ||
| 559 | matrix_write(matrix, logo[0][1]); | ||
| 560 | }else{ | ||
| 561 | matrix_write(matrix, logo[1][0]); | ||
| 562 | matrix_write_P(matrix, PSTR("\n")); | ||
| 563 | matrix_write(matrix, logo[1][1]); | ||
| 564 | } | ||
| 565 | |||
| 566 | // 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 | ||
| 567 | char buf[40]; | ||
| 568 | snprintf(buf,sizeof(buf), "Undef-%ld", layer_state); | ||
| 569 | matrix_write_P(matrix, PSTR("\nLayer: ")); | ||
| 570 | switch (layer_state) { | ||
| 571 | case L_BASE: | ||
| 572 | matrix_write_P(matrix, PSTR("Default")); | ||
| 573 | break; | ||
| 574 | case L_RAISE: | ||
| 575 | matrix_write_P(matrix, PSTR("Raise")); | ||
| 576 | break; | ||
| 577 | case L_LOWER: | ||
| 578 | matrix_write_P(matrix, PSTR("Lower")); | ||
| 579 | break; | ||
| 580 | case L_ADJUST: | ||
| 581 | case L_ADJUST_TRI: | ||
| 582 | matrix_write_P(matrix, PSTR("Adjust")); | ||
| 583 | break; | ||
| 584 | default: | ||
| 585 | matrix_write(matrix, buf); | ||
| 586 | } | ||
| 587 | |||
| 588 | // Host Keyboard LED Status | ||
| 589 | char led[40]; | ||
| 590 | snprintf(led, sizeof(led), "\n%s %s %s", | ||
| 591 | (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? "NUMLOCK" : " ", | ||
| 592 | (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? "CAPS" : " ", | ||
| 593 | (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) ? "SCLK" : " "); | ||
| 594 | matrix_write(matrix, led); | ||
| 595 | } | ||
| 596 | |||
| 597 | |||
| 598 | void iota_gfx_task_user(void) { | ||
| 599 | struct CharacterMatrix matrix; | ||
| 600 | |||
| 601 | #if DEBUG_TO_SCREEN | ||
| 602 | if (debug_enable) { | ||
| 603 | return; | ||
| 604 | } | ||
| 605 | #endif | ||
| 606 | |||
| 607 | matrix_clear(&matrix); | ||
| 608 | if(is_master){ | ||
| 609 | render_status(&matrix); | ||
| 610 | }else{ | ||
| 611 | render_logo(&matrix); | ||
| 612 | } | ||
| 613 | matrix_update(&display, &matrix); | ||
| 614 | } | ||
| 615 | |||
| 616 | #endif | ||
diff --git a/keyboards/helix/rev2/keymaps/led_test/rgblight.c b/keyboards/helix/rev2/keymaps/led_test/rgblight.c new file mode 100644 index 000000000..fee614db0 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/led_test/rgblight.c | |||
| @@ -0,0 +1,666 @@ | |||
| 1 | /* Copyright 2016-2017 Yang Liu | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include <math.h> | ||
| 17 | #include <avr/eeprom.h> | ||
| 18 | #include <avr/interrupt.h> | ||
| 19 | #include <util/delay.h> | ||
| 20 | #include "progmem.h" | ||
| 21 | #include "timer.h" | ||
| 22 | #include "rgblight.h" | ||
| 23 | #include "debug.h" | ||
| 24 | #include "led_tables.h" | ||
| 25 | |||
| 26 | __attribute__ ((weak)) | ||
| 27 | const uint16_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {1024, 20, 10, 5}; //modify for led_test | ||
| 28 | __attribute__ ((weak)) | ||
| 29 | const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; | ||
| 30 | __attribute__ ((weak)) | ||
| 31 | const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 32 | __attribute__ ((weak)) | ||
| 33 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; | ||
| 34 | __attribute__ ((weak)) | ||
| 35 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; | ||
| 36 | __attribute__ ((weak)) | ||
| 37 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; | ||
| 38 | |||
| 39 | rgblight_config_t rgblight_config; | ||
| 40 | rgblight_config_t inmem_config; | ||
| 41 | |||
| 42 | LED_TYPE led[RGBLED_NUM]; | ||
| 43 | uint8_t rgblight_inited = 0; | ||
| 44 | bool rgblight_timer_enabled = false; | ||
| 45 | |||
| 46 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { | ||
| 47 | uint8_t r = 0, g = 0, b = 0, base, color; | ||
| 48 | |||
| 49 | #ifdef RGBLIGHT_LIMIT_VAL | ||
| 50 | if (val > RGBLIGHT_LIMIT_VAL) { | ||
| 51 | val=RGBLIGHT_LIMIT_VAL; // limit the val | ||
| 52 | } | ||
| 53 | #endif | ||
| 54 | |||
| 55 | if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. | ||
| 56 | r = val; | ||
| 57 | g = val; | ||
| 58 | b = val; | ||
| 59 | } else { | ||
| 60 | base = ((255 - sat) * val) >> 8; | ||
| 61 | color = (val - base) * (hue % 60) / 60; | ||
| 62 | |||
| 63 | switch (hue / 60) { | ||
| 64 | case 0: | ||
| 65 | r = val; | ||
| 66 | g = base + color; | ||
| 67 | b = base; | ||
| 68 | break; | ||
| 69 | case 1: | ||
| 70 | r = val - color; | ||
| 71 | g = val; | ||
| 72 | b = base; | ||
| 73 | break; | ||
| 74 | case 2: | ||
| 75 | r = base; | ||
| 76 | g = val; | ||
| 77 | b = base + color; | ||
| 78 | break; | ||
| 79 | case 3: | ||
| 80 | r = base; | ||
| 81 | g = val - color; | ||
| 82 | b = val; | ||
| 83 | break; | ||
| 84 | case 4: | ||
| 85 | r = base + color; | ||
| 86 | g = base; | ||
| 87 | b = val; | ||
| 88 | break; | ||
| 89 | case 5: | ||
| 90 | r = val; | ||
| 91 | g = base; | ||
| 92 | b = val - color; | ||
| 93 | break; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | r = pgm_read_byte(&CIE1931_CURVE[r]); | ||
| 97 | g = pgm_read_byte(&CIE1931_CURVE[g]); | ||
| 98 | b = pgm_read_byte(&CIE1931_CURVE[b]); | ||
| 99 | |||
| 100 | setrgb(r, g, b, led1); | ||
| 101 | } | ||
| 102 | |||
| 103 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { | ||
| 104 | (*led1).r = r; | ||
| 105 | (*led1).g = g; | ||
| 106 | (*led1).b = b; | ||
| 107 | } | ||
| 108 | |||
| 109 | |||
| 110 | uint32_t eeconfig_read_rgblight(void) { | ||
| 111 | return eeprom_read_dword(EECONFIG_RGBLIGHT); | ||
| 112 | } | ||
| 113 | void eeconfig_update_rgblight(uint32_t val) { | ||
| 114 | eeprom_update_dword(EECONFIG_RGBLIGHT, val); | ||
| 115 | } | ||
| 116 | void eeconfig_update_rgblight_default(void) { | ||
| 117 | dprintf("eeconfig_update_rgblight_default\n"); | ||
| 118 | rgblight_config.enable = 1; | ||
| 119 | rgblight_config.mode = 1; | ||
| 120 | rgblight_config.hue = 0; | ||
| 121 | rgblight_config.sat = 255; | ||
| 122 | rgblight_config.val = 255; | ||
| 123 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 124 | } | ||
| 125 | void eeconfig_debug_rgblight(void) { | ||
| 126 | dprintf("rgblight_config eprom\n"); | ||
| 127 | dprintf("rgblight_config.enable = %d\n", rgblight_config.enable); | ||
| 128 | dprintf("rghlight_config.mode = %d\n", rgblight_config.mode); | ||
| 129 | dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); | ||
| 130 | dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); | ||
| 131 | dprintf("rgblight_config.val = %d\n", rgblight_config.val); | ||
| 132 | } | ||
| 133 | |||
| 134 | void rgblight_init(void) { | ||
| 135 | debug_enable = 1; // Debug ON! | ||
| 136 | dprintf("rgblight_init called.\n"); | ||
| 137 | rgblight_inited = 1; | ||
| 138 | dprintf("rgblight_init start!\n"); | ||
| 139 | if (!eeconfig_is_enabled()) { | ||
| 140 | dprintf("rgblight_init eeconfig is not enabled.\n"); | ||
| 141 | eeconfig_init(); | ||
| 142 | eeconfig_update_rgblight_default(); | ||
| 143 | } | ||
| 144 | rgblight_config.raw = eeconfig_read_rgblight(); | ||
| 145 | if (!rgblight_config.mode) { | ||
| 146 | dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n"); | ||
| 147 | eeconfig_update_rgblight_default(); | ||
| 148 | rgblight_config.raw = eeconfig_read_rgblight(); | ||
| 149 | } | ||
| 150 | eeconfig_debug_rgblight(); // display current eeprom values | ||
| 151 | |||
| 152 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 153 | rgblight_timer_init(); // setup the timer | ||
| 154 | #endif | ||
| 155 | |||
| 156 | if (rgblight_config.enable) { | ||
| 157 | rgblight_mode(rgblight_config.mode); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | void rgblight_update_dword(uint32_t dword) { | ||
| 162 | rgblight_config.raw = dword; | ||
| 163 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 164 | if (rgblight_config.enable) | ||
| 165 | rgblight_mode(rgblight_config.mode); | ||
| 166 | else { | ||
| 167 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 168 | rgblight_timer_disable(); | ||
| 169 | #endif | ||
| 170 | rgblight_set(); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | void rgblight_increase(void) { | ||
| 175 | uint8_t mode = 0; | ||
| 176 | if (rgblight_config.mode < RGBLIGHT_MODES) { | ||
| 177 | mode = rgblight_config.mode + 1; | ||
| 178 | } | ||
| 179 | rgblight_mode(mode); | ||
| 180 | } | ||
| 181 | void rgblight_decrease(void) { | ||
| 182 | uint8_t mode = 0; | ||
| 183 | // Mode will never be < 1. If it ever is, eeprom needs to be initialized. | ||
| 184 | if (rgblight_config.mode > 1) { | ||
| 185 | mode = rgblight_config.mode - 1; | ||
| 186 | } | ||
| 187 | rgblight_mode(mode); | ||
| 188 | } | ||
| 189 | void rgblight_step(void) { | ||
| 190 | uint8_t mode = 0; | ||
| 191 | mode = rgblight_config.mode + 1; | ||
| 192 | if (mode > RGBLIGHT_MODES) { | ||
| 193 | mode = 1; | ||
| 194 | } | ||
| 195 | rgblight_mode(mode); | ||
| 196 | } | ||
| 197 | void rgblight_step_reverse(void) { | ||
| 198 | uint8_t mode = 0; | ||
| 199 | mode = rgblight_config.mode - 1; | ||
| 200 | if (mode < 1) { | ||
| 201 | mode = RGBLIGHT_MODES; | ||
| 202 | } | ||
| 203 | rgblight_mode(mode); | ||
| 204 | } | ||
| 205 | |||
| 206 | uint32_t rgblight_get_mode(void) { | ||
| 207 | if (!rgblight_config.enable) { | ||
| 208 | return false; | ||
| 209 | } | ||
| 210 | |||
| 211 | return rgblight_config.mode; | ||
| 212 | } | ||
| 213 | |||
| 214 | void rgblight_mode(uint8_t mode) { | ||
| 215 | if (!rgblight_config.enable) { | ||
| 216 | return; | ||
| 217 | } | ||
| 218 | if (mode < 1) { | ||
| 219 | rgblight_config.mode = 1; | ||
| 220 | } else if (mode > RGBLIGHT_MODES) { | ||
| 221 | rgblight_config.mode = RGBLIGHT_MODES; | ||
| 222 | } else { | ||
| 223 | rgblight_config.mode = mode; | ||
| 224 | } | ||
| 225 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 226 | xprintf("rgblight mode: %u\n", rgblight_config.mode); | ||
| 227 | if (rgblight_config.mode == 1) { | ||
| 228 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 229 | rgblight_timer_disable(); | ||
| 230 | #endif | ||
| 231 | } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) { | ||
| 232 | // MODE 2-5, breathing | ||
| 233 | // MODE 6-8, rainbow mood | ||
| 234 | // MODE 9-14, rainbow swirl | ||
| 235 | // MODE 15-20, snake | ||
| 236 | // MODE 21-23, knight | ||
| 237 | // MODE 24, xmas | ||
| 238 | // MODE 25-34, static rainbow | ||
| 239 | |||
| 240 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 241 | rgblight_timer_enable(); | ||
| 242 | #endif | ||
| 243 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 244 | // MODE 25-34, static gradient | ||
| 245 | |||
| 246 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 247 | rgblight_timer_disable(); | ||
| 248 | #endif | ||
| 249 | } | ||
| 250 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 251 | } | ||
| 252 | |||
| 253 | void rgblight_toggle(void) { | ||
| 254 | xprintf("rgblight toggle: rgblight_config.enable = %u\n", !rgblight_config.enable); | ||
| 255 | if (rgblight_config.enable) { | ||
| 256 | rgblight_disable(); | ||
| 257 | } | ||
| 258 | else { | ||
| 259 | rgblight_enable(); | ||
| 260 | } | ||
| 261 | } | ||
| 262 | |||
| 263 | void rgblight_enable(void) { | ||
| 264 | rgblight_config.enable = 1; | ||
| 265 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 266 | xprintf("rgblight enable: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 267 | rgblight_mode(rgblight_config.mode); | ||
| 268 | } | ||
| 269 | |||
| 270 | void rgblight_disable(void) { | ||
| 271 | rgblight_config.enable = 0; | ||
| 272 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 273 | xprintf("rgblight disable: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 274 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 275 | rgblight_timer_disable(); | ||
| 276 | #endif | ||
| 277 | _delay_ms(50); | ||
| 278 | rgblight_set(); | ||
| 279 | } | ||
| 280 | |||
| 281 | |||
| 282 | void rgblight_increase_hue(void) { | ||
| 283 | uint16_t hue; | ||
| 284 | hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360; | ||
| 285 | rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); | ||
| 286 | } | ||
| 287 | void rgblight_decrease_hue(void) { | ||
| 288 | uint16_t hue; | ||
| 289 | if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) { | ||
| 290 | hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360; | ||
| 291 | } else { | ||
| 292 | hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360; | ||
| 293 | } | ||
| 294 | rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); | ||
| 295 | } | ||
| 296 | void rgblight_increase_sat(void) { | ||
| 297 | uint8_t sat; | ||
| 298 | if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) { | ||
| 299 | sat = 255; | ||
| 300 | } else { | ||
| 301 | sat = rgblight_config.sat + RGBLIGHT_SAT_STEP; | ||
| 302 | } | ||
| 303 | rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); | ||
| 304 | } | ||
| 305 | void rgblight_decrease_sat(void) { | ||
| 306 | uint8_t sat; | ||
| 307 | if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) { | ||
| 308 | sat = 0; | ||
| 309 | } else { | ||
| 310 | sat = rgblight_config.sat - RGBLIGHT_SAT_STEP; | ||
| 311 | } | ||
| 312 | rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); | ||
| 313 | } | ||
| 314 | void rgblight_increase_val(void) { | ||
| 315 | uint8_t val; | ||
| 316 | if (rgblight_config.val + RGBLIGHT_VAL_STEP > 255) { | ||
| 317 | val = 255; | ||
| 318 | } else { | ||
| 319 | val = rgblight_config.val + RGBLIGHT_VAL_STEP; | ||
| 320 | } | ||
| 321 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); | ||
| 322 | } | ||
| 323 | void rgblight_decrease_val(void) { | ||
| 324 | uint8_t val; | ||
| 325 | if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) { | ||
| 326 | val = 0; | ||
| 327 | } else { | ||
| 328 | val = rgblight_config.val - RGBLIGHT_VAL_STEP; | ||
| 329 | } | ||
| 330 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); | ||
| 331 | } | ||
| 332 | |||
| 333 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 334 | inmem_config.raw = rgblight_config.raw; | ||
| 335 | if (rgblight_config.enable) { | ||
| 336 | LED_TYPE tmp_led; | ||
| 337 | sethsv(hue, sat, val, &tmp_led); | ||
| 338 | inmem_config.hue = hue; | ||
| 339 | inmem_config.sat = sat; | ||
| 340 | inmem_config.val = val; | ||
| 341 | // dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val); | ||
| 342 | rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); | ||
| 343 | } | ||
| 344 | } | ||
| 345 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 346 | if (rgblight_config.enable) { | ||
| 347 | if (rgblight_config.mode == 1) { | ||
| 348 | // same static color | ||
| 349 | rgblight_sethsv_noeeprom(hue, sat, val); | ||
| 350 | } else { | ||
| 351 | // all LEDs in same color | ||
| 352 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { | ||
| 353 | // breathing mode, ignore the change of val, use in memory value instead | ||
| 354 | val = rgblight_config.val; | ||
| 355 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { | ||
| 356 | // rainbow mood and rainbow swirl, ignore the change of hue | ||
| 357 | hue = rgblight_config.hue; | ||
| 358 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 359 | // static gradient | ||
| 360 | uint16_t _hue; | ||
| 361 | int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1; | ||
| 362 | uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]); | ||
| 363 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 364 | _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; | ||
| 365 | dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); | ||
| 366 | sethsv(_hue, sat, val, (LED_TYPE *)&led[i]); | ||
| 367 | } | ||
| 368 | rgblight_set(); | ||
| 369 | } | ||
| 370 | } | ||
| 371 | rgblight_config.hue = hue; | ||
| 372 | rgblight_config.sat = sat; | ||
| 373 | rgblight_config.val = val; | ||
| 374 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 375 | xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 376 | } | ||
| 377 | } | ||
| 378 | |||
| 379 | uint16_t rgblight_get_hue(void) { | ||
| 380 | return rgblight_config.hue; | ||
| 381 | } | ||
| 382 | |||
| 383 | uint8_t rgblight_get_sat(void) { | ||
| 384 | return rgblight_config.sat; | ||
| 385 | } | ||
| 386 | |||
| 387 | uint8_t rgblight_get_val(void) { | ||
| 388 | return rgblight_config.val; | ||
| 389 | } | ||
| 390 | |||
| 391 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | ||
| 392 | if (!rgblight_config.enable) { return; } | ||
| 393 | |||
| 394 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 395 | led[i].r = r; | ||
| 396 | led[i].g = g; | ||
| 397 | led[i].b = b; | ||
| 398 | } | ||
| 399 | rgblight_set(); | ||
| 400 | } | ||
| 401 | |||
| 402 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) { | ||
| 403 | if (!rgblight_config.enable || index >= RGBLED_NUM) { return; } | ||
| 404 | |||
| 405 | led[index].r = r; | ||
| 406 | led[index].g = g; | ||
| 407 | led[index].b = b; | ||
| 408 | rgblight_set(); | ||
| 409 | } | ||
| 410 | |||
| 411 | void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) { | ||
| 412 | if (!rgblight_config.enable) { return; } | ||
| 413 | |||
| 414 | LED_TYPE tmp_led; | ||
| 415 | sethsv(hue, sat, val, &tmp_led); | ||
| 416 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); | ||
| 417 | } | ||
| 418 | |||
| 419 | #ifndef RGBLIGHT_CUSTOM_DRIVER | ||
| 420 | void rgblight_set(void) { | ||
| 421 | if (rgblight_config.enable) { | ||
| 422 | #ifdef RGBW | ||
| 423 | ws2812_setleds_rgbw(led, RGBLED_NUM); | ||
| 424 | #else | ||
| 425 | ws2812_setleds(led, RGBLED_NUM); | ||
| 426 | #endif | ||
| 427 | } else { | ||
| 428 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 429 | led[i].r = 0; | ||
| 430 | led[i].g = 0; | ||
| 431 | led[i].b = 0; | ||
| 432 | } | ||
| 433 | #ifdef RGBW | ||
| 434 | ws2812_setleds_rgbw(led, RGBLED_NUM); | ||
| 435 | #else | ||
| 436 | ws2812_setleds(led, RGBLED_NUM); | ||
| 437 | #endif | ||
| 438 | } | ||
| 439 | } | ||
| 440 | #endif | ||
| 441 | |||
| 442 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 443 | |||
| 444 | // Animation timer -- AVR Timer3 | ||
| 445 | void rgblight_timer_init(void) { | ||
| 446 | // static uint8_t rgblight_timer_is_init = 0; | ||
| 447 | // if (rgblight_timer_is_init) { | ||
| 448 | // return; | ||
| 449 | // } | ||
| 450 | // rgblight_timer_is_init = 1; | ||
| 451 | // /* Timer 3 setup */ | ||
| 452 | // TCCR3B = _BV(WGM32) // CTC mode OCR3A as TOP | ||
| 453 | // | _BV(CS30); // Clock selelct: clk/1 | ||
| 454 | // /* Set TOP value */ | ||
| 455 | // uint8_t sreg = SREG; | ||
| 456 | // cli(); | ||
| 457 | // OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff; | ||
| 458 | // OCR3AL = RGBLED_TIMER_TOP & 0xff; | ||
| 459 | // SREG = sreg; | ||
| 460 | |||
| 461 | rgblight_timer_enabled = true; | ||
| 462 | } | ||
| 463 | void rgblight_timer_enable(void) { | ||
| 464 | rgblight_timer_enabled = true; | ||
| 465 | dprintf("TIMER3 enabled.\n"); | ||
| 466 | } | ||
| 467 | void rgblight_timer_disable(void) { | ||
| 468 | rgblight_timer_enabled = false; | ||
| 469 | dprintf("TIMER3 disabled.\n"); | ||
| 470 | } | ||
| 471 | void rgblight_timer_toggle(void) { | ||
| 472 | rgblight_timer_enabled ^= rgblight_timer_enabled; | ||
| 473 | dprintf("TIMER3 toggled.\n"); | ||
| 474 | } | ||
| 475 | |||
| 476 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { | ||
| 477 | rgblight_enable(); | ||
| 478 | rgblight_mode(1); | ||
| 479 | rgblight_setrgb(r, g, b); | ||
| 480 | } | ||
| 481 | |||
| 482 | void rgblight_task(void) { | ||
| 483 | if (rgblight_inited == 1) { //modify for led_test | ||
| 484 | /* first call */ | ||
| 485 | rgblight_inited = 2; | ||
| 486 | rgblight_enable(); | ||
| 487 | rgblight_mode(2); | ||
| 488 | } | ||
| 489 | if (rgblight_timer_enabled) { | ||
| 490 | // mode = 1, static light, do nothing here | ||
| 491 | if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { | ||
| 492 | // mode = 2 to 5, breathing mode | ||
| 493 | rgblight_effect_breathing(rgblight_config.mode - 2); | ||
| 494 | #if 0 | ||
| 495 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) { | ||
| 496 | // mode = 6 to 8, rainbow mood mod | ||
| 497 | rgblight_effect_rainbow_mood(rgblight_config.mode - 6); | ||
| 498 | } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) { | ||
| 499 | // mode = 9 to 14, rainbow swirl mode | ||
| 500 | rgblight_effect_rainbow_swirl(rgblight_config.mode - 9); | ||
| 501 | } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) { | ||
| 502 | // mode = 15 to 20, snake mode | ||
| 503 | rgblight_effect_snake(rgblight_config.mode - 15); | ||
| 504 | } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { | ||
| 505 | // mode = 21 to 23, knight mode | ||
| 506 | rgblight_effect_knight(rgblight_config.mode - 21); | ||
| 507 | } else if (rgblight_config.mode == 24) { | ||
| 508 | // mode = 24, christmas mode | ||
| 509 | rgblight_effect_christmas(); | ||
| 510 | #endif | ||
| 511 | } | ||
| 512 | } | ||
| 513 | } | ||
| 514 | |||
| 515 | // Effects | ||
| 516 | void rgblight_effect_breathing(uint8_t interval) { | ||
| 517 | static uint8_t pos = 0; | ||
| 518 | static uint16_t last_timer = 0; | ||
| 519 | |||
| 520 | if (timer_elapsed(last_timer) < pgm_read_word(&RGBLED_BREATHING_INTERVALS[interval])) {//modify for led_test | ||
| 521 | return; | ||
| 522 | } | ||
| 523 | last_timer = timer_read(); | ||
| 524 | |||
| 525 | |||
| 526 | //modify for led_test | ||
| 527 | rgblight_config.hue = (pos*120)%360; | ||
| 528 | rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | ||
| 529 | pos = (pos + 1) % 3; | ||
| 530 | } | ||
| 531 | #if 0 | ||
| 532 | void rgblight_effect_rainbow_mood(uint8_t interval) { | ||
| 533 | static uint16_t current_hue = 0; | ||
| 534 | static uint16_t last_timer = 0; | ||
| 535 | |||
| 536 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval])) { | ||
| 537 | return; | ||
| 538 | } | ||
| 539 | last_timer = timer_read(); | ||
| 540 | rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, rgblight_config.val); | ||
| 541 | current_hue = (current_hue + 1) % 360; | ||
| 542 | } | ||
| 543 | void rgblight_effect_rainbow_swirl(uint8_t interval) { | ||
| 544 | static uint16_t current_hue = 0; | ||
| 545 | static uint16_t last_timer = 0; | ||
| 546 | uint16_t hue; | ||
| 547 | uint8_t i; | ||
| 548 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_SWIRL_INTERVALS[interval / 2])) { | ||
| 549 | return; | ||
| 550 | } | ||
| 551 | last_timer = timer_read(); | ||
| 552 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 553 | hue = (360 / RGBLED_NUM * i + current_hue) % 360; | ||
| 554 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | ||
| 555 | } | ||
| 556 | rgblight_set(); | ||
| 557 | |||
| 558 | if (interval % 2) { | ||
| 559 | current_hue = (current_hue + 1) % 360; | ||
| 560 | } else { | ||
| 561 | if (current_hue - 1 < 0) { | ||
| 562 | current_hue = 359; | ||
| 563 | } else { | ||
| 564 | current_hue = current_hue - 1; | ||
| 565 | } | ||
| 566 | } | ||
| 567 | } | ||
| 568 | void rgblight_effect_snake(uint8_t interval) { | ||
| 569 | static uint8_t pos = 0; | ||
| 570 | static uint16_t last_timer = 0; | ||
| 571 | uint8_t i, j; | ||
| 572 | int8_t k; | ||
| 573 | int8_t increment = 1; | ||
| 574 | if (interval % 2) { | ||
| 575 | increment = -1; | ||
| 576 | } | ||
| 577 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval / 2])) { | ||
| 578 | return; | ||
| 579 | } | ||
| 580 | last_timer = timer_read(); | ||
| 581 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 582 | led[i].r = 0; | ||
| 583 | led[i].g = 0; | ||
| 584 | led[i].b = 0; | ||
| 585 | for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { | ||
| 586 | k = pos + j * increment; | ||
| 587 | if (k < 0) { | ||
| 588 | k = k + RGBLED_NUM; | ||
| 589 | } | ||
| 590 | if (i == k) { | ||
| 591 | sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), (LED_TYPE *)&led[i]); | ||
| 592 | } | ||
| 593 | } | ||
| 594 | } | ||
| 595 | rgblight_set(); | ||
| 596 | if (increment == 1) { | ||
| 597 | if (pos - 1 < 0) { | ||
| 598 | pos = RGBLED_NUM - 1; | ||
| 599 | } else { | ||
| 600 | pos -= 1; | ||
| 601 | } | ||
| 602 | } else { | ||
| 603 | pos = (pos + 1) % RGBLED_NUM; | ||
| 604 | } | ||
| 605 | } | ||
| 606 | void rgblight_effect_knight(uint8_t interval) { | ||
| 607 | static uint16_t last_timer = 0; | ||
| 608 | if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) { | ||
| 609 | return; | ||
| 610 | } | ||
| 611 | last_timer = timer_read(); | ||
| 612 | |||
| 613 | static int8_t low_bound = 0; | ||
| 614 | static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1; | ||
| 615 | static int8_t increment = 1; | ||
| 616 | uint8_t i, cur; | ||
| 617 | |||
| 618 | // Set all the LEDs to 0 | ||
| 619 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 620 | led[i].r = 0; | ||
| 621 | led[i].g = 0; | ||
| 622 | led[i].b = 0; | ||
| 623 | } | ||
| 624 | // Determine which LEDs should be lit up | ||
| 625 | for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) { | ||
| 626 | cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; | ||
| 627 | |||
| 628 | if (i >= low_bound && i <= high_bound) { | ||
| 629 | sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]); | ||
| 630 | } else { | ||
| 631 | led[cur].r = 0; | ||
| 632 | led[cur].g = 0; | ||
| 633 | led[cur].b = 0; | ||
| 634 | } | ||
| 635 | } | ||
| 636 | rgblight_set(); | ||
| 637 | |||
| 638 | // Move from low_bound to high_bound changing the direction we increment each | ||
| 639 | // time a boundary is hit. | ||
| 640 | low_bound += increment; | ||
| 641 | high_bound += increment; | ||
| 642 | |||
| 643 | if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) { | ||
| 644 | increment = -increment; | ||
| 645 | } | ||
| 646 | } | ||
| 647 | |||
| 648 | |||
| 649 | void rgblight_effect_christmas(void) { | ||
| 650 | static uint16_t current_offset = 0; | ||
| 651 | static uint16_t last_timer = 0; | ||
| 652 | uint16_t hue; | ||
| 653 | uint8_t i; | ||
| 654 | if (timer_elapsed(last_timer) < RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL) { | ||
| 655 | return; | ||
| 656 | } | ||
| 657 | last_timer = timer_read(); | ||
| 658 | current_offset = (current_offset + 1) % 2; | ||
| 659 | for (i = 0; i < RGBLED_NUM; i++) { | ||
| 660 | hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + current_offset) % 2) * 120; | ||
| 661 | sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); | ||
| 662 | } | ||
| 663 | rgblight_set(); | ||
| 664 | } | ||
| 665 | #endif /* 0 */ | ||
| 666 | #endif /* RGBLIGHT_ANIMATIONS */ | ||
diff --git a/keyboards/helix/rev2/keymaps/led_test/rgblight.h b/keyboards/helix/rev2/keymaps/led_test/rgblight.h new file mode 100644 index 000000000..9c1c0add2 --- /dev/null +++ b/keyboards/helix/rev2/keymaps/led_test/rgblight.h | |||
| @@ -0,0 +1,148 @@ | |||
| 1 | /* Copyright 2017 Yang Liu | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef RGBLIGHT_H | ||
| 17 | #define RGBLIGHT_H | ||
| 18 | |||
| 19 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 20 | #define RGBLIGHT_MODES 5 | ||
| 21 | #else | ||
| 22 | #define RGBLIGHT_MODES 1 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #ifndef RGBLIGHT_EFFECT_BREATHE_CENTER | ||
| 26 | #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1-2.7 | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #ifndef RGBLIGHT_EFFECT_BREATHE_MAX | ||
| 30 | #define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH | ||
| 34 | #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4 | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH | ||
| 38 | #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3 | ||
| 39 | #endif | ||
| 40 | |||
| 41 | #ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET | ||
| 42 | #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0 | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM | ||
| 46 | #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM RGBLED_NUM | ||
| 47 | #endif | ||
| 48 | |||
| 49 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL | ||
| 50 | #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 | ||
| 51 | #endif | ||
| 52 | |||
| 53 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP | ||
| 54 | #define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2 | ||
| 55 | #endif | ||
| 56 | |||
| 57 | #ifndef RGBLIGHT_HUE_STEP | ||
| 58 | #define RGBLIGHT_HUE_STEP 10 | ||
| 59 | #endif | ||
| 60 | #ifndef RGBLIGHT_SAT_STEP | ||
| 61 | #define RGBLIGHT_SAT_STEP 17 | ||
| 62 | #endif | ||
| 63 | #ifndef RGBLIGHT_VAL_STEP | ||
| 64 | #define RGBLIGHT_VAL_STEP 17 | ||
| 65 | #endif | ||
| 66 | |||
| 67 | #define RGBLED_TIMER_TOP F_CPU/(256*64) | ||
| 68 | // #define RGBLED_TIMER_TOP 0xFF10 | ||
| 69 | |||
| 70 | #include <stdint.h> | ||
| 71 | #include <stdbool.h> | ||
| 72 | #include "eeconfig.h" | ||
| 73 | #ifndef RGBLIGHT_CUSTOM_DRIVER | ||
| 74 | #include "ws2812.h" | ||
| 75 | #endif | ||
| 76 | #include "rgblight_types.h" | ||
| 77 | |||
| 78 | extern LED_TYPE led[RGBLED_NUM]; | ||
| 79 | |||
| 80 | extern const uint16_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; //modify for led_test | ||
| 81 | extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM; | ||
| 82 | extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM; | ||
| 83 | extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM; | ||
| 84 | extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM; | ||
| 85 | |||
| 86 | typedef union { | ||
| 87 | uint32_t raw; | ||
| 88 | struct { | ||
| 89 | bool enable :1; | ||
| 90 | uint8_t mode :6; | ||
| 91 | uint16_t hue :9; | ||
| 92 | uint8_t sat :8; | ||
| 93 | uint8_t val :8; | ||
| 94 | }; | ||
| 95 | } rgblight_config_t; | ||
| 96 | |||
| 97 | void rgblight_init(void); | ||
| 98 | void rgblight_increase(void); | ||
| 99 | void rgblight_decrease(void); | ||
| 100 | void rgblight_toggle(void); | ||
| 101 | void rgblight_enable(void); | ||
| 102 | void rgblight_disable(void); | ||
| 103 | void rgblight_step(void); | ||
| 104 | void rgblight_step_reverse(void); | ||
| 105 | uint32_t rgblight_get_mode(void); | ||
| 106 | void rgblight_mode(uint8_t mode); | ||
| 107 | void rgblight_set(void); | ||
| 108 | void rgblight_update_dword(uint32_t dword); | ||
| 109 | void rgblight_increase_hue(void); | ||
| 110 | void rgblight_decrease_hue(void); | ||
| 111 | void rgblight_increase_sat(void); | ||
| 112 | void rgblight_decrease_sat(void); | ||
| 113 | void rgblight_increase_val(void); | ||
| 114 | void rgblight_decrease_val(void); | ||
| 115 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); | ||
| 116 | uint16_t rgblight_get_hue(void); | ||
| 117 | uint8_t rgblight_get_sat(void); | ||
| 118 | uint8_t rgblight_get_val(void); | ||
| 119 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); | ||
| 120 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); | ||
| 121 | void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index); | ||
| 122 | |||
| 123 | uint32_t eeconfig_read_rgblight(void); | ||
| 124 | void eeconfig_update_rgblight(uint32_t val); | ||
| 125 | void eeconfig_update_rgblight_default(void); | ||
| 126 | void eeconfig_debug_rgblight(void); | ||
| 127 | |||
| 128 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); | ||
| 129 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); | ||
| 130 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); | ||
| 131 | |||
| 132 | #define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) | ||
| 133 | void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); | ||
| 134 | |||
| 135 | void rgblight_task(void); | ||
| 136 | |||
| 137 | void rgblight_timer_init(void); | ||
| 138 | void rgblight_timer_enable(void); | ||
| 139 | void rgblight_timer_disable(void); | ||
| 140 | void rgblight_timer_toggle(void); | ||
| 141 | void rgblight_effect_breathing(uint8_t interval); | ||
| 142 | void rgblight_effect_rainbow_mood(uint8_t interval); | ||
| 143 | void rgblight_effect_rainbow_swirl(uint8_t interval); | ||
| 144 | void rgblight_effect_snake(uint8_t interval); | ||
| 145 | void rgblight_effect_knight(uint8_t interval); | ||
| 146 | void rgblight_effect_christmas(void); | ||
| 147 | |||
| 148 | #endif | ||
diff --git a/keyboards/helix/rev2/keymaps/led_test/rules.mk b/keyboards/helix/rev2/keymaps/led_test/rules.mk new file mode 100644 index 000000000..71323916b --- /dev/null +++ b/keyboards/helix/rev2/keymaps/led_test/rules.mk | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | |||
| 2 | # Build Options | ||
| 3 | # change to "no" to disable the options, or define them in the Makefile in | ||
| 4 | # the appropriate keymap folder that will get included automatically | ||
| 5 | # | ||
| 6 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) | ||
| 7 | MOUSEKEY_ENABLE = no # Mouse keys(+4700) | ||
| 8 | EXTRAKEY_ENABLE = no # Audio control and System control(+450) | ||
| 9 | CONSOLE_ENABLE = no # Console for debug(+400) | ||
| 10 | COMMAND_ENABLE = no # Commands for debug and configuration | ||
| 11 | NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | ||
| 12 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
| 13 | MIDI_ENABLE = no # MIDI controls | ||
| 14 | AUDIO_ENABLE = no # Audio output on port C6 | ||
| 15 | UNICODE_ENABLE = no # Unicode | ||
| 16 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | ||
| 17 | # Helix keyboard : see ./config.h: RGBLED_NUM 6 or 32 | ||
| 18 | # Helix keyboard : RGBLIGHT_ENABLE = no or yes | ||
| 19 | RGBLIGHT_ENABLE = yes-but-local # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | ||
| 20 | ONEHAND_ENABLE = no # Enable one-hand typing | ||
| 21 | |||
| 22 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | ||
| 23 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | ||
| 24 | |||
| 25 | ifndef QUANTUM_DIR | ||
| 26 | include ../../../../Makefile | ||
| 27 | endif | ||
| 28 | |||
| 29 | #copy from common_features.mk and modify rgblight.c | ||
| 30 | OPT_DEFS += -DRGBLIGHT_ENABLE | ||
| 31 | SRC += rgblight.c | ||
| 32 | CIE1931_CURVE = yes | ||
| 33 | LED_BREATHING_TABLE = yes | ||
| 34 | ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes) | ||
| 35 | OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER | ||
| 36 | else | ||
| 37 | SRC += ws2812.c | ||
| 38 | endif | ||
