From e821ec575a8ee14a1354e82a040fd5c95b7d306f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Vollst=C3=A4dt?= Date: Wed, 14 Dec 2022 17:26:58 +0100 Subject: [PATCH] =?UTF-8?q?oled=5Fext=5Fpwr:=20Apply=20ddudek=E2=80=99s=20?= =?UTF-8?q?OLED=20re-init=20patch=20This=20commit=20allows=20zmk=20to=20pr?= =?UTF-8?q?operly=20reinitialize=20the=20OLED=20display=20after=20ext=20po?= =?UTF-8?q?wer=20is=20re-enabled.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit More info here: zmkfirmware/zmk#674 --- app/app_oled_i2c_fix.diff.txt | 48 +++++++++++++++++++++++++++++++++++ app/src/ext_power_generic.c | 16 ++++++++++++ app/west.yml | 6 +++-- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 app/app_oled_i2c_fix.diff.txt diff --git a/app/app_oled_i2c_fix.diff.txt b/app/app_oled_i2c_fix.diff.txt new file mode 100644 index 00000000000..0e0c92dd782 --- /dev/null +++ b/app/app_oled_i2c_fix.diff.txt @@ -0,0 +1,48 @@ +diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c +index d2ca14dc..9619fcf7 100644 +--- a/app/src/ext_power_generic.c ++++ b/app/src/ext_power_generic.c +@@ -13,6 +13,9 @@ + #include + #include + #include ++#include ++ ++#define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME + + #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +@@ -59,6 +62,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; +@@ -68,6 +81,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(); + } + +@@ -80,6 +94,8 @@ 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(); + } + diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index aab09cecbbc..cd418eb913f 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -14,6 +14,9 @@ #include #include #include +#include + +#define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) @@ -57,6 +60,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; @@ -66,6 +79,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(); } @@ -78,6 +92,8 @@ 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(); } diff --git a/app/west.yml b/app/west.yml index a0c56501faa..3ada3d82f96 100644 --- a/app/west.yml +++ b/app/west.yml @@ -4,10 +4,12 @@ manifest: url-base: https://github.com/zephyrproject-rtos - name: zmkfirmware url-base: https://github.com/zmkfirmware + - name: zephyr-dododo + url-base: https://github.com/bobobo1618 projects: - name: zephyr - remote: zmkfirmware - revision: v3.0.0+zmk-fixes + remote: zephyr-dododo + revision: fix-oled clone-depth: 1 import: # TODO: Rename once upstream offers option like `exclude` or `denylist`