mirror of
https://github.com/wled/WLED.git
synced 2025-07-25 11:46:34 +00:00
HTML API "/url" for the current effect settings (#664)
This commit is contained in:
parent
8be72f6f23
commit
e8fd5de5b2
@ -99,6 +99,53 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
|
|||||||
if (request != nullptr) request->send(200, "text/xml", obuf);
|
if (request != nullptr) request->send(200, "text/xml", obuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* URL_response(AsyncWebServerRequest *request)
|
||||||
|
{
|
||||||
|
char sbuf[256]; //allocate local buffer if none passed
|
||||||
|
char s2buf[100];
|
||||||
|
obuf = s2buf;
|
||||||
|
olen = 0;
|
||||||
|
|
||||||
|
char s[16];
|
||||||
|
oappend("http://");
|
||||||
|
IPAddress localIP = WiFi.localIP();
|
||||||
|
sprintf(s, "%d.%d.%d.%d", localIP[0], localIP[1], localIP[2], localIP[3]);
|
||||||
|
oappend(s);
|
||||||
|
oappend("/win&A=");
|
||||||
|
oappendi(bri);
|
||||||
|
oappend("&CL=h");
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
sprintf(s,"%02X", col[i]);
|
||||||
|
oappend(s);
|
||||||
|
}
|
||||||
|
oappend("&C2=h");
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
sprintf(s,"%02X", colSec[i]);
|
||||||
|
oappend(s);
|
||||||
|
}
|
||||||
|
oappend("&FX=");
|
||||||
|
oappendi(effectCurrent);
|
||||||
|
oappend("&SX=");
|
||||||
|
oappendi(effectSpeed);
|
||||||
|
oappend("&IX=");
|
||||||
|
oappendi(effectIntensity);
|
||||||
|
oappend("&FP=");
|
||||||
|
oappendi(effectPalette);
|
||||||
|
|
||||||
|
obuf = sbuf;
|
||||||
|
olen = 0;
|
||||||
|
|
||||||
|
oappend("<html><body><a href=\"");
|
||||||
|
oappend(s2buf);
|
||||||
|
oappend("\" target=\"_blank\">");
|
||||||
|
oappend(s2buf);
|
||||||
|
oappend("</a></body></html>");
|
||||||
|
|
||||||
|
if (request != nullptr) request->send(200, "text/html", obuf);
|
||||||
|
}
|
||||||
|
|
||||||
//append a numeric setting to string buffer
|
//append a numeric setting to string buffer
|
||||||
void sappend(char stype, const char* key, int val)
|
void sappend(char stype, const char* key, int val)
|
||||||
{
|
{
|
||||||
|
@ -143,6 +143,10 @@ void initServer()
|
|||||||
request->send_P(200, "text/html", PAGE_usermod);
|
request->send_P(200, "text/html", PAGE_usermod);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.on("/url", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
|
URL_response(request);
|
||||||
|
});
|
||||||
|
|
||||||
server.on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){
|
server.on("/teapot", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
serveMessage(request, 418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254);
|
serveMessage(request, 418, "418. I'm a teapot.", "(Tangible Embedded Advanced Project Of Twinkling)", 254);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user