Small refactors

This commit is contained in:
Theo Arends 2022-08-27 12:28:34 +02:00
parent 7e34936e6b
commit e06793eb8c
3 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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