New logging and more (#446)

- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
Ken Van Hoeylandt
2026-01-06 22:35:39 +01:00
committed by GitHub
parent 719f7bcece
commit f620255c41
188 changed files with 1973 additions and 1755 deletions
+8 -7
View File
@@ -2,32 +2,33 @@
#include <Tactility/Thread.h>
#include <Tactility/CpuAffinity.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h>
#include <Tactility/lvgl/LvglSync.h>
#include <esp_lvgl_port.h>
namespace tt::lvgl {
// LVGL
// The minimum task stack seems to be about 3500, but that crashes the wifi app in some scenarios
// At 8192, it sometimes crashes when wifi-auto enables and is busy connecting and then you open WifiManage
#define TDECK_LVGL_TASK_STACK_DEPTH 9216
auto constexpr TAG = "lvgl";
constexpr auto LVGL_TASK_STACK_DEPTH = 9216;
namespace tt::lvgl {
static const auto LOGGER = Logger("EspLvglPort");
bool initEspLvglPort() {
TT_LOG_D(TAG, "Port init");
LOGGER.debug("Init");
const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = static_cast<UBaseType_t>(Thread::Priority::Critical),
.task_stack = TDECK_LVGL_TASK_STACK_DEPTH,
.task_stack = LVGL_TASK_STACK_DEPTH,
.task_affinity = getCpuAffinityConfiguration().graphics,
.task_max_sleep_ms = 500,
.timer_period_ms = 5
};
if (lvgl_port_init(&lvgl_cfg) != ESP_OK) {
TT_LOG_E(TAG, "Port init failed");
LOGGER.error("Init failed");
return false;
}
+3 -5
View File
@@ -1,11 +1,9 @@
#include "Tactility/lvgl/LabelUtils.h"
#include "Tactility/file/File.h"
#include "Tactility/file/FileLock.h"
#include <Tactility/lvgl/LabelUtils.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
namespace tt::lvgl {
constexpr auto* TAG = "LabelUtils";
bool label_set_text_file(lv_obj_t* label, const char* filepath) {
std::unique_ptr<uint8_t[]> text;
file::getLock(filepath)->withLock([&text, filepath] {
+32 -31
View File
@@ -3,6 +3,7 @@
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/keyboard/KeyboardDevice.h>
#include <Tactility/hal/touch/TouchDevice.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Keyboard.h>
#include <Tactility/lvgl/Lvgl.h>
#include <Tactility/lvgl/LvglSync.h>
@@ -18,12 +19,12 @@
namespace tt::lvgl {
constexpr auto* TAG = "Lvgl";
static const auto LOGGER = Logger("Lvgl");
static bool started = false;
void init(const hal::Configuration& config) {
TT_LOG_I(TAG, "Init started");
LOGGER.info("Init started");
#ifdef ESP_PLATFORM
if (config.lvglInit == hal::LvglInit::Default && !initEspLvglPort()) {
@@ -33,7 +34,7 @@ void init(const hal::Configuration& config) {
start();
TT_LOG_I(TAG, "Init finished");
LOGGER.info("Init finished");
}
bool isStarted() {
@@ -41,10 +42,10 @@ bool isStarted() {
}
void start() {
TT_LOG_I(TAG, "Start LVGL");
LOGGER.info("Start LVGL");
if (started) {
TT_LOG_W(TAG, "Can't start LVGL twice");
LOGGER.warn("Can't start LVGL twice");
return;
}
@@ -53,12 +54,12 @@ void start() {
// Start displays (their related touch devices start automatically within)
TT_LOG_I(TAG, "Start displays");
LOGGER.info("Start displays");
auto displays = hal::findDevices<hal::display::DisplayDevice>(hal::Device::Type::Display);
for (auto display : displays) {
for (const auto& display : displays) {
if (display->supportsLvgl()) {
if (display->startLvgl()) {
TT_LOG_I(TAG, "Started %s", display->getName().c_str());
LOGGER.info("Started {}", display->getName());
auto lvgl_display = display->getLvglDisplay();
assert(lvgl_display != nullptr);
auto settings = settings::display::loadOrGetDefault();
@@ -67,7 +68,7 @@ void start() {
lv_display_set_rotation(lvgl_display, rotation);
}
} else {
TT_LOG_E(TAG, "Start failed for %s", display->getName().c_str());
LOGGER.error("Start failed for {}", display->getName());
}
}
}
@@ -79,42 +80,42 @@ void start() {
// Start display-related peripherals
if (primary_display != nullptr) {
TT_LOG_I(TAG, "Start touch devices");
LOGGER.info("Start touch devices");
auto touch_devices = hal::findDevices<hal::touch::TouchDevice>(hal::Device::Type::Touch);
for (auto touch_device : touch_devices) {
for (const auto& touch_device : touch_devices) {
// Start any touch devices that haven't been started yet
if (touch_device->supportsLvgl() && touch_device->getLvglIndev() == nullptr) {
if (touch_device->startLvgl(primary_display->getLvglDisplay())) {
TT_LOG_I(TAG, "Started %s", touch_device->getName().c_str());
LOGGER.info("Started {}", touch_device->getName());
} else {
TT_LOG_E(TAG, "Start failed for %s", touch_device->getName().c_str());
LOGGER.error("Start failed for {}", touch_device->getName());
}
}
}
// Start keyboards
TT_LOG_I(TAG, "Start keyboards");
LOGGER.info("Start keyboards");
auto keyboards = hal::findDevices<hal::keyboard::KeyboardDevice>(hal::Device::Type::Keyboard);
for (auto keyboard : keyboards) {
for (const auto& keyboard : keyboards) {
if (keyboard->isAttached()) {
if (keyboard->startLvgl(primary_display->getLvglDisplay())) {
lv_indev_t* keyboard_indev = keyboard->getLvglIndev();
hardware_keyboard_set_indev(keyboard_indev);
TT_LOG_I(TAG, "Started %s", keyboard->getName().c_str());
LOGGER.info("Started {}", keyboard->getName());
} else {
TT_LOG_E(TAG, "Start failed for %s", keyboard->getName().c_str());
LOGGER.error("Start failed for {}", keyboard->getName());
}
}
}
// Start encoders
TT_LOG_I(TAG, "Start encoders");
LOGGER.info("Start encoders");
auto encoders = hal::findDevices<hal::encoder::EncoderDevice>(hal::Device::Type::Encoder);
for (auto encoder : encoders) {
for (const auto& encoder : encoders) {
if (encoder->startLvgl(primary_display->getLvglDisplay())) {
TT_LOG_I(TAG, "Started %s", encoder->getName().c_str());
LOGGER.info("Started {}", encoder->getName());
} else {
TT_LOG_E(TAG, "Start failed for %s", encoder->getName().c_str());
LOGGER.error("Start failed for {}", encoder->getName());
}
}
}
@@ -127,7 +128,7 @@ void start() {
if (service::getState("Gui") == service::State::Stopped) {
service::startService("Gui");
} else {
TT_LOG_E(TAG, "Gui service is not in Stopped state");
LOGGER.error("Gui service is not in Stopped state");
}
}
@@ -137,7 +138,7 @@ void start() {
if (service::getState("Statusbar") == service::State::Stopped) {
service::startService("Statusbar");
} else {
TT_LOG_E(TAG, "Statusbar service is not in Stopped state");
LOGGER.error("Statusbar service is not in Stopped state");
}
}
@@ -149,10 +150,10 @@ void start() {
}
void stop() {
TT_LOG_I(TAG, "Stopping LVGL");
LOGGER.info("Stopping LVGL");
if (!started) {
TT_LOG_W(TAG, "Can't stop LVGL: not started");
LOGGER.warn("Can't stop LVGL: not started");
return;
}
@@ -166,7 +167,7 @@ void stop() {
// Stop keyboards
TT_LOG_I(TAG, "Stopping keyboards");
LOGGER.info("Stopping keyboards");
auto keyboards = hal::findDevices<hal::keyboard::KeyboardDevice>(hal::Device::Type::Keyboard);
for (auto keyboard : keyboards) {
if (keyboard->getLvglIndev() != nullptr) {
@@ -176,7 +177,7 @@ void stop() {
// Stop touch
TT_LOG_I(TAG, "Stopping touch");
LOGGER.info("Stopping touch");
// The display generally stops their own touch devices, but we'll clean up anything that didn't
auto touch_devices = hal::findDevices<hal::touch::TouchDevice>(hal::Device::Type::Touch);
for (auto touch_device : touch_devices) {
@@ -187,7 +188,7 @@ void stop() {
// Stop encoders
TT_LOG_I(TAG, "Stopping encoders");
LOGGER.info("Stopping encoders");
// The display generally stops their own touch devices, but we'll clean up anything that didn't
auto encoder_devices = hal::findDevices<hal::encoder::EncoderDevice>(hal::Device::Type::Encoder);
for (auto encoder_device : encoder_devices) {
@@ -197,11 +198,11 @@ void stop() {
}
// Stop displays (and their touch devices)
TT_LOG_I(TAG, "Stopping displays");
LOGGER.info("Stopping displays");
auto displays = hal::findDevices<hal::display::DisplayDevice>(hal::Device::Type::Display);
for (auto display : displays) {
if (display->supportsLvgl() && display->getLvglDisplay() != nullptr && !display->stopLvgl()) {
TT_LOG_E("HelloWorld", "Failed to detach display from LVGL");
LOGGER.error("Failed to detach display from LVGL");
}
}
@@ -209,7 +210,7 @@ void stop() {
kernel::publishSystemEvent(kernel::SystemEvent::LvglStopped);
TT_LOG_I(TAG, "Stopped LVGL");
LOGGER.info("Stopped LVGL");
}
} // namespace
-1
View File
@@ -2,7 +2,6 @@
#include <Tactility/Assets.h>
#include <Tactility/CoreDefines.h>
#include <Tactility/Log.h>
#include <lvgl.h>
+31 -15
View File
@@ -1,22 +1,23 @@
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
#include <Tactility/Tactility.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/PubSub.h>
#include <Tactility/Timer.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/PubSub.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/settings/Time.h>
#include <Tactility/Tactility.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/Timer.h>
#include <lvgl.h>
namespace tt::lvgl {
constexpr auto TAG = "statusbar";
static const auto LOGGER = Logger("statusbar");
static void onUpdateTime();
@@ -58,7 +59,9 @@ static TickType_t getNextUpdateTime() {
time_t now = ::time(nullptr);
tm* tm_struct = localtime(&now);
uint32_t seconds_to_wait = 60U - tm_struct->tm_sec;
TT_LOG_D(TAG, "Update in %lu s", seconds_to_wait);
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("Update in {} s", seconds_to_wait);
}
return pdMS_TO_TICKS(seconds_to_wait * 1000U);
}
@@ -101,13 +104,15 @@ static const lv_obj_class_t statusbar_class = {
};
static void statusbar_pubsub_event(Statusbar* statusbar) {
TT_LOG_D(TAG, "Update event");
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("Update event");
}
if (lock(defaultLockTime)) {
update_main(statusbar);
lv_obj_invalidate(&statusbar->obj);
unlock();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "Statusbar");
LOGGER.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "Statusbar");
}
}
@@ -152,7 +157,6 @@ static void update_icon(lv_obj_t* image, const StatusbarIcon* icon) {
}
lv_obj_t* statusbar_create(lv_obj_t* parent) {
LV_LOG_INFO("begin");
lv_obj_t* obj = lv_obj_class_create_obj(&statusbar_class, parent);
lv_obj_class_init_obj(obj);
@@ -235,7 +239,9 @@ int8_t statusbar_icon_add(const std::string& image, bool visible) {
statusbar_data.icons[i].visible = visible;
statusbar_data.icons[i].image = image;
result = i;
TT_LOG_D(TAG, "id %d: added", i);
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("id {}: added", i);
}
break;
}
}
@@ -249,7 +255,9 @@ int8_t statusbar_icon_add() {
}
void statusbar_icon_remove(int8_t id) {
TT_LOG_D(TAG, "id %d: remove", id);
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("id {}: remove", id);
}
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
statusbar_data.mutex.lock();
StatusbarIcon* icon = &statusbar_data.icons[id];
@@ -261,7 +269,13 @@ void statusbar_icon_remove(int8_t id) {
}
void statusbar_icon_set_image(int8_t id, const std::string& image) {
TT_LOG_D(TAG, "id %d: set image %s", id, image.empty() ? "(none)" : image.c_str());
if (LOGGER.isLoggingDebug()) {
if (image.empty()) {
LOGGER.debug("id {}: set image (none)", id);
} else {
LOGGER.debug("id {}: set image {}", id, image);
}
}
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
statusbar_data.mutex.lock();
StatusbarIcon* icon = &statusbar_data.icons[id];
@@ -272,7 +286,9 @@ void statusbar_icon_set_image(int8_t id, const std::string& image) {
}
void statusbar_icon_set_visibility(int8_t id, bool visible) {
TT_LOG_D(TAG, "id %d: set visibility %d", id, visible);
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("id {}: set visibility {}", id, visible);
}
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
statusbar_data.mutex.lock();
StatusbarIcon* icon = &statusbar_data.icons[id];
-3
View File
@@ -1,11 +1,8 @@
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
#include <Tactility/TactilityConfig.h>
#include <Tactility/lvgl/Keyboard.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Spinner.h>
namespace tt::lvgl {