Added spreading from center and fixed the enable
This commit is contained in:
parent
2b87817ba2
commit
339d2a7bf3
@ -30,6 +30,8 @@ IP adress of your Klipper instance you want to poll. ESP has to be restarted aft
|
|||||||
|
|
||||||
1 = reversed
|
1 = reversed
|
||||||
|
|
||||||
|
2 = center
|
||||||
|
|
||||||
-----
|
-----
|
||||||
Author:
|
Author:
|
||||||
|
|
||||||
|
@ -70,34 +70,36 @@ public:
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
if (enabled)
|
||||||
if (WLED_CONNECTED)
|
|
||||||
{
|
{
|
||||||
if (millis() - lastTime > 10000)
|
if (WLED_CONNECTED)
|
||||||
{
|
{
|
||||||
httpGet(wifiClient, errorMessage);
|
if (millis() - lastTime > 10000)
|
||||||
if (strcmp(errorMessage, "") == 0)
|
|
||||||
{
|
{
|
||||||
PSRAMDynamicJsonDocument klipperDoc(4096); // in practive about 2673
|
httpGet(wifiClient, errorMessage);
|
||||||
DeserializationError error = deserializeJson(klipperDoc, wifiClient);
|
if (strcmp(errorMessage, "") == 0)
|
||||||
if (error)
|
|
||||||
{
|
{
|
||||||
strcat(errorMessage, PSTR("deserializeJson() failed: "));
|
PSRAMDynamicJsonDocument klipperDoc(4096); // in practive about 2673
|
||||||
strcat(errorMessage, error.c_str());
|
DeserializationError error = deserializeJson(klipperDoc, wifiClient);
|
||||||
}
|
if (error)
|
||||||
printPercent = (int)(klipperDoc["result"]["status"]["virtual_sdcard"]["progress"].as<float>() * 100);
|
{
|
||||||
|
strcat(errorMessage, PSTR("deserializeJson() failed: "));
|
||||||
|
strcat(errorMessage, error.c_str());
|
||||||
|
}
|
||||||
|
printPercent = (int)(klipperDoc["result"]["status"]["virtual_sdcard"]["progress"].as<float>() * 100);
|
||||||
|
|
||||||
DEBUG_PRINT("Percent: ");
|
DEBUG_PRINT("Percent: ");
|
||||||
DEBUG_PRINTLN((int)(klipperDoc["result"]["status"]["virtual_sdcard"]["progress"].as<float>() * 100));
|
DEBUG_PRINTLN((int)(klipperDoc["result"]["status"]["virtual_sdcard"]["progress"].as<float>() * 100));
|
||||||
DEBUG_PRINT("LEDs: ");
|
DEBUG_PRINT("LEDs: ");
|
||||||
DEBUG_PRINTLN(strip.getLengthTotal() * printPercent / 100);
|
DEBUG_PRINTLN(direction == 2 ? (strip.getLengthTotal() / 2) * printPercent / 100 : strip.getLengthTotal() * printPercent / 100);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG_PRINTLN(errorMessage);
|
||||||
|
DEBUG_PRINTLN(ip);
|
||||||
|
}
|
||||||
|
lastTime = millis();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
DEBUG_PRINTLN(errorMessage);
|
|
||||||
DEBUG_PRINTLN(ip);
|
|
||||||
}
|
|
||||||
lastTime = millis();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,7 +131,6 @@ public:
|
|||||||
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
|
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
|
||||||
* Below it is shown how this could be used for e.g. a light sensor
|
* Below it is shown how this could be used for e.g. a light sensor
|
||||||
*/
|
*/
|
||||||
/* TODO: NOT WORKING YET
|
|
||||||
void addToJsonInfo(JsonObject &root)
|
void addToJsonInfo(JsonObject &root)
|
||||||
{
|
{
|
||||||
JsonObject user = root["u"];
|
JsonObject user = root["u"];
|
||||||
@ -149,7 +150,6 @@ public:
|
|||||||
infoArr.add(uiDomString);
|
infoArr.add(uiDomString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void addToJsonState(JsonObject &root)
|
void addToJsonState(JsonObject &root)
|
||||||
{
|
{
|
||||||
JsonObject usermod = root[FPSTR(_name)];
|
JsonObject usermod = root[FPSTR(_name)];
|
||||||
@ -170,7 +170,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* handleOverlayDraw() is called just before every show() (LED strip update frame) after effects have set the colors.
|
* handleOverlayDraw() is called just before every show() (LED strip update frame) after effects have set the colors.
|
||||||
@ -188,13 +187,25 @@ public:
|
|||||||
strip.setPixelColor(i, strip.getSegment(0).colors[1]);
|
strip.setPixelColor(i, strip.getSegment(0).colors[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // reversed
|
else if (direction == 1) // reversed
|
||||||
{
|
{
|
||||||
for (int i = 0; i < strip.getLengthTotal() * printPercent / 100; i++)
|
for (int i = 0; i < strip.getLengthTotal() * printPercent / 100; i++)
|
||||||
{
|
{
|
||||||
strip.setPixelColor(strip.getLengthTotal() - i, strip.getSegment(0).colors[1]);
|
strip.setPixelColor(strip.getLengthTotal() - i, strip.getSegment(0).colors[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (direction == 2) // center
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (strip.getLengthTotal() / 2) * printPercent / 100; i++)
|
||||||
|
{
|
||||||
|
strip.setPixelColor((strip.getLengthTotal() / 2) + i, strip.getSegment(0).colors[1]);
|
||||||
|
strip.setPixelColor((strip.getLengthTotal() / 2) - i, strip.getSegment(0).colors[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
direction = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user