Browse Source

improve cyd backlight dimming (reduced flicker)

Thomas Buck 2 months ago
parent
commit
6186324659
3 changed files with 6 additions and 6 deletions
  1. 1
    1
      compile_commands.json
  2. 2
    2
      platformio.ini
  3. 3
    3
      src/ui.cpp

+ 1
- 1
compile_commands.json View File

1
-.pio/build/lorarx/compile_commands.json
1
+.pio/build/cyd/compile_commands.json

+ 2
- 2
platformio.ini View File

13
 board = esp32dev
13
 board = esp32dev
14
 framework = arduino
14
 framework = arduino
15
 upload_protocol = esptool
15
 upload_protocol = esptool
16
-upload_port = /dev/ttyUSB2
17
-monitor_port = /dev/ttyUSB2
16
+upload_port = /dev/ttyUSB1
17
+monitor_port = /dev/ttyUSB1
18
 monitor_speed = 115200
18
 monitor_speed = 115200
19
 extra_scripts = pre:extra_script.py
19
 extra_scripts = pre:extra_script.py
20
 build_flags =
20
 build_flags =

+ 3
- 3
src/ui.cpp View File

60
 #define LDR_CHECK_MS 100
60
 #define LDR_CHECK_MS 100
61
 #define LDR_DARK_VALUE 1200
61
 #define LDR_DARK_VALUE 1200
62
 #define LDR_BRIGHT_VALUE 0
62
 #define LDR_BRIGHT_VALUE 0
63
-#define LDR_LOWPASS_FACT 0.025f
63
+#define LDR_LOWPASS_FACT 0.01f
64
 
64
 
65
 #define STANDBY_BRIGHTNESS 10
65
 #define STANDBY_BRIGHTNESS 10
66
 #define LCD_MIN_BRIGHTNESS (STANDBY_BRIGHTNESS * 2)
66
 #define LCD_MIN_BRIGHTNESS (STANDBY_BRIGHTNESS * 2)
101
 static enum ui_pages ui_page = UI_START;
101
 static enum ui_pages ui_page = UI_START;
102
 static bool is_touched = false;
102
 static bool is_touched = false;
103
 static unsigned long last_ldr = 0;
103
 static unsigned long last_ldr = 0;
104
-static int ldr_value = 0;
104
+static float ldr_value = 0;
105
 static unsigned long last_touch_time = 0;
105
 static unsigned long last_touch_time = 0;
106
 static int curr_brightness = LCD_MAX_BRIGHTNESS;
106
 static int curr_brightness = LCD_MAX_BRIGHTNESS;
107
 static int set_max_brightness = LCD_MAX_BRIGHTNESS;
107
 static int set_max_brightness = LCD_MAX_BRIGHTNESS;
464
     // read out LDR in regular intervals
464
     // read out LDR in regular intervals
465
     if (now >= (last_ldr + LDR_CHECK_MS)) {
465
     if (now >= (last_ldr + LDR_CHECK_MS)) {
466
         last_ldr = now;
466
         last_ldr = now;
467
-        int ldr = analogRead(LDR_PIN);
467
+        float ldr = analogRead(LDR_PIN);
468
 
468
 
469
         ldr_value = (ldr_value * (1.0f - LDR_LOWPASS_FACT)) + (ldr * LDR_LOWPASS_FACT);
469
         ldr_value = (ldr_value * (1.0f - LDR_LOWPASS_FACT)) + (ldr * LDR_LOWPASS_FACT);
470
 
470
 

Loading…
Cancel
Save