Skip to content

Commit

Permalink
# oled ext pwr: Apply ddudek OLED ext pwr patch
Browse files Browse the repository at this point in the history
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:
zmkfirmware#674

Original code by ddudek can also be found in the above issue.

These changes are based on infused-kim zmk repo
  • Loading branch information
saitamandl committed Oct 12, 2023
1 parent 19a6af8 commit 8580f9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
/build
*.DS_Store
__pycache__
.idea
.idea
.vscode
15 changes: 15 additions & 0 deletions app/src/ext_power_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include <zephyr/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 @@ -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;
Expand All @@ -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();
}

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

Expand Down

0 comments on commit 8580f9f

Please sign in to comment.