Pārlūkot izejas kodu

change backlight in menu, not persistent

Thomas Buck 1 gadu atpakaļ
vecāks
revīzija
a0555b0d45
2 mainītis faili ar 12 papildinājumiem un 4 dzēšanām
  1. 1
    2
      src/main.c
  2. 11
    2
      src/menu.c

+ 1
- 2
src/main.c Parādīt failu

@@ -53,7 +53,7 @@ int main(void) {
53 53
     debug("lcd_init");
54 54
     lcd_init();
55 55
     draw_splash();
56
-    lcd_set_backlight(0x8000);
56
+    lcd_set_backlight(0xFF00);
57 57
 
58 58
     if (watchdog_caused_reboot()) {
59 59
         debug("reset by watchdog");
@@ -88,7 +88,6 @@ int main(void) {
88 88
 
89 89
     debug("init done");
90 90
     battery_run();
91
-    lcd_set_backlight(0x8000); // TODO dynamic
92 91
 
93 92
     // wait for BLE stack to be ready before using it
94 93
     debug("wait for bt stack");

+ 11
- 2
src/menu.c Parādīt failu

@@ -21,6 +21,7 @@
21 21
 #include "config.h"
22 22
 #include "buttons.h"
23 23
 #include "text.h"
24
+#include "lcd.h"
24 25
 #include "menu.h"
25 26
 
26 27
 static char prev_buff[MENU_MAX_LEN] = {0};
@@ -31,10 +32,18 @@ static void (*exit_callback)(void) = NULL;
31 32
 
32 33
 static void menu_buttons(enum buttons btn, bool state) {
33 34
     if (state && (btn == BTN_LEFT)) {
34
-        // TODO brightness down
35
+        uint16_t backlight_value = lcd_get_backlight();
36
+        if (backlight_value > 0x00FF) {
37
+            backlight_value = backlight_value >> 1;
38
+        }
39
+        lcd_set_backlight(backlight_value);
35 40
         return;
36 41
     } else if (state && (btn == BTN_RIGHT)) {
37
-        // TODO brightness up
42
+        uint16_t backlight_value = lcd_get_backlight();
43
+        if (backlight_value < 0xFF00) {
44
+            backlight_value = backlight_value << 1;
45
+        }
46
+        lcd_set_backlight(backlight_value);
38 47
         return;
39 48
     } else if (state && ((btn == BTN_ENTER) || (btn == BTN_A))) {
40 49
         if (enter_callback) {

Notiek ielāde…
Atcelt
Saglabāt