Merge pull request #3007 from Drachenkaetzchen/development

Major performace Improvements for WS2812 pixels
This commit is contained in:
Theo Arends 2018-06-24 17:55:58 +02:00 committed by GitHub
commit 63ee0a5870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -1118,6 +1118,7 @@ boolean LightCommand()
if (XdrvMailbox.data_len > 0) {
char *p;
uint16_t idx = XdrvMailbox.index;
Ws2812ForceSuspend();
for (char *color = strtok_r(XdrvMailbox.data, " ", &p); color; color = strtok_r(NULL, " ", &p)) {
if (LightColorEntry(color, strlen(color))) {
Ws2812SetColor(idx, light_entry_color[0], light_entry_color[1], light_entry_color[2], light_entry_color[3]);
@ -1127,6 +1128,8 @@ boolean LightCommand()
break;
}
}
Ws2812ForceUpdate();
}
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, XdrvMailbox.index, Ws2812GetColor(XdrvMailbox.index, scolor));
}

View File

@ -93,7 +93,7 @@ uint8_t kRepeat[5] = {
1 }; // All
uint8_t ws_show_next = 1;
bool ws_suspend_update = false;
/********************************************************************************************/
void Ws2812StripShow()
@ -365,6 +365,19 @@ void Ws2812SetColor(uint16_t led, uint8_t red, uint8_t green, uint8_t blue, uint
strip->SetPixelColor(i, lcolor);
}
}
if (!ws_suspend_update) {
strip->Show();
ws_show_next = 1;
}
}
void Ws2812ForceSuspend () {
ws_suspend_update = true;
}
void Ws2812ForceUpdate () {
ws_suspend_update = false;
strip->Show();
ws_show_next = 1;
}