mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-29 11:01:15 +00:00
improve blink; LED or SCREEN as POST Parameter
This commit is contained in:
parent
db2193b526
commit
2f779bfd37
@ -897,20 +897,15 @@ void Screen::handleStartBluetoothPinScreen(uint32_t pin)
|
|||||||
void Screen::blink() {
|
void Screen::blink() {
|
||||||
setFastFramerate();
|
setFastFramerate();
|
||||||
uint8_t count = 10;
|
uint8_t count = 10;
|
||||||
uint8_t blinker = 0;
|
|
||||||
|
|
||||||
dispdev.setBrightness(254);
|
dispdev.setBrightness(254);
|
||||||
|
|
||||||
while(count>0) {
|
while(count>0) {
|
||||||
if (blinker == 254) {
|
dispdev.fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
blinker = 0;
|
|
||||||
count--;
|
|
||||||
} else {
|
|
||||||
blinker++;
|
|
||||||
}
|
|
||||||
int width = blinker / (254.00 / SCREEN_WIDTH);
|
|
||||||
dispdev.fillRect(0, 0, width, SCREEN_HEIGHT);
|
|
||||||
dispdev.display();
|
dispdev.display();
|
||||||
|
delay(50);
|
||||||
|
dispdev.clear();
|
||||||
|
dispdev.display();
|
||||||
|
delay(50);
|
||||||
|
count = count -1;
|
||||||
}
|
}
|
||||||
dispdev.setBrightness(brightness);
|
dispdev.setBrightness(brightness);
|
||||||
}
|
}
|
||||||
|
@ -979,23 +979,46 @@ void handleBlinkLED(HTTPRequest *req, HTTPResponse *res)
|
|||||||
res->setHeader("Content-Type", "application/json");
|
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.
|
// 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;
|
uint8_t count = 10;
|
||||||
|
while (count > 0)
|
||||||
/*while (count > 0)
|
|
||||||
{
|
{
|
||||||
setLed(true);
|
setLed(true);
|
||||||
delay(50);
|
delay(50);
|
||||||
setLed(false);
|
setLed(false);
|
||||||
delay(50);
|
delay(50);
|
||||||
count = count - 1;
|
count = count - 1;
|
||||||
}*/
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
screen->blink();
|
screen->blink();
|
||||||
|
}
|
||||||
|
|
||||||
|
res->println("{");
|
||||||
|
res->println("\"status\": \"Blink completed: LED\"");
|
||||||
|
res->println("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)
|
void handleScanNetworks(HTTPRequest *req, HTTPResponse *res)
|
||||||
|
Loading…
Reference in New Issue
Block a user