Replaced Logger usage with LOG_x (#548)
This commit is contained in:
committed by
GitHub
parent
ecad2248d9
commit
9d5993930d
@@ -3,13 +3,13 @@
|
||||
#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>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
#include <Tactility/settings/DisplaySettings.h>
|
||||
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/lvgl_module.h>
|
||||
#include <tactility/module.h>
|
||||
|
||||
@@ -17,26 +17,26 @@
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
static const auto LOGGER = Logger("LVGL");
|
||||
constexpr auto* TAG = "LVGL";
|
||||
|
||||
bool isStarted() {
|
||||
return module_is_started(&lvgl_module);
|
||||
}
|
||||
|
||||
void attachDevices() {
|
||||
LOGGER.info("Adding devices");
|
||||
LOG_I(TAG, "Adding devices");
|
||||
|
||||
auto lock = getSyncLock()->asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
// Start displays (their related touch devices start automatically within)
|
||||
|
||||
LOGGER.info("Start displays");
|
||||
LOG_I(TAG, "Start displays");
|
||||
auto displays = hal::findDevices<hal::display::DisplayDevice>(hal::Device::Type::Display);
|
||||
for (const auto& display: displays) {
|
||||
if (display->supportsLvgl()) {
|
||||
if (display->startLvgl()) {
|
||||
LOGGER.info("Started {}", display->getName());
|
||||
LOG_I(TAG, "Started %s", display->getName().c_str());
|
||||
auto lvgl_display = display->getLvglDisplay();
|
||||
assert(lvgl_display != nullptr);
|
||||
auto settings = settings::display::loadOrGetDefault();
|
||||
@@ -45,7 +45,7 @@ void attachDevices() {
|
||||
lv_display_set_rotation(lvgl_display, rotation);
|
||||
}
|
||||
} else {
|
||||
LOGGER.error("Start failed for {}", display->getName());
|
||||
LOG_E(TAG, "Start failed for %s", display->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,42 +57,42 @@ void attachDevices() {
|
||||
|
||||
// Start display-related peripherals
|
||||
if (primary_display != nullptr) {
|
||||
LOGGER.info("Start touch devices");
|
||||
LOG_I(TAG, "Start touch devices");
|
||||
auto touch_devices = hal::findDevices<hal::touch::TouchDevice>(hal::Device::Type::Touch);
|
||||
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())) {
|
||||
LOGGER.info("Started {}", touch_device->getName());
|
||||
LOG_I(TAG, "Started %s", touch_device->getName().c_str());
|
||||
} else {
|
||||
LOGGER.error("Start failed for {}", touch_device->getName());
|
||||
LOG_E(TAG, "Start failed for %s", touch_device->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start keyboards
|
||||
LOGGER.info("Start keyboards");
|
||||
LOG_I(TAG, "Start keyboards");
|
||||
auto keyboards = hal::findDevices<hal::keyboard::KeyboardDevice>(hal::Device::Type::Keyboard);
|
||||
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);
|
||||
LOGGER.info("Started {}", keyboard->getName());
|
||||
LOG_I(TAG, "Started %s", keyboard->getName().c_str());
|
||||
} else {
|
||||
LOGGER.error("Start failed for {}", keyboard->getName());
|
||||
LOG_E(TAG, "Start failed for %s", keyboard->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start encoders
|
||||
LOGGER.info("Start encoders");
|
||||
LOG_I(TAG, "Start encoders");
|
||||
auto encoders = hal::findDevices<hal::encoder::EncoderDevice>(hal::Device::Type::Encoder);
|
||||
for (const auto& encoder: encoders) {
|
||||
if (encoder->startLvgl(primary_display->getLvglDisplay())) {
|
||||
LOGGER.info("Started {}", encoder->getName());
|
||||
LOG_I(TAG, "Started %s", encoder->getName().c_str());
|
||||
} else {
|
||||
LOGGER.error("Start failed for {}", encoder->getName());
|
||||
LOG_E(TAG, "Start failed for %s", encoder->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ void attachDevices() {
|
||||
if (service::getState("Gui") == service::State::Stopped) {
|
||||
service::startService("Gui");
|
||||
} else {
|
||||
LOGGER.error("Gui service is not in Stopped state");
|
||||
LOG_E(TAG, "Gui service is not in Stopped state");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,13 +115,13 @@ void attachDevices() {
|
||||
if (service::getState("Statusbar") == service::State::Stopped) {
|
||||
service::startService("Statusbar");
|
||||
} else {
|
||||
LOGGER.error("Statusbar service is not in Stopped state");
|
||||
LOG_E(TAG, "Statusbar service is not in Stopped state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detachDevices() {
|
||||
LOGGER.info("Removing devices");
|
||||
LOG_I(TAG, "Removing devices");
|
||||
|
||||
auto lock = getSyncLock()->asScopedLock();
|
||||
lock.lock();
|
||||
@@ -133,7 +133,7 @@ void detachDevices() {
|
||||
|
||||
// Stop keyboards
|
||||
|
||||
LOGGER.info("Stopping keyboards");
|
||||
LOG_I(TAG, "Stopping keyboards");
|
||||
auto keyboards = hal::findDevices<hal::keyboard::KeyboardDevice>(hal::Device::Type::Keyboard);
|
||||
for (auto keyboard: keyboards) {
|
||||
if (keyboard->getLvglIndev() != nullptr) {
|
||||
@@ -143,7 +143,7 @@ void detachDevices() {
|
||||
|
||||
// Stop touch
|
||||
|
||||
LOGGER.info("Stopping touch");
|
||||
LOG_I(TAG, "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) {
|
||||
@@ -154,7 +154,7 @@ void detachDevices() {
|
||||
|
||||
// Stop encoders
|
||||
|
||||
LOGGER.info("Stopping encoders");
|
||||
LOG_I(TAG, "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) {
|
||||
@@ -164,11 +164,11 @@ void detachDevices() {
|
||||
}
|
||||
// Stop displays (and their touch devices)
|
||||
|
||||
LOGGER.info("Stopping displays");
|
||||
LOG_I(TAG, "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()) {
|
||||
LOGGER.error("Failed to detach display from LVGL");
|
||||
LOG_E(TAG, "Failed to detach display from LVGL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
|
||||
|
||||
#include <Tactility/LogMessages.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
@@ -13,6 +12,7 @@
|
||||
#include <Tactility/settings/Time.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/log.h>
|
||||
#include <tactility/lvgl_fonts.h>
|
||||
#include <tactility/lvgl_module.h>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
static const auto LOGGER = Logger("statusbar");
|
||||
constexpr auto* TAG = "statusbar";
|
||||
|
||||
static void onUpdateTime();
|
||||
|
||||
@@ -62,9 +62,7 @@ static TickType_t getNextUpdateTime() {
|
||||
time_t now = ::time(nullptr);
|
||||
tm* tm_struct = localtime(&now);
|
||||
uint32_t seconds_to_wait = 60U - tm_struct->tm_sec;
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Update in {} s", seconds_to_wait);
|
||||
}
|
||||
LOG_D(TAG, "Update in %d s", (int)seconds_to_wait);
|
||||
return pdMS_TO_TICKS(seconds_to_wait * 1000U);
|
||||
}
|
||||
|
||||
@@ -107,15 +105,13 @@ static lv_obj_class_t statusbar_class = {
|
||||
};
|
||||
|
||||
static void statusbar_pubsub_event(Statusbar* statusbar) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Update event");
|
||||
}
|
||||
LOG_D(TAG, "Update event");
|
||||
if (lock(defaultLockTime)) {
|
||||
update_main(statusbar);
|
||||
lv_obj_invalidate(&statusbar->obj);
|
||||
unlock();
|
||||
} else {
|
||||
LOGGER.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "Statusbar");
|
||||
LOG_W(TAG, "Mutex acquisition timeout (%s)", "Statusbar");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,9 +243,7 @@ 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;
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("id {}: added", i);
|
||||
}
|
||||
LOG_D(TAG, "id %d: added", (int)i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -263,9 +257,7 @@ int8_t statusbar_icon_add() {
|
||||
}
|
||||
|
||||
void statusbar_icon_remove(int8_t id) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("id {}: remove", id);
|
||||
}
|
||||
LOG_D(TAG, "id %d: remove", (int)id);
|
||||
check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
statusbar_data.mutex.lock();
|
||||
StatusbarIcon* icon = &statusbar_data.icons[id];
|
||||
@@ -277,12 +269,10 @@ void statusbar_icon_remove(int8_t id) {
|
||||
}
|
||||
|
||||
void statusbar_icon_set_image(int8_t id, const std::string& image) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
if (image.empty()) {
|
||||
LOGGER.debug("id {}: set image (none)", id);
|
||||
} else {
|
||||
LOGGER.debug("id {}: set image {}", id, image);
|
||||
}
|
||||
if (image.empty()) {
|
||||
LOG_D(TAG, "id %d: set image (none)", (int)id);
|
||||
} else {
|
||||
LOG_D(TAG, "id %d: set image %s", (int)id, image.c_str());
|
||||
}
|
||||
check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
statusbar_data.mutex.lock();
|
||||
@@ -294,9 +284,7 @@ void statusbar_icon_set_image(int8_t id, const std::string& image) {
|
||||
}
|
||||
|
||||
void statusbar_icon_set_visibility(int8_t id, bool visible) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("id {}: set visibility {}", id, visible);
|
||||
}
|
||||
LOG_D(TAG, "id %d: set visibility %d", (int)id, (int)visible);
|
||||
check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
|
||||
statusbar_data.mutex.lock();
|
||||
StatusbarIcon* icon = &statusbar_data.icons[id];
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
#include <Tactility/lvgl/Keyboard.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/usb_host_hid.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/queue.h>
|
||||
@@ -21,7 +20,7 @@
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
static const auto LOGGER = Logger("UsbHidInput");
|
||||
constexpr auto* TAG = "UsbHidInput";
|
||||
|
||||
constexpr auto HID_EVENT_QUEUE_SIZE = 64;
|
||||
constexpr auto KEY_EVENT_QUEUE_SIZE = 64;
|
||||
@@ -147,7 +146,7 @@ static void keyboard_read_cb(lv_indev_t* indev, lv_indev_data_t* data) {
|
||||
|
||||
static void usbHidInputTask(void* arg) {
|
||||
auto* ctx = static_cast<UsbHidInputCtx*>(arg);
|
||||
LOGGER.info("started");
|
||||
LOG_I(TAG, "started");
|
||||
|
||||
while (!lv_is_initialized()) {
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
@@ -172,9 +171,9 @@ static void usbHidInputTask(void* arg) {
|
||||
lv_indev_set_group(ctx->kb_indev, lv_group_get_default());
|
||||
|
||||
unlock();
|
||||
LOGGER.info("LVGL input devices registered");
|
||||
LOG_I(TAG, "LVGL input devices registered");
|
||||
} else {
|
||||
LOGGER.warn("could not acquire LVGL lock for indev registration");
|
||||
LOG_W(TAG, "could not acquire LVGL lock for indev registration");
|
||||
}
|
||||
|
||||
// Drain the HID event queue and route events to the appropriate destinations
|
||||
@@ -270,7 +269,7 @@ static void usbHidInputTask(void* arg) {
|
||||
unlock();
|
||||
}
|
||||
|
||||
LOGGER.info("stopped");
|
||||
LOG_I(TAG, "stopped");
|
||||
xSemaphoreGive(ctx->task_done);
|
||||
vTaskDelete(nullptr);
|
||||
}
|
||||
@@ -282,14 +281,14 @@ void startUsbHidInput() {
|
||||
|
||||
ctx->hid_queue = xQueueCreate(HID_EVENT_QUEUE_SIZE, sizeof(UsbHidEvent));
|
||||
if (!ctx->hid_queue) {
|
||||
LOGGER.error("failed to create HID event queue");
|
||||
LOG_E(TAG, "failed to create HID event queue");
|
||||
delete ctx;
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->key_queue = xQueueCreate(KEY_EVENT_QUEUE_SIZE, sizeof(KeyEvent));
|
||||
if (!ctx->key_queue) {
|
||||
LOGGER.error("failed to create key event queue");
|
||||
LOG_E(TAG, "failed to create key event queue");
|
||||
vQueueDelete(ctx->hid_queue);
|
||||
delete ctx;
|
||||
return;
|
||||
@@ -297,7 +296,7 @@ void startUsbHidInput() {
|
||||
|
||||
ctx->task_done = xSemaphoreCreateBinary();
|
||||
if (!ctx->task_done) {
|
||||
LOGGER.error("failed to create task done semaphore");
|
||||
LOG_E(TAG, "failed to create task done semaphore");
|
||||
vQueueDelete(ctx->hid_queue);
|
||||
vQueueDelete(ctx->key_queue);
|
||||
delete ctx;
|
||||
@@ -309,7 +308,7 @@ void startUsbHidInput() {
|
||||
|
||||
ctx->running = true;
|
||||
if (xTaskCreate(usbHidInputTask, "usb_hid_inp", TASK_STACK, ctx, TASK_PRIORITY, &ctx->task) != pdPASS) {
|
||||
LOGGER.error("failed to create task");
|
||||
LOG_E(TAG, "failed to create task");
|
||||
ctx->running = false;
|
||||
if (hid_dev) usb_host_hid_unsubscribe(hid_dev, ctx->hid_queue);
|
||||
vQueueDelete(ctx->hid_queue);
|
||||
@@ -320,7 +319,7 @@ void startUsbHidInput() {
|
||||
}
|
||||
|
||||
s_ctx = ctx;
|
||||
LOGGER.info("started");
|
||||
LOG_I(TAG, "started");
|
||||
}
|
||||
|
||||
void stopUsbHidInput() {
|
||||
@@ -331,7 +330,7 @@ void stopUsbHidInput() {
|
||||
ctx->running = false;
|
||||
|
||||
if (xSemaphoreTake(ctx->task_done, pdMS_TO_TICKS(STOP_TIMEOUT_MS)) != pdTRUE) {
|
||||
LOGGER.warn("task stop timed out, force terminating");
|
||||
LOG_W(TAG, "task stop timed out, force terminating");
|
||||
vTaskDelete(ctx->task);
|
||||
// Task was killed before it could clean up LVGL objects; do it here to
|
||||
// prevent mouse_read_cb / keyboard_read_cb from running with a freed ctx.
|
||||
@@ -357,7 +356,7 @@ void stopUsbHidInput() {
|
||||
vSemaphoreDelete(ctx->task_done);
|
||||
delete ctx;
|
||||
|
||||
LOGGER.info("stopped");
|
||||
LOG_I(TAG, "stopped");
|
||||
}
|
||||
|
||||
} // namespace tt::lvgl
|
||||
|
||||
Reference in New Issue
Block a user