From db2193b52612eb9542e573520168afdd0e9c3383 Mon Sep 17 00:00:00 2001 From: Charles Crossan Date: Sun, 20 Dec 2020 17:45:45 -0500 Subject: [PATCH] implement screen blink --- src/graphics/Screen.cpp | 21 +++++++++++++++++++++ src/graphics/Screen.h | 2 ++ src/meshwifi/meshhttp.cpp | 6 ++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 229aa63a..e9cfe89a 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -894,6 +894,27 @@ void Screen::handleStartBluetoothPinScreen(uint32_t pin) setFastFramerate(); } +void Screen::blink() { + setFastFramerate(); + uint8_t count = 10; + uint8_t blinker = 0; + + dispdev.setBrightness(254); + + while(count>0) { + if (blinker == 254) { + blinker = 0; + count--; + } else { + blinker++; + } + int width = blinker / (254.00 / SCREEN_WIDTH); + dispdev.fillRect(0, 0, width, SCREEN_HEIGHT); + dispdev.display(); + } + dispdev.setBrightness(brightness); +} + void Screen::handlePrint(const char *text) { DEBUG_MSG("Screen: %s", text); diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 90e8ad08..888f3101 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -107,6 +107,8 @@ class Screen : public concurrency::OSThread */ void doDeepSleep(); + void blink(); + /// Handles a button press. void onPress() { enqueueCmd(ScreenCmd{.cmd = Cmd::ON_PRESS}); } diff --git a/src/meshwifi/meshhttp.cpp b/src/meshwifi/meshhttp.cpp index 47d6e6d1..50a1ac32 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -986,14 +986,16 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res) uint8_t count = 10; - while (count > 0) + /*while (count > 0) { setLed(true); delay(50); setLed(false); delay(50); count = count - 1; - } + }*/ + + screen->blink(); } void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)