Expand 'Pixels' with reverse, height and alternate (#22755)

This commit is contained in:
s-hadinger 2025-01-03 08:24:49 +01:00 committed by GitHub
parent 64a2fe8aee
commit 50f0f8a651
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 14 deletions

View File

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Support for ESP32 Two-Wire Automotive Interface (TWAI) or Controller Area Network (CAN) busses
- Support for Senseair S88 CO2 sensor (#22733)
- TasmotaLED change dynamically the number of pixels
- Expand `Pixels` with reverse, height and alternate
### Breaking Changed

View File

@ -665,7 +665,8 @@ typedef struct {
// ----------------------------------------
#endif // ESP32S3
uint16_t light_pixels; // 496
uint16_t light_pixels : 15; // 496
uint16_t light_pixels_reverse : 1; // 496
uint8_t light_color[LST_MAX]; // 498 LST_MAX = 5
uint8_t light_correction; // 49D
uint8_t light_dimmer; // 49E
@ -786,8 +787,10 @@ typedef struct {
uint8_t web_color2[2][3]; // EA0 Needs to be on integer / 3 distance from web_color
uint16_t zcdimmerset[5]; // EA6
uint8_t free_eb0[22]; // EB0 22 bytes
uint8_t free_eb0[20]; // EB0 20 bytes
uint16_t light_pixels_height : 15; // EC4 Pixels height minus 1, default 0 (0 means 1 line)
uint16_t light_pixels_alternate : 1;// EC4 Indicates alternate lines in Pixels Matrix
uint8_t shift595_device_count; // EC6
uint8_t sta_config; // EC7
uint8_t sta_active; // EC8

View File

@ -633,6 +633,16 @@ bool Ws2812InitStrip(void)
return false;
}
bool Ws2812ChangePixelCount(void)
{
if (strip == nullptr) {
return true;
}
strip->SetPixelCount(Settings->light_pixels);
Ws2812Clear();
return true;
}
void Ws2812ModuleSelected(void)
{
if (Ws2812InitStrip()) {
@ -682,6 +692,14 @@ bool Ws2812CanShow(void) {
return false;
}
void Ws2812CanShowWait(void) {
if (strip) {
while (!strip->CanShow()) {
yield();
}
}
}
bool Ws2812IsDirty(void) {
if (strip) { return strip->IsDirty(); }
return false;
@ -773,19 +791,22 @@ void CmndLed(void)
void CmndPixels(void)
{
if ((XdrvMailbox.payload > 0) && (XdrvMailbox.payload <= WS2812_MAX_LEDS)) {
/*
Settings->light_pixels = XdrvMailbox.payload;
Settings->light_rotation = 0;
Ws2812ReinitStrip(); -- does not work with latest NeoPixelBus driver
Light.update = true;
*/
Ws2812Clear(); // Clear all known pixels
Settings->light_pixels = XdrvMailbox.payload;
Settings->light_rotation = 0;
TasmotaGlobal.restart_flag = 2; // reboot instead
uint32_t parm[4] = { Settings->light_pixels, Settings->light_pixels_reverse,
(uint32_t) Settings->light_pixels_height + 1, Settings->light_pixels_alternate };
if (ParseParameters(4, parm) > 0) {
if ((parm[0] > 0) && (parm[0] <= WS2812_MAX_LEDS)) {
Ws2812Clear(); // Clear all known pixels
Ws2812CanShowWait();
Settings->light_pixels = parm[0];
Settings->light_pixels_reverse = parm[1];
Settings->light_pixels_height = (parm[2] > 0) ? parm[2] - 1 : 1;
Settings->light_pixels_alternate = parm[3];
Ws2812ChangePixelCount();
Light.update = true;
}
}
ResponseCmndNumber(Settings->light_pixels);
Response_P(PSTR("{\"Pixels\":%i,\"PixelsReverse\":%i,\"PixelsHeight\":%i,\"PixelsAlternate\":%i}"),
Settings->light_pixels, Settings->light_pixels_reverse, Settings->light_pixels_height + 1, Settings->light_pixels_alternate);
}
void CmndStepPixels(void)