Skip to content

Commit

Permalink
Set default EXT_POWER status via Kconfig.
Browse files Browse the repository at this point in the history
Ws previously on by default if no settings.
  • Loading branch information
donaldsycamore authored and chrisandreae committed Jan 27, 2023
1 parent c2f187f commit f55bf4c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
9 changes: 9 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ config ZMK_EXT_POWER
bool "Enable support to control external power output"
default y

if ZMK_EXT_POWER

config ZMK_EXT_POWER_START
bool "Enable external power output by default"
default y

#ZMK_EXT_POWER
endif

#Power Management
endmenu

Expand Down
3 changes: 3 additions & 0 deletions app/boards/arm/glove80/glove80_lh_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ CONFIG_ZMK_RGB_UNDERGLOW=y
CONFIG_WS2812_STRIP=y
CONFIG_SPI=y

# disable EXT_POWER until underglow gets turned on
CONFIG_ZMK_EXT_POWER_START=n

CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER=y
CONFIG_ZMK_RGB_UNDERGLOW_ON_START=n
CONFIG_ZMK_RGB_UNDERGLOW_BRT_STEP=4
Expand Down
3 changes: 3 additions & 0 deletions app/boards/arm/glove80/glove80_rh_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ CONFIG_ZMK_RGB_UNDERGLOW=y
CONFIG_WS2812_STRIP=y
CONFIG_SPI=y

# disable EXT_POWER until underglow gets turned on
CONFIG_ZMK_EXT_POWER_START=n

CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER=y
CONFIG_ZMK_RGB_UNDERGLOW_ON_START=n
CONFIG_ZMK_RGB_UNDERGLOW_BRT_STEP=4
Expand Down
18 changes: 13 additions & 5 deletions app/src/ext_power_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,26 @@ static int ext_power_generic_init(const struct device *dev) {

k_work_init_delayable(&ext_power_save_work, ext_power_save_state_work);

// Set default value (on) if settings isn't set
// Set default value if settings isn't set
settings_load_subtree("ext_power");
if (!data->settings_init) {

data->status = true;
data->status = IS_ENABLED(CONFIG_ZMK_EXT_POWER_START);
k_work_schedule(&ext_power_save_work, K_NO_WAIT);

ext_power_enable(dev);
if (data->status) {
ext_power_enable(dev);
} else {
ext_power_disable(dev);
}
}
#else
// Default to the ext_power being open when no settings
ext_power_enable(dev);
// If no settings, set ext_power on/off
if (IS_ENABLED(CONFIG_ZMK_EXT_POWER_START)) {
ext_power_enable(dev);
} else {
ext_power_disable(dev);
}
#endif

if (config->init_delay_ms) {
Expand Down

0 comments on commit f55bf4c

Please sign in to comment.