Skip to content

Commit

Permalink
ext_power: add Kconfig for initial ext_power state
Browse files Browse the repository at this point in the history
Adds a Kconfig setting for the default EXT_POWER status at initialization time. Previously it was always initialized to on if no saved value was present.
  • Loading branch information
donaldsycamore authored and chrisandreae committed Jul 1, 2024
1 parent 435f1aa commit 7ebd1f5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
9 changes: 9 additions & 0 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,15 @@ config ZMK_GPIO_KEY_WAKEUP_TRIGGER
default y
depends on DT_HAS_ZMK_GPIO_KEY_WAKEUP_TRIGGER_ENABLED && ZMK_PM_SOFT_OFF

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
18 changes: 13 additions & 5 deletions app/src/ext_power_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,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 7ebd1f5

Please sign in to comment.