Initial support for WS2812 scheme 14

This commit is contained in:
Theo Arends 2023-05-26 17:47:57 +02:00
parent 7f312ba589
commit fcf3477165
5 changed files with 45 additions and 20 deletions

View File

@ -186,8 +186,8 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t no_voltage_common : 1; // bit 4 (v12.3.1.5) - SetOption150 - (Energy) Force no voltage/frequency common uint32_t no_voltage_common : 1; // bit 4 (v12.3.1.5) - SetOption150 - (Energy) Force no voltage/frequency common
uint32_t matter_enabled : 1; // bit 5 (v12.3.1.5) - SetOption151 - (Matter) Enable Matter protocol over Wifi uint32_t matter_enabled : 1; // bit 5 (v12.3.1.5) - SetOption151 - (Matter) Enable Matter protocol over Wifi
uint32_t bistable_single_pin : 1; // bit 6 (v12.5.0.1) - SetOption152 - (Power) Switch between two (0) or one (1) pin bistable relay control uint32_t bistable_single_pin : 1; // bit 6 (v12.5.0.1) - SetOption152 - (Power) Switch between two (0) or one (1) pin bistable relay control
uint32_t berry_autoexec : 1; // bit 7 (v12.5.0.3) - SetOption153 - (Berry) Disable autoexec.be on restart (1) uint32_t berry_no_autoexec : 1; // bit 7 (v12.5.0.3) - SetOption153 - (Berry) Disable autoexec.be on restart (1)
uint32_t spare08 : 1; // bit 8 uint32_t berry_light_scheme : 1; // bit 8 (v12.5.0.3) - SetOption154 - (Berry) Handle berry led using RMT0 as additional WS2812 scheme
uint32_t spare09 : 1; // bit 9 uint32_t spare09 : 1; // bit 9
uint32_t spare10 : 1; // bit 10 uint32_t spare10 : 1; // bit 10
uint32_t spare11 : 1; // bit 11 uint32_t spare11 : 1; // bit 11

View File

