Update ext_power_generic.c
This commit is contained in:
parent
41ebd22fea
commit
c3f8ad4636
1 changed files with 16 additions and 0 deletions
|
@ -14,6 +14,9 @@
|
||||||
#include <settings/settings.h>
|
#include <settings/settings.h>
|
||||||
#include <drivers/gpio.h>
|
#include <drivers/gpio.h>
|
||||||
#include <drivers/ext_power.h>
|
#include <drivers/ext_power.h>
|
||||||
|
#include <drivers/display.h>
|
||||||
|
|
||||||
|
#define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME
|
||||||
|
|
||||||
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
|
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
|
||||||
|
|
||||||
|
@ -57,6 +60,16 @@ int ext_power_save_state() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drivers_update_power_state(bool power) {
|
||||||
|
LOG_DBG("drivers_update_power_state: %s", power?"true":"false");
|
||||||
|
static const struct device *display;
|
||||||
|
display = device_get_binding(ZMK_DISPLAY_NAME);
|
||||||
|
|
||||||
|
if (display != NULL) {
|
||||||
|
display_update_ext_power(display, power);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int ext_power_generic_enable(const struct device *dev) {
|
static int ext_power_generic_enable(const struct device *dev) {
|
||||||
struct ext_power_generic_data *data = dev->data;
|
struct ext_power_generic_data *data = dev->data;
|
||||||
const struct ext_power_generic_config *config = dev->config;
|
const struct ext_power_generic_config *config = dev->config;
|
||||||
|
@ -66,6 +79,7 @@ static int ext_power_generic_enable(const struct device *dev) {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
data->status = true;
|
data->status = true;
|
||||||
|
drivers_update_power_state(true);
|
||||||
return ext_power_save_state();
|
return ext_power_save_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +92,8 @@ static int ext_power_generic_disable(const struct device *dev) {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
data->status = false;
|
data->status = false;
|
||||||
|
|
||||||
|
drivers_update_power_state(false);
|
||||||
return ext_power_save_state();
|
return ext_power_save_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue