mirror of https://github.com/arendst/Tasmota.git
Add relay status functionality to LED2
Add relay status functionality to LED2 when configured leaving LED1 for (wifi/mqtt) status indication
This commit is contained in:
parent
55f700cd2f
commit
0195cabbd6
|
@ -1,5 +1,6 @@
|
|||
/* 6.4.1.7 20190106
|
||||
* Fix HLW8012, HJL01 and BL0937 based energy sensors low Power (below 10W) measurement regression from 6.4.1.6
|
||||
* Add relay status functionality to LED2 when configured leaving LED1 for (wifi/mqtt) status indication
|
||||
*
|
||||
* 6.4.1.6 20190105
|
||||
* Add commands PowerCal, VoltageCal and CurrentCal for HLW8012, HJL01 and BL0937 based energy sensors
|
||||
|
|
|
@ -370,6 +370,15 @@ void SetDevicePower(power_t rpower, int source)
|
|||
}
|
||||
|
||||
void SetLedPower(uint8_t state)
|
||||
{
|
||||
if (state) state = 1;
|
||||
|
||||
uint8_t led_pin = 0;
|
||||
if (pin[GPIO_LED2] < 99) { led_pin = 1; }
|
||||
digitalWrite(pin[GPIO_LED1 + led_pin], (bitRead(led_inverted, led_pin)) ? !state : state);
|
||||
}
|
||||
|
||||
void SetLedWifi(uint8_t state)
|
||||
{
|
||||
if (state) state = 1;
|
||||
digitalWrite(pin[GPIO_LED1], (bitRead(led_inverted, 0)) ? !state : state);
|
||||
|
@ -1276,7 +1285,10 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
|||
else if (CMND_LEDSTATE == command_code) {
|
||||
if ((payload >= 0) && (payload < MAX_LED_OPTION)) {
|
||||
Settings.ledstate = payload;
|
||||
if (!Settings.ledstate) SetLedPower(0);
|
||||
if (!Settings.ledstate) {
|
||||
SetLedPower(0);
|
||||
SetLedWifi(0);
|
||||
}
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.ledstate);
|
||||
}
|
||||
|
@ -1966,7 +1978,8 @@ void Every250mSeconds(void)
|
|||
}
|
||||
if ((!(Settings.ledstate &0x08)) && ((Settings.ledstate &0x06) || (blinks > 200) || (blinkstate))) {
|
||||
// if ( (!Settings.flag.global_state && global_state.data) || ((!(Settings.ledstate &0x08)) && ((Settings.ledstate &0x06) || (blinks > 200) || (blinkstate))) ) {
|
||||
SetLedPower(blinkstate); // Set led on or off
|
||||
// SetLedPower(blinkstate); // Set led on or off
|
||||
SetLedWifi(blinkstate); // Set led on or off
|
||||
}
|
||||
if (!blinkstate) {
|
||||
blinks--;
|
||||
|
@ -2501,6 +2514,7 @@ void GpioInit(void)
|
|||
}
|
||||
|
||||
SetLedPower(Settings.ledstate &8);
|
||||
SetLedWifi(Settings.ledstate &8);
|
||||
|
||||
XdrvCall(FUNC_PRE_INIT);
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
#ifdef USE_MAX31855
|
||||
GPIO_MAX31855CS, // MAX31855 Serial interface
|
||||
GPIO_MAX31855CLK, // MAX31855 Serial interface
|
||||
GPIO_MAX31855DO, // MAX31855 Serial interface
|
||||
GPIO_MAX31855DO, // MAX31855 Serial interface
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -565,7 +565,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
{ "Sonoff RF", // Sonoff RF (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
GPIO_USER, // GPIO02 Optional sensor
|
||||
GPIO_USER, // GPIO02 Optional sensor
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
|
||||
GPIO_USER, // GPIO04 Optional sensor
|
||||
0,
|
||||
|
@ -1140,7 +1140,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
GPIO_PWM3, // GPIO12 RGB LED Blue
|
||||
GPIO_USER, // GPIO13 RGBW LED White (optional - set to PWM4 for Cold White or Warm White as used on Arilux LC10)
|
||||
GPIO_PWM1, // GPIO14 RGB LED Red
|
||||
GPIO_LED2_INV, // GPIO15 RF receiver control (Arilux LC10)
|
||||
GPIO_LED4_INV, // GPIO15 RF receiver control (Arilux LC10)
|
||||
0, 0
|
||||
},
|
||||
{ "Luani HVIO", // ESP8266_HVIO
|
||||
|
@ -1186,7 +1186,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
// (PwmFrequency 1111Hz)
|
||||
GPIO_KEY1, // GPIO00 Optional Button
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
GPIO_LED2_INV, // GPIO02 RF receiver control
|
||||
GPIO_LED4_INV, // GPIO02 RF receiver control
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
|
||||
GPIO_ARIRFRCV, // GPIO04 IR or RF receiver (optional)
|
||||
GPIO_PWM1, // GPIO05 RGB LED Red
|
||||
|
@ -1206,7 +1206,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
// (PwmFrequency 540Hz)
|
||||
GPIO_KEY1, // GPIO00 Optional Button
|
||||
GPIO_USER, // GPIO01 Serial RXD and Optional sensor
|
||||
GPIO_LED2_INV, // GPIO02 RF receiver control
|
||||
GPIO_LED4_INV, // GPIO02 RF receiver control
|
||||
GPIO_USER, // GPIO03 Serial TXD and Optional sensor
|
||||
GPIO_PWM2, // GPIO04 RGB LED Green
|
||||
GPIO_PWM1, // GPIO05 RGB LED Red
|
||||
|
@ -1444,7 +1444,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285)
|
||||
0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285)
|
||||
// GPIO11 (SD_CMD Flash)
|
||||
GPIO_LED2, // GPIO12 (Relay ON, but set to LOW, so we can switch with GPIO05)
|
||||
GPIO_LED3, // GPIO12 (Relay ON, but set to LOW, so we can switch with GPIO05)
|
||||
GPIO_USER, // GPIO13
|
||||
GPIO_KEY1, // GPIO14 Button
|
||||
0,
|
||||
|
@ -1670,7 +1670,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
GPIO_PWM3, // GPIO12 RGB LED Blue
|
||||
GPIO_PWM4, // GPIO13 RGBW LED White
|
||||
GPIO_PWM1, // GPIO14 RGB LED Red
|
||||
GPIO_LED2_INV, // GPIO15 RF receiver control
|
||||
GPIO_LED4_INV, // GPIO15 RF receiver control
|
||||
0, 0
|
||||
}
|
||||
|
||||
|
|
|
@ -247,23 +247,23 @@ void AriluxRfHandler(void)
|
|||
|
||||
void AriluxRfInit(void)
|
||||
{
|
||||
if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) {
|
||||
if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED4] < 99)) {
|
||||
if (Settings.last_module != Settings.module) {
|
||||
Settings.rf_code[1][6] = 0;
|
||||
Settings.rf_code[1][7] = 0;
|
||||
Settings.last_module = Settings.module;
|
||||
}
|
||||
arilux_rf_received_value = 0;
|
||||
digitalWrite(pin[GPIO_LED2], !bitRead(led_inverted, 1)); // Turn on RF
|
||||
digitalWrite(pin[GPIO_LED4], !bitRead(led_inverted, 3)); // Turn on RF
|
||||
attachInterrupt(pin[GPIO_ARIRFRCV], AriluxRfInterrupt, CHANGE);
|
||||
}
|
||||
}
|
||||
|
||||
void AriluxRfDisable(void)
|
||||
{
|
||||
if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) {
|
||||
if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED4] < 99)) {
|
||||
detachInterrupt(pin[GPIO_ARIRFRCV]);
|
||||
digitalWrite(pin[GPIO_LED2], bitRead(led_inverted, 1)); // Turn off RF
|
||||
digitalWrite(pin[GPIO_LED4], bitRead(led_inverted, 3)); // Turn off RF
|
||||
}
|
||||
}
|
||||
#endif // USE_ARILUX_RF
|
||||
|
@ -387,8 +387,8 @@ void LightInit(void)
|
|||
}
|
||||
}
|
||||
if (pin[GPIO_ARIRFRCV] < 99) {
|
||||
if (pin[GPIO_LED2] < 99) {
|
||||
digitalWrite(pin[GPIO_LED2], bitRead(led_inverted, 1)); // Turn off RF
|
||||
if (pin[GPIO_LED4] < 99) {
|
||||
digitalWrite(pin[GPIO_LED4], bitRead(led_inverted, 3)); // Turn off RF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue