Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crkbd:thunderbird2086 - layer status with RGB lighting/matrix #21063

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 47 additions & 29 deletions keyboards/crkbd/keymaps/thunderbird2086/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# undef TAPPING_TERM
#endif
#define TAPPING_TERM 200
#define VER_NEWLINE_WAIT 200 // in milliseconds

#define NO_ACTION_ONESHOT

Expand All @@ -32,63 +33,80 @@
#define RGBLIGHT_SLEEP

#if defined(RGBLIGHT_ENABLE)
# define RGBLIGHT_LAYERS
# define RGBLIGHT_LIMIT_VAL 150
# define RGBLIGHT_HUE_STEP 16
# define RGBLIGHT_SAT_STEP 32
# define RGBLIGHT_VAL_STEP 32

# define RGBLIGHT_EFFECT_ALTERING
# define RGBLIGHT_EFFECT_BREATHING
# define RGBLIGHT_EFFECT_CHRISTMAS
# define RGBLIGHT_EFFECT_KNIGHT
# define RGBLIGHT_EFFECT_RAINBOW_MOOD
# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
# define RGBLIGHT_EFFECT_KNIGHT
# define RGBLIGHT_EFFECT_RGB_TEST
# define RGBLIGHT_EFFECT_SNAKE
# define RGBLIGHT_EFFECT_STATIC_GRADIENT
# define RGBLIGHT_EFFECT_TWINKLE
#endif

#if defined(RGB_MATRIX_ENABLE)
# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150
# define SPLIT_LAYER_STATE_ENABLE
# define RGB_MATRIX_KEYPRESSES // reacts to keypresses
# define RGB_MATRIX_FRAMEBUFFER_EFFECTS
# define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150
// limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash.
# define RGB_MATRIX_HUE_STEP 32
# define RGB_MATRIX_SAT_STEP 64
# define RGB_MATRIX_VAL_STEP 64
# define RGB_MATRIX_SPD_STEP 20
# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR
# define RGB_MATRIX_HUE_STEP 32
# define RGB_MATRIX_SAT_STEP 64
# define RGB_MATRIX_VAL_STEP 64
# define RGB_MATRIX_SPD_STEP 20
# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR

/* Disable the animations you don't want/need. You will need to disable a good number of these *
* because they take up a lot of space. Disable until you can successfully compile your firmware. */
# undef ENABLE_RGB_MATRIX_ALPHAS_MODS
Thunderbird2086 marked this conversation as resolved.
Show resolved Hide resolved
# define ENABLE_RGB_MATRIX_ALPHAS_MODS
# undef ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN
# define ENABLE_RGB_MATRIX_BREATHING
# undef ENABLE_RGB_MATRIX_BREATHING
# undef ENABLE_RGB_MATRIX_BAND_SAT
# undef ENABLE_RGB_MATRIX_BAND_VAL
# undef ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
# undef ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
# undef ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT
# undef ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL
# define ENABLE_RGB_MATRIX_CYCLE_ALL
# undef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
# undef ENABLE_RGB_MATRIX_CYCLE_ALL
# define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
# undef ENABLE_RGB_MATRIX_CYCLE_UP_DOWN
# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
# undef ENABLE_RGB_MATRIX_CYCLE_OUT_IN
# undef ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
# define ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
# undef ENABLE_RGB_MATRIX_DUAL_BEACON
# undef ENABLE_RGB_MATRIX_CYCLE_PINWHEEL
# undef ENABLE_RGB_MATRIX_CYCLE_SPIRAL
# undef ENABLE_RGB_MATRIX_RAINBOW_BEACON
# undef ENABLE_RGB_MATRIX_DUAL_BEACON
# define ENABLE_RGB_MATRIX_RAINBOW_BEACON
# undef ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS
# undef ENABLE_RGB_MATRIX_RAINDROPS
# undef ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
# undef ENABLE_RGB_MATRIX_HUE_BREATHING
# undef ENABLE_RGB_MATRIX_HUE_PENDULUM
# undef ENABLE_RGB_MATRIX_HUE_WAVE
# undef ENABLE_RGB_MATRIX_PIXEL_FRACTAL
# define ENABLE_RGB_MATRIX_PIXEL_FLOW
# undef ENABLE_RGB_MATRIX_PIXEL_RAIN
# undef ENABLE_RGB_MATRIX_TYPING_HEATMAP
# undef ENABLE_RGB_MATRIX_DIGITAL_RAIN
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
# define ENABLE_RGB_MATRIX_SPLASH
# undef ENABLE_RGB_MATRIX_MULTISPLASH
# undef ENABLE_RGB_MATRIX_SOLID_SPLASH
# undef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
# define ENABLE_RGB_MATRIX_DIGITAL_RAIN

# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS
# undef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS
# undef ENABLE_RGB_MATRIX_SPLASH
# define ENABLE_RGB_MATRIX_MULTISPLASH
# undef ENABLE_RGB_MATRIX_SOLID_SPLASH
# undef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
#endif
5 changes: 4 additions & 1 deletion keyboards/crkbd/keymaps/thunderbird2086/keycodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@

