mirror of https://github.com/zmkfirmware/zmk.git
Improve readability with additional macro
This commit is contained in:
parent
c7ab8715de
commit
c28536ee29
|
|
@ -21,6 +21,9 @@
|
|||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
#define PERSIST_EXT_POWER_STATE \
|
||||
IS_ENABLED(CONFIG_SETTINGS) && !IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
|
||||
|
||||
struct ext_power_generic_config {
|
||||
const struct gpio_dt_spec *control;
|
||||
const size_t control_gpios_count;
|
||||
|
|
@ -29,12 +32,12 @@ struct ext_power_generic_config {
|
|||
|
||||
struct ext_power_generic_data {
|
||||
bool status;
|
||||
#if IS_ENABLED(CONFIG_SETTINGS) && !IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
|
||||
#if PERSIST_EXT_POWER_STATE
|
||||
bool settings_init;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_SETTINGS) && !IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
|
||||
#if PERSIST_EXT_POWER_STATE
|
||||
static void ext_power_save_state_work(struct k_work *work) {
|
||||
char setting_path[40];
|
||||
const struct device *ext_power = DEVICE_DT_GET(DT_DRV_INST(0));
|
||||
|
|
@ -48,7 +51,7 @@ static struct k_work_delayable ext_power_save_work;
|
|||
#endif
|
||||
|
||||
int ext_power_save_state(void) {
|
||||
#if IS_ENABLED(CONFIG_SETTINGS) && !IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
|
||||
#if PERSIST_EXT_POWER_STATE
|
||||
int ret = k_work_reschedule(&ext_power_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE));
|
||||
return MIN(ret, 0);
|
||||
#else
|
||||
|
|
@ -91,7 +94,7 @@ static int ext_power_generic_get(const struct device *dev) {
|
|||
return data->status;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_SETTINGS) && !IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
|
||||
#if PERSIST_EXT_POWER_STATE
|
||||
static int ext_power_settings_set_status(const struct device *dev, size_t len,
|
||||
settings_read_cb read_cb, void *cb_arg) {
|
||||
struct ext_power_generic_data *data = dev->data;
|
||||
|
|
@ -158,7 +161,7 @@ static int ext_power_generic_init(const struct device *dev) {
|
|||
}
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_SETTINGS) && !IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
|
||||
#if PERSIST_EXT_POWER_STATE
|
||||
k_work_init_delayable(&ext_power_save_work, ext_power_save_state_work);
|
||||
#endif
|
||||
|
||||
|
|
@ -197,7 +200,7 @@ static const struct ext_power_generic_config config = {
|
|||
|
||||
static struct ext_power_generic_data data = {
|
||||
.status = false,
|
||||
#if IS_ENABLED(CONFIG_SETTINGS) && !IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
|
||||
#if PERSIST_EXT_POWER_STATE
|
||||
.settings_init = false,
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue