mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Small refactors
This commit is contained in:
parent
7e34936e6b
commit
e06793eb8c
@ -224,13 +224,13 @@ void ButtonInit(void) {
|
|||||||
// Button.last_state[i] = digitalRead(Pin(GPIO_KEY1, i)); // Set global now so doesn't change the saved power state on first button check
|
// Button.last_state[i] = digitalRead(Pin(GPIO_KEY1, i)); // Set global now so doesn't change the saved power state on first button check
|
||||||
Button.last_state[i] = (digitalRead(Pin(GPIO_KEY1, i)) != bitRead(Button.inverted_mask, i));
|
Button.last_state[i] = (digitalRead(Pin(GPIO_KEY1, i)) != bitRead(Button.inverted_mask, i));
|
||||||
}
|
}
|
||||||
Button.virtual_state[i] = Button.last_state[i];
|
|
||||||
}
|
}
|
||||||
#ifdef USE_ADC
|
#ifdef USE_ADC
|
||||||
else if (PinUsed(GPIO_ADC_BUTTON, i) || PinUsed(GPIO_ADC_BUTTON_INV, i)) {
|
else if (PinUsed(GPIO_ADC_BUTTON, i) || PinUsed(GPIO_ADC_BUTTON_INV, i)) {
|
||||||
Button.present++;
|
Button.present++;
|
||||||
}
|
}
|
||||||
#endif // USE_ADC
|
#endif // USE_ADC
|
||||||
|
Button.virtual_state[i] = Button.last_state[i];
|
||||||
}
|
}
|
||||||
if (Button.present) {
|
if (Button.present) {
|
||||||
Button.first_change = true;
|
Button.first_change = true;
|
||||||
|
@ -197,7 +197,7 @@ void SwitchInit(void) {
|
|||||||
|
|
||||||
Switch.present = 0;
|
Switch.present = 0;
|
||||||
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
|
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
|
||||||
Switch.last_state[i] = 1; // Init global to virtual switch state;
|
Switch.last_state[i] = NOT_PRESSED; // Init global to virtual switch state;
|
||||||
if (PinUsed(GPIO_SWT1, i)) {
|
if (PinUsed(GPIO_SWT1, i)) {
|
||||||
Switch.present++;
|
Switch.present++;
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
Loading…
x
Reference in New Issue
Block a user