enum custom_keycodes {
// Layer Macros
COLEMAK = SAFE_RANGE,
COLEMAK = QK_USER,
QWERTY,
FUNCTION,
CODE,
ADJUST,
# if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
RGBRST,
# endif
VRSN,
// Secret Macros
M_XXX1,
M_XXX2,
Expand Down
10 changes: 10 additions & 0 deletions keyboards/crkbd/keymaps/thunderbird2086/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
// clang-format off

#if defined(RGBLIGHT_ENABLE)
__attribute__((weak))
void set_rgb_by_layer(layer_state_t state) {
return;
}
#endif

layer_state_t layer_state_set_user(layer_state_t state) {
# if defined(RGBLIGHT_ENABLE)
set_rgb_by_layer(state);
# endif
return update_tri_layer_state(state, _FUNCTION, _ADJUST, _SECRET);
}
4 changes: 2 additions & 2 deletions keyboards/crkbd/keymaps/thunderbird2086/layers_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@

#if defined(RGB_MATRIX_ENABLE) || defined(RGBLIGHT_ENABLE)
# define ________________________ADJUST_L2________________________ RGBRST , XXXXXXX , RGB_SPI , RGB_SAI , RGB_HUI , RGB_VAI
# define ________________________ADJUST_L3________________________ EE_CLR , XXXXXXX , RGB_SPD , RGB_SAD , RGB_HUD , RGB_VAD
# define ________________________ADJUST_L3________________________ EE_CLR , VRSN , RGB_SPD , RGB_SAD , RGB_HUD , RGB_VAD
#else
# define ________________________ADJUST_L2________________________ XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX
# define ________________________ADJUST_L3________________________ EE_CLR , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX
# define ________________________ADJUST_L3________________________ EE_CLR , VRSN , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX
#endif

#if defined(RGB_MATRIX_ENABLE) || defined(RGBLIGHT_ENABLE)
Expand Down
36 changes: 25 additions & 11 deletions keyboards/crkbd/keymaps/thunderbird2086/process_records.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include QMK_KEYBOARD_H

#include "keycodes.h"
#include "version.h"

__attribute__((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
Expand All @@ -23,18 +24,31 @@ bool process_record_oled(uint16_t keycode, keyrecord_t *record) {
#endif

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {

case COLEMAK:
if (record->event.pressed) {
set_single_persistent_default_layer(_COLEMAK);
}
break;
case QWERTY:
if (record->event.pressed) {
set_single_persistent_default_layer(_QWERTY);
if (record->event.pressed) {
switch (keycode) {
case COLEMAK:
set_single_persistent_default_layer(_COLEMAK);
break;
case QWERTY:
set_single_persistent_default_layer(_QWERTY);
break;
# if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
case RGBRST:
# if defined(RGBLIGHT_ENABLE)
eeconfig_update_rgblight_default();
rgblight_enable();
# else
eeconfig_update_rgb_matrix_default();
# endif
break;
# endif
case VRSN:
send_string(
"# qmk " QMK_VERSION "\n" SS_DELAY(VER_NEWLINE_WAIT)
"# " QMK_KEYBOARD "/" QMK_KEYMAP "\n" SS_DELAY(VER_NEWLINE_WAIT)
"# built on: " QMK_BUILDDATE "\n");
break;
}
break;
}

return process_record_keymap(keycode, record) && process_record_secrets(keycode, record)
Expand Down
2 changes: 1 addition & 1 deletion keyboards/crkbd/keymaps/thunderbird2086/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The concept is Mac and **baby finger** friendly keymap.
| --- | --- | --- |
| ESC | Caps lock | |

- ADJUST: RGB control, Power control, default layer setting and reset
- ADJUST: RGB control, Power control, default layer setting, QMK version and reset
![adjust](https://i.imgur.com/uDIhigd.png)
- SECRET: hold `ADJUST` and `FUNCTION` to activate

Expand Down
61 changes: 61 additions & 0 deletions keyboards/crkbd/keymaps/thunderbird2086/rgb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2023 Allen Choi (@thunderbird2086)
// SPDX-License-Identifier: GPL-2.0-or-later

#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
Thunderbird2086 marked this conversation as resolved.
Show resolved Hide resolved
# include QMK_KEYBOARD_H

# include "keycodes.h"

# ifdef RGBLIGHT_ENABLE

const rgblight_segment_t PROGMEM _rgb_layer_0[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 56, HSV_BLUE}
);
const rgblight_segment_t PROGMEM _rgb_layer_1[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 56, HSV_GREEN}
);
const rgblight_segment_t PROGMEM _rgb_layer_2[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 56, HSV_YELLOW}
);

const rgblight_segment_t* const PROGMEM _rgb_layers[] = RGBLIGHT_LAYERS_LIST(
_rgb_layer_0,
_rgb_layer_1,
_rgb_layer_2
);

void keyboard_post_init_user(void) {
// Enable the LED layers
rgblight_layers = _rgb_layers;
}

void set_rgb_by_layer(layer_state_t state) {
rgblight_set_layer_state(0, layer_state_cmp(state, _CODE));
rgblight_set_layer_state(1, layer_state_cmp(state, _FUNCTION));
rgblight_set_layer_state(2, layer_state_cmp(state, _ADJUST));
}

# else

bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
for (uint8_t i = led_min; i < led_max; i++) {
switch(get_highest_layer(layer_state|default_layer_state)) {
case _CODE:
rgb_matrix_set_color(i, RGB_BLUE);
break;
case _FUNCTION:
rgb_matrix_set_color(i, RGB_GREEN);
break;
case _ADJUST:
rgb_matrix_set_color(i, RGB_YELLOW);
// RGB_WHITE caused crash
break;
default:
break;
}
}
return false;
}

# endif
#endif
1 change: 1 addition & 0 deletions keyboards/crkbd/keymaps/thunderbird2086/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ TAP_DANCE_ENABLE = yes

SRC += oled.c
SRC += process_records.c
SRC += rgb.c
SRC += tap_dances.c

ifneq ("$(wildcard keyboards/crkbd/keymaps/thunderbird2086/secrets.c)","")
Expand Down