Merge pull request #11334 from pcdiem/pwm1

Use SO32 for power button hold time
This commit is contained in:
Theo Arends 2021-03-14 08:30:19 +01:00 committed by GitHub
commit 9da1134dab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -755,21 +755,8 @@ bool Xdrv35(uint8_t function)
// If the button is pressed, ...
if (!XdrvMailbox.payload) {
// If the button was just pressed, flag the button as pressed, set the hold time and
// increment the buttons pressed count.
// If the button was just pressed, ...
if (!button_pressed[button_index]) {
button_pressed[button_index] = true;
uint32_t hold_delay = 250;
if (button_index == power_button_index) {
#ifdef USE_PWM_DIMMER_REMOTE
if (!(active_remote_pwm_dimmer ? active_remote_pwm_dimmer->power_on : TasmotaGlobal.power)) hold_delay = 500;
#else // USE_PWM_DIMMER_REMOTE
if (!TasmotaGlobal.power) hold_delay = 500;
#endif // USE_PWM_DIMMER_REMOTE
}
button_hold_time[button_index] = now + hold_delay;
buttons_pressed++;
if (buttons_pressed > 1) multibutton_in_progress = true;
#ifdef USE_PWM_DIMMER_REMOTE
// If there are no other buttons pressed right now and remote mode is enabled, make the
@ -785,7 +772,7 @@ bool Xdrv35(uint8_t function)
// Top 0 1 1 0
// Middle 1 2 15 0
// Bottom 15 3 15 1
if (buttons_pressed == 1 && Settings.flag4.multiple_device_groups) {
if (!buttons_pressed && Settings.flag4.multiple_device_groups) {
power_button_index = button_index;
down_button_index = (Pin(GPIO_KEY1, power_button_index) == 15 ? TasmotaGlobal.gpio_pin[1] : TasmotaGlobal.gpio_pin[15]) - 32;
active_remote_pwm_dimmer = nullptr;
@ -793,9 +780,17 @@ bool Xdrv35(uint8_t function)
active_remote_pwm_dimmer = &remote_pwm_dimmers[power_button_index];
}
#endif // USE_PWM_DIMMER_REMOTE
// Flag the button as pressed, increment the buttons pressed count and set the hold time.
button_pressed[button_index] = true;
buttons_pressed++;
if (buttons_pressed > 1) multibutton_in_progress = true;
uint32_t hold_delay = 250;
if (button_index == power_button_index) hold_delay = Settings.param[P_HOLD_TIME] * 10;
button_hold_time[button_index] = now + hold_delay;
}
// If hold time has arrived and a rule is enabled that handles the button hold, handle it.
// If hold time has arrived and no rule is enabled that handles the button hold, handle it.
else if (button_hold_time[button_index] <= now) {
#ifdef USE_RULES
sprintf(TasmotaGlobal.mqtt_data, PSTR("{\"Button%u\":{\"State\":3}}"), button_index + 1);