diff options
| -rw-r--r-- | keyboards/clueboard/rev1/config.h | 5 | ||||
| -rw-r--r-- | keyboards/clueboard/rev2/config.h | 5 | ||||
| -rw-r--r-- | keyboards/cluepad/config.h | 13 | ||||
| -rw-r--r-- | keyboards/kc60/keymaps/ws2812/config.h | 5 | ||||
| -rw-r--r-- | keyboards/lets_split/config.h | 5 | ||||
| -rw-r--r-- | keyboards/phantom/config.h | 13 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/experimental/Makefile | 6 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/experimental/config.h | 8 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/experimental/keymap.c | 73 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/pvc/config.h | 5 | ||||
| -rw-r--r-- | keyboards/planck/keymaps/yang/config.h | 5 | ||||
| -rw-r--r-- | keyboards/preonic/config.h | 5 | ||||
| -rw-r--r-- | keyboards/satan/config.h | 14 | ||||
| -rwxr-xr-x | quantum/light_ws2812.c | 25 | ||||
| -rw-r--r-- | quantum/rgblight.c | 23 | ||||
| -rw-r--r-- | quantum/rgblight.h | 7 | ||||
| -rw-r--r-- | readme.md | 17 |
17 files changed, 160 insertions, 74 deletions
diff --git a/keyboards/clueboard/rev1/config.h b/keyboards/clueboard/rev1/config.h index 9bb58f56e..8c9497232 100644 --- a/keyboards/clueboard/rev1/config.h +++ b/keyboards/clueboard/rev1/config.h | |||
| @@ -25,9 +25,8 @@ | |||
| 25 | 25 | ||
| 26 | /* Underlight configuration | 26 | /* Underlight configuration |
| 27 | */ | 27 | */ |
| 28 | #define ws2812_PORTREG PORTB | 28 | #define RGB_DI_PIN B2 |
| 29 | #define ws2812_DDRREG DDRB | 29 | #define RGBLIGHT_TIMER |
| 30 | #define ws2812_pin 2 | ||
| 31 | #define RGBLED_NUM 14 // Number of LEDs | 30 | #define RGBLED_NUM 14 // Number of LEDs |
| 32 | #define RGBLIGHT_HUE_STEP 10 | 31 | #define RGBLIGHT_HUE_STEP 10 |
| 33 | #define RGBLIGHT_SAT_STEP 17 | 32 | #define RGBLIGHT_SAT_STEP 17 |
diff --git a/keyboards/clueboard/rev2/config.h b/keyboards/clueboard/rev2/config.h index e2f8336be..02982ff29 100644 --- a/keyboards/clueboard/rev2/config.h +++ b/keyboards/clueboard/rev2/config.h | |||
| @@ -29,9 +29,8 @@ | |||
| 29 | 29 | ||
| 30 | /* Underlight configuration | 30 | /* Underlight configuration |
| 31 | */ | 31 | */ |
| 32 | #define ws2812_PORTREG PORTD | 32 | #define RGB_DI_PIN D7 |
| 33 | #define ws2812_DDRREG DDRD | 33 | #define RGBLIGHT_TIMER |
| 34 | #define ws2812_pin 7 | ||
| 35 | #define RGBLED_NUM 14 // Number of LEDs | 34 | #define RGBLED_NUM 14 // Number of LEDs |
| 36 | #define RGBLIGHT_HUE_STEP 10 | 35 | #define RGBLIGHT_HUE_STEP 10 |
| 37 | #define RGBLIGHT_SAT_STEP 17 | 36 | #define RGBLIGHT_SAT_STEP 17 |
diff --git a/keyboards/cluepad/config.h b/keyboards/cluepad/config.h index 0955e0f70..bae05fade 100644 --- a/keyboards/cluepad/config.h +++ b/keyboards/cluepad/config.h | |||
| @@ -69,13 +69,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 69 | 69 | ||
| 70 | /* Underlight configuration | 70 | /* Underlight configuration |
| 71 | */ | 71 | */ |
| 72 | #define ws2812_PORTREG PORTF | 72 | #define RGB_DI_PIN F6 |
| 73 | #define ws2812_DDRREG DDRF | 73 | #define RGBLIGHT_TIMER |
| 74 | #define ws2812_pin 6 | 74 | #define RGBLED_NUM 4 // Number of LEDs |
| 75 | #define RGBLED_NUM 4 // Number of LEDs | 75 | #define RGBLIGHT_HUE_STEP 10 |
| 76 | #define RGBLIGHT_HUE_STEP 10 | 76 | #define RGBLIGHT_SAT_STEP 17 |
| 77 | #define RGBLIGHT_SAT_STEP 17 | 77 | #define RGBLIGHT_VAL_STEP 17 |
| 78 | #define RGBLIGHT_VAL_STEP 17 | ||
| 79 | 78 | ||
| 80 | /* | 79 | /* |
| 81 | * Feature disable options | 80 | * Feature disable options |
diff --git a/keyboards/kc60/keymaps/ws2812/config.h b/keyboards/kc60/keymaps/ws2812/config.h index 933bb0d2d..2f39ea8e5 100644 --- a/keyboards/kc60/keymaps/ws2812/config.h +++ b/keyboards/kc60/keymaps/ws2812/config.h | |||
| @@ -1,9 +1,8 @@ | |||
| 1 | #include "../../config.h" | 1 | #include "../../config.h" |
| 2 | 2 | ||
| 3 | /* WS2812B RGB Underglow LED */ | 3 | /* WS2812B RGB Underglow LED */ |
| 4 | #define ws2812_PORTREG PORTF | 4 | #define RGB_DI_PIN F5 // Based on wiring depicted in ws2812_wiring.jpg |
| 5 | #define ws2812_DDRREG DDRF | 5 | #define RGBLIGHT_TIMER |
| 6 | #define ws2812_pin PF5 // Based on wiring depicted in ws2812_wiring.jpg | ||
| 7 | #define RGBLED_NUM 16 // Number of LEDs. Change this to match your use case. | 6 | #define RGBLED_NUM 16 // Number of LEDs. Change this to match your use case. |
| 8 | #define RGBLIGHT_HUE_STEP 8 | 7 | #define RGBLIGHT_HUE_STEP 8 |
| 9 | #define RGBLIGHT_SAT_STEP 8 | 8 | #define RGBLIGHT_SAT_STEP 8 |
diff --git a/keyboards/lets_split/config.h b/keyboards/lets_split/config.h index 6f90997ab..833818ce6 100644 --- a/keyboards/lets_split/config.h +++ b/keyboards/lets_split/config.h | |||
| @@ -69,9 +69,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 69 | ) | 69 | ) |
| 70 | 70 | ||
| 71 | /* ws2812 RGB LED */ | 71 | /* ws2812 RGB LED */ |
| 72 | #define ws2812_PORTREG PORTD | 72 | #define RGB_DI_PIN D2 |
| 73 | #define ws2812_DDRREG DDRD | 73 | #define RGBLIGHT_TIMER |
| 74 | #define ws2812_pin PD1 | ||
| 75 | #define RGBLED_NUM 28 // Number of LEDs | 74 | #define RGBLED_NUM 28 // Number of LEDs |
| 76 | #define RGBLIGHT_HUE_STEP 10 | 75 | #define RGBLIGHT_HUE_STEP 10 |
| 77 | #define RGBLIGHT_SAT_STEP 17 | 76 | #define RGBLIGHT_SAT_STEP 17 |
diff --git a/keyboards/phantom/config.h b/keyboards/phantom/config.h index d5878766f..983a1d73f 100644 --- a/keyboards/phantom/config.h +++ b/keyboards/phantom/config.h | |||
| @@ -62,13 +62,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 62 | 62 | ||
| 63 | /* Underlight configuration | 63 | /* Underlight configuration |
| 64 | */ | 64 | */ |
| 65 | #define ws2812_PORTREG PORTE | 65 | #define RGB_DI_PIN E2 |
| 66 | #define ws2812_DDRREG DDRE | 66 | #define RGBLIGHT_TIMER |
| 67 | #define ws2812_pin 2 | 67 | #define RGBLED_NUM 20 // Number of LEDs |
| 68 | #define RGBLED_NUM 20 // Number of LEDs | 68 | #define RGBLIGHT_HUE_STEP 10 |
| 69 | #define RGBLIGHT_HUE_STEP 10 | 69 | #define RGBLIGHT_SAT_STEP 17 |
| 70 | #define RGBLIGHT_SAT_STEP 17 | 70 | #define RGBLIGHT_VAL_STEP 17 |
| 71 | #define RGBLIGHT_VAL_STEP 17 | ||
| 72 | 71 | ||
| 73 | /* | 72 | /* |
| 74 | * Feature disable options | 73 | * Feature disable options |
diff --git a/keyboards/planck/keymaps/experimental/Makefile b/keyboards/planck/keymaps/experimental/Makefile index 581e08cd0..877c4aed0 100644 --- a/keyboards/planck/keymaps/experimental/Makefile +++ b/keyboards/planck/keymaps/experimental/Makefile | |||
| @@ -10,12 +10,12 @@ EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | |||
| 10 | CONSOLE_ENABLE = no # Console for debug(+400) | 10 | CONSOLE_ENABLE = no # Console for debug(+400) |
| 11 | COMMAND_ENABLE = yes # Commands for debug and configuration | 11 | COMMAND_ENABLE = yes # Commands for debug and configuration |
| 12 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work | 12 | NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work |
| 13 | BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality | 13 | BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality |
| 14 | MIDI_ENABLE = no # MIDI controls | 14 | MIDI_ENABLE = no # MIDI controls |
| 15 | AUDIO_ENABLE = yes # Audio output on port C6 | 15 | AUDIO_ENABLE = no # Audio output on port C6 |
| 16 | UNICODE_ENABLE = no # Unicode | 16 | UNICODE_ENABLE = no # Unicode |
| 17 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 17 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 18 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. | 18 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. |
| 19 | 19 | ||
| 20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
diff --git a/keyboards/planck/keymaps/experimental/config.h b/keyboards/planck/keymaps/experimental/config.h index 985e250ab..52acd1905 100644 --- a/keyboards/planck/keymaps/experimental/config.h +++ b/keyboards/planck/keymaps/experimental/config.h | |||
| @@ -6,4 +6,12 @@ | |||
| 6 | #define LEADER_TIMEOUT 300 | 6 | #define LEADER_TIMEOUT 300 |
| 7 | #define BACKLIGHT_BREATHING | 7 | #define BACKLIGHT_BREATHING |
| 8 | 8 | ||
| 9 | |||
| 10 | /* ws2812 RGB LED */ | ||
| 11 | #define RGB_DI_PIN B1 | ||
| 12 | #define RGBLIGHT_TIMER | ||
| 13 | #define RGBLED_NUM 8 // Number of LEDs | ||
| 14 | #define RGBLIGHT_HUE_STEP 10 | ||
| 15 | #define RGBLIGHT_SAT_STEP 17 | ||
| 16 | |||
| 9 | #endif | 17 | #endif |
diff --git a/keyboards/planck/keymaps/experimental/keymap.c b/keyboards/planck/keymaps/experimental/keymap.c index 8ec335d7d..d9303fcae 100644 --- a/keyboards/planck/keymaps/experimental/keymap.c +++ b/keyboards/planck/keymaps/experimental/keymap.c | |||
| @@ -15,7 +15,7 @@ extern keymap_config_t keymap_config; | |||
| 15 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. | 15 | // The underscores don't mean anything - you can have a layer called STUFF or any other name. |
| 16 | // Layer names don't all need to be of the same length, obviously, and you can also skip them | 16 | // Layer names don't all need to be of the same length, obviously, and you can also skip them |
| 17 | // entirely and just use numbers. | 17 | // entirely and just use numbers. |
| 18 | #define _QWERTY 0 | 18 | #define _QWERTY 10 |
| 19 | #define _COLEMAK 1 | 19 | #define _COLEMAK 1 |
| 20 | #define _DVORAK 2 | 20 | #define _DVORAK 2 |
| 21 | #define _LOWER 3 | 21 | #define _LOWER 3 |
| @@ -31,7 +31,15 @@ enum planck_keycodes { | |||
| 31 | LOWER, | 31 | LOWER, |
| 32 | RAISE, | 32 | RAISE, |
| 33 | BACKLIT, | 33 | BACKLIT, |
| 34 | EXT_PLV | 34 | EXT_PLV, |
| 35 | RGBLED_TOGGLE, | ||
| 36 | RGBLED_STEP_MODE, | ||
| 37 | RGBLED_INCREASE_HUE, | ||
| 38 | RGBLED_DECREASE_HUE, | ||
| 39 | RGBLED_INCREASE_SAT, | ||
| 40 | RGBLED_DECREASE_SAT, | ||
| 41 | RGBLED_INCREASE_VAL, | ||
| 42 | RGBLED_DECREASE_VAL, | ||
| 35 | }; | 43 | }; |
| 36 | 44 | ||
| 37 | // Fillers to make layering more clear | 45 | // Fillers to make layering more clear |
| @@ -39,14 +47,20 @@ enum planck_keycodes { | |||
| 39 | #define XXXXXXX KC_NO | 47 | #define XXXXXXX KC_NO |
| 40 | 48 | ||
| 41 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 49 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
| 50 | [0] = { | ||
| 51 | {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL}, | ||
| 52 | {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL}, | ||
| 53 | {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL}, | ||
| 54 | {KC_NO, KC_NO, KC_NO, KC_NO, RGBLED_TOGGLE, RGBLED_STEP_MODE, RGBLED_INCREASE_HUE, RGBLED_DECREASE_HUE, RGBLED_INCREASE_SAT, RGBLED_DECREASE_SAT, RGBLED_INCREASE_VAL, RGBLED_DECREASE_VAL} | ||
| 55 | }, | ||
| 42 | 56 | ||
| 43 | /* Qwerty | 57 | /* Qwerty |
| 44 | * ,-----------------------------------------------------------------------------------. | 58 | ,-----------------------------------------------------------------------------------. |
| 45 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | | 59 | * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | |
| 46 | * |------+------+------+------+------+-------------+------+------+------+------+------| | 60 | * |------+------+------+------+------+-------------+------+------+------+------+------| |
| 47 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | | 61 | * | Esc | A | S | D | F | G | H | J | K | L | ; | " | |
| 48 | * |------+------+------+------+------+------|------+------+------+------+------+------| | 62 | * |------+------+------+------+------+------|------+------+------+------+------+------| |
| 49 | * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | | 63 | * | Shift| Z | X | C | V | B | N | M |, | . | / |Enter | |
| 50 | * |------+------+------+------+------+------+------+------+------+------+------+------| | 64 | * |------+------+------+------+------+------+------+------+------+------+------+------| |
| 51 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | | 65 | * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | |
| 52 | * `-----------------------------------------------------------------------------------' | 66 | * `-----------------------------------------------------------------------------------' |
| @@ -292,6 +306,57 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 292 | break; | 306 | break; |
| 293 | return false; | 307 | return false; |
| 294 | 308 | ||
| 309 | case RGBLED_TOGGLE: | ||
| 310 | //led operations | ||
| 311 | if (record->event.pressed) { | ||
| 312 | rgblight_toggle(); | ||
| 313 | } | ||
| 314 | return false; | ||
| 315 | break; | ||
| 316 | case RGBLED_INCREASE_HUE: | ||
| 317 | if (record->event.pressed) { | ||
| 318 | rgblight_increase_hue(); | ||
| 319 | } | ||
| 320 | return false; | ||
| 321 | break; | ||
| 322 | case RGBLED_DECREASE_HUE: | ||
| 323 | if (record->event.pressed) { | ||
| 324 | rgblight_decrease_hue(); | ||
| 325 | } | ||
| 326 | return false; | ||
| 327 | break; | ||
| 328 | case RGBLED_INCREASE_SAT: | ||
| 329 | if (record->event.pressed) { | ||
| 330 | rgblight_increase_sat(); | ||
| 331 | } | ||
| 332 | return false; | ||
| 333 | break; | ||
| 334 | case RGBLED_DECREASE_SAT: | ||
| 335 | if (record->event.pressed) { | ||
| 336 | rgblight_decrease_sat(); | ||
| 337 | } | ||
| 338 | return false; | ||
| 339 | break; | ||
| 340 | case RGBLED_INCREASE_VAL: | ||
| 341 | if (record->event.pressed) { | ||
| 342 | rgblight_increase_val(); | ||
| 343 | } | ||
| 344 | return false; | ||
| 345 | break; | ||
| 346 | case RGBLED_DECREASE_VAL: | ||
| 347 | if (record->event.pressed) { | ||
| 348 | rgblight_decrease_val(); | ||
| 349 | } | ||
| 350 | return false; | ||
| 351 | break; | ||
| 352 | case RGBLED_STEP_MODE: | ||
| 353 | if (record->event.pressed) { | ||
| 354 | rgblight_step(); | ||
| 355 | } | ||
| 356 | return false; | ||
| 357 | break; | ||
| 358 | |||
| 359 | |||
| 295 | } | 360 | } |
| 296 | return true; | 361 | return true; |
| 297 | }; | 362 | }; |
diff --git a/keyboards/planck/keymaps/pvc/config.h b/keyboards/planck/keymaps/pvc/config.h index b64893108..c857a3e89 100644 --- a/keyboards/planck/keymaps/pvc/config.h +++ b/keyboards/planck/keymaps/pvc/config.h | |||
| @@ -60,9 +60,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 60 | ) | 60 | ) |
| 61 | 61 | ||
| 62 | /* ws2812 RGB LED */ | 62 | /* ws2812 RGB LED */ |
| 63 | #define ws2812_PORTREG PORTD | 63 | #define RGB_DI_PIN D1 |
| 64 | #define ws2812_DDRREG DDRD | 64 | #define RGBLIGHT_TIMER |
| 65 | #define ws2812_pin PD1 | ||
| 66 | #define RGBLED_NUM 28 // Number of LEDs | 65 | #define RGBLED_NUM 28 // Number of LEDs |
| 67 | #define RGBLIGHT_HUE_STEP 10 | 66 | #define RGBLIGHT_HUE_STEP 10 |
| 68 | #define RGBLIGHT_SAT_STEP 17 | 67 | #define RGBLIGHT_SAT_STEP 17 |
diff --git a/keyboards/planck/keymaps/yang/config.h b/keyboards/planck/keymaps/yang/config.h index 5921e9377..feb5a1190 100644 --- a/keyboards/planck/keymaps/yang/config.h +++ b/keyboards/planck/keymaps/yang/config.h | |||
| @@ -4,9 +4,8 @@ | |||
| 4 | #include "../../config.h" | 4 | #include "../../config.h" |
| 5 | 5 | ||
| 6 | /* ws2812 RGB LED */ | 6 | /* ws2812 RGB LED */ |
| 7 | #define ws2812_PORTREG PORTD | 7 | #define RGB_DI_PIN D1 |
| 8 | #define ws2812_DDRREG DDRD | 8 | #define RGBLIGHT_TIMER |
| 9 | #define ws2812_pin PD1 | ||
| 10 | #define RGBLED_NUM 28 // Number of LEDs | 9 | #define RGBLED_NUM 28 // Number of LEDs |
| 11 | #define RGBLIGHT_HUE_STEP 10 | 10 | #define RGBLIGHT_HUE_STEP 10 |
| 12 | #define RGBLIGHT_SAT_STEP 17 | 11 | #define RGBLIGHT_SAT_STEP 17 |
diff --git a/keyboards/preonic/config.h b/keyboards/preonic/config.h index 04946f7fb..3fb978c2f 100644 --- a/keyboards/preonic/config.h +++ b/keyboards/preonic/config.h | |||
| @@ -62,9 +62,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 62 | ) | 62 | ) |
| 63 | 63 | ||
| 64 | /* ws2812 RGB LED */ | 64 | /* ws2812 RGB LED */ |
| 65 | #define ws2812_PORTREG PORTD | 65 | #define RGB_DI_PIN D1 |
| 66 | #define ws2812_DDRREG DDRD | 66 | #define RGBLIGHT_TIMER |
| 67 | #define ws2812_pin PD1 | ||
| 68 | #define RGBLED_NUM 28 // Number of LEDs | 67 | #define RGBLED_NUM 28 // Number of LEDs |
| 69 | #define RGBLIGHT_HUE_STEP 10 | 68 | #define RGBLIGHT_HUE_STEP 10 |
| 70 | #define RGBLIGHT_SAT_STEP 17 | 69 | #define RGBLIGHT_SAT_STEP 17 |
diff --git a/keyboards/satan/config.h b/keyboards/satan/config.h index a7ea8f904..7e9f91cc8 100644 --- a/keyboards/satan/config.h +++ b/keyboards/satan/config.h | |||
| @@ -65,13 +65,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 65 | 65 | ||
| 66 | /* Underlight configuration | 66 | /* Underlight configuration |
| 67 | */ | 67 | */ |
| 68 | #define ws2812_PORTREG PORTE | 68 | |
| 69 | #define ws2812_DDRREG DDRE | 69 | #define RGB_DI_PIN E2 |
| 70 | #define ws2812_pin 2 | 70 | #define RGBLIGHT_TIMER |
| 71 | #define RGBLED_NUM 8 // Number of LEDs | 71 | #define RGBLED_NUM 8 // Number of LEDs |
| 72 | #define RGBLIGHT_HUE_STEP 10 | 72 | #define RGBLIGHT_HUE_STEP 10 |
| 73 | #define RGBLIGHT_SAT_STEP 17 | 73 | #define RGBLIGHT_SAT_STEP 17 |
| 74 | #define RGBLIGHT_VAL_STEP 17 | 74 | #define RGBLIGHT_VAL_STEP 17 |
| 75 | 75 | ||
| 76 | /* | 76 | /* |
| 77 | * Feature disable options | 77 | * Feature disable options |
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index f20043067..401845e85 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
| @@ -19,12 +19,16 @@ | |||
| 19 | // Setleds for standard RGB | 19 | // Setleds for standard RGB |
| 20 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) | 20 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) |
| 21 | { | 21 | { |
| 22 | ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); | 22 | // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin)); |
| 23 | ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF)); | ||
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask) | 26 | void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask) |
| 26 | { | 27 | { |
| 27 | ws2812_DDRREG |= pinmask; // Enable DDR | 28 | // ws2812_DDRREG |= pinmask; // Enable DDR |
| 29 | // new universal format (DDR) | ||
| 30 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask; | ||
| 31 | |||
| 28 | ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask); | 32 | ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask); |
| 29 | _delay_us(50); | 33 | _delay_us(50); |
| 30 | } | 34 | } |
| @@ -32,14 +36,17 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin | |||
| 32 | // Setleds for SK6812RGBW | 36 | // Setleds for SK6812RGBW |
| 33 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | 37 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) |
| 34 | { | 38 | { |
| 35 | ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR | 39 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR |
| 36 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(ws2812_pin)); | 40 | // new universal format (DDR) |
| 41 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); | ||
| 42 | |||
| 43 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | ||
| 37 | _delay_us(80); | 44 | _delay_us(80); |
| 38 | } | 45 | } |
| 39 | 46 | ||
| 40 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) | 47 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) |
| 41 | { | 48 | { |
| 42 | ws2812_sendarray_mask(data,datlen,_BV(ws2812_pin)); | 49 | ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF)); |
| 43 | } | 50 | } |
| 44 | 51 | ||
| 45 | /* | 52 | /* |
| @@ -108,8 +115,10 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi) | |||
| 108 | uint8_t curbyte,ctr,masklo; | 115 | uint8_t curbyte,ctr,masklo; |
| 109 | uint8_t sreg_prev; | 116 | uint8_t sreg_prev; |
| 110 | 117 | ||
| 111 | masklo =~maskhi&ws2812_PORTREG; | 118 | // masklo =~maskhi&ws2812_PORTREG; |
| 112 | maskhi |= ws2812_PORTREG; | 119 | // maskhi |= ws2812_PORTREG; |
| 120 | masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2); | ||
| 121 | maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2); | ||
| 113 | sreg_prev=SREG; | 122 | sreg_prev=SREG; |
| 114 | cli(); | 123 | cli(); |
| 115 | 124 | ||
| @@ -173,7 +182,7 @@ w_nop16 | |||
| 173 | " dec %0 \n\t" // '1' [+2] '0' [+2] | 182 | " dec %0 \n\t" // '1' [+2] '0' [+2] |
| 174 | " brne loop%=\n\t" // '1' [+3] '0' [+4] | 183 | " brne loop%=\n\t" // '1' [+3] '0' [+4] |
| 175 | : "=&d" (ctr) | 184 | : "=&d" (ctr) |
| 176 | : "r" (curbyte), "I" (_SFR_IO_ADDR(ws2812_PORTREG)), "r" (maskhi), "r" (masklo) | 185 | : "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo) |
| 177 | ); | 186 | ); |
| 178 | } | 187 | } |
| 179 | 188 | ||
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index c29ffedc3..b1b0f035d 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -146,7 +146,9 @@ void rgblight_init(void) { | |||
| 146 | } | 146 | } |
| 147 | eeconfig_debug_rgblight(); // display current eeprom values | 147 | eeconfig_debug_rgblight(); // display current eeprom values |
| 148 | 148 | ||
| 149 | rgblight_timer_init(); // setup the timer | 149 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) |
| 150 | rgblight_timer_init(); // setup the timer | ||
| 151 | #endif | ||
| 150 | 152 | ||
| 151 | if (rgblight_config.enable) { | 153 | if (rgblight_config.enable) { |
| 152 | rgblight_mode(rgblight_config.mode); | 154 | rgblight_mode(rgblight_config.mode); |
| @@ -192,14 +194,19 @@ void rgblight_mode(uint8_t mode) { | |||
| 192 | eeconfig_update_rgblight(rgblight_config.raw); | 194 | eeconfig_update_rgblight(rgblight_config.raw); |
| 193 | xprintf("rgblight mode: %u\n", rgblight_config.mode); | 195 | xprintf("rgblight mode: %u\n", rgblight_config.mode); |
| 194 | if (rgblight_config.mode == 1) { | 196 | if (rgblight_config.mode == 1) { |
| 195 | rgblight_timer_disable(); | 197 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) |
| 198 | rgblight_timer_disable(); | ||
| 199 | #endif | ||
| 196 | } else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) { | 200 | } else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) { |
| 197 | // MODE 2-5, breathing | 201 | // MODE 2-5, breathing |
| 198 | // MODE 6-8, rainbow mood | 202 | // MODE 6-8, rainbow mood |
| 199 | // MODE 9-14, rainbow swirl | 203 | // MODE 9-14, rainbow swirl |
| 200 | // MODE 15-20, snake | 204 | // MODE 15-20, snake |
| 201 | // MODE 21-23, knight | 205 | // MODE 21-23, knight |
| 202 | rgblight_timer_enable(); | 206 | |
| 207 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) | ||
| 208 | rgblight_timer_enable(); | ||
| 209 | #endif | ||
| 203 | } | 210 | } |
| 204 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | 211 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); |
| 205 | } | 212 | } |
| @@ -211,7 +218,10 @@ void rgblight_toggle(void) { | |||
| 211 | if (rgblight_config.enable) { | 218 | if (rgblight_config.enable) { |
| 212 | rgblight_mode(rgblight_config.mode); | 219 | rgblight_mode(rgblight_config.mode); |
| 213 | } else { | 220 | } else { |
| 214 | rgblight_timer_disable(); | 221 | |
| 222 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) | ||
| 223 | rgblight_timer_disable(); | ||
| 224 | #endif | ||
| 215 | _delay_ms(50); | 225 | _delay_ms(50); |
| 216 | rgblight_set(); | 226 | rgblight_set(); |
| 217 | } | 227 | } |
| @@ -328,6 +338,9 @@ void rgblight_set(void) { | |||
| 328 | } | 338 | } |
| 329 | } | 339 | } |
| 330 | 340 | ||
| 341 | |||
| 342 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) | ||
| 343 | |||
| 331 | // Animation timer -- AVR Timer3 | 344 | // Animation timer -- AVR Timer3 |
| 332 | void rgblight_timer_init(void) { | 345 | void rgblight_timer_init(void) { |
| 333 | static uint8_t rgblight_timer_is_init = 0; | 346 | static uint8_t rgblight_timer_is_init = 0; |
| @@ -503,3 +516,5 @@ void rgblight_effect_knight(uint8_t interval) { | |||
| 503 | } | 516 | } |
| 504 | 517 | ||
| 505 | } | 518 | } |
| 519 | |||
| 520 | #endif \ No newline at end of file | ||
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 64f92523e..def26c428 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | #ifndef RGBLIGHT_H | 1 | #ifndef RGBLIGHT_H |
| 2 | #define RGBLIGHT_H | 2 | #define RGBLIGHT_H |
| 3 | 3 | ||
| 4 | #ifndef RGBLIGHT_MODES | 4 | |
| 5 | #define RGBLIGHT_MODES 23 | 5 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) |
| 6 | #define RGBLIGHT_MODES 23 | ||
| 7 | #else | ||
| 8 | #define RGBLIGHT_MODES 1 | ||
| 6 | #endif | 9 | #endif |
| 7 | 10 | ||
| 8 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH | 11 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH |
| @@ -704,23 +704,18 @@ For this mod, you need an unused pin wiring to DI of WS2812 strip. After wiring | |||
| 704 | 704 | ||
| 705 | RGBLIGHT_ENABLE = yes | 705 | RGBLIGHT_ENABLE = yes |
| 706 | 706 | ||
| 707 | Please note that the underglow is not compatible with audio output. So you cannot enable both of them at the same time. | 707 | In order to use the underglow timer functions, you need to have `#define RGBLIGHT_TIMER` in your `config.h`, and have audio disabled (`AUDIO_ENABLE = no` in your Makefile). |
| 708 | 708 | ||
| 709 | Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the F4 by default: | 709 | Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the `F4` pin by default: |
| 710 | 710 | ||
| 711 | #define ws2812_PORTREG PORTF | 711 | #define RGB_DI_PIN F4 // The pin your RGB strip is wired to |
| 712 | #define ws2812_DDRREG DDRF | 712 | #define RGBLIGHT_TIMER // Require for fancier stuff (not compatible with audio) |
| 713 | #define ws2812_pin PF4 | ||
| 714 | #define RGBLED_NUM 14 // Number of LEDs | 713 | #define RGBLED_NUM 14 // Number of LEDs |
| 715 | #define RGBLIGHT_HUE_STEP 10 | 714 | #define RGBLIGHT_HUE_STEP 10 |
| 716 | #define RGBLIGHT_SAT_STEP 17 | 715 | #define RGBLIGHT_SAT_STEP 17 |
| 717 | #define RGBLIGHT_VAL_STEP 17 | 716 | #define RGBLIGHT_VAL_STEP 17 |
| 718 | 717 | ||
| 719 | You'll need to edit `PORTF`, `DDRF`, and `PF4` on the first three lines to the port/pin you have your LED(s) wired to, eg for B3 change things to: | 718 | You'll need to edit `RGB_DI_PIN` to the pin you have your `DI` on your RGB strip wired to. |
| 720 | |||
| 721 | #define ws2812_PORTREG PORTB | ||
| 722 | #define ws2812_DDRREG DDRB | ||
| 723 | #define ws2812_pin PB3 | ||
| 724 | 719 | ||
| 725 | The firmware supports 5 different light effects, and the color (hue, saturation, brightness) can be customized in most effects. To control the underglow, you need to modify your keymap file to assign those functions to some keys/key combinations. For details, please check this keymap. `keyboards/planck/keymaps/yang/keymap.c` | 720 | The firmware supports 5 different light effects, and the color (hue, saturation, brightness) can be customized in most effects. To control the underglow, you need to modify your keymap file to assign those functions to some keys/key combinations. For details, please check this keymap. `keyboards/planck/keymaps/yang/keymap.c` |
| 726 | 721 | ||
