Refactor buttons and switches Pt.3

- Quick return from interrupts
This commit is contained in:
Theo Arends 2023-02-12 17:40:24 +01:00
parent dab80f9d29
commit b72cf69d2c
2 changed files with 12 additions and 6 deletions

View File

@ -134,6 +134,11 @@ void ButtonProbe(void) {
uint32_t not_activated;
for (uint32_t i = 0; i < MAX_KEYS_SET; i++) {
if (!bitRead(Button.used, i)) {
Button.probe_mutex = false;
return;
}
if (PinUsed(GPIO_KEY1, i)) {
#if defined(SOC_TOUCH_VERSION_1) || defined(SOC_TOUCH_VERSION_2)
if (bitRead(TouchButton.touch_mask, i)) {
@ -147,11 +152,9 @@ void ButtonProbe(void) {
} else
#endif // ESP32 SOC_TOUCH_VERSION_1 or SOC_TOUCH_VERSION_2
not_activated = (digitalRead(Pin(GPIO_KEY1, i)) != bitRead(Button.inverted_mask, i));
}
else if (bitRead(Button.used, i)) {
} else {
not_activated = (bitRead(Button.virtual_pin, i) != bitRead(Button.inverted_mask, i));
}
else { continue; }
if (not_activated) {

View File

@ -138,13 +138,16 @@ void SwitchProbe(void) {
uint32_t not_activated;
for (uint32_t i = 0; i < MAX_SWITCHES_SET; i++) {
if (!bitRead(Switch.used, i)) {
Switch.probe_mutex = false;
return;
}
if (PinUsed(GPIO_SWT1, i)) {
not_activated = digitalRead(Pin(GPIO_SWT1, i));
}
else if (bitRead(Switch.used, i)) {
} else {
not_activated = bitRead(Switch.virtual_pin, i);
}
else { continue; }
// Olimex user_switch2.c code to fix 50Hz induced pulses
if (not_activated) {