mirror of https://github.com/arendst/Tasmota.git
Add commands ``SwitchMode 17`` and ``SwitchMode 18``
Add commands ``SwitchMode 17`` PushHoldMultiDelay and ``SwitchMode 18`` PushHoldMultiDelayInverted adding delayed single press event (#12973)
This commit is contained in:
parent
d52fdd5dd2
commit
e2e90cc18a
|
@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Command ``Subscribe2 ...`` to subscribe to a MQTT topic without appended "/#" (#12858)
|
||||
- Support for Hydreon RG-15 Solid State Rain sensor (#12974)
|
||||
- Support for IKEA VINDRIKTNING particle concentration sensor (#12976)
|
||||
- Commands ``SwitchMode 17`` PushHoldMultiDelay and ``SwitchMode 18`` PushHoldMultiDelayInverted adding delayed single press event (#12973)
|
||||
|
||||
### Changed
|
||||
- Shelly EM template needs to use GPIO ADE7953_IRQ_2
|
||||
|
@ -1037,7 +1038,7 @@ All notable changes to this project will be documented in this file.
|
|||
## [8.1.0.6] - 20200205
|
||||
### Added
|
||||
- Support for sensors DS18x20 and DHT family on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
|
||||
- Commands ``SwitchMode 11`` PushHoldMulti and ``SwitchMode 12`` PushHoldInverted (#7603)
|
||||
- Commands ``SwitchMode 11`` PushHoldMulti and ``SwitchMode 12`` PushHoldMultiInverted (#7603)
|
||||
- Command ``Buzzer -1`` for infinite mode and command ``Buzzer -2`` for following led mode (#7623)
|
||||
- Support for MI-BLE sensors using HM-10 Bluetooth 4.0 module by Christian Staars (#7683)
|
||||
- BootCount Reset Time as BCResetTime to ``Status 1``
|
||||
|
|
|
@ -104,6 +104,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
|
|||
- Command ``SetOption127 1`` to force Wi-Fi in no-sleep mode even if ``Sleep 0`` is not enabled
|
||||
- Command ``SetOption128 0|1`` web referer check disabling HTTP API commands if set to 0. Default set to 1 for backward compatibility [#12828](https://github.com/arendst/Tasmota/issues/12828)
|
||||
- Command ``SetSensor1..127 0|1`` to globally disable individual sensor driver
|
||||
- Commands ``SwitchMode 17`` PushHoldMultiDelay and ``SwitchMode 18`` PushHoldMultiDelayInverted adding delayed single press event [#12973](https://github.com/arendst/Tasmota/issues/12973)
|
||||
- Neopool commands ``NPPHRes``, ``NPCLRes`` and ``NPIonRes`` [#12813](https://github.com/arendst/Tasmota/issues/12813)
|
||||
- Support for second DNS server
|
||||
- Support for (Yeelight) Mi Desk Pro using binary tasmota32solo1.bin
|
||||
|
|
|
@ -237,17 +237,32 @@ void SwitchHandler(uint32_t mode) {
|
|||
uint32_t mqtt_action = POWER_NONE;
|
||||
uint32_t switchmode = Settings->switchmode[i];
|
||||
|
||||
if (Switch.hold_timer[i] & (((switchmode == PUSHHOLDMULTI) | (switchmode == PUSHHOLDMULTI_INV)) ? SM_TIMER_MASK: SM_NO_TIMER_MASK)) {
|
||||
bool push_hold_multi_delay = ((PUSHHOLDMULTIDELAY == switchmode) || (PUSHHOLDMULTIDELAY_INV == switchmode));
|
||||
if (push_hold_multi_delay) {
|
||||
switchmode -= (PUSHHOLDMULTIDELAY - PUSHHOLDMULTI);
|
||||
}
|
||||
bool push_hold_multi = ((PUSHHOLDMULTI == switchmode) || (PUSHHOLDMULTI_INV == switchmode));
|
||||
|
||||
if (Switch.hold_timer[i] & ((push_hold_multi) ? SM_TIMER_MASK : SM_NO_TIMER_MASK)) {
|
||||
Switch.hold_timer[i]--;
|
||||
if ((Switch.hold_timer[i] & SM_TIMER_MASK) == loops_per_second * Settings->param[P_HOLD_TIME] / 25) {
|
||||
if ((switchmode == PUSHHOLDMULTI) & (NOT_PRESSED == Switch.last_state[i])) {
|
||||
SendKey(KEY_SWITCH, i +1, POWER_INCREMENT); // Execute command via MQTT
|
||||
bool do_sendkey = false;
|
||||
switch (switchmode) {
|
||||
case PUSHHOLDMULTI:
|
||||
do_sendkey = (NOT_PRESSED == Switch.last_state[i]);
|
||||
break;
|
||||
case PUSHHOLDMULTI_INV:
|
||||
do_sendkey = (PRESSED == Switch.last_state[i]);
|
||||
break;
|
||||
}
|
||||
if ((switchmode == PUSHHOLDMULTI_INV) & (PRESSED == Switch.last_state[i])) {
|
||||
if (do_sendkey) {
|
||||
SendKey(KEY_SWITCH, i +1, POWER_INCREMENT); // Execute command via MQTT
|
||||
} else if (push_hold_multi_delay && ((Switch.hold_timer[i] & ~SM_TIMER_MASK) == SM_FIRST_PRESS)) {
|
||||
switchflag = POWER_TOGGLE; // Toggle with pushbutton
|
||||
Switch.hold_timer[i] = 0;
|
||||
}
|
||||
}
|
||||
if (0 == (Switch.hold_timer[i] & (((switchmode == PUSHHOLDMULTI) | (switchmode == PUSHHOLDMULTI_INV)) ? SM_TIMER_MASK: SM_NO_TIMER_MASK))) {
|
||||
if (0 == (Switch.hold_timer[i] & ((push_hold_multi) ? SM_TIMER_MASK: SM_NO_TIMER_MASK))) {
|
||||
switch (switchmode) {
|
||||
case TOGGLEMULTI:
|
||||
switchflag = POWER_TOGGLE; // Toggle after hold
|
||||
|
@ -274,7 +289,6 @@ void SwitchHandler(uint32_t mode) {
|
|||
Switch.hold_timer[i] = loops_per_second * Settings->param[P_HOLD_TIME] / 25;
|
||||
SendKey(KEY_SWITCH, i +1, POWER_INCREMENT); // Execute command via MQTT
|
||||
mqtt_action = POWER_INCREMENT;
|
||||
|
||||
} else {
|
||||
Switch.hold_timer[i]= 0;
|
||||
SendKey(KEY_SWITCH, i +1, POWER_CLEAR); // Execute command via MQTT
|
||||
|
@ -349,9 +363,11 @@ void SwitchHandler(uint32_t mode) {
|
|||
}
|
||||
} else {
|
||||
if ((Switch.hold_timer[i] & SM_TIMER_MASK) > loops_per_second * Settings->param[P_HOLD_TIME] / 25) {
|
||||
if((Switch.hold_timer[i] & ~SM_TIMER_MASK) != SM_SECOND_PRESS) {
|
||||
if ((Switch.hold_timer[i] & ~SM_TIMER_MASK) != SM_SECOND_PRESS) {
|
||||
Switch.hold_timer[i]= SM_FIRST_PRESS;
|
||||
switchflag = POWER_TOGGLE; // Toggle with pushbutton
|
||||
if (!push_hold_multi_delay) {
|
||||
switchflag = POWER_TOGGLE; // Toggle with pushbutton
|
||||
}
|
||||
}
|
||||
else{
|
||||
SendKey(KEY_SWITCH, i +1, POWER_100); // Execute command via MQTT
|
||||
|
@ -375,9 +391,11 @@ void SwitchHandler(uint32_t mode) {
|
|||
}
|
||||
} else {
|
||||
if ((Switch.hold_timer[i] & SM_TIMER_MASK)> loops_per_second * Settings->param[P_HOLD_TIME] / 25) {
|
||||
if((Switch.hold_timer[i] & ~SM_TIMER_MASK) != SM_SECOND_PRESS) {
|
||||
if ((Switch.hold_timer[i] & ~SM_TIMER_MASK) != SM_SECOND_PRESS) {
|
||||
Switch.hold_timer[i]= SM_FIRST_PRESS;
|
||||
switchflag = POWER_TOGGLE; // Toggle with pushbutton
|
||||
if (!push_hold_multi_delay) {
|
||||
switchflag = POWER_TOGGLE; // Toggle with pushbutton
|
||||
}
|
||||
}
|
||||
else{
|
||||
SendKey(KEY_SWITCH, i +1, POWER_100); // Execute command via MQTT
|
||||
|
|
|
@ -280,7 +280,8 @@ enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_D
|
|||
enum WifiConfigOptions {WIFI_RESTART, EX_WIFI_SMARTCONFIG, WIFI_MANAGER, EX_WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL, WIFI_MANAGER_RESET_ONLY, MAX_WIFI_OPTION};
|
||||
|
||||
enum SwitchModeOptions {TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON, PUSHBUTTON_INV, PUSHBUTTONHOLD, PUSHBUTTONHOLD_INV, PUSHBUTTON_TOGGLE, TOGGLEMULTI,
|
||||
FOLLOWMULTI, FOLLOWMULTI_INV, PUSHHOLDMULTI, PUSHHOLDMULTI_INV, PUSHON, PUSHON_INV, PUSH_IGNORE, MAX_SWITCH_OPTION};
|
||||
FOLLOWMULTI, FOLLOWMULTI_INV, PUSHHOLDMULTI, PUSHHOLDMULTI_INV, PUSHON, PUSHON_INV, PUSH_IGNORE, PUSHNOTUSED, PUSHHOLDMULTIDELAY,
|
||||
PUSHHOLDMULTIDELAY_INV, MAX_SWITCH_OPTION};
|
||||
|
||||
enum LedStateOptions {LED_OFF, LED_POWER, LED_MQTTSUB, LED_POWER_MQTTSUB, LED_MQTTPUB, LED_POWER_MQTTPUB, LED_MQTT, LED_POWER_MQTT, MAX_LED_OPTION};
|
||||
|
||||
|
|
Loading…
Reference in New Issue