mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
parent
1de275c82b
commit
fe63ddbd20
@ -24,6 +24,7 @@
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define MAX_BUTTON_COMMANDS 5 // Max number of button commands supported
|
||||
|
||||
const char kCommands[] PROGMEM =
|
||||
D_CMND_WIFICONFIG " 2|" D_CMND_WIFICONFIG " 2|" D_CMND_WIFICONFIG " 2|" D_CMND_RESTART " 1|" D_CMND_UPGRADE " 1";
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define BUTTON_V2
|
||||
//#define BUTTON_V2
|
||||
#ifdef BUTTON_V2
|
||||
/*********************************************************************************************\
|
||||
* Button support
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define MAX_BUTTON_COMMANDS 3 // Max number of button commands supported
|
||||
#define MAX_BUTTON_COMMANDS_V2 3 // Max number of button commands supported
|
||||
#define MAX_RELAY_BUTTON1 4 // Max number of relay controlled by button1
|
||||
|
||||
const char kCommands[] PROGMEM =
|
||||
@ -127,6 +127,7 @@ void ButtonHandler(void)
|
||||
uint8_t button = NOT_PRESSED;
|
||||
uint8_t button_present = 0;
|
||||
|
||||
#ifdef ESP8266
|
||||
if (!button_index && ((SONOFF_DUAL == my_module_type) || (CH4 == my_module_type))) {
|
||||
button_present = 1;
|
||||
if (Button.dual_code) {
|
||||
@ -139,7 +140,9 @@ void ButtonHandler(void)
|
||||
Button.dual_code = 0;
|
||||
}
|
||||
}
|
||||
else if (pin[GPIO_KEY1 +button_index] < 99) {
|
||||
else
|
||||
#endif // ESP8266
|
||||
if (pin[GPIO_KEY1 +button_index] < 99) {
|
||||
button_present = 1;
|
||||
button = (digitalRead(pin[GPIO_KEY1 +button_index]) != bitRead(Button.inverted_mask, button_index));
|
||||
}
|
||||
@ -161,6 +164,7 @@ void ButtonHandler(void)
|
||||
if (XdrvCall(FUNC_BUTTON_PRESSED)) {
|
||||
// Serviced
|
||||
}
|
||||
#ifdef ESP8266
|
||||
else if (SONOFF_4CHPRO == my_module_type) {
|
||||
if (Button.hold_timer[button_index]) { Button.hold_timer[button_index]--; }
|
||||
|
||||
@ -180,7 +184,9 @@ void ButtonHandler(void)
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#endif // ESP8266
|
||||
else {
|
||||
|
||||
if ((PRESSED == button) && (NOT_PRESSED == Button.last_state[button_index])) {
|
||||
|
||||
@ -231,12 +237,15 @@ void ButtonHandler(void)
|
||||
if (Button.window_timer[button_index]) {
|
||||
Button.window_timer[button_index]--;
|
||||
} else {
|
||||
if (!restart_flag && !Button.hold_timer[button_index] && (Button.press_counter[button_index] > 0) && (Button.press_counter[button_index] < MAX_BUTTON_COMMANDS +6)) {
|
||||
if (!restart_flag && !Button.hold_timer[button_index] && (Button.press_counter[button_index] > 0) && (Button.press_counter[button_index] < MAX_BUTTON_COMMANDS_V2 +6)) {
|
||||
bool single_press = false;
|
||||
if (Button.press_counter[button_index] < 3) { // Single or Double press
|
||||
#ifdef ESP8266
|
||||
if ((SONOFF_DUAL_R2 == my_module_type) || (SONOFF_DUAL == my_module_type) || (CH4 == my_module_type)) {
|
||||
single_press = true;
|
||||
} else {
|
||||
} else
|
||||
#endif // ESP8266
|
||||
{
|
||||
single_press = (Settings.flag.button_swap +1 == Button.press_counter[button_index]); // SetOption11 (0)
|
||||
if ((1 == Button.present) && (2 == devices_present)) { // Single Button with two devices only
|
||||
if (Settings.flag.button_swap) { // SetOption11 (0)
|
Loading…
x
Reference in New Issue
Block a user