From f32216d17f33a5cdcff36398dbcc10a69cb9cb63 Mon Sep 17 00:00:00 2001 From: Michael Sauer Date: Sun, 13 Sep 2026 02:32:31 +0200 Subject: [PATCH] fix: SM2135EH beim Ausschalten in den Standby legen Bei allen Kanaelen auf null schrieb der Treiber nur Nullen ins Kanal-Register, liess den Chip aber aktiv - er laesst dann genug Reststrom durch, dass die Lampe schwach weiterglimmt. An einer migrierten GU10 RGB gemessen. Jetzt wird Bit 5 (Standby) gesetzt. Die alte QConnex-Firmware hatte diese Logik, aber auskommentiert (qcl_lamp.c) - das Verhalten ist von dort geerbt. Lampen an direkten PWM-Pins (G95, CW-Varianten) sind nicht betroffen. Co-Authored-By: Claude Opus 5 --- src/drivers/nl_sm2135eh.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/drivers/nl_sm2135eh.c b/src/drivers/nl_sm2135eh.c index da0f95e..6730251 100644 --- a/src/drivers/nl_sm2135eh.c +++ b/src/drivers/nl_sm2135eh.c @@ -7,6 +7,7 @@ #define SM_ADDR_CURRENT 0xC0u #define SM_ADDR_WY 0xC5u #define SM_CHANNEL_WY 0x80u /* channel select bit 7: 0 = RGB, 1 = WY */ +#define SM_CHANNEL_STBY 0x20u /* standby bit 5: powers the outputs down */ extern void delay_us(unsigned int us); /* provided by libwlan.a */ @@ -76,7 +77,15 @@ void nl_sm2135eh_set(const uint8_t ch[NL_CH_COUNT]) s_have_last = true; if (!white) { - uint8_t d[6] = {SM_ADDR_CURRENT, s_current, 0x00, ch[NL_CH_B], ch[NL_CH_G], ch[NL_CH_R]}; + /* All channels dark: put the driver into standby instead of just writing zero duty. + Without bit 5 the chip stays active and leaks enough current to keep the lamp + faintly glowing - measured on a migrated GU10 RGB, 2026-09-13. The old QConnex + firmware had this logic but left it commented out (qcl_lamp.c), which is why the + behaviour was inherited. Lamps driven straight from PWM pins (G95, the CW variants) + are unaffected. Turning back on writes 0x00 or SM_CHANNEL_WY here and clears it. */ + bool dark = !ch[NL_CH_R] && !ch[NL_CH_G] && !ch[NL_CH_B]; + uint8_t chan = dark ? SM_CHANNEL_STBY : 0x00u; + uint8_t d[6] = {SM_ADDR_CURRENT, s_current, chan, ch[NL_CH_B], ch[NL_CH_G], ch[NL_CH_R]}; sm_send(d, 6); } else { uint8_t h[3] = {SM_ADDR_CURRENT, s_current, SM_CHANNEL_WY};