Ken Van Hoeylandt d875ade8cb
Touch and display driver subsystems reworked (and more) (#302)
- Refactored `TouchDevice`: it can now start/stop LVGL separately, and it has an optional `TouchDriver` interface
- Refactored `DisplayDevice`: it can now start/stop LVGL separately, and it has an optional `DisplayDriver` interface
- Updated all boards and drivers for above changes
- LVGL can now be stopped and (re)started on the fly
- Fixed issues with restarting Gui and Statusbar services
- Refactored `Gui` service to be class and renamed `Gui` to `GuiService`
- Fixed `Statusbar` service: forgot to deregister one of the icons
- Updated `esp_lcd_st7701` to v1.1.3
- `lv_textarea_create()` now automatically registers the hardware keyboard hooks (by wrapping the function)
- Fixed and updated `tactility.py`
- Cleanup of a lot of code
- `BootInitLvglBegin` and `BootInitLvglEnd` are replaced by `LvglStarted` and `LvglStopped`.
- Introduced `tt::service::State` which is accessible via `tt::service::getState()` (and internally via `ServiceInstance`)
- Started replacing `#define TAG` with `constexpr auto TAG = "..";`
2025-08-16 20:22:49 +02:00

54 lines
1.8 KiB
C++

#include "Tactility/hal/Configuration.h"
#include "Tactility/hal/Device.h"
#include "Tactility/hal/gps/GpsInit.h"
#include "Tactility/hal/i2c/I2cInit.h"
#include "Tactility/hal/power/PowerDevice.h"
#include "Tactility/hal/spi/SpiInit.h"
#include "Tactility/hal/uart/UartInit.h"
#include <Tactility/kernel/SystemEvents.h>
#define TAG "hal"
#define TT_SDCARD_MOUNT_POINT "/sdcard"
namespace tt::hal {
void init(const Configuration& configuration) {
kernel::publishSystemEvent(kernel::SystemEvent::BootInitHalBegin);
kernel::publishSystemEvent(kernel::SystemEvent::BootInitI2cBegin);
tt_check(i2c::init(configuration.i2c), "I2C init failed");
kernel::publishSystemEvent(kernel::SystemEvent::BootInitI2cEnd);
kernel::publishSystemEvent(kernel::SystemEvent::BootInitSpiBegin);
tt_check(spi::init(configuration.spi), "SPI init failed");
kernel::publishSystemEvent(kernel::SystemEvent::BootInitSpiEnd);
kernel::publishSystemEvent(kernel::SystemEvent::BootInitUartBegin);
tt_check(uart::init(configuration.uart), "UART init failed");
kernel::publishSystemEvent(kernel::SystemEvent::BootInitUartEnd);
if (configuration.initBoot != nullptr) {
TT_LOG_I(TAG, "Init power");
tt_check(configuration.initBoot(), "Init power failed");
}
if (configuration.sdcard != nullptr) {
TT_LOG_I(TAG, "Mounting sdcard");
if (!configuration.sdcard->mount(TT_SDCARD_MOUNT_POINT)) {
TT_LOG_W(TAG, "SD card mount failed (init can continue)");
}
registerDevice(configuration.sdcard);
}
if (configuration.power != nullptr) {
std::shared_ptr<power::PowerDevice> power = configuration.power();
registerDevice(power);
}
kernel::publishSystemEvent(kernel::SystemEvent::BootInitHalEnd);
}
} // namespace