sforkowany z mirror/meshtastic-firmware
improve blink; LED or SCREEN as POST Parameter
rodzic
db2193b526
commit
2f779bfd37
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
res->println("{");
|
||||
res->println("\"status\": \"ok\"");
|
||||
res->println("}");
|
||||
|
||||
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)
|
||||
while (count > 0)
|
||||
{
|
||||
setLed(true);
|
||||
delay(50);
|
||||
setLed(false);
|
||||
delay(50);
|
||||
count = count - 1;
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
screen->blink();
|
||||
}
|
||||
|
||||
res->println("{");
|
||||
res->println("\"status\": \"Blink completed: LED\"");
|
||||
res->println("}");
|
||||
}
|
||||
|
||||
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)
|
||||
|
|
Ładowanie…
Reference in New Issue