From 13dbcab6c09d701e30addef4cadf3ea4af2774c7 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Fri, 9 Apr 2021 19:21:02 -0400 Subject: erosq: When mucking with the clickwheel, ensure we keep the screen awake! Change-Id: I49d39f301f4b44c2477a657e2af964b97d73cf6b --- firmware/target/hosted/button-devinput.c | 33 ++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'firmware/target') diff --git a/firmware/target/hosted/button-devinput.c b/firmware/target/hosted/button-devinput.c index b1b4dfca5d..df2358579b 100644 --- a/firmware/target/hosted/button-devinput.c +++ b/firmware/target/hosted/button-devinput.c @@ -33,6 +33,22 @@ #include "button.h" #include "panic.h" +#ifdef HAVE_SCROLLWHEEL +#include "powermgmt.h" +#if defined(HAVE_BACKLIGHT) || defined(HAVE_BUTTON_LIGHT) +#include "backlight.h" +#endif +#endif /* HAVE_SCROLLWHEEL */ + +/* TODO: HAVE_SCROLLWHEEL is a hack. Instead of posting the exact number + of clicks, instead do it similar to the ipod clickwheel and post + the wheel angular velocity (degrees per second) + + * Track the relative position (ie based on click events) + * Use WHEELCLICKS_PER_ROTATION to convert clicks to angular distance + * Compute to angular velocity (degrees per second) + + */ #define NR_POLL_DESC 4 static int num_devices = 0; @@ -150,8 +166,17 @@ int button_read_device(void) } #ifdef HAVE_SCROLLWHEEL - // TODO: Is there a better way to handle this? - // TODO: enable BUTTON_REPEAT if the events happen quickly enough + /* Reset backlight and poweroff timers */ + if (wheel_ticks) { +#ifdef HAVE_BACKLIGHT + backlight_on(); +#endif +#ifdef HAVE_BUTTON_LIGHT + buttonlight_on(); +#endif + reset_poweroff_timer(); + } + if (wheel_ticks > 0) { while (wheel_ticks-- > 0) @@ -159,14 +184,14 @@ int button_read_device(void) queue_post(&button_queue, BUTTON_SCROLL_FWD, 0); } } - else + else if (wheel_ticks < 0) { while (wheel_ticks++ < 0) { queue_post(&button_queue, BUTTON_SCROLL_BACK, 0); } } -#endif +#endif /* HAVE_SCROLLWHEEL */ return button_bitmap; } -- cgit v1.2.3