]> git.tnoah.ca Git - lora-radio.git/commitdiff
Updated display blanking/unblanking
authorMark Qvist <mark@unsigned.io>
Tue, 1 Oct 2024 15:40:18 +0000 (17:40 +0200)
committerMark Qvist <mark@unsigned.io>
Tue, 1 Oct 2024 15:40:18 +0000 (17:40 +0200)
Display.h
RNode_Firmware.ino

index 8dfa0e84412fb54e89f3adfc2b95f5be3461d2ec..d4effde3588aec64e81fbd7fab4aa3c4693a6e8d 100644 (file)
--- a/Display.h
+++ b/Display.h
@@ -67,6 +67,7 @@ uint32_t last_disp_update = 0;
 uint32_t last_unblank_event = 0;
 uint32_t display_blanking_timeout = DISPLAY_BLANKING_TIMEOUT;
 uint8_t display_unblank_intensity = display_intensity;
+bool display_blanked = false;
 uint8_t disp_target_fps = 7;
 int disp_update_interval = 1000/disp_target_fps;
 uint32_t last_page_flip = 0;
@@ -597,11 +598,13 @@ void update_disp_area() {
 void update_display(bool blank = false) {
   if (display_blanking_enabled && millis()-last_unblank_event >= display_blanking_timeout) {
     blank = true;
+    display_blanked = true;
     if (display_intensity != 0) {
       display_unblank_intensity = display_intensity;
     }
     display_intensity = 0;
   } else {
+    display_blanked = false;
     if (display_unblank_intensity != 0x00) {
       display_intensity = display_unblank_intensity;
       display_unblank_intensity = 0x00;
index 987a534dfcb55b35ae6ff3aa31acd3ef4373cf79..bd6c6d6a00b74923cfa40064feb1174b713d20e9 100644 (file)
@@ -427,7 +427,6 @@ void flushQueue(void) {
   if (!queue_flushing) {
     queue_flushing = true;
 
-    display_unblank();
     led_tx_on();
     uint16_t processed = 0;
 
@@ -588,7 +587,6 @@ void serialCallback(uint8_t sbyte) {
             fifo16_push(&packet_lengths, l);
 
             current_packet_start = queue_cursor;
-            display_unblank();
         }
 
     }
@@ -604,7 +602,6 @@ void serialCallback(uint8_t sbyte) {
     } else if (command == CMD_DATA) {
         if (bt_state != BT_STATE_CONNECTED) {
           cable_state = CABLE_STATE_CONNECTED;
-          display_unblank();
         }
         if (sbyte == FESC) {
             ESCAPE = true;
@@ -1378,35 +1375,38 @@ void sleep_now() {
 
 void button_event(uint8_t event, unsigned long duration) {
   #if MCU_VARIANT == MCU_ESP32
-    display_unblank();
-    if (duration > 10000) {
-      #if HAS_CONSOLE
+    if (display_blanked) {
+      display_unblank();
+    } else {
+      if (duration > 10000) {
+        #if HAS_CONSOLE
+          #if HAS_BLUETOOTH || HAS_BLE
+            bt_stop();
+          #endif
+          console_active = true;
+          console_start();
+        #endif
+      } else if (duration > 5000) {
         #if HAS_BLUETOOTH || HAS_BLE
-          bt_stop();
+          if (bt_state != BT_STATE_CONNECTED) { bt_enable_pairing(); }
         #endif
-        console_active = true;
-        console_start();
-      #endif
-    } else if (duration > 5000) {
-      #if HAS_BLUETOOTH || HAS_BLE
-        if (bt_state != BT_STATE_CONNECTED) { bt_enable_pairing(); }
-      #endif
-    } else if (duration > 700) {
-      #if HAS_SLEEP
-        sleep_now();
-      #endif
-    } else {
-      #if HAS_BLUETOOTH || HAS_BLE
-      if (bt_state != BT_STATE_CONNECTED) {
-        if (bt_state == BT_STATE_OFF) {
-          bt_start();
-          bt_conf_save(true);
-        } else {
-          bt_stop();
-          bt_conf_save(false);
+      } else if (duration > 700) {
+        #if HAS_SLEEP
+          sleep_now();
+        #endif
+      } else {
+        #if HAS_BLUETOOTH || HAS_BLE
+        if (bt_state != BT_STATE_CONNECTED) {
+          if (bt_state == BT_STATE_OFF) {
+            bt_start();
+            bt_conf_save(true);
+          } else {
+            bt_stop();
+            bt_conf_save(false);
+          }
         }
+        #endif
       }
-      #endif
     }
   #endif
 }