improve blink; LED or SCREEN as POST Parameter

1.2-legacy
Charles Crossan 2020-12-20 18:24:48 -05:00
rodzic db2193b526
commit 2f779bfd37
2 zmienionych plików z 43 dodań i 25 usunięć

Wyświetl plik

@ -897,20 +897,15 @@ void Screen::handleStartBluetoothPinScreen(uint32_t pin)
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.fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
dispdev.display();
delay(50);
dispdev.clear();
dispdev.display();
delay(50);
count = count -1;
}
dispdev.setBrightness(brightness);
}

Wyświetl plik

@ -979,23 +979,46 @@ 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.
std::string contentType = req->getHeader("Content-Type");
std::string blink_target;
HTTPBodyParser *parser;
if (contentType.rfind("multipart/form-data",0) == 0) {
// If a body was submitted to /blink, then figure out whether the user
// watned to blink the LED or the screen
parser = new HTTPMultipartBodyParser(req);
while (parser->nextField()) {
std::string name = parser->getFieldName();
if (name == "blink_target") {
char buf[512];
size_t readLength = parser->read((byte *)buf, 512);
// filename = std::string("/public/") + std::string(buf, readLength);
blink_target = std::string(buf, readLength);
}
}
} else {
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("\"status\": \"Blink completed: LED\"");
res->println("}");
uint8_t count = 10;
/*while (count > 0)
{
setLed(true);
delay(50);
setLed(false);
delay(50);
count = count - 1;
}*/
screen->blink();
}
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)