summaryrefslogtreecommitdiff
path: root/firmware/backlight-sw-fading.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-01 22:43:54 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-02 02:45:43 +0000
commitb5cb99a7bf3486ce7347dc06451f209b193d516c (patch)
tree9cbebc4c97a7e61d838e5a47928d9c43a78ad5f5 /firmware/backlight-sw-fading.c
parent9ee618e8891638027d05114250190f215bc01a63 (diff)
downloadrockbox-b5cb99a7bf3486ce7347dc06451f209b193d516c.tar.gz
rockbox-b5cb99a7bf3486ce7347dc06451f209b193d516c.zip
For backlights that have a wide control, support skipping steps.
the rocker, x3ii, and x20 now take advantage of this, and fades are far faster now. Change-Id: Iceb1a5a6c1d1389c3fdb859b32016b5114a80a22
Diffstat (limited to 'firmware/backlight-sw-fading.c')
-rw-r--r--firmware/backlight-sw-fading.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/firmware/backlight-sw-fading.c b/firmware/backlight-sw-fading.c
index c336d40458..ecd225667f 100644
--- a/firmware/backlight-sw-fading.c
+++ b/firmware/backlight-sw-fading.c
@@ -27,6 +27,10 @@
27#include "backlight.h" 27#include "backlight.h"
28#include "backlight-sw-fading.h" 28#include "backlight-sw-fading.h"
29 29
30#ifndef BRIGHTNESS_STEP
31#define BRIGHTNESS_STEP 1
32#endif
33
30/* To adapt a target do: 34/* To adapt a target do:
31 * - make sure backlight_hw_on doesn't set the brightness to something other than 35 * - make sure backlight_hw_on doesn't set the brightness to something other than
32 * the previous value (lowest brightness in most cases) 36 * the previous value (lowest brightness in most cases)
@@ -46,7 +50,14 @@ static bool _backlight_fade_up(void)
46{ 50{
47 if (LIKELY(current_brightness < backlight_brightness)) 51 if (LIKELY(current_brightness < backlight_brightness))
48 { 52 {
53#if BRIGHTNESS_STEP == 1
49 backlight_hw_brightness(++current_brightness); 54 backlight_hw_brightness(++current_brightness);
55#else
56 current_brightness += BRIGHTNESS_STEP;
57 if (current_brightness > MAX_BRIGHTNESS_SETTING)
58 current_brightness = MAX_BRIGHTNESS_SETTING;
59 backlight_hw_brightness(current_brightness);
60#endif
50 } 61 }
51 return(current_brightness >= backlight_brightness); 62 return(current_brightness >= backlight_brightness);
52} 63}
@@ -56,13 +67,24 @@ static bool _backlight_fade_down(void)
56{ 67{
57 if (LIKELY(current_brightness > MIN_BRIGHTNESS_SETTING)) 68 if (LIKELY(current_brightness > MIN_BRIGHTNESS_SETTING))
58 { 69 {
70#if BRIGHTNESS_STEP == 1
59 backlight_hw_brightness(--current_brightness); 71 backlight_hw_brightness(--current_brightness);
72#else
73 current_brightness -= BRIGHTNESS_STEP;
74 if (current_brightness < MIN_BRIGHTNESS_SETTING)
75 current_brightness = MIN_BRIGHTNESS_SETTING;
76 backlight_hw_brightness(current_brightness);
77#endif
60 return false; 78 return false;
61 } 79 }
62 else 80 else
63 { 81 {
64 /* decrement once more, since backlight is off */ 82 /* decrement once more, since backlight is off */
83#if BRIGHTNESS_STEP == 1
65 current_brightness--; 84 current_brightness--;
85#else
86 current_brightness=MIN_BRIGHTNESS_SETTING -1;
87#endif
66 backlight_hw_off(); 88 backlight_hw_off();
67 return true; 89 return true;
68 } 90 }