Refactor SM2135 model detection

This commit is contained in:
Theo Arends 2020-12-16 14:58:30 +01:00
parent 694a675ddf
commit 2486d5730a
1 changed files with 1 additions and 10 deletions

View File

@ -182,21 +182,12 @@ void Sm2135ModuleSelected(void)
Sm2135.clk = Pin(GPIO_SM2135_CLK);
Sm2135.data = Pin(GPIO_SM2135_DAT, GPIO_ANY);
Sm2135.model = SM2135_WCGRB;
Sm2135.model = GetPin(Sm2135.data) - AGPIO(GPIO_SM2135_DAT); // 0 .. 3
if (PinUsed(GPIO_SWT1)) {
Sm2135.model = SM2135_WCBGR;
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