50c0a14a93
- Added kernel base drivers for: display, pointer (touch, mouse, etc.), keyboard, adc, power supply and backlight - Implement new kernel driver modules: `st7789-module` and `gt911-module` - Implement ESP32 ADC "oneshot" kernel driver - Implement ESP32 backlight kernel driver with ledc API - Implemented `battery-sense` driver that allows for voltage measurement and creates a power supply child device - Updated github actions - Updated flash scripts - Fix for esp32 legacy driver conflict with ADC - Created separate `lilygo-tdeck` and `lilygo-tdeck-plus` devices - Created `lilygo-module` with LilyGO kernel drivers - Fix for intermittent errors in build related to code generation of `devicetree.c` - `lvgl-module` can now map kernel drivers onto LVGL devices - Created `KernelDisplayApp` as a mirror of `HalDisplayApp` (formerly `DisplayApp`) - Removed `struct` and `enum` prefix in a lot of kernel driver cpp source files - `lilygo-tdeck` and `lilygo-tdeck-plus` are now fully relying on kernel drivers and don't use any of the old HAL
72 lines
1.9 KiB
C
72 lines
1.9 KiB
C
// SPDX-License-Identifier: Apache-2.0
|
|
#ifdef ESP_PLATFORM
|
|
|
|
#include <esp_lvgl_port.h>
|
|
|
|
#include <tactility/time.h>
|
|
#include <tactility/error.h>
|
|
#include <tactility/lvgl_module.h>
|
|
|
|
extern struct LvglModuleConfig lvgl_module_config;
|
|
extern void lvgl_devices_attach();
|
|
extern void lvgl_devices_detach();
|
|
|
|
static bool initialized = false;
|
|
|
|
bool lvgl_lock(void) {
|
|
if (!initialized) return true; // We allow (fake) locking because it's safe to do so as LVGL is not running yet
|
|
return lvgl_port_lock(portMAX_DELAY);
|
|
}
|
|
|
|
bool lvgl_try_lock(uint32_t timeout) {
|
|
if (!initialized) return true; // We allow (fake) locking because it's safe to do so as LVGL is not running yet
|
|
return lvgl_port_lock(millis_to_ticks(timeout));
|
|
}
|
|
|
|
void lvgl_unlock(void) {
|
|
if (!initialized) return;
|
|
lvgl_port_unlock();
|
|
}
|
|
|
|
error_t lvgl_arch_start() {
|
|
const lvgl_port_cfg_t lvgl_cfg = {
|
|
.task_priority = lvgl_module_config.task_priority,
|
|
.task_stack = lvgl_module_config.task_stack_size,
|
|
.task_affinity = lvgl_module_config.task_affinity,
|
|
.task_max_sleep_ms = 500,
|
|
.timer_period_ms = 5
|
|
};
|
|
|
|
if (lvgl_port_init(&lvgl_cfg) != ESP_OK) {
|
|
return ERROR_RESOURCE;
|
|
}
|
|
|
|
// We must have the state set to "initialized" so that the lvgl lock works
|
|
// when we call listener functions. These functions could create new
|
|
// devices and services. The latter might start adding widgets immediately.
|
|
initialized = true;
|
|
|
|
lvgl_devices_attach();
|
|
|
|
if (lvgl_module_config.on_start) lvgl_module_config.on_start();
|
|
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
error_t lvgl_arch_stop() {
|
|
if (lvgl_module_config.on_stop) lvgl_module_config.on_stop();
|
|
|
|
lvgl_devices_detach();
|
|
|
|
if (lvgl_port_deinit() != ESP_OK) {
|
|
// Call on_start again to recover
|
|
if (lvgl_module_config.on_start) lvgl_module_config.on_start();
|
|
return ERROR_RESOURCE;
|
|
}
|
|
|
|
initialized = false;
|
|
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
#endif |