StripState pin (led_enableAll state output for transistor control for DMX LED strip)

This commit is contained in:
Tester23 2025-09-16 01:15:33 +02:00
parent ea3ea1ffcf
commit 59df875216
6 changed files with 81 additions and 1 deletions

View File

@ -876,8 +876,20 @@ void LED_ToggleEnabled() {
}
bool g_guard_led_enable_event_cast = false;
void LED_SetStripStateOutputs() {
for (int i = 0; i < PLATFORM_GPIO_MAX; i++) {
int state = g_cfg.pins.roles[i];
if (state == IOR_StripState) {
HAL_PIN_SetOutputValue(i, g_lightEnableAll);
}
else if (state == IOR_StripState_n) {
HAL_PIN_SetOutputValue(i, !g_lightEnableAll);
}
}
}
void LED_SetEnableAll(int bEnable) {
bool bEnableAllWasSetTo1;
bool bHadChange;
if (g_lightEnableAll == 0 && bEnable == 1) {
bEnableAllWasSetTo1 = true;
@ -904,6 +916,7 @@ void LED_SetEnableAll(int bEnable) {
}
g_lightEnableAll = bEnable;
LED_SetStripStateOutputs();
apply_smart_light();
#if ENABLE_TASMOTADEVICEGROUPS
DRV_DGR_OnLedEnableAllChange(bEnable);

View File

@ -274,6 +274,7 @@ void LED_ToggleEnabled();
bool LED_IsLedDriverChipRunning();
bool LED_IsLEDRunning();
void LED_SetEnableAll(int bEnable);
void LED_SetStripStateOutputs();
int LED_GetEnableAll();
void LED_SaveStateToFlashVarsNow();
void LED_GetBaseColorString(char* s);

View File

@ -555,6 +555,8 @@ const char* htmlPinRoleNames[] = {
"Counter_f",
"Counter_r",
"IRRecv_nPup",
"StripState",
"StripState_n",
"error",
"error",
"error",

View File

@ -408,6 +408,9 @@ void PIN_SetupPins() {
#ifdef ENABLE_DRIVER_DHT
// TODO: better place to call?
DHT_OnPinsConfigChanged();
#endif
#if ENABLE_LED_BASIC
LED_SetStripStateOutputs();
#endif
addLogAdv(LOG_INFO, LOG_FEATURE_GENERAL, "PIN_SetupPins pins have been set up.\r\n");
}
@ -1141,6 +1144,20 @@ void PIN_SetPinRoleForPinIndex(int index, int role) {
}
}
break;
#if ENABLE_LED_BASIC
case IOR_StripState:
case IOR_StripState_n:
{
HAL_PIN_Setup_Output(index);
if (role == IOR_StripState) {
HAL_PIN_SetOutputValue(index, LED_GetEnableAll());
}
else {
HAL_PIN_SetOutputValue(index, !LED_GetEnableAll());
}
}
break;
#endif
case IOR_BridgeForward:
case IOR_BridgeReverse:
{

View File

@ -595,6 +595,20 @@ typedef enum ioRole_e {
//iodetail:"file":"new_pins.h",
//iodetail:"driver":""}
IOR_IRRecv_nPup,
//iodetail:{"name":"StripState",
//iodetail:"title":"TODO",
//iodetail:"descr":"This is an output pin which has current led_enableAll value",
//iodetail:"enum":"IOR_StripState",
//iodetail:"file":"new_pins.h",
//iodetail:"driver":""}
IOR_StripState,
//iodetail:{"name":"StripState_n",
//iodetail:"title":"TODO",
//iodetail:"descr":"This is an output pin which has negation of current led_enableAll value",
//iodetail:"enum":"IOR_StripState_n",
//iodetail:"file":"new_pins.h",
//iodetail:"driver":""}
IOR_StripState_n,
//iodetail:{"name":"Total_Options",
//iodetail:"title":"TODO",
//iodetail:"descr":"Current total number of available IOR roles",

View File

@ -556,6 +556,11 @@ void Test_LEDDriver_BP5758_RGBCW() {
// reset whole device
SIM_ClearOBK(0);
PIN_SetPinRoleForPinIndex(10, IOR_StripState);
PIN_SetPinRoleForPinIndex(11, IOR_StripState_n);
SELFTEST_ASSERT_PIN_BOOLEAN(10, false); // IOR_StripState is false
SELFTEST_ASSERT_PIN_BOOLEAN(11, true); // IOR_StripState_n is true
Test_FakeHTTPClientPacket_GET("index");
SELFTEST_ASSERT_PAGE_NOT_CONTAINS("index","LED RGB Color");
SELFTEST_ASSERT_HTML_REPLY_NOT_CONTAINS("LED Temperature Slider");
@ -567,22 +572,36 @@ void Test_LEDDriver_BP5758_RGBCW() {
CMD_ExecuteCommand("led_basecolor_rgb FF0000", 0);
CMD_ExecuteCommand("led_enableAll 1", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, true); // IOR_StripState is true
SELFTEST_ASSERT_PIN_BOOLEAN(11, false); // IOR_StripState_n is false
// set RED - FF0000 , remap 0 to 0 -> 1023 (10 bit resolution)
SELFTEST_ASSERT_SM_CHANNELS(1023, 0, 0, 0, 0);
CMD_ExecuteCommand("LED_Map 4 1 2 3 0", 0);
CMD_ExecuteCommand("led_enableAll 0", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, false); // IOR_StripState is false
SELFTEST_ASSERT_PIN_BOOLEAN(11, true); // IOR_StripState_n is true
CMD_ExecuteCommand("led_enableAll 1", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, true); // IOR_StripState is true
SELFTEST_ASSERT_PIN_BOOLEAN(11, false); // IOR_StripState_n is false
SELFTEST_ASSERT_SM_CHANNELS(0, 0, 0, 0, 1023);
CMD_ExecuteCommand("LED_Map 1 4 2 3 0", 0);
CMD_ExecuteCommand("led_enableAll 0", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, false); // IOR_StripState is false
SELFTEST_ASSERT_PIN_BOOLEAN(11, true); // IOR_StripState_n is true
CMD_ExecuteCommand("led_enableAll 1", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, true); // IOR_StripState is true
SELFTEST_ASSERT_PIN_BOOLEAN(11, false); // IOR_StripState_n is false
SELFTEST_ASSERT_SM_CHANNELS(0, 0, 0, 0, 1023);
CMD_ExecuteCommand("LED_Map 1 0 2 3 4", 0);
CMD_ExecuteCommand("led_enableAll 0", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, false); // IOR_StripState is false
SELFTEST_ASSERT_PIN_BOOLEAN(11, true); // IOR_StripState_n is true
CMD_ExecuteCommand("led_enableAll 1", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, true); // IOR_StripState is true
SELFTEST_ASSERT_PIN_BOOLEAN(11, false); // IOR_StripState_n is false
SELFTEST_ASSERT_SM_CHANNELS(0, 1023, 0, 0, 0);
Test_FakeHTTPClientPacket_GET("index");
@ -629,6 +648,8 @@ void Test_LEDDriver_BP5758_RGBCW() {
CMD_ExecuteCommand("led_temperature 500", 0);
CMD_ExecuteCommand("led_enableAll 1", 0);
CMD_ExecuteCommand("led_enableAll 1", 1);
SELFTEST_ASSERT_PIN_BOOLEAN(10, true); // IOR_StripState is true
SELFTEST_ASSERT_PIN_BOOLEAN(11, false); // IOR_StripState_n is false
SELFTEST_ASSERT_SM_CHANNELS(0, 0, 0, 0, 1023);
CMD_ExecuteCommand("led_temperature 154", 0);
SELFTEST_ASSERT_SM_CHANNELS(0, 0, 0, 1023, 0);
@ -670,9 +691,17 @@ void Test_LEDDriver_RGB(int firstChannel) {
PIN_SetPinRoleForPinIndex(9, IOR_PWM);
PIN_SetPinChannelForPinIndex(9, firstChannel + 2);
PIN_SetPinRoleForPinIndex(10, IOR_StripState);
PIN_SetPinRoleForPinIndex(11, IOR_StripState_n);
SELFTEST_ASSERT_PIN_BOOLEAN(10, false); // IOR_StripState is false
SELFTEST_ASSERT_PIN_BOOLEAN(11, true); // IOR_StripState_n is true
CMD_ExecuteCommand("led_enableAll 1", 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, true); // IOR_StripState is true
SELFTEST_ASSERT_PIN_BOOLEAN(11, false); // IOR_StripState_n is false
// check expressions (not really LED related but ok)
SELFTEST_ASSERT_EXPRESSION("$led_enableAll", 1.0f);
SELFTEST_ASSERT_EXPRESSION("$led_enableAll", 1.0f);
// Set red
CMD_ExecuteCommand("led_baseColor_rgb FF0000", 0);
// full brightness
@ -742,11 +771,15 @@ void Test_LEDDriver_RGB(int firstChannel) {
SELFTEST_ASSERT_CHANNEL(firstChannel, 0);
SELFTEST_ASSERT_CHANNEL(firstChannel+1, 0);
SELFTEST_ASSERT_CHANNEL(firstChannel+2, 0);
SELFTEST_ASSERT_PIN_BOOLEAN(10, false); // IOR_StripState is false
SELFTEST_ASSERT_PIN_BOOLEAN(11, true); // IOR_StripState_n is true
// Tasmota style command should enable LED
Test_FakeHTTPClientPacket_GET("cm?cmnd=POWER%201");
SELFTEST_ASSERT_CHANNEL(firstChannel, 0);
SELFTEST_ASSERT_CHANNEL(firstChannel+1, 0);
SELFTEST_ASSERT_CHANNEL(firstChannel+2, 79);
SELFTEST_ASSERT_PIN_BOOLEAN(10, true); // IOR_StripState is true
SELFTEST_ASSERT_PIN_BOOLEAN(11, false); // IOR_StripState_n is false
// set 100% brightness
CMD_ExecuteCommand("led_dimmer 100", 0);