From 5b80d88b869a8dcd189d82be0ba4108d3225e5f1 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 28 Nov 2017 15:58:46 +0100 Subject: [PATCH] Extend keepalive if the user is currently touching the screen -- this avoids the screen fading out on presses longer than the inactivity timeout --- src/backlight.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/backlight.c b/src/backlight.c index 0707558..3d263b9 100644 --- a/src/backlight.c +++ b/src/backlight.c @@ -1,4 +1,5 @@ #include "backlight.h" +#include "stmpe610.h" static float backlight_duty; static float backlight_target_duty; @@ -57,6 +58,14 @@ static void backlight_set(float new_duty, int fader_msec) { } static void backlight_keepalive_cb(void *arg) { + + // Extend the keepalive if the current state is TOUCH_DOWN + if (mgos_stmpe610_is_touching()) { + LOG(LL_DEBUG, ("SMTPE610 is touching, extending keepalive")); + backlight_keepalive(); + return; + } + // We trigger a fade if: // - current time is more than 3sec since our last keepalive // - backlight_duty>0: the screen is on