diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 229aa63a1..3f98969d1 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -894,6 +894,22 @@ void Screen::handleStartBluetoothPinScreen(uint32_t pin) setFastFramerate(); } +void Screen::blink() { + setFastFramerate(); + uint8_t count = 10; + dispdev.setBrightness(254); + while(count>0) { + dispdev.fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + dispdev.display(); + delay(50); + dispdev.clear(); + dispdev.display(); + delay(50); + count = count -1; + } + 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 90e8ad089..888f31011 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 d3e1c9bb7..1af531129 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -244,7 +244,7 @@ void initWebServer() ResourceNode *node404 = new ResourceNode("", "GET", &handle404); ResourceNode *nodeFormUpload = new ResourceNode("/upload", "POST", &handleFormUpload); ResourceNode *nodeJsonScanNetworks = new ResourceNode("/json/scanNetworks", "GET", &handleScanNetworks); - ResourceNode *nodeJsonBlinkLED = new ResourceNode("/json/blink", "GET", &handleBlinkLED); + ResourceNode *nodeJsonBlinkLED = new ResourceNode("/json/blink", "POST", &handleBlinkLED); ResourceNode *nodeJsonSpiffsBrowseStatic = new ResourceNode("/json/spiffs/browse/static/", "GET", &handleSpiffsBrowseStatic); // Secure nodes @@ -978,22 +978,31 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res) { res->setHeader("Content-Type", "application/json"); - // This can be cleaned up at some point to make it non-blocking and to allow for more configuration. + ResourceParameters *params = req->getParams(); + std::string blink_target; + + if (!params->getQueryParameter("blink_target", blink_target)) { + // if no blink_target was supplied in the URL parameters of the + // POST request, then assume we should blink the LED + blink_target = "LED"; + } + + if (blink_target == "LED") { + uint8_t count = 10; + while (count > 0) { + setLed(true); + delay(50); + setLed(false); + delay(50); + count = count - 1; + } + } else { + screen->blink(); + } res->println("{"); res->println("\"status\": \"ok\""); res->println("}"); - - uint8_t count = 50; - - while (count > 0) - { - setLed(true); - delay(10); - setLed(false); - delay(10); - count = count - 1; - } } void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)