Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce new api-call for dimmer-devices #4656

Merged
merged 1 commit into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sonoff/sonoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_MODULE_INIT, FUNC_PRE_INIT, FUN
FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA,
FUNC_SET_POWER, FUNC_SET_DEVICE_POWER, FUNC_SHOW_SENSOR,
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_BUTTON_PRESSED,
FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON, FUNC_WEB_ADD_HANDLER};
FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_MAIN_BUTTON, FUNC_WEB_ADD_HANDLER, FUNC_SET_CHANNELS};

enum CommandSource { SRC_IGNORE, SRC_MQTT, SRC_RESTART, SRC_BUTTON, SRC_SWITCH, SRC_BACKLOG, SRC_SERIAL, SRC_WEBGUI, SRC_WEBCOMMAND, SRC_WEBCONSOLE, SRC_PULSETIMER,
SRC_TIMER, SRC_RULE, SRC_MAXPOWER, SRC_MAXENERGY, SRC_LIGHT, SRC_KNX, SRC_DISPLAY, SRC_WEMO, SRC_HUE, SRC_RETRY, SRC_MAX };
Expand Down
26 changes: 8 additions & 18 deletions sonoff/xdrv_04_light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -828,30 +828,20 @@ void LightAnimate(void)
}
}
}
XdrvMailbox.index = light_device;
XdrvMailbox.data = (char*)cur_col;
XdrvMailbox.data_len = sizeof(cur_col);
if (XdrvCall(FUNC_SET_CHANNELS)) {
// Serviced
}
#ifdef USE_WS2812 // ************************************************************************
if (LT_WS2812 == light_type) {
else if (LT_WS2812 == light_type) {
Ws2812SetColor(0, cur_col[0], cur_col[1], cur_col[2], cur_col[3]);
}
#endif // USE_ES2812 ************************************************************************
if (light_type > LT_WS2812) {
else if (light_type > LT_WS2812) {
LightMy92x1Duty(cur_col[0], cur_col[1], cur_col[2], cur_col[3], cur_col[4]);
}
#ifdef USE_TUYA_DIMMER
if (light_type == LT_SERIAL1 && Settings.module == TUYA_DIMMER ) {
LightSerialDuty(cur_col[0]);
}
#endif // USE_TUYA_DIMMER
#ifdef USE_ARMTRONIX_DIMMERS
if (light_type == LT_SERIAL2) {
LightSerial2Duty(cur_col[0],cur_col[1]);
}
#endif // USE_ARMTRONIX_DIMMERS
#ifdef USE_PS_16_DZ
if (light_type == LT_SERIAL1 && Settings.module == PS_16_DZ) {
PS16DZSerialDuty(cur_col[0]);
}
#endif // USE_PS_16_DZ

}
}
}
Expand Down
9 changes: 9 additions & 0 deletions sonoff/xdrv_16_tuyadimmer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ boolean TuyaSetPower(void)
return status;
}

boolean TuyaSetChannels(void)
{
LightSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
return true;
}

void LightSerialDuty(uint8_t duty)
{
if (duty > 0 && !tuya_ignore_dim && TuyaSerial) {
Expand Down Expand Up @@ -416,6 +422,9 @@ boolean Xdrv16(byte function)
case FUNC_EVERY_SECOND:
if(TuyaSerial && tuya_wifi_state!=WifiState()) { TuyaSetWifiLed(); }
break;
case FUNC_SET_CHANNELS:
result = TuyaSetChannels();
break;
}
}
return result;
Expand Down
9 changes: 9 additions & 0 deletions sonoff/xdrv_18_armtronix_dimmers.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ int8_t armtronix_knobState[2]; // Dimmer state values.
* Internal Functions
\*********************************************************************************************/

boolean ArmtronixSetChannels(void)
{
LightSerial2Duty(((uint8_t*)XdrvMailbox.data)[0], ((uint8_t*)XdrvMailbox.data)[1]);
return true;
}

void LightSerial2Duty(uint8_t duty1, uint8_t duty2)
{
if (ArmtronixSerial && !armtronix_ignore_dim) {
Expand Down Expand Up @@ -186,6 +192,9 @@ boolean Xdrv18(byte function)
}
}
break;
case FUNC_SET_CHANNELS:
result = ArmtronixSetChannels();
break;
}
}
return result;
Expand Down
9 changes: 9 additions & 0 deletions sonoff/xdrv_19_ps16dz_dimmer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ boolean PS16DZSetPower(void)
return status;
}

boolean PS16DZSetChannels(void)
{
PS16DZSerialDuty(((uint8_t*)XdrvMailbox.data)[0]);
return true;
}

void PS16DZSerialDuty(uint8_t duty)
{
if (duty > 0 && !ps16dz_ignore_dim && PS16DZSerial) {
Expand Down Expand Up @@ -236,6 +242,9 @@ boolean Xdrv19(byte function)
case FUNC_SET_DEVICE_POWER:
result = PS16DZSetPower();
break;
case FUNC_SET_CHANNELS:
result = PS16DZSetChannels();
break;
}
}
return result;
Expand Down