diff --git a/Devices/cyd-4848s040c/Source/devices/St7701Display.cpp b/Devices/cyd-4848s040c/Source/devices/St7701Display.cpp index 4ac8fb99..e9f14d47 100644 --- a/Devices/cyd-4848s040c/Source/devices/St7701Display.cpp +++ b/Devices/cyd-4848s040c/Source/devices/St7701Display.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -11,7 +11,7 @@ #include #include -constexpr auto TAG = "St7701Display"; +static const auto LOGGER = Logger("St7701Display"); static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = { // {cmd, { data }, data_size, delay_ms} @@ -153,28 +153,28 @@ bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc }; if (esp_lcd_new_panel_st7701(ioHandle, &panel_config, &panelHandle) != ESP_OK) { - TT_LOG_E(TAG, "Failed to create panel"); + LOGGER.error("Failed to create panel"); return false; } if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { - TT_LOG_E(TAG, "Failed to reset panel"); + LOGGER.error("Failed to reset panel"); return false; } if (esp_lcd_panel_init(panelHandle) != ESP_OK) { - TT_LOG_E(TAG, "Failed to init panel"); + LOGGER.error("Failed to init panel"); return false; } if (esp_lcd_panel_invert_color(panelHandle, false) != ESP_OK) { - TT_LOG_E(TAG, "Failed to invert color"); + LOGGER.error("Failed to invert color"); } esp_lcd_panel_set_gap(panelHandle, 0, 0); if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { - TT_LOG_E(TAG, "Failed to turn display on"); + LOGGER.error("Failed to turn display on"); } return true; diff --git a/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp b/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp index 0ae50f4c..5c3ee000 100644 --- a/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp +++ b/Devices/heltec-wifi-lora-32-v3/Source/Configuration.cpp @@ -4,11 +4,11 @@ #include #include +#include #include #include "driver/gpio.h" #include "driver/i2c.h" -#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -24,7 +24,7 @@ static void enableOledPower() { gpio_set_level(DISPLAY_PIN_POWER, 0); // Active low vTaskDelay(pdMS_TO_TICKS(500)); // Add a small delay for power to stabilize - TT_LOG_I("OLED_POWER", "OLED power enabled"); + Logger("HeltecV3").info("OLED power enabled"); } static bool initBoot() { diff --git a/Devices/lilygo-tdeck/Source/devices/TdeckKeyboard.cpp b/Devices/lilygo-tdeck/Source/devices/TdeckKeyboard.cpp index 31cf0173..5d730e0b 100644 --- a/Devices/lilygo-tdeck/Source/devices/TdeckKeyboard.cpp +++ b/Devices/lilygo-tdeck/Source/devices/TdeckKeyboard.cpp @@ -6,11 +6,13 @@ #include #include #include +#include #include using tt::hal::findFirstDevice; -constexpr auto* TAG = "TdeckKeyboard"; +static const auto LOGGER = tt::Logger("TdeckKeyboard"); + constexpr auto TDECK_KEYBOARD_I2C_BUS_HANDLE = I2C_NUM_0; constexpr auto TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55; @@ -37,11 +39,15 @@ static void keyboard_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t* if (keyboard_i2c_read(&read_buffer)) { if (read_buffer == 0 && read_buffer != last_buffer) { - TT_LOG_D(TAG, "Released %d", last_buffer); + if (LOGGER.isLoggingDebug()) { + LOGGER.debug("Released {}", last_buffer); + } data->key = last_buffer; data->state = LV_INDEV_STATE_RELEASED; } else if (read_buffer != 0) { - TT_LOG_D(TAG, "Pressed %d", read_buffer); + if (LOGGER.isLoggingDebug()) { + LOGGER.debug("Pressed {}", read_buffer); + } data->key = read_buffer; data->state = LV_INDEV_STATE_PRESSED; // TODO: Avoid performance hit by calling loadOrGetDefault() on each key press diff --git a/Devices/lilygo-tdongle-s3/Source/Init.cpp b/Devices/lilygo-tdongle-s3/Source/Init.cpp index c185e5d5..abb194ac 100644 --- a/Devices/lilygo-tdongle-s3/Source/Init.cpp +++ b/Devices/lilygo-tdongle-s3/Source/Init.cpp @@ -1,13 +1,14 @@ #include "PwmBacklight.h" -#include "Tactility/service/gps/GpsService.h" +#include +#include #include -#define TAG "T-Dongle" +static const auto LOGGER = tt::Logger("T-Dongle S3"); bool initBoot() { if (!driver::pwmbacklight::init(GPIO_NUM_38, 12000)) { - TT_LOG_E(TAG, "Backlight init failed"); + LOGGER.error("Backlight init failed"); return false; } diff --git a/Devices/lilygo-tlora-pager/Source/Init.cpp b/Devices/lilygo-tlora-pager/Source/Init.cpp index cf1c7ce7..8d2f44a6 100644 --- a/Devices/lilygo-tlora-pager/Source/Init.cpp +++ b/Devices/lilygo-tlora-pager/Source/Init.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -8,16 +9,16 @@ #include -constexpr auto* TAG = "TLoraPager"; +static const auto LOGGER = tt::Logger("T-Lora Pager"); bool tpagerInit() { - ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START); + LOGGER.info(LOG_MESSAGE_POWER_ON_START); /* 32 Khz and higher gives an issue where the screen starts dimming again above 80% brightness * when moving the brightness slider rapidly from a lower setting to 100%. * This is not a slider bug (data was debug-traced) */ if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) { - TT_LOG_E(TAG, "Backlight init failed"); + LOGGER.error("Backlight init failed"); return false; } @@ -44,9 +45,9 @@ bool tpagerInit() { .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10 })) { - TT_LOG_I(TAG, "Configured internal GPS"); + LOGGER.info("Configured internal GPS"); } else { - TT_LOG_E(TAG, "Failed to configure internal GPS"); + LOGGER.error("Failed to configure internal GPS"); } } } diff --git a/Devices/lilygo-tlora-pager/Source/devices/TpagerEncoder.cpp b/Devices/lilygo-tlora-pager/Source/devices/TpagerEncoder.cpp index f14b2f37..da2ffdbe 100644 --- a/Devices/lilygo-tlora-pager/Source/devices/TpagerEncoder.cpp +++ b/Devices/lilygo-tlora-pager/Source/devices/TpagerEncoder.cpp @@ -1,9 +1,10 @@ #include "TpagerEncoder.h" -#include +#include #include -constexpr auto* TAG = "TpagerEncoder"; +static const auto LOGGER = tt::Logger("TpagerEncoder"); + constexpr auto ENCODER_A = GPIO_NUM_40; constexpr auto ENCODER_B = GPIO_NUM_41; constexpr auto ENCODER_ENTER = GPIO_NUM_7; @@ -52,7 +53,7 @@ void TpagerEncoder::initEncoder() { }; if (pcnt_new_unit(&unit_config, &encPcntUnit) != ESP_OK) { - TT_LOG_E(TAG, "Pulsecounter intialization failed"); + LOGGER.error("Pulsecounter intialization failed"); } pcnt_glitch_filter_config_t filter_config = { @@ -60,7 +61,7 @@ void TpagerEncoder::initEncoder() { }; if (pcnt_unit_set_glitch_filter(encPcntUnit, &filter_config) != ESP_OK) { - TT_LOG_E(TAG, "Pulsecounter glitch filter config failed"); + LOGGER.error("Pulsecounter glitch filter config failed"); } pcnt_chan_config_t chan_1_config = { @@ -78,36 +79,36 @@ void TpagerEncoder::initEncoder() { if ((pcnt_new_channel(encPcntUnit, &chan_1_config, &pcnt_chan_1) != ESP_OK) || (pcnt_new_channel(encPcntUnit, &chan_2_config, &pcnt_chan_2) != ESP_OK)) { - TT_LOG_E(TAG, "Pulsecounter channel config failed"); + LOGGER.error("Pulsecounter channel config failed"); } // Second argument is rising edge, third argument is falling edge if ((pcnt_channel_set_edge_action(pcnt_chan_1, PCNT_CHANNEL_EDGE_ACTION_DECREASE, PCNT_CHANNEL_EDGE_ACTION_INCREASE) != ESP_OK) || (pcnt_channel_set_edge_action(pcnt_chan_2, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_DECREASE) != ESP_OK)) { - TT_LOG_E(TAG, "Pulsecounter edge action config failed"); + LOGGER.error("Pulsecounter edge action config failed"); } // Second argument is low level, third argument is high level if ((pcnt_channel_set_level_action(pcnt_chan_1, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK) || (pcnt_channel_set_level_action(pcnt_chan_2, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK)) { - TT_LOG_E(TAG, "Pulsecounter level action config failed"); + LOGGER.error("Pulsecounter level action config failed"); } if ((pcnt_unit_add_watch_point(encPcntUnit, LOW_LIMIT) != ESP_OK) || (pcnt_unit_add_watch_point(encPcntUnit, HIGH_LIMIT) != ESP_OK)) { - TT_LOG_E(TAG, "Pulsecounter watch point config failed"); + LOGGER.error("Pulsecounter watch point config failed"); } if (pcnt_unit_enable(encPcntUnit) != ESP_OK) { - TT_LOG_E(TAG, "Pulsecounter could not be enabled"); + LOGGER.error("Pulsecounter could not be enabled"); } if (pcnt_unit_clear_count(encPcntUnit) != ESP_OK) { - TT_LOG_E(TAG, "Pulsecounter could not be cleared"); + LOGGER.error("Pulsecounter could not be cleared"); } if (pcnt_unit_start(encPcntUnit) != ESP_OK) { - TT_LOG_E(TAG, "Pulsecounter could not be started"); + LOGGER.error("Pulsecounter could not be started"); } } diff --git a/Devices/lilygo-tlora-pager/Source/devices/TpagerKeyboard.cpp b/Devices/lilygo-tlora-pager/Source/devices/TpagerKeyboard.cpp index 366ac44f..ac51b44b 100644 --- a/Devices/lilygo-tlora-pager/Source/devices/TpagerKeyboard.cpp +++ b/Devices/lilygo-tlora-pager/Source/devices/TpagerKeyboard.cpp @@ -1,12 +1,12 @@ #include "TpagerKeyboard.h" #include -#include +#include #include #include -constexpr auto* TAG = "TpagerKeyboard"; +static const auto LOGGER = tt::Logger("TpagerKeyboard"); constexpr auto BACKLIGHT = GPIO_NUM_46; @@ -174,7 +174,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti }; if (ledc_timer_config(&ledc_timer) != ESP_OK) { - TT_LOG_E(TAG, "Backlight timer config failed"); + LOGGER.error("Backlight timer config failed"); return false; } @@ -193,7 +193,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti }; if (ledc_channel_config(&ledc_channel) != ESP_OK) { - TT_LOG_E(TAG, "Backlight channel config failed"); + LOGGER.error("Backlight channel config failed"); } return true; @@ -201,7 +201,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti bool TpagerKeyboard::setBacklightDuty(uint8_t duty) { if (!backlightOkay) { - TT_LOG_E(TAG, "Backlight not ready"); + LOGGER.error("Backlight not ready"); return false; } return (ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK) && diff --git a/Devices/lilygo-tlora-pager/Source/devices/TpagerPower.cpp b/Devices/lilygo-tlora-pager/Source/devices/TpagerPower.cpp index 98dfa04e..35d291ad 100644 --- a/Devices/lilygo-tlora-pager/Source/devices/TpagerPower.cpp +++ b/Devices/lilygo-tlora-pager/Source/devices/TpagerPower.cpp @@ -1,9 +1,9 @@ #include "TpagerPower.h" #include -#include +#include -constexpr auto* TAG = "TpagerPower"; +static const auto LOGGER = tt::Logger("TpagerPower"); constexpr auto TPAGER_GAUGE_I2C_BUS_HANDLE = I2C_NUM_0; @@ -68,7 +68,7 @@ void TpagerPower::powerOff() { }); if (device == nullptr) { - TT_LOG_E(TAG, "BQ25896 not found"); + LOGGER.error("BQ25896 not found"); return; }