Add RGB Sleep toggle feature

This commit is contained in:
Drashna Jael're
2020-08-05 01:53:59 -07:00
parent f4f158ad55
commit b8b71a7be2
3 changed files with 38 additions and 3 deletions

View File

@@ -319,7 +319,7 @@ led_config_t g_led_config = { {
// clang-format on // clang-format on
void suspend_power_down_kb(void) { void suspend_power_down_kb(void) {
rgb_matrix_set_suspend_state(true); rgb_matrix_set_suspend_state(keyboard_config.rgb_matrix_sleep_enable);
suspend_power_down_user(); suspend_power_down_user();
} }
@@ -416,7 +416,36 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
eeconfig_update_kb(keyboard_config.raw); eeconfig_update_kb(keyboard_config.raw);
} }
return false; return false;
case RGB_SLEEP_TOG:
if (record->event.pressed) {
keyboard_config.rgb_matrix_sleep_enable ^= true;
eeconfig_update_kb(keyboard_config.raw);
}
break;
#endif #endif
} }
return process_record_user(keycode, record); return process_record_user(keycode, record);
} }
void matrix_init_kb(void) {
keyboard_config.raw = eeconfig_read_kb();
#ifdef RGB_MATRIX_ENABLE
if (keyboard_config.rgb_matrix_enable) {
rgb_matrix_set_flags(LED_FLAG_ALL);
} else {
rgb_matrix_set_flags(LED_FLAG_NONE);
}
#endif
}
void eeconfig_init_kb(void) { // EEPROM is getting reset!
keyboard_config.raw = 0;
keyboard_config.rgb_matrix_enable = true;
#ifndef MOONLANDER_PRODUCTION_TESTING
keyboard_config.rgb_matrix_sleep_enable = true;
#endif
eeconfig_update_kb(keyboard_config.raw);
eeconfig_update_rgb_matrix_default();
eeconfig_init_user();
}

View File

@@ -57,14 +57,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
enum planck_ez_keycodes { enum planck_ez_keycodes {
TOGGLE_LAYER_COLOR = SAFE_RANGE, TOGGLE_LAYER_COLOR = SAFE_RANGE,
RGB_SLEEP_TOG,
ML_SAFE_RANGE, ML_SAFE_RANGE,
}; };
typedef union { typedef union {
uint32_t raw; uint32_t raw;
struct { struct {
bool disable_layer_led :1; bool disable_layer_led :1;
bool rgb_matrix_enable :1; bool rgb_matrix_enable :1;
bool rgb_matrix_sleep_enable :1;
}; };
} keyboard_config_t; } keyboard_config_t;

View File

@@ -22,3 +22,7 @@ EEPROM_DRIVER = i2c
#project specific files #project specific files
SRC = matrix.c SRC = matrix.c
QUANTUM_LIB_SRC += i2c_master.c QUANTUM_LIB_SRC += i2c_master.c
ifeq ($(strip $(MOONLANDER_PRODUCTION_TESTING)), yes)
OPT_DEFS += -DMOONLANDER_PRODUCTION_TESTING
endif