sforkowany z mirror/meshtastic-firmware
Merge pull request #31 from crossan007/adjust-blink-timings
adjust LED timings; switch to HTTP/POST; add SCREEN blink support1.2-legacy
commit
88cf60ad9d
|
@ -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);
|
||||
|
|
|
@ -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}); }
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue