Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(display): Add ability to set display on/off pin. #2814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/src/display/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);

#include <zephyr/drivers/display.h>
#include <zephyr/drivers/led.h>
#include <lvgl.h>

#include "theme.h"
Expand All @@ -22,6 +23,14 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/display/status_screen.h>

static const struct device *display = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));

#if DT_HAS_CHOSEN(zmk_display_led)

static const struct device *display_led = DEVICE_DT_GET(DT_PARENT(DT_CHOSEN(zmk_display_led)));
static const uint8_t display_led_idx = DT_NODE_CHILD_IDX(DT_CHOSEN(zmk_display_led));

#endif

static bool initialized = false;

static lv_obj_t *screen;
Expand Down Expand Up @@ -55,6 +64,9 @@ void display_timer_cb() { k_work_submit_to_queue(zmk_display_work_q(), &display_
K_TIMER_DEFINE(display_timer, display_timer_cb, NULL);

void unblank_display_cb(struct k_work *work) {
#if DT_HAS_CHOSEN(zmk_display_led)
led_on(display_led, display_led_idx);
#endif
display_blanking_off(display);
#if !IS_ENABLED(CONFIG_ARCH_POSIX)
k_timer_start(&display_timer, K_MSEC(TICK_MS), K_MSEC(TICK_MS));
Expand All @@ -68,6 +80,9 @@ void blank_display_cb(struct k_work *work) {
k_timer_stop(&display_timer);
#endif // !IS_ENABLED(CONFIG_ARCH_POSIX)
display_blanking_on(display);
#if DT_HAS_CHOSEN(zmk_display_led)
led_off(display_led, display_led_idx);
#endif
}
K_WORK_DEFINE(blank_display_work, blank_display_cb);
K_WORK_DEFINE(unblank_display_work, unblank_display_cb);
Expand Down
9 changes: 9 additions & 0 deletions docs/docs/config/displays.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ See the Devicetree bindings for your display. Here are the bindings for common d
- [SSD1306 (spi)](https://docs.zephyrproject.org/3.5.0/build/dts/api/bindings/display/solomon,ssd1306fb-spi.html)

A full list of drivers provided by Zephyr can be found in [Zephyr's Devicetree bindings index](https://docs.zephyrproject.org/3.5.0/build/dts/api/bindings.html).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is how we normally document these in config pages: https://zmk.dev/docs/config/kscan#devicetree

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Missed that. I'll update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caksoylar Tweaked.

### Chosen nodes

Applies to: [`/chosen` node](https://docs.zephyrproject.org/3.5.0/build/dts/intro-syntax-structure.html#aliases-and-chosen-nodes)

| Property | Type | Description |
| ----------------- | ---- | -------------------------------------------------------------------------------------------------------- |
| `zephyr,display` | path | The display device to use. |
| `zmk,display-led` | path | The LED device to use for on/off blanking, if the hardware requires it. Can be a PWM or GPIO LED device. |