Browse Source

change backlight in menu, not persistent

Thomas Buck 1 year ago
parent
commit
a0555b0d45
2 changed files with 12 additions and 4 deletions
  1. 1
    2
      src/main.c
  2. 11
    2
      src/menu.c

+ 1
- 2
src/main.c View File

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

+ 11
- 2
src/menu.c View File

21
 #include "config.h"
21
 #include "config.h"
22
 #include "buttons.h"
22
 #include "buttons.h"
23
 #include "text.h"
23
 #include "text.h"
24
+#include "lcd.h"
24
 #include "menu.h"
25
 #include "menu.h"
25
 
26
 
26
 static char prev_buff[MENU_MAX_LEN] = {0};
27
 static char prev_buff[MENU_MAX_LEN] = {0};
31
 
32
 
32
 static void menu_buttons(enum buttons btn, bool state) {
33
 static void menu_buttons(enum buttons btn, bool state) {
33
     if (state && (btn == BTN_LEFT)) {
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
         return;
40
         return;
36
     } else if (state && (btn == BTN_RIGHT)) {
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
         return;
47
         return;
39
     } else if (state && ((btn == BTN_ENTER) || (btn == BTN_A))) {
48
     } else if (state && ((btn == BTN_ENTER) || (btn == BTN_A))) {
40
         if (enter_callback) {
49
         if (enter_callback) {

Loading…
Cancel
Save