Add support for LE LampUX 907001-US

Add support for LE LampUX 907001-US (#10114)
This commit is contained in:
Theo Arends 2020-12-13 15:34:17 +01:00
parent d5ee0936c0
commit 5a57ec3dab
2 changed files with 54 additions and 22 deletions

View File

@ -247,6 +247,7 @@ const char kSensorNamesFixed[] PROGMEM =
#define MAX_A4988_MSS 3
#define MAX_WEBCAM_DATA 8
#define MAX_WEBCAM_HSD 3
#define MAX_SM2135_DAT 4
const uint16_t kGpioNiceList[] PROGMEM = {
GPIO_NONE, // Not used
@ -353,7 +354,7 @@ const uint16_t kGpioNiceList[] PROGMEM = {
#endif // USE_SM16716
#ifdef USE_SM2135
AGPIO(GPIO_SM2135_CLK), // SM2135 CLOCK
AGPIO(GPIO_SM2135_DAT), // SM2135 DATA
AGPIO(GPIO_SM2135_DAT) + MAX_SM2135_DAT, // SM2135 DATA
#endif // USE_SM2135
#ifdef USE_TUYA_MCU
AGPIO(GPIO_TUYA_TX), // Tuya Serial interface

View File

@ -24,8 +24,13 @@
*
* Action LSC SmartLed (GreenRedBlue)
* {"NAME":"LSC RGBCW LED","GPIO":[0,0,0,0,0,0,0,0,181,0,180,0,0],"FLAG":0,"BASE":18}
* {"NAME":"LSC RGBCW LED","GPIO":[0,0,0,0,0,0,0,0,4064,0,4032,0,0,0],"FLAG":0,"BASE":18}
* Polux E14 (BlueGreenRed) - Notice GPIO00 = 9 (Switch1)
* {"NAME":"Polux RGBCW E14","GPIO":[9,0,0,0,0,0,0,0,181,0,180,0,0],"FLAG":0,"BASE":18}
* Polux E14 (BlueGreenRed)
* {"NAME":"Polux RGBCW E14","GPIO":[0,0,0,0,0,0,0,0,4065,0,4032,0,0,0],"FLAG":0,"BASE":18}
* LE LampUX 907001-US
* {"NAME":"LE LampUX 907001-US","GPIO":[0,0,0,0,0,0,0,0,4066,0,4032,0,0,0],"FLAG":0,"BASE":18}
\*********************************************************************************************/
#define XLGT_04 4
@ -53,14 +58,12 @@
#define SM2135_55MA 0x09
#define SM2135_60MA 0x0A
enum Sm2135Color { SM2135_WCGRB, SM2135_WCBGR };
// RGB current CW current
const uint8_t SM2135_CURRENT = (SM2135_20MA << 4) | SM2135_15MA; // See https://github.com/arendst/Tasmota/issues/6495#issuecomment-549121683
enum Sm2135Color { SM2135_WCGRB, SM2135_WCBGR, SM2135_WCGRBHI, SM2135_WCBGRHI };
struct SM2135 {
uint8_t clk = 0;
uint8_t data = 0;
uint8_t current;
uint8_t model = SM2135_WCGRB;
} Sm2135;
@ -135,37 +138,49 @@ bool Sm2135SetChannels(void) {
uint8_t *cur_col = (uint8_t*)XdrvMailbox.data;
uint8_t data[6];
Sm2135Start(SM2135_ADDR_MC);
Sm2135Write(SM2135_CURRENT);
uint32_t light_type = 3; // RGB and CW
if (Sm2135.model < 2) {
if ((0 == cur_col[0]) && (0 == cur_col[1]) && (0 == cur_col[2])) {
light_type = 1; // CW only
} else {
light_type = 2; // RGB only
}
}
if (light_type &2) { // Set RGB
Sm2135Start(SM2135_ADDR_MC);
Sm2135Write(Sm2135.current);
Sm2135Write(SM2135_RGB);
if (Sm2135.model &1) { // SM2135_WCBGR
Sm2135Write(cur_col[2]); // Blue
Sm2135Write(cur_col[1]); // Green
Sm2135Write(cur_col[0]); // Red
} else { // SM2135_WCGRB
Sm2135Write(cur_col[1]); // Green
Sm2135Write(cur_col[0]); // Red
Sm2135Write(cur_col[2]); // Blue
}
Sm2135Stop();
}
if (light_type &1) { // Set CW
Sm2135Start(SM2135_ADDR_MC);
Sm2135Write(Sm2135.current);
Sm2135Write(SM2135_CW);
Sm2135Stop();
delay(1);
Sm2135Start(SM2135_ADDR_C);
Sm2135Write(cur_col[4]); // Warm
Sm2135Write(cur_col[3]); // Cold
} else {
Sm2135Write(SM2135_RGB);
if (SM2135_WCBGR == Sm2135.model) {
Sm2135Write(cur_col[2]); // Blue
Sm2135Write(cur_col[1]); // Green
Sm2135Write(cur_col[0]); // Red
} else {
Sm2135Write(cur_col[1]); // Green
Sm2135Write(cur_col[0]); // Red
Sm2135Write(cur_col[2]); // Blue
}
}
Sm2135Stop();
}
return true;
}
void Sm2135ModuleSelected(void)
{
if (PinUsed(GPIO_SM2135_CLK) && PinUsed(GPIO_SM2135_DAT)) {
if (PinUsed(GPIO_SM2135_CLK) && PinUsed(GPIO_SM2135_DAT, GPIO_ANY)) {
Sm2135.clk = Pin(GPIO_SM2135_CLK);
Sm2135.data = Pin(GPIO_SM2135_DAT);
Sm2135.data = Pin(GPIO_SM2135_DAT, GPIO_ANY);
Sm2135.model = SM2135_WCGRB;
if (PinUsed(GPIO_SWT1)) {
@ -173,12 +188,28 @@ void Sm2135ModuleSelected(void)
pinMode(Pin(GPIO_SWT1), INPUT); // Discard GPIO_SWT functionality
SetPin(Pin(GPIO_SWT1), AGPIO(GPIO_NONE));
}
if (PinUsed(GPIO_SM2135_DAT, 1)) {
Sm2135.model = SM2135_WCBGR;
}
if (PinUsed(GPIO_SM2135_DAT, 2)) {
Sm2135.model = SM2135_WCGRBHI;
}
if (PinUsed(GPIO_SM2135_DAT, 3)) {
Sm2135.model = SM2135_WCBGRHI;
}
// RGB current CW current
Sm2135.current = (SM2135_20MA << 4) | SM2135_15MA; // See https://github.com/arendst/Tasmota/issues/6495#issuecomment-549121683
if (Sm2135.model > SM2135_WCBGR) {
Sm2135.current = (SM2135_20MA << 4) | SM2135_30MA;
}
Sm2135Init();
TasmotaGlobal.light_type = LT_RGBWC;
TasmotaGlobal.light_driver = XLGT_04;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: SM2135 (%s) Found"), (SM2135_WCBGR == Sm2135.model) ? PSTR("BGR") : PSTR("GRB"));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: SM2135 (%s-%s current) Found"),
(SM2135_WCBGR == (Sm2135.model &1)) ? PSTR("BGR") : PSTR("GRB"), (Sm2135.model > SM2135_WCBGR) ? PSTR("High") : PSTR("Low"));
}
}