@ -50,7 +50,8 @@
* 10 yes no no Kwanzaa * 10 yes no no Kwanzaa
* 11 yes no no Rainbow * 11 yes no no Rainbow
* 12 yes no no Fire * 12 yes no no Fire
* * 13 yes no no Stairs
* 14 yes no no Clear (= Berry)
\*********************************************************************************************/ \*********************************************************************************************/
/*********************************************************************************************\ /*********************************************************************************************\
@ -1866,7 +1867,7 @@ void LightAnimate(void)
break; break;
#endif #endif
default: default:
XlgtCall(FUNC_SET_SCHEME); XlgtCall(FUNC_SET_SCHEME);
} }
#ifdef USE_DEVICE_GROUPS #ifdef USE_DEVICE_GROUPS
@ -2858,7 +2859,7 @@ void CmndHsbColor(void)
void CmndScheme(void) void CmndScheme(void)
{ {
// Scheme 0..12 - Select one of schemes 0 to 12 // Scheme 0..14 - Select one of schemes 0 to 14
// Scheme 2 - Select scheme 2 // Scheme 2 - Select scheme 2
// Scheme 2,0 - Select scheme 2 with color wheel set to 0 (HSB Red) // Scheme 2,0 - Select scheme 2 with color wheel set to 0 (HSB Red)
// Scheme + - Select next scheme // Scheme + - Select next scheme

View File

@ -135,7 +135,23 @@ extern "C" {
break; break;
case 2: // # 02 : show void -> void case 2: // # 02 : show void -> void
{ {
uint32_t pixels_size; // number of bytes to push if (Settings->flag6.berry_light_scheme &&
(1 == TasmotaGlobal.light_driver)) { // XLGT_01
#ifdef USE_NETWORK_LIGHT_SCHEMES
bool scheme_berry = ((Light.max_scheme -1) == Settings->light_scheme);
#else
bool scheme_berry = (Light.max_scheme == Settings->light_scheme);
#endif
if (scheme_berry) {
if (!Light.power) {
break;
}
} else {
// Skip berry Show() but use WS2812 driver Show() instead
break;
}
}
uint32_t pixels_size; // number of bytes to push
if (s_ws2812_grb) { s_ws2812_grb->Show(); pixels_size = s_ws2812_grb->PixelsSize(); } if (s_ws2812_grb) { s_ws2812_grb->Show(); pixels_size = s_ws2812_grb->PixelsSize(); }
if (s_sk6812_grbw) { s_sk6812_grbw->Show(); pixels_size = s_ws2812_grb->PixelsSize(); } if (s_sk6812_grbw) { s_sk6812_grbw->Show(); pixels_size = s_ws2812_grb->PixelsSize(); }

View File

@ -379,7 +379,7 @@ void BrLoad(const char * script_name) {
if (berry.vm == nullptr || TasmotaGlobal.no_autoexec) { return; } // abort is berry is not running, or bootloop prevention kicked in if (berry.vm == nullptr || TasmotaGlobal.no_autoexec) { return; } // abort is berry is not running, or bootloop prevention kicked in
if (!strcmp_P(script_name, "autoexec.be")) { if (!strcmp_P(script_name, "autoexec.be")) {
if (Settings->flag6.berry_autoexec) { // SetOption153 - (Berry) Disable autoexec.be on restart (1) if (Settings->flag6.berry_no_autoexec) { // SetOption153 - (Berry) Disable autoexec.be on restart (1)
return; return;
} }
} }

View File

@ -33,15 +33,13 @@
* 6 (11) yes no no Rainbow * 6 (11) yes no no Rainbow
* 7 (12) yes no no Fire * 7 (12) yes no no Fire
* 8 (13) yes no no Stairs * 8 (13) yes no no Stairs
* 9 (14) yes no no Clear (= Berry)
* 10 (15) yes no no Optional DDP
\*********************************************************************************************/ \*********************************************************************************************/
#define XLGT_01 1 #define XLGT_01 1
#ifdef USE_NETWORK_LIGHT_SCHEMES
const uint8_t WS2812_SCHEMES = 10; // Number of WS2812 schemes const uint8_t WS2812_SCHEMES = 10; // Number of WS2812 schemes
#else
const uint8_t WS2812_SCHEMES = 9; // Number of WS2812 schemes
#endif
const char kWs2812Commands[] PROGMEM = "|" // No prefix const char kWs2812Commands[] PROGMEM = "|" // No prefix
D_CMND_LED "|" D_CMND_PIXELS "|" D_CMND_ROTATION "|" D_CMND_WIDTH "|" D_CMND_STEPPIXELS ; D_CMND_LED "|" D_CMND_PIXELS "|" D_CMND_ROTATION "|" D_CMND_WIDTH "|" D_CMND_STEPPIXELS ;
@ -172,11 +170,7 @@ WsColor kRainbow[7] = { 255,0,0, 255,128,0, 255,255,0, 0,255,0, 0,0,255, 128,0,2
WsColor kFire[3] = { 255,0,0, 255,102,0, 255,192,0 }; WsColor kFire[3] = { 255,0,0, 255,102,0, 255,192,0 };
WsColor kStairs[2] = { 0,0,0, 255,255,255 }; WsColor kStairs[2] = { 0,0,0, 255,255,255 };
#ifdef USE_NETWORK_LIGHT_SCHEMES ColorScheme kSchemes[WS2812_SCHEMES -2] = { // Skip clock and clear scheme
ColorScheme kSchemes[WS2812_SCHEMES -2] = { // Skip clock scheme and DDP scheme
#else
ColorScheme kSchemes[WS2812_SCHEMES -1] = { // Skip clock scheme
#endif
kIncandescent, 2, kIncandescent, 2,
kRgb, 3, kRgb, 3,
kChristmas, 2, kChristmas, 2,
@ -203,6 +197,7 @@ struct WS2812 {
uint8_t show_next = 1; uint8_t show_next = 1;
uint8_t scheme_offset = 0; uint8_t scheme_offset = 0;
bool suspend_update = false; bool suspend_update = false;
bool scheme9;
} Ws2812; } Ws2812;
/********************************************************************************************/ /********************************************************************************************/
@ -554,7 +549,7 @@ void Ws2812DDP(void)
Ws2812StripShow(); Ws2812StripShow();
} }
} }
#endif #endif // USE_NETWORK_LIGHT_SCHEMES
void Ws2812Clear(void) void Ws2812Clear(void)
{ {
@ -645,8 +640,11 @@ void Ws2812ShowScheme(void)
{ {
uint32_t scheme = Settings->light_scheme - Ws2812.scheme_offset; uint32_t scheme = Settings->light_scheme - Ws2812.scheme_offset;
if (scheme != 9) {
Ws2812.scheme9 = 0;
}
#ifdef USE_NETWORK_LIGHT_SCHEMES #ifdef USE_NETWORK_LIGHT_SCHEMES
if ((scheme != 9) && (ddp_udp_up)) { if ((scheme != 10) && (ddp_udp_up)) {
ddp_udp.stop(); ddp_udp.stop();
ddp_udp_up = 0; ddp_udp_up = 0;
AddLog(LOG_LEVEL_DEBUG_MORE, "DDP: UDP Stopped: WS2812 Scheme not DDP"); AddLog(LOG_LEVEL_DEBUG_MORE, "DDP: UDP Stopped: WS2812 Scheme not DDP");
@ -659,11 +657,17 @@ void Ws2812ShowScheme(void)
Ws2812.show_next = 0; Ws2812.show_next = 0;
} }
break; break;
case 9: // Clear
if (!Ws2812.scheme9) {
Ws2812Clear();
Ws2812.scheme9 = 1;
}
break;
#ifdef USE_NETWORK_LIGHT_SCHEMES #ifdef USE_NETWORK_LIGHT_SCHEMES
case 9: case 10:
Ws2812DDP(); Ws2812DDP();
break; break;
#endif #endif // USE_NETWORK_LIGHT_SCHEMES
default: default:
if(Settings->light_step_pixels > 0){ if(Settings->light_step_pixels > 0){
Ws2812Steps(scheme -1); Ws2812Steps(scheme -1);
@ -713,6 +717,10 @@ void Ws2812ModuleSelected(void)
Ws2812.scheme_offset = Light.max_scheme +1; Ws2812.scheme_offset = Light.max_scheme +1;
Light.max_scheme += WS2812_SCHEMES; Light.max_scheme += WS2812_SCHEMES;
#ifdef USE_NETWORK_LIGHT_SCHEMES
Light.max_scheme++;
#endif
#if (USE_WS2812_CTYPE > NEO_3LED) #if (USE_WS2812_CTYPE > NEO_3LED)
TasmotaGlobal.light_type = LT_RGBW; TasmotaGlobal.light_type = LT_RGBW;
#else #else