Add support for EXS Relay V5.0

Add support for EXS Relay V5.0 (#3810)
This commit is contained in:
Theo Arends 2018-09-30 16:52:25 +02:00
parent 2fd42446e9
commit 191df17b13
2 changed files with 20 additions and 16 deletions

View File

@ -1,6 +1,7 @@
/* 6.2.1.10 20180930 /* 6.2.1.10 20180930
* Add command RGBWWTable to support color calibration (#3933) * Add command RGBWWTable to support color calibration (#3933)
* Add support for Michael Haustein ESP Switch * Add support for Michael Haustein ESP Switch
* Add support for EXS Relay V5.0 (#3810)
* *
* 6.2.1.9 20180928 * 6.2.1.9 20180928
* Add Apparent Power and Reactive Power to Energy Monitoring devices (#251) * Add Apparent Power and Reactive Power to Energy Monitoring devices (#251)

View File

@ -296,20 +296,23 @@ char* GetStateText(byte state)
/********************************************************************************************/ /********************************************************************************************/
void SetLatchingRelay(power_t power, uint8_t state) void SetLatchingRelay(power_t lpower, uint8_t state)
{ {
power &= 1; // power xx00 - toggle REL1 (Off) and REL3 (Off) - device 1 Off, device 2 Off
if (2 == state) { // Reset relay // power xx01 - toggle REL2 (On) and REL3 (Off) - device 1 On, device 2 Off
state = 0; // power xx10 - toggle REL1 (Off) and REL4 (On) - device 1 Off, device 2 On
latching_power = power; // power xx11 - toggle REL2 (On) and REL4 (On) - device 1 On, device 2 On
latching_relay_pulse = 0;
if (state && !latching_relay_pulse) { // Set latching relay to power if previous pulse has finished
latching_power = lpower;
latching_relay_pulse = 2; // max 200mS (initiated by stateloop())
} }
else if (state && !latching_relay_pulse) { // Set port power to On
latching_power = power; for (byte i = 0; i < devices_present; i++) {
latching_relay_pulse = 2; // max 200mS (initiated by stateloop()) uint8_t port = (i << 1) + ((latching_power >> i) &1);
} if (pin[GPIO_REL1 +port] < 99) {
if (pin[GPIO_REL1 +latching_power] < 99) { digitalWrite(pin[GPIO_REL1 +port], bitRead(rel_inverted, port) ? !state : state);
digitalWrite(pin[GPIO_REL1 +latching_power], bitRead(rel_inverted, latching_power) ? !state : state); }
} }
} }
@ -2453,6 +2456,10 @@ void GpioInit()
if (pin[GPIO_REL1 +i] < 99) { if (pin[GPIO_REL1 +i] < 99) {
pinMode(pin[GPIO_REL1 +i], OUTPUT); pinMode(pin[GPIO_REL1 +i], OUTPUT);
devices_present++; devices_present++;
if (EXS_RELAY == Settings.module) {
digitalWrite(pin[GPIO_REL1 +i], bitRead(rel_inverted, i) ? 1 : 0);
if (i &1) { devices_present--; }
}
} }
} }
} }
@ -2493,10 +2500,6 @@ void GpioInit()
} }
} }
if (EXS_RELAY == Settings.module) {
SetLatchingRelay(0,2);
SetLatchingRelay(1,2);
}
SetLedPower(Settings.ledstate &8); SetLedPower(Settings.ledstate &8);
XdrvCall(FUNC_PRE_INIT); XdrvCall(FUNC_PRE_INIT);