mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-30 14:16:32 +00:00
Disable Button/Switch 4 seconds
Disable both Buttons and Switches 4 seconds after power on to workaround Wemos and Obi startup issues.
This commit is contained in:
parent
112e3ec457
commit
3d31dd1457
@ -1750,6 +1750,8 @@ void PerformEverySecond(void)
|
|||||||
|
|
||||||
void ButtonHandler(void)
|
void ButtonHandler(void)
|
||||||
{
|
{
|
||||||
|
if (uptime < 4) { return; } // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit
|
||||||
|
|
||||||
uint8_t button = NOT_PRESSED;
|
uint8_t button = NOT_PRESSED;
|
||||||
uint8_t button_present = 0;
|
uint8_t button_present = 0;
|
||||||
uint8_t hold_time_extent = IMMINENT_RESET_FACTOR; // Extent hold time factor in case of iminnent Reset command
|
uint8_t hold_time_extent = IMMINENT_RESET_FACTOR; // Extent hold time factor in case of iminnent Reset command
|
||||||
@ -1775,11 +1777,8 @@ void ButtonHandler(void)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pin[GPIO_KEY1 +button_index] < 99) {
|
if (pin[GPIO_KEY1 +button_index] < 99) {
|
||||||
// if (!((uptime < 4) && (0 == pin[GPIO_KEY1 +button_index]))) { // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit
|
button_present = 1;
|
||||||
if (uptime > 3) { // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit
|
button = digitalRead(pin[GPIO_KEY1 +button_index]);
|
||||||
button_present = 1;
|
|
||||||
button = digitalRead(pin[GPIO_KEY1 +button_index]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,41 +65,41 @@ uint8_t SwitchGetVirtual(uint8_t index)
|
|||||||
|
|
||||||
void SwitchProbe(void)
|
void SwitchProbe(void)
|
||||||
{
|
{
|
||||||
|
if (uptime < 4) { return; } // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit
|
||||||
|
|
||||||
uint8_t state_filter = Settings.switch_debounce / SWITCH_PROBE_INTERVAL; // 5, 10, 15
|
uint8_t state_filter = Settings.switch_debounce / SWITCH_PROBE_INTERVAL; // 5, 10, 15
|
||||||
uint8_t force_high = (Settings.switch_debounce % 50) &1; // 51, 101, 151 etc
|
uint8_t force_high = (Settings.switch_debounce % 50) &1; // 51, 101, 151 etc
|
||||||
uint8_t force_low = (Settings.switch_debounce % 50) &2; // 52, 102, 152 etc
|
uint8_t force_low = (Settings.switch_debounce % 50) &2; // 52, 102, 152 etc
|
||||||
|
|
||||||
for (byte i = 0; i < MAX_SWITCHES; i++) {
|
for (byte i = 0; i < MAX_SWITCHES; i++) {
|
||||||
if (pin[GPIO_SWT1 +i] < 99) {
|
if (pin[GPIO_SWT1 +i] < 99) {
|
||||||
if (!((uptime < 4) && (0 == pin[GPIO_SWT1 +i]))) { // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit
|
// Olimex user_switch2.c code to fix 50Hz induced pulses
|
||||||
// Olimex user_switch2.c code to fix 50Hz induced pulses
|
if (1 == digitalRead(pin[GPIO_SWT1 +i])) {
|
||||||
if (1 == digitalRead(pin[GPIO_SWT1 +i])) {
|
|
||||||
|
|
||||||
if (force_high) { // Enabled with SwitchDebounce x1
|
if (force_high) { // Enabled with SwitchDebounce x1
|
||||||
if (1 == switch_virtual[i]) {
|
if (1 == switch_virtual[i]) {
|
||||||
switch_state_buf[i] = state_filter; // With noisy input keep current state 1 unless constant 0
|
switch_state_buf[i] = state_filter; // With noisy input keep current state 1 unless constant 0
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_state_buf[i] < state_filter) {
|
if (switch_state_buf[i] < state_filter) {
|
||||||
switch_state_buf[i]++;
|
switch_state_buf[i]++;
|
||||||
if (state_filter == switch_state_buf[i]) {
|
if (state_filter == switch_state_buf[i]) {
|
||||||
switch_virtual[i] = 1;
|
switch_virtual[i] = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
if (force_low) { // Enabled with SwitchDebounce x2
|
if (force_low) { // Enabled with SwitchDebounce x2
|
||||||
if (0 == switch_virtual[i]) {
|
if (0 == switch_virtual[i]) {
|
||||||
switch_state_buf[i] = 0; // With noisy input keep current state 0 unless constant 1
|
switch_state_buf[i] = 0; // With noisy input keep current state 0 unless constant 1
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_state_buf[i] > 0) {
|
if (switch_state_buf[i] > 0) {
|
||||||
switch_state_buf[i]--;
|
switch_state_buf[i]--;
|
||||||
if (0 == switch_state_buf[i]) {
|
if (0 == switch_state_buf[i]) {
|
||||||
switch_virtual[i] = 0;
|
switch_virtual[i] = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user