Skip to content

Commit

Permalink
oled_ext_pwr: Apply ddudek’s OLED re-init patch This commit allows zm…
Browse files Browse the repository at this point in the history
…k to properly reinitialize the OLED display after ext power is re-enabled.

More info here:
zmkfirmware#674
  • Loading branch information
istatv authored and packorf committed Feb 6, 2023
1 parent b7d5865 commit 7c00a85
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
48 changes: 48 additions & 0 deletions app/app_oled_i2c_fix.diff.txt
Original file line number Diff line number Diff line change
@@ -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 <settings/settings.h>
#include <drivers/gpio.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)

@@ -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();
}

16 changes: 16 additions & 0 deletions app/src/ext_power_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <settings/settings.h>
#include <drivers/gpio.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)

Expand Down Expand Up @@ -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;
Expand All @@ -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();
}

Expand All @@ -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();
}

Expand Down
6 changes: 4 additions & 2 deletions app/west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
name-blocklist:
Expand Down

0 comments on commit 7c00a85

Please sign in to comment.