Skip to content
Draft
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
37 changes: 36 additions & 1 deletion app/src/rgb_underglow.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,24 @@ static int rgb_settings_set(const char *name, size_t len, settings_read_cb read_
rc = read_cb(cb_arg, &state, sizeof(state));
if (rc >= 0) {
if (state.on) {
#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
if (ext_power != NULL) {
int rc = ext_power_enable(ext_power);
if (rc != 0) {
LOG_ERR("Unable to enable EXT_POWER: %d", rc);
}
}
#endif
k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50));
} else {
#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
if (ext_power != NULL) {
int rc = ext_power_disable(ext_power);
if (rc != 0) {
LOG_ERR("Unable to disable EXT_POWER: %d", rc);
}
}
#endif
}

return 0;
Expand Down Expand Up @@ -269,12 +286,30 @@ static int zmk_rgb_underglow_init(void) {
k_work_init_delayable(&underglow_save_work, zmk_rgb_underglow_save_state_work);
#endif

#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_AUTO_OFF_USB)
#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_AUTO_OFF_USB) && \
!IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
state.on = zmk_usb_is_powered();
#endif

if (state.on) {
#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
if (ext_power != NULL) {
int rc = ext_power_enable(ext_power);
if (rc != 0) {
LOG_ERR("Unable to enable EXT_POWER: %d", rc);
}
}
#endif
k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50));
} else {
#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
if (ext_power != NULL) {
int rc = ext_power_disable(ext_power);
if (rc != 0) {
LOG_ERR("Unable to disable EXT_POWER: %d", rc);
}
}
#endif
}

return 0;
Expand Down