| 126 | } |
| 127 | |
| 128 | void ButtonControl::driverThreadMain() { |
| 129 | ButtonEvent event; |
| 130 | while (buttonQueue.get(&event, portMAX_DELAY)) { |
| 131 | if (event.pin == GPIO_NUM_NC) { |
| 132 | break; // shutdown sentinel |
| 133 | } |
| 134 | LOGGER.info("Pin {} {}", static_cast<int>(event.pin), event.pressed ? "down" : "up"); |
| 135 | if (mutex.lock(portMAX_DELAY)) { |
| 136 | // Update ALL PinConfiguration entries that share this physical pin. |
| 137 | for (size_t i = 0; i < pinConfigurations.size(); i++) { |
| 138 | if (static_cast<gpio_num_t>(pinConfigurations[i].pin) == event.pin) { |
| 139 | updatePin(pinConfigurations[i], pinStates[i], event.pressed); |
| 140 | } |
| 141 | } |
| 142 | mutex.unlock(); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | bool ButtonControl::startThread() { |
| 148 | LOGGER.info("Start"); |