feat(display): Add device runtime PM handling.
* Properly get/put the display device as needed when we start/ stop using it as part of our high level app logic.
This commit is contained in:
parent
3ddaac19a1
commit
6c1d6fb3e4
1 changed files with 11 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/init.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/pm/device_runtime.h>
|
||||
#include <zephyr/devicetree.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
|
@ -55,7 +56,16 @@ 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) {
|
||||
int err = pm_device_runtime_get(display);
|
||||
if (err < 0) {
|
||||
LOG_ERR("Failed to get the display device PM (%d)", err);
|
||||
return;
|
||||
}
|
||||
|
||||
display_blanking_off(display);
|
||||
|
||||
lv_obj_invalidate(lv_scr_act());
|
||||
|
||||
k_timer_start(&display_timer, K_MSEC(TICK_MS), K_MSEC(TICK_MS));
|
||||
}
|
||||
|
||||
|
@ -64,6 +74,7 @@ void unblank_display_cb(struct k_work *work) {
|
|||
void blank_display_cb(struct k_work *work) {
|
||||
k_timer_stop(&display_timer);
|
||||
display_blanking_on(display);
|
||||
pm_device_runtime_put(display);
|
||||
}
|
||||
K_WORK_DEFINE(blank_display_work, blank_display_cb);
|
||||
K_WORK_DEFINE(unblank_display_work, unblank_display_cb);
|
||||
|
|
Loading…
Add table
Reference in a new issue