From 8580f9fd0c429b5fd16be82bc710b034b9f8a05c Mon Sep 17 00:00:00 2001 From: saitamandl Date: Thu, 12 Oct 2023 10:29:26 +0200 Subject: [PATCH] # oled ext pwr: Apply ddudek OLED ext pwr patch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit properly reinitializes the OLED display after ext power is re-enabled. It requires a patch pn zephyr itself. Until the patch is implemented in zephyr, it can be applied in your zmk-config’s github build action. More info here: #674 Original code by ddudek can also be found in the above issue. These changes are based on infused-kim zmk repo --- .gitignore | 3 ++- app/src/ext_power_generic.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 11b2d321a79..453d9d33e1f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ /build *.DS_Store __pycache__ -.idea \ No newline at end of file +.idea +.vscode \ No newline at end of file diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index e35714da10b..bb194b37041 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -15,6 +15,9 @@ #include #include +#include + +#define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) @@ -55,6 +58,16 @@ int ext_power_save_state() { #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) { struct ext_power_generic_data *data = dev->data; const struct ext_power_generic_config *config = dev->config; @@ -64,6 +77,7 @@ static int ext_power_generic_enable(const struct device *dev) { return -EIO; } data->status = true; + drivers_update_power_state(true); return ext_power_save_state(); } @@ -77,6 +91,7 @@ static int ext_power_generic_disable(const struct device *dev) { return -EIO; } data->status = false; + drivers_update_power_state(false); return ext_power_save_state(); }