| 121 | } |
| 122 | |
| 123 | void detachDevices() { |
| 124 | LOGGER.info("Removing devices"); |
| 125 | |
| 126 | auto lock = getSyncLock()->asScopedLock(); |
| 127 | lock.lock(); |
| 128 | |
| 129 | // Stop services that highly depend on LVGL |
| 130 | |
| 131 | service::stopService("Statusbar"); |
| 132 | service::stopService("Gui"); |
| 133 | |
| 134 | // Stop keyboards |
| 135 | |
| 136 | LOGGER.info("Stopping keyboards"); |
| 137 | auto keyboards = hal::findDevices<hal::keyboard::KeyboardDevice>(hal::Device::Type::Keyboard); |
| 138 | for (auto keyboard: keyboards) { |
| 139 | if (keyboard->getLvglIndev() != nullptr) { |
| 140 | keyboard->stopLvgl(); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | // Stop touch |
| 145 | |
| 146 | LOGGER.info("Stopping touch"); |
| 147 | // The display generally stops their own touch devices, but we'll clean up anything that didn't |
| 148 | auto touch_devices = hal::findDevices<hal::touch::TouchDevice>(hal::Device::Type::Touch); |
| 149 | for (auto touch_device: touch_devices) { |
| 150 | if (touch_device->getLvglIndev() != nullptr) { |
| 151 | touch_device->stopLvgl(); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // Stop encoders |
| 156 | |
| 157 | LOGGER.info("Stopping encoders"); |
| 158 | // The display generally stops their own touch devices, but we'll clean up anything that didn't |
| 159 | auto encoder_devices = hal::findDevices<hal::encoder::EncoderDevice>(hal::Device::Type::Encoder); |
| 160 | for (auto encoder_device: encoder_devices) { |
| 161 | if (encoder_device->getLvglIndev() != nullptr) { |
| 162 | encoder_device->stopLvgl(); |
| 163 | } |
| 164 | } |
| 165 | // Stop displays (and their touch devices) |
| 166 | |
| 167 | LOGGER.info("Stopping displays"); |
| 168 | auto displays = hal::findDevices<hal::display::DisplayDevice>(hal::Device::Type::Display); |
| 169 | for (auto display: displays) { |
| 170 | if (display->supportsLvgl() && display->getLvglDisplay() != nullptr && !display->stopLvgl()) { |
| 171 | LOGGER.error("Failed to detach display from LVGL"); |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | void start() { |
| 177 | check(module_start(&lvgl_module) == ERROR_NONE); |
nothing calls this directly
no test coverage detected