Pārlūkot izejas kodu

improve cyd backlight dimming (reduced flicker)

Thomas Buck 4 mēnešus atpakaļ
vecāks
revīzija
6186324659
3 mainītis faili ar 6 papildinājumiem un 6 dzēšanām
  1. 1
    1
      compile_commands.json
  2. 2
    2
      platformio.ini
  3. 3
    3
      src/ui.cpp

+ 1
- 1
compile_commands.json Parādīt failu

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

+ 2
- 2
platformio.ini Parādīt failu

@@ -13,8 +13,8 @@ platform = platformio/espressif32@6.4.0
13 13
 board = esp32dev
14 14
 framework = arduino
15 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 18
 monitor_speed = 115200
19 19
 extra_scripts = pre:extra_script.py
20 20
 build_flags =

+ 3
- 3
src/ui.cpp Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt