Replaced Logger usage with LOG_x (#548)

This commit is contained in:
Ken Van Hoeylandt
2026-07-04 23:49:19 +02:00
committed by GitHub
parent ecad2248d9
commit 9d5993930d
162 changed files with 1776 additions and 1842 deletions
@@ -2,9 +2,9 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/Logger.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/log.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <esp_err.h> #include <esp_err.h>
@@ -16,7 +16,7 @@
#include <soc/spi_periph.h> #include <soc/spi_periph.h>
#include <driver/spi_master.h> #include <driver/spi_master.h>
static const auto LOGGER = tt::Logger("St7701Display"); constexpr auto* TAG = "St7701Display";
// GPIO47/48 are physically shared between this bit-banged 3-wire command bus // GPIO47/48 are physically shared between this bit-banged 3-wire command bus
// and the SD card's real SPI2 bus (no alternate pins exist on this PCB). // and the SD card's real SPI2 bus (no alternate pins exist on this PCB).
@@ -171,29 +171,29 @@ bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
}; };
if (esp_lcd_new_panel_st7701(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_st7701(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, false) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, false) != ESP_OK) {
LOGGER.error("Failed to invert color"); LOG_E(TAG, "Failed to invert color");
return false; return false;
} }
esp_lcd_panel_set_gap(panelHandle, 0, 0); esp_lcd_panel_set_gap(panelHandle, 0, 0);
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
@@ -3,10 +3,10 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h> #include <Tactility/Mutex.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/log.h>
constexpr auto LCD_PIN_RESET = GPIO_NUM_0; // Match P4 EV board reset line constexpr auto LCD_PIN_RESET = GPIO_NUM_0; // Match P4 EV board reset line
constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_23; constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_23;
@@ -36,7 +36,7 @@ static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
// Initialize PWM backlight // Initialize PWM backlight
if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT, 20000, LEDC_TIMER_1, LEDC_CHANNEL_0)) { if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT, 20000, LEDC_TIMER_1, LEDC_CHANNEL_0)) {
tt::Logger("jc1060p470ciwy").warn("Failed to initialize backlight"); LOG_W("jc1060p470ciwy", "Failed to initialize backlight");
} }
auto touch = createTouch(); auto touch = createTouch();
@@ -1,10 +1,10 @@
#include "Jd9165Display.h" #include "Jd9165Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lcd_jd9165.h> #include <esp_lcd_jd9165.h>
static const auto LOGGER = tt::Logger("JD9165"); constexpr auto* TAG = "JD9165";
// MIPI DSI PHY power configuration // MIPI DSI PHY power configuration
#define MIPI_DSI_PHY_PWR_LDO_CHAN 3 // LDO_VO3 connects to VDD_MIPI_DPHY #define MIPI_DSI_PHY_PWR_LDO_CHAN 3 // LDO_VO3 connects to VDD_MIPI_DPHY
@@ -87,11 +87,11 @@ bool Jd9165Display::createMipiDsiBus() {
}; };
if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) { if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) {
LOGGER.error("Failed to acquire LDO channel for MIPI DSI PHY"); LOG_E(TAG, "Failed to acquire LDO channel for MIPI DSI PHY");
return false; return false;
} }
LOGGER.info("MIPI DSI PHY powered on"); LOG_I(TAG, "MIPI DSI PHY powered on");
// Create MIPI DSI bus // Create MIPI DSI bus
// TODO: use MIPI_DSI_PHY_CLK_SRC_DEFAULT() in future ESP-IDF 6.0.0 update with esp_lcd_jd9165 library version 2.x // TODO: use MIPI_DSI_PHY_CLK_SRC_DEFAULT() in future ESP-IDF 6.0.0 update with esp_lcd_jd9165 library version 2.x
@@ -103,11 +103,11 @@ bool Jd9165Display::createMipiDsiBus() {
}; };
if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) { if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) {
LOGGER.error("Failed to create MIPI DSI bus"); LOG_E(TAG, "Failed to create MIPI DSI bus");
return false; return false;
} }
LOGGER.info("MIPI DSI bus created"); LOG_I(TAG, "MIPI DSI bus created");
return true; return true;
} }
@@ -123,7 +123,7 @@ bool Jd9165Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
esp_lcd_dbi_io_config_t dbi_config = JD9165_PANEL_IO_DBI_CONFIG(); esp_lcd_dbi_io_config_t dbi_config = JD9165_PANEL_IO_DBI_CONFIG();
if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) { if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) {
LOGGER.error("Failed to create panel IO"); LOG_E(TAG, "Failed to create panel IO");
return false; return false;
} }
@@ -184,11 +184,11 @@ bool Jd9165Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, const
mutable_panel_config.vendor_config = &vendor_config; mutable_panel_config.vendor_config = &vendor_config;
if (esp_lcd_new_panel_jd9165(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_jd9165(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
LOGGER.info("JD9165 panel created successfully"); LOG_I(TAG, "JD9165 panel created successfully");
// Defer reset/init to base class applyConfiguration to avoid double initialization // Defer reset/init to base class applyConfiguration to avoid double initialization
return true; return true;
} }
@@ -1,14 +1,14 @@
#include "Power.h" #include "Power.h"
#include <Tactility/Logger.h>
#include <ChargeFromVoltage.h> #include <ChargeFromVoltage.h>
#include <tactility/log.h>
#include <esp_adc/adc_oneshot.h> #include <esp_adc/adc_oneshot.h>
#include <esp_adc/adc_cali.h> #include <esp_adc/adc_cali.h>
#include <esp_adc/adc_cali_scheme.h> #include <esp_adc/adc_cali_scheme.h>
using tt::hal::power::PowerDevice; using tt::hal::power::PowerDevice;
static const auto LOGGER = tt::Logger("JcPower"); constexpr auto* TAG = "JcPower";
namespace { namespace {
@@ -71,7 +71,7 @@ private:
.ulp_mode = ADC_ULP_MODE_DISABLE, .ulp_mode = ADC_ULP_MODE_DISABLE,
}; };
if (adc_oneshot_new_unit(&init_cfg, &adcHandle) != ESP_OK) { if (adc_oneshot_new_unit(&init_cfg, &adcHandle) != ESP_OK) {
LOGGER.error("ADC unit init failed"); LOG_E(TAG, "ADC unit init failed");
return false; return false;
} }
@@ -80,7 +80,7 @@ private:
.bitwidth = ADC_BITWIDTH_DEFAULT, .bitwidth = ADC_BITWIDTH_DEFAULT,
}; };
if (adc_oneshot_config_channel(adcHandle, ADC_CHANNEL, &chan_cfg) != ESP_OK) { if (adc_oneshot_config_channel(adcHandle, ADC_CHANNEL, &chan_cfg) != ESP_OK) {
LOGGER.error("ADC channel config failed"); LOG_E(TAG, "ADC channel config failed");
adc_oneshot_del_unit(adcHandle); adc_oneshot_del_unit(adcHandle);
adcHandle = nullptr; adcHandle = nullptr;
return false; return false;
@@ -100,7 +100,7 @@ private:
}; };
if (adc_cali_create_scheme_line_fitting(&cali_config, &caliHandle) == ESP_OK) { if (adc_cali_create_scheme_line_fitting(&cali_config, &caliHandle) == ESP_OK) {
calScheme = CaliScheme::Line; calScheme = CaliScheme::Line;
LOGGER.info("ADC calibration (line fitting) enabled"); LOG_I(TAG, "ADC calibration (line fitting) enabled");
return true; return true;
} }
#endif #endif
@@ -114,19 +114,19 @@ private:
}; };
if (adc_cali_create_scheme_curve_fitting(&curve_cfg, &caliHandle) == ESP_OK) { if (adc_cali_create_scheme_curve_fitting(&curve_cfg, &caliHandle) == ESP_OK) {
calScheme = CaliScheme::Curve; calScheme = CaliScheme::Curve;
LOGGER.info("ADC calibration (curve fitting) enabled"); LOG_I(TAG, "ADC calibration (curve fitting) enabled");
return true; return true;
} }
#endif #endif
LOGGER.warn("ADC calibration not available, using raw scaling"); LOG_W(TAG, "ADC calibration not available, using raw scaling");
return false; return false;
} }
bool readBatteryMilliVolt(uint32_t& outMv) { bool readBatteryMilliVolt(uint32_t& outMv) {
int raw = 0; int raw = 0;
if (adc_oneshot_read(adcHandle, ADC_CHANNEL, &raw) != ESP_OK) { if (adc_oneshot_read(adcHandle, ADC_CHANNEL, &raw) != ESP_OK) {
LOGGER.error("ADC read failed"); LOG_E(TAG, "ADC read failed");
return false; return false;
} }
@@ -1,6 +1,5 @@
#include "Axs15231bDisplay.h" #include "Axs15231bDisplay.h"
#include <Tactility/Logger.h>
#include <Tactility/hal/touch/TouchDevice.h> #include <Tactility/hal/touch/TouchDevice.h>
#include <Axs15231b/Axs15231bTouch.h> #include <Axs15231b/Axs15231bTouch.h>
#include <EspLcdDisplayDriver.h> #include <EspLcdDisplayDriver.h>
@@ -9,8 +8,9 @@
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <esp_lcd_panel_ops.h> #include <esp_lcd_panel_ops.h>
#include <esp_heap_caps.h> #include <esp_heap_caps.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("AXS15231B"); constexpr auto* TAG = "AXS15231B";
static const axs15231b_lcd_init_cmd_t lcd_init_cmds[] = { static const axs15231b_lcd_init_cmd_t lcd_init_cmds[] = {
{0xBB, (uint8_t[]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5}, 8, 0}, {0xBB, (uint8_t[]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5}, 8, 0},
@@ -74,7 +74,7 @@ void Axs15231bDisplay::lvgl_port_flush_callback(lv_display_t *drv, const lv_area
MALLOC_CAP_SPIRAM); MALLOC_CAP_SPIRAM);
if (self->tempBuf == nullptr) { if (self->tempBuf == nullptr) {
if (!allocationErrorLogged) { if (!allocationErrorLogged) {
LOGGER.error("Failed to allocate rotation buffer, drawing unrotated"); LOG_E(TAG, "Failed to allocate rotation buffer, drawing unrotated");
allocationErrorLogged = true; allocationErrorLogged = true;
} }
if (esp_lcd_panel_draw_bitmap(panel_handle, 0, 0, self->configuration->horizontalResolution, self->configuration->verticalResolution, draw_buf) != ESP_OK) { if (esp_lcd_panel_draw_bitmap(panel_handle, 0, 0, self->configuration->horizontalResolution, self->configuration->verticalResolution, draw_buf) != ESP_OK) {
@@ -145,7 +145,7 @@ void Axs15231bDisplay::lvgl_port_flush_callback(lv_display_t *drv, const lv_area
if (ret != ESP_OK) { if (ret != ESP_OK) {
// If SPI transfer failed, on_color_trans_done won't fire. // If SPI transfer failed, on_color_trans_done won't fire.
// Manually signal flush ready to prevent LVGL from hanging. // Manually signal flush ready to prevent LVGL from hanging.
LOGGER.error("draw_bitmap failed: {}", esp_err_to_name(ret)); LOG_E(TAG, "draw_bitmap failed: %s", esp_err_to_name(ret));
lv_display_flush_ready(drv); lv_display_flush_ready(drv);
} }
} }
@@ -169,13 +169,13 @@ void IRAM_ATTR Axs15231bDisplay::teIsrHandler(void* arg) {
bool Axs15231bDisplay::setupTeSync() { bool Axs15231bDisplay::setupTeSync() {
if (configuration->tePin == GPIO_NUM_NC) { if (configuration->tePin == GPIO_NUM_NC) {
LOGGER.info("TE pin not configured, skipping TE sync"); LOG_I(TAG, "TE pin not configured, skipping TE sync");
return true; return true;
} }
teSyncSemaphore = xSemaphoreCreateBinary(); teSyncSemaphore = xSemaphoreCreateBinary();
if (teSyncSemaphore == nullptr) { if (teSyncSemaphore == nullptr) {
LOGGER.error("Failed to create TE sync semaphore"); LOG_E(TAG, "Failed to create TE sync semaphore");
return false; return false;
} }
@@ -187,7 +187,7 @@ bool Axs15231bDisplay::setupTeSync() {
io_conf.pin_bit_mask = (1ULL << configuration->tePin); io_conf.pin_bit_mask = (1ULL << configuration->tePin);
if (gpio_config(&io_conf) != ESP_OK) { if (gpio_config(&io_conf) != ESP_OK) {
LOGGER.error("Failed to configure TE GPIO"); LOG_E(TAG, "Failed to configure TE GPIO");
vSemaphoreDelete(teSyncSemaphore); vSemaphoreDelete(teSyncSemaphore);
teSyncSemaphore = nullptr; teSyncSemaphore = nullptr;
return false; return false;
@@ -197,14 +197,14 @@ bool Axs15231bDisplay::setupTeSync() {
if (err == ESP_OK) { if (err == ESP_OK) {
isrServiceInstalledByUs = true; isrServiceInstalledByUs = true;
} else if (err != ESP_ERR_INVALID_STATE) { } else if (err != ESP_ERR_INVALID_STATE) {
LOGGER.error("Failed to install GPIO ISR service"); LOG_E(TAG, "Failed to install GPIO ISR service");
vSemaphoreDelete(teSyncSemaphore); vSemaphoreDelete(teSyncSemaphore);
teSyncSemaphore = nullptr; teSyncSemaphore = nullptr;
return false; return false;
} }
if (gpio_isr_handler_add(configuration->tePin, teIsrHandler, (void*)teSyncSemaphore) != ESP_OK) { if (gpio_isr_handler_add(configuration->tePin, teIsrHandler, (void*)teSyncSemaphore) != ESP_OK) {
LOGGER.error("Failed to add TE ISR handler"); LOG_E(TAG, "Failed to add TE ISR handler");
gpio_intr_disable(configuration->tePin); gpio_intr_disable(configuration->tePin);
if (isrServiceInstalledByUs) { if (isrServiceInstalledByUs) {
gpio_uninstall_isr_service(); gpio_uninstall_isr_service();
@@ -216,7 +216,7 @@ bool Axs15231bDisplay::setupTeSync() {
} }
teIsrInstalled = true; teIsrInstalled = true;
LOGGER.info("TE sync enabled on GPIO {}", (int)configuration->tePin); LOG_I(TAG, "TE sync enabled on GPIO %d", (int)configuration->tePin);
return true; return true;
} }
@@ -285,19 +285,19 @@ bool Axs15231bDisplay::createPanelHandle() {
}; };
if (esp_lcd_new_panel_axs15231b(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_axs15231b(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create axs15231b"); LOG_E(TAG, "Failed to create axs15231b");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
esp_lcd_panel_del(panelHandle); esp_lcd_panel_del(panelHandle);
panelHandle = nullptr; panelHandle = nullptr;
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
esp_lcd_panel_del(panelHandle); esp_lcd_panel_del(panelHandle);
panelHandle = nullptr; panelHandle = nullptr;
return false; return false;
@@ -305,28 +305,28 @@ bool Axs15231bDisplay::createPanelHandle() {
//SWAPXY Doesn't work with the JC3248W535... Left in for future compatibility. //SWAPXY Doesn't work with the JC3248W535... Left in for future compatibility.
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY"); LOG_E(TAG, "Failed to swap XY");
esp_lcd_panel_del(panelHandle); esp_lcd_panel_del(panelHandle);
panelHandle = nullptr; panelHandle = nullptr;
return false; return false;
} }
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to mirror panel"); LOG_E(TAG, "Failed to mirror panel");
esp_lcd_panel_del(panelHandle); esp_lcd_panel_del(panelHandle);
panelHandle = nullptr; panelHandle = nullptr;
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to invert color"); LOG_E(TAG, "Failed to invert color");
esp_lcd_panel_del(panelHandle); esp_lcd_panel_del(panelHandle);
panelHandle = nullptr; panelHandle = nullptr;
return false; return false;
} }
if (esp_lcd_panel_disp_on_off(panelHandle, false) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, false) != ESP_OK) {
LOGGER.error("Failed to turn off panel"); LOG_E(TAG, "Failed to turn off panel");
esp_lcd_panel_del(panelHandle); esp_lcd_panel_del(panelHandle);
panelHandle = nullptr; panelHandle = nullptr;
return false; return false;
@@ -343,19 +343,19 @@ Axs15231bDisplay::Axs15231bDisplay(std::unique_ptr<Configuration> inConfiguratio
bool Axs15231bDisplay::start() { bool Axs15231bDisplay::start() {
if (!createIoHandle()) { if (!createIoHandle()) {
LOGGER.error("Failed to create IO handle"); LOG_E(TAG, "Failed to create IO handle");
return false; return false;
} }
if (!createPanelHandle()) { if (!createPanelHandle()) {
LOGGER.error("Failed to create panel handle"); LOG_E(TAG, "Failed to create panel handle");
esp_lcd_panel_io_del(ioHandle); esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr; ioHandle = nullptr;
return false; return false;
} }
if (!setupTeSync()) { if (!setupTeSync()) {
LOGGER.warn("TE sync setup failed, continuing without TE synchronization"); LOG_W(TAG, "TE sync setup failed, continuing without TE synchronization");
} }
return true; return true;
@@ -372,12 +372,12 @@ bool Axs15231bDisplay::stop() {
displayDriver.reset(); displayDriver.reset();
if (panelHandle != nullptr && esp_lcd_panel_del(panelHandle) != ESP_OK) { if (panelHandle != nullptr && esp_lcd_panel_del(panelHandle) != ESP_OK) {
LOGGER.error("Failed to delete panel"); LOG_E(TAG, "Failed to delete panel");
} }
panelHandle = nullptr; panelHandle = nullptr;
if (ioHandle != nullptr && esp_lcd_panel_io_del(ioHandle) != ESP_OK) { if (ioHandle != nullptr && esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
LOGGER.error("Failed to delete IO"); LOG_E(TAG, "Failed to delete IO");
} }
ioHandle = nullptr; ioHandle = nullptr;
@@ -386,7 +386,7 @@ bool Axs15231bDisplay::stop() {
bool Axs15231bDisplay::startLvgl() { bool Axs15231bDisplay::startLvgl() {
if (lvglDisplay != nullptr) { if (lvglDisplay != nullptr) {
LOGGER.error("LVGL already started"); LOG_E(TAG, "LVGL already started");
return false; return false;
} }
@@ -399,7 +399,7 @@ bool Axs15231bDisplay::startLvgl() {
buffer1 = (uint16_t*)heap_caps_malloc(bufferSize, MALLOC_CAP_SPIRAM); buffer1 = (uint16_t*)heap_caps_malloc(bufferSize, MALLOC_CAP_SPIRAM);
buffer2 = (uint16_t*)heap_caps_malloc(bufferSize, MALLOC_CAP_SPIRAM); buffer2 = (uint16_t*)heap_caps_malloc(bufferSize, MALLOC_CAP_SPIRAM);
if (buffer1 == nullptr || buffer2 == nullptr) { if (buffer1 == nullptr || buffer2 == nullptr) {
LOGGER.error("Failed to allocate buffers"); LOG_E(TAG, "Failed to allocate buffers");
heap_caps_free(buffer1); heap_caps_free(buffer1);
heap_caps_free(buffer2); heap_caps_free(buffer2);
buffer1 = nullptr; buffer1 = nullptr;
@@ -419,7 +419,7 @@ bool Axs15231bDisplay::startLvgl() {
.on_color_trans_done = onColorTransDone, .on_color_trans_done = onColorTransDone,
}; };
if (esp_lcd_panel_io_register_event_callbacks(ioHandle, &cbs, lvglDisplay) != ESP_OK) { if (esp_lcd_panel_io_register_event_callbacks(ioHandle, &cbs, lvglDisplay) != ESP_OK) {
LOGGER.error("Failed to register panel IO callbacks"); LOG_E(TAG, "Failed to register panel IO callbacks");
heap_caps_free(buffer1); heap_caps_free(buffer1);
heap_caps_free(buffer2); heap_caps_free(buffer2);
buffer1 = nullptr; buffer1 = nullptr;
@@ -474,11 +474,11 @@ bool Axs15231bDisplay::stopLvgl() {
std::shared_ptr<tt::hal::display::DisplayDriver> Axs15231bDisplay::getDisplayDriver() { std::shared_ptr<tt::hal::display::DisplayDriver> Axs15231bDisplay::getDisplayDriver() {
if (lvglDisplay != nullptr) { if (lvglDisplay != nullptr) {
LOGGER.error("Cannot get DisplayDriver while LVGL is active - call stopLvgl() first"); LOG_E(TAG, "Cannot get DisplayDriver while LVGL is active - call stopLvgl() first");
return nullptr; return nullptr;
} }
if (panelHandle == nullptr) { if (panelHandle == nullptr) {
LOGGER.error("Cannot get DisplayDriver - display is not started"); LOG_E(TAG, "Cannot get DisplayDriver - display is not started");
return nullptr; return nullptr;
} }
if (displayDriver == nullptr) { if (displayDriver == nullptr) {
+13 -13
View File
@@ -5,11 +5,11 @@
#include <Tactility/hal/gps/GpsConfiguration.h> #include <Tactility/hal/gps/GpsConfiguration.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <Tactility/kernel/SystemEvents.h> #include <Tactility/kernel/SystemEvents.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/service/gps/GpsService.h> #include <Tactility/service/gps/GpsService.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("T-Deck"); constexpr auto* TAG = "T-Deck";
constexpr auto TDECK_POWERON_GPIO = GPIO_NUM_10; constexpr auto TDECK_POWERON_GPIO = GPIO_NUM_10;
@@ -37,9 +37,9 @@ static bool powerOn() {
} }
bool initBoot() { bool initBoot() {
LOGGER.info(LOG_MESSAGE_POWER_ON_START); LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
if (!powerOn()) { if (!powerOn()) {
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED); LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
return false; return false;
} }
@@ -47,7 +47,7 @@ bool initBoot() {
* when moving the brightness slider rapidly from a lower setting to 100%. * when moving the brightness slider rapidly from a lower setting to 100%.
* This is not a slider bug (data was debug-traced) */ * This is not a slider bug (data was debug-traced) */
if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) { if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) {
LOGGER.error("Backlight init failed"); LOG_E(TAG, "Backlight init failed");
return false; return false;
} }
@@ -58,9 +58,9 @@ bool initBoot() {
gps_service->getGpsConfigurations(gps_configurations); gps_service->getGpsConfigurations(gps_configurations);
if (gps_configurations.empty()) { if (gps_configurations.empty()) {
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "uart0", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) { if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "uart0", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) {
LOGGER.info("Configured internal GPS"); LOG_I(TAG, "Configured internal GPS");
} else { } else {
LOGGER.error("Failed to configure internal GPS"); LOG_E(TAG, "Failed to configure internal GPS");
} }
} }
} }
@@ -69,23 +69,23 @@ bool initBoot() {
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) { tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) {
auto kbBacklight = tt::hal::findDevice("Keyboard Backlight"); auto kbBacklight = tt::hal::findDevice("Keyboard Backlight");
if (kbBacklight != nullptr) { if (kbBacklight != nullptr) {
LOGGER.info("{} starting", kbBacklight->getName()); LOG_I(TAG, "%s starting", kbBacklight->getName().c_str());
auto kbDevice = std::static_pointer_cast<KeyboardBacklightDevice>(kbBacklight); auto kbDevice = std::static_pointer_cast<KeyboardBacklightDevice>(kbBacklight);
if (kbDevice->start()) { if (kbDevice->start()) {
LOGGER.info("{} started", kbBacklight->getName()); LOG_I(TAG, "%s started", kbBacklight->getName().c_str());
} else { } else {
LOGGER.error("{} start failed", kbBacklight->getName()); LOG_E(TAG, "%s start failed", kbBacklight->getName().c_str());
} }
} }
auto trackball = tt::hal::findDevice("Trackball"); auto trackball = tt::hal::findDevice("Trackball");
if (trackball != nullptr) { if (trackball != nullptr) {
LOGGER.info("{} starting", trackball->getName()); LOG_I(TAG, "%s starting", trackball->getName().c_str());
auto tbDevice = std::static_pointer_cast<TrackballDevice>(trackball); auto tbDevice = std::static_pointer_cast<TrackballDevice>(trackball);
if (tbDevice->start()) { if (tbDevice->start()) {
LOGGER.info("{} started", trackball->getName()); LOG_I(TAG, "%s started", trackball->getName().c_str());
} else { } else {
LOGGER.error("{} start failed", trackball->getName()); LOG_E(TAG, "%s start failed", trackball->getName().c_str());
} }
} }
}); });
@@ -1,11 +1,10 @@
#include "KeyboardBacklight.h" #include "KeyboardBacklight.h"
#include <Tactility/Logger.h>
#include <cstring> #include <cstring>
#include <esp_log.h> #include <esp_log.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("KeyboardBacklight"); constexpr auto* TAG = "KeyboardBacklight";
namespace keyboardbacklight { namespace keyboardbacklight {
@@ -21,16 +20,16 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
g_i2cPort = i2cPort; g_i2cPort = i2cPort;
g_slaveAddress = slaveAddress; g_slaveAddress = slaveAddress;
LOGGER.info("Initialized on I2C port {}, address 0x{:02X}", static_cast<int>(g_i2cPort), g_slaveAddress); LOG_I(TAG, "Initialized on I2C port %d, address 0x%02X", static_cast<int>(g_i2cPort), (unsigned)g_slaveAddress);
// Set a reasonable default brightness // Set a reasonable default brightness
if (!setDefaultBrightness(127)) { if (!setDefaultBrightness(127)) {
LOGGER.error("Failed to set default brightness"); LOG_E(TAG, "Failed to set default brightness");
return false; return false;
} }
if (!setBrightness(127)) { if (!setBrightness(127)) {
LOGGER.error("Failed to set brightness"); LOG_E(TAG, "Failed to set brightness");
return false; return false;
} }
@@ -39,7 +38,7 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
bool setBrightness(uint8_t brightness) { bool setBrightness(uint8_t brightness) {
if (g_i2cPort >= I2C_NUM_MAX) { if (g_i2cPort >= I2C_NUM_MAX) {
LOGGER.error("Not initialized"); LOG_E(TAG, "Not initialized");
return false; return false;
} }
@@ -48,7 +47,7 @@ bool setBrightness(uint8_t brightness) {
return true; return true;
} }
LOGGER.info("Setting brightness to {} on I2C port {}, address 0x{:02X}", brightness, static_cast<int>(g_i2cPort), g_slaveAddress); LOG_I(TAG, "Setting brightness to %d on I2C port %d, address 0x%02X", brightness, static_cast<int>(g_i2cPort), (unsigned)g_slaveAddress);
i2c_cmd_handle_t cmd = i2c_cmd_link_create(); i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd); i2c_master_start(cmd);
@@ -62,17 +61,17 @@ bool setBrightness(uint8_t brightness) {
if (ret == ESP_OK) { if (ret == ESP_OK) {
g_currentBrightness = brightness; g_currentBrightness = brightness;
LOGGER.info("Successfully set brightness to {}", brightness); LOG_I(TAG, "Successfully set brightness to %d", brightness);
return true; return true;
} else { } else {
LOGGER.error("Failed to set brightness: {} (0x{:02X})", esp_err_to_name(ret), ret); LOG_E(TAG, "Failed to set brightness: %s (0x%02X)", esp_err_to_name(ret), (unsigned)ret);
return false; return false;
} }
} }
bool setDefaultBrightness(uint8_t brightness) { bool setDefaultBrightness(uint8_t brightness) {
if (g_i2cPort >= I2C_NUM_MAX) { if (g_i2cPort >= I2C_NUM_MAX) {
LOGGER.error("Not initialized"); LOG_E(TAG, "Not initialized");
return false; return false;
} }
@@ -92,17 +91,17 @@ bool setDefaultBrightness(uint8_t brightness) {
i2c_cmd_link_delete(cmd); i2c_cmd_link_delete(cmd);
if (ret == ESP_OK) { if (ret == ESP_OK) {
LOGGER.debug("Set default brightness to {}", brightness); LOG_D(TAG, "Set default brightness to %d", brightness);
return true; return true;
} else { } else {
LOGGER.error("Failed to set default brightness: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to set default brightness: %s", esp_err_to_name(ret));
return false; return false;
} }
} }
uint8_t getBrightness() { uint8_t getBrightness() {
if (g_i2cPort >= I2C_NUM_MAX) { if (g_i2cPort >= I2C_NUM_MAX) {
LOGGER.error("Not initialized"); LOG_E(TAG, "Not initialized");
return 0; return 0;
} }
@@ -1,10 +1,10 @@
#include "Trackball.h" #include "Trackball.h"
#include <Tactility/Assets.h> #include <Tactility/Assets.h>
#include <Tactility/Logger.h>
#include <atomic> #include <atomic>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("Trackball"); constexpr auto* TAG = "Trackball";
namespace trackball { namespace trackball {
@@ -133,7 +133,7 @@ static void read_cb(lv_indev_t* indev, lv_indev_data_t* data) {
lv_indev_t* init(const TrackballConfig& config) { lv_indev_t* init(const TrackballConfig& config) {
if (g_initialized.load(std::memory_order_relaxed)) { if (g_initialized.load(std::memory_order_relaxed)) {
LOGGER.warn("Already initialized"); LOG_W(TAG, "Already initialized");
return g_indev; return g_indev;
} }
@@ -177,7 +177,7 @@ lv_indev_t* init(const TrackballConfig& config) {
// ESP_ERR_INVALID_STATE means already installed, which is fine // ESP_ERR_INVALID_STATE means already installed, which is fine
isr_service_installed = true; isr_service_installed = true;
} else { } else {
LOGGER.error("Failed to install GPIO ISR service: {}", esp_err_to_name(err)); LOG_E(TAG, "Failed to install GPIO ISR service: %s", esp_err_to_name(err));
return nullptr; return nullptr;
} }
} }
@@ -190,7 +190,7 @@ lv_indev_t* init(const TrackballConfig& config) {
io_conf.pin_bit_mask = (1ULL << dirPins[i]); io_conf.pin_bit_mask = (1ULL << dirPins[i]);
esp_err_t err = gpio_config(&io_conf); esp_err_t err = gpio_config(&io_conf);
if (err != ESP_OK) { if (err != ESP_OK) {
LOGGER.error("Failed to configure GPIO {}: {}", static_cast<int>(dirPins[i]), esp_err_to_name(err)); LOG_E(TAG, "Failed to configure GPIO %d: %s", static_cast<int>(dirPins[i]), esp_err_to_name(err));
// Cleanup previously added handlers // Cleanup previously added handlers
for (int j = 0; j < handlersAdded; j++) { for (int j = 0; j < handlersAdded; j++) {
gpio_isr_handler_remove(dirPins[j]); gpio_isr_handler_remove(dirPins[j]);
@@ -200,7 +200,7 @@ lv_indev_t* init(const TrackballConfig& config) {
err = gpio_isr_handler_add(dirPins[i], trackball_isr_handler, reinterpret_cast<void*>(static_cast<intptr_t>(dirPins[i]))); err = gpio_isr_handler_add(dirPins[i], trackball_isr_handler, reinterpret_cast<void*>(static_cast<intptr_t>(dirPins[i])));
if (err != ESP_OK) { if (err != ESP_OK) {
LOGGER.error("Failed to add ISR for GPIO {}: {}", static_cast<int>(dirPins[i]), esp_err_to_name(err)); LOG_E(TAG, "Failed to add ISR for GPIO %d: %s", static_cast<int>(dirPins[i]), esp_err_to_name(err));
// Cleanup previously added handlers // Cleanup previously added handlers
for (int j = 0; j < handlersAdded; j++) { for (int j = 0; j < handlersAdded; j++) {
gpio_isr_handler_remove(dirPins[j]); gpio_isr_handler_remove(dirPins[j]);
@@ -215,7 +215,7 @@ lv_indev_t* init(const TrackballConfig& config) {
io_conf.pin_bit_mask = (1ULL << config.pinClick); io_conf.pin_bit_mask = (1ULL << config.pinClick);
esp_err_t err = gpio_config(&io_conf); esp_err_t err = gpio_config(&io_conf);
if (err != ESP_OK) { if (err != ESP_OK) {
LOGGER.error("Failed to configure button GPIO {}: {}", static_cast<int>(config.pinClick), esp_err_to_name(err)); LOG_E(TAG, "Failed to configure button GPIO %d: %s", static_cast<int>(config.pinClick), esp_err_to_name(err));
// Cleanup direction handlers // Cleanup direction handlers
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
gpio_isr_handler_remove(dirPins[i]); gpio_isr_handler_remove(dirPins[i]);
@@ -225,7 +225,7 @@ lv_indev_t* init(const TrackballConfig& config) {
err = gpio_isr_handler_add(config.pinClick, button_isr_handler, nullptr); err = gpio_isr_handler_add(config.pinClick, button_isr_handler, nullptr);
if (err != ESP_OK) { if (err != ESP_OK) {
LOGGER.error("Failed to add button ISR: {}", esp_err_to_name(err)); LOG_E(TAG, "Failed to add button ISR: %s", esp_err_to_name(err));
// Cleanup direction handlers // Cleanup direction handlers
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
gpio_isr_handler_remove(dirPins[i]); gpio_isr_handler_remove(dirPins[i]);
@@ -239,7 +239,7 @@ lv_indev_t* init(const TrackballConfig& config) {
// Register as LVGL encoder input device for group navigation (default mode) // Register as LVGL encoder input device for group navigation (default mode)
g_indev = lv_indev_create(); g_indev = lv_indev_create();
if (g_indev == nullptr) { if (g_indev == nullptr) {
LOGGER.error("Failed to register LVGL input device"); LOG_E(TAG, "Failed to register LVGL input device");
// Cleanup ISR handlers on failure // Cleanup ISR handlers on failure
const gpio_num_t pins[5] = { const gpio_num_t pins[5] = {
config.pinRight, config.pinUp, config.pinLeft, config.pinRight, config.pinUp, config.pinLeft,
@@ -255,7 +255,7 @@ lv_indev_t* init(const TrackballConfig& config) {
lv_indev_set_type(g_indev, LV_INDEV_TYPE_ENCODER); lv_indev_set_type(g_indev, LV_INDEV_TYPE_ENCODER);
lv_indev_set_read_cb(g_indev, read_cb); lv_indev_set_read_cb(g_indev, read_cb);
g_initialized.store(true, std::memory_order_relaxed); g_initialized.store(true, std::memory_order_relaxed);
LOGGER.info("Initialized with interrupts (R:{} U:{} L:{} D:{} Click:{})", LOG_I(TAG, "Initialized with interrupts (R:%d U:%d L:%d D:%d Click:%d)",
static_cast<int>(config.pinRight), static_cast<int>(config.pinRight),
static_cast<int>(config.pinUp), static_cast<int>(config.pinUp),
static_cast<int>(config.pinLeft), static_cast<int>(config.pinLeft),
@@ -276,7 +276,7 @@ static void createCursor() {
// Set cursor image // Set cursor image
lv_image_set_src(g_cursor, TT_ASSETS_UI_CURSOR); lv_image_set_src(g_cursor, TT_ASSETS_UI_CURSOR);
lv_indev_set_cursor(g_indev, g_cursor); lv_indev_set_cursor(g_indev, g_cursor);
LOGGER.debug("Cursor created"); LOG_D(TAG, "Cursor created");
} }
} }
@@ -287,7 +287,7 @@ static void destroyCursor() {
// Delete the cursor object - this automatically detaches it from the indev // Delete the cursor object - this automatically detaches it from the indev
lv_obj_delete(g_cursor); lv_obj_delete(g_cursor);
g_cursor = nullptr; g_cursor = nullptr;
LOGGER.debug("Cursor destroyed"); LOG_D(TAG, "Cursor destroyed");
} }
void deinit() { void deinit() {
@@ -317,14 +317,14 @@ void deinit() {
g_initialized.store(false, std::memory_order_relaxed); g_initialized.store(false, std::memory_order_relaxed);
g_mode.store(Mode::Encoder, std::memory_order_relaxed); g_mode.store(Mode::Encoder, std::memory_order_relaxed);
g_enabled.store(true, std::memory_order_relaxed); g_enabled.store(true, std::memory_order_relaxed);
LOGGER.info("Deinitialized"); LOG_I(TAG, "Deinitialized");
} }
void setEncoderSensitivity(uint8_t sensitivity) { void setEncoderSensitivity(uint8_t sensitivity) {
if (sensitivity > 0) { if (sensitivity > 0) {
// Only update the atomic - ISR reads from atomic, not g_config // Only update the atomic - ISR reads from atomic, not g_config
g_encoderSensitivity.store(sensitivity, std::memory_order_relaxed); g_encoderSensitivity.store(sensitivity, std::memory_order_relaxed);
LOGGER.debug("Encoder sensitivity set to {}", sensitivity); LOG_D(TAG, "Encoder sensitivity set to %d", sensitivity);
} }
} }
@@ -332,7 +332,7 @@ void setPointerSensitivity(uint8_t sensitivity) {
if (sensitivity > 0) { if (sensitivity > 0) {
// Only update the atomic - ISR reads from atomic, not g_config // Only update the atomic - ISR reads from atomic, not g_config
g_pointerSensitivity.store(sensitivity, std::memory_order_relaxed); g_pointerSensitivity.store(sensitivity, std::memory_order_relaxed);
LOGGER.debug("Pointer sensitivity set to {}", sensitivity); LOG_D(TAG, "Pointer sensitivity set to %d", sensitivity);
} }
} }
@@ -355,13 +355,13 @@ void setEnabled(bool enabled) {
} }
} }
LOGGER.info("{}", enabled ? "Enabled" : "Disabled"); LOG_I(TAG, "%s", enabled ? "Enabled" : "Disabled");
} }
void setMode(Mode mode) { void setMode(Mode mode) {
// Note: Must be called from LVGL thread (main thread) for thread safety // Note: Must be called from LVGL thread (main thread) for thread safety
if (!g_initialized.load(std::memory_order_relaxed) || g_indev == nullptr) { if (!g_initialized.load(std::memory_order_relaxed) || g_indev == nullptr) {
LOGGER.warn("Cannot set mode - not initialized"); LOG_W(TAG, "Cannot set mode - not initialized");
return; return;
} }
@@ -381,13 +381,13 @@ void setMode(Mode mode) {
// Reset cursor to center when switching modes // Reset cursor to center when switching modes
g_cursorX.store(SCREEN_WIDTH / 2, std::memory_order_relaxed); g_cursorX.store(SCREEN_WIDTH / 2, std::memory_order_relaxed);
g_cursorY.store(SCREEN_HEIGHT / 2, std::memory_order_relaxed); g_cursorY.store(SCREEN_HEIGHT / 2, std::memory_order_relaxed);
LOGGER.info("Switched to Pointer mode"); LOG_I(TAG, "Switched to Pointer mode");
} else { } else {
// Switch to encoder mode // Switch to encoder mode
destroyCursor(); destroyCursor();
lv_indev_set_type(g_indev, LV_INDEV_TYPE_ENCODER); lv_indev_set_type(g_indev, LV_INDEV_TYPE_ENCODER);
g_encoderDiff.store(0, std::memory_order_relaxed); // Reset encoder diff g_encoderDiff.store(0, std::memory_order_relaxed); // Reset encoder diff
LOGGER.info("Switched to Encoder mode"); LOG_I(TAG, "Switched to Encoder mode");
} }
} }
@@ -1,16 +1,16 @@
#include "TdeckKeyboard.h" #include "TdeckKeyboard.h"
#include <KeyboardBacklight/KeyboardBacklight.h> #include <KeyboardBacklight/KeyboardBacklight.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/display/DisplayDevice.h> #include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/settings/DisplaySettings.h> #include <Tactility/settings/DisplaySettings.h>
#include <Tactility/settings/KeyboardSettings.h> #include <Tactility/settings/KeyboardSettings.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/drivers/i2c_controller.h> #include <tactility/drivers/i2c_controller.h>
#include <tactility/log.h>
using tt::hal::findFirstDevice; using tt::hal::findFirstDevice;
static const auto LOGGER = tt::Logger("TdeckKeyboard"); constexpr auto* TAG = "TdeckKeyboard";
constexpr uint8_t TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55; constexpr uint8_t TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55;
@@ -34,15 +34,11 @@ static void keyboard_read_callback(lv_indev_t* indev, lv_indev_data_t* data) {
auto* keyboard = static_cast<TdeckKeyboard*>(lv_indev_get_user_data(indev)); auto* keyboard = static_cast<TdeckKeyboard*>(lv_indev_get_user_data(indev));
if (i2c_controller_read(keyboard->getI2cController(), TDECK_KEYBOARD_SLAVE_ADDRESS, &read_buffer, 1, 100 / portTICK_PERIOD_MS) == ERROR_NONE) { if (i2c_controller_read(keyboard->getI2cController(), TDECK_KEYBOARD_SLAVE_ADDRESS, &read_buffer, 1, 100 / portTICK_PERIOD_MS) == ERROR_NONE) {
if (read_buffer == 0 && read_buffer != last_buffer) { if (read_buffer == 0 && read_buffer != last_buffer) {
if (LOGGER.isLoggingDebug()) { LOG_D(TAG, "Released %d", last_buffer);
LOGGER.debug("Released {}", last_buffer);
}
data->key = last_buffer; data->key = last_buffer;
data->state = LV_INDEV_STATE_RELEASED; data->state = LV_INDEV_STATE_RELEASED;
} else if (read_buffer != 0) { } else if (read_buffer != 0) {
if (LOGGER.isLoggingDebug()) { LOG_D(TAG, "Pressed %d", read_buffer);
LOGGER.debug("Pressed {}", read_buffer);
}
data->key = read_buffer; data->key = read_buffer;
data->state = LV_INDEV_STATE_PRESSED; data->state = LV_INDEV_STATE_PRESSED;
// TODO: Avoid performance hit by calling loadOrGetDefault() on each key press // TODO: Avoid performance hit by calling loadOrGetDefault() on each key press
@@ -1,10 +1,10 @@
#include "TrackballDevice.h" #include "TrackballDevice.h"
#include <Trackball/Trackball.h> // Driver #include <Trackball/Trackball.h> // Driver
#include <Tactility/Logger.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/settings/TrackballSettings.h> #include <Tactility/settings/TrackballSettings.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("TrackballDevice"); constexpr auto* TAG = "TrackballDevice";
bool TrackballDevice::start() { bool TrackballDevice::start() {
if (initialized) { if (initialized) {
@@ -40,7 +40,7 @@ bool TrackballDevice::start() {
trackball::setEnabled(tbSettings.trackballEnabled); trackball::setEnabled(tbSettings.trackballEnabled);
tt::lvgl::unlock(); tt::lvgl::unlock();
} else { } else {
LOGGER.warn("Failed to acquire LVGL lock for trackball settings"); LOG_W(TAG, "Failed to acquire LVGL lock for trackball settings");
} }
return true; return true;
+5 -4
View File
@@ -2,8 +2,9 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/kernel/SystemEvents.h" #include <Tactility/kernel/SystemEvents.h>
#include <Tactility/TactilityCore.h> #include <Tactility/TactilityCore.h>
#include <tactility/log.h>
#define TAG "tdisplay-s3" #define TAG "tdisplay-s3"
@@ -28,14 +29,14 @@ static bool powerOn() {
} }
bool initBoot() { bool initBoot() {
ESP_LOGI(TAG, "Powering on the board..."); LOG_I(TAG, "Powering on");
if (!powerOn()) { if (!powerOn()) {
ESP_LOGE(TAG, "Failed to power on the board."); LOG_E(TAG, "Power on failed");
return false; return false;
} }
if (!driver::pwmbacklight::init(DISPLAY_BL, 30000)) { if (!driver::pwmbacklight::init(DISPLAY_BL, 30000)) {
ESP_LOGE(TAG, "Failed to initialize backlight."); LOG_E(TAG, "Backlight init failed");
return false; return false;
} }
+3 -3
View File
@@ -1,14 +1,14 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include <Tactility/Logger.h>
#include <Tactility/service/gps/GpsService.h> #include <Tactility/service/gps/GpsService.h>
#include <Tactility/TactilityCore.h> #include <Tactility/TactilityCore.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("T-Dongle S3"); constexpr auto* TAG = "T-Dongle S3";
bool initBoot() { bool initBoot() {
if (!driver::pwmbacklight::init(GPIO_NUM_38, 12000)) { if (!driver::pwmbacklight::init(GPIO_NUM_38, 12000)) {
LOGGER.error("Backlight init failed"); LOG_E(TAG, "Backlight init failed");
return false; return false;
} }
+5 -4
View File
@@ -2,7 +2,8 @@
#include "devices/Display.h" #include "devices/Display.h"
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/kernel/SystemEvents.h" #include <Tactility/kernel/SystemEvents.h>
#include <tactility/log.h>
#include <Tactility/TactilityCore.h> #include <Tactility/TactilityCore.h>
#define TAG "thmi" #define TAG "thmi"
@@ -32,14 +33,14 @@ static bool powerOn() {
} }
bool initBoot() { bool initBoot() {
ESP_LOGI(TAG, "Powering on the board..."); LOG_I(TAG, "Powering on the board...");
if (!powerOn()) { if (!powerOn()) {
ESP_LOGE(TAG, "Failed to power on the board."); LOG_E(TAG, "Failed to power on the board.");
return false; return false;
} }
if (!driver::pwmbacklight::init(DISPLAY_BL, 30000)) { if (!driver::pwmbacklight::init(DISPLAY_BL, 30000)) {
ESP_LOGE(TAG, "Failed to initialize backlight."); LOG_E(TAG, "Failed to initialize backlight.");
return false; return false;
} }
+11 -11
View File
@@ -1,24 +1,24 @@
#include "Power.h" #include "Power.h"
#include <Tactility/Logger.h>
#include <driver/adc.h> #include <driver/adc.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("Power"); constexpr auto* TAG = "Power";
bool Power::adcInitCalibration() { bool Power::adcInitCalibration() {
bool calibrated = false; bool calibrated = false;
esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT); esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT);
if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) { if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) {
LOGGER.warn("Calibration scheme not supported, skip software calibration"); LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) { } else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
LOGGER.warn("eFuse not burnt, skip software calibration"); LOG_W(TAG, "eFuse not burnt, skip software calibration");
} else if (efuse_read_result == ESP_OK) { } else if (efuse_read_result == ESP_OK) {
calibrated = true; calibrated = true;
LOGGER.info("Calibration success"); LOG_I(TAG, "Calibration success");
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics); esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics);
} else { } else {
LOGGER.warn("eFuse read failed, skipping calibration"); LOG_W(TAG, "eFuse read failed, skipping calibration");
} }
return calibrated; return calibrated;
@@ -26,16 +26,16 @@ bool Power::adcInitCalibration() {
uint32_t Power::adcReadValue() const { uint32_t Power::adcReadValue() const {
int adc_raw = adc1_get_raw(ADC1_CHANNEL_4); int adc_raw = adc1_get_raw(ADC1_CHANNEL_4);
LOGGER.debug("Raw data: {}", adc_raw); LOG_D(TAG, "Raw data: %d", adc_raw);
uint32_t voltage; uint32_t voltage;
if (calibrated) { if (calibrated) {
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics); voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
LOGGER.debug("Calibrated data: {} mV", voltage); LOG_D(TAG, "Calibrated data: %d mV", (int)voltage);
} else { } else {
voltage = (adc_raw * 3300) / 4095; // fallback voltage = (adc_raw * 3300) / 4095; // fallback
LOGGER.debug("Estimated data: {} mV", voltage); LOG_D(TAG, "Estimated data: %d mV", (int)voltage);
} }
return voltage; return voltage;
@@ -45,12 +45,12 @@ bool Power::ensureInitialized() {
if (!initialized) { if (!initialized) {
if (adc1_config_width(ADC_WIDTH_BIT_12) != ESP_OK) { if (adc1_config_width(ADC_WIDTH_BIT_12) != ESP_OK) {
LOGGER.error("ADC1 config width failed"); LOG_E(TAG, "ADC1 config width failed");
return false; return false;
} }
if (adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_11) != ESP_OK) { if (adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_11) != ESP_OK) {
LOGGER.error("ADC1 config attenuation failed"); LOG_E(TAG, "ADC1 config attenuation failed");
return false; return false;
} }
+6 -6
View File
@@ -1,5 +1,4 @@
#include <Bq27220.h> #include <Bq27220.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/kernel/SystemEvents.h> #include <Tactility/kernel/SystemEvents.h>
#include <Tactility/service/gps/GpsService.h> #include <Tactility/service/gps/GpsService.h>
@@ -8,17 +7,18 @@
#include <driver/gpio.h> #include <driver/gpio.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("T-Lora Pager"); constexpr auto* TAG = "T-Lora Pager";
bool tpagerInit() { bool tpagerInit() {
LOGGER.info(LOG_MESSAGE_POWER_ON_START); LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
/* 32 Khz and higher gives an issue where the screen starts dimming again above 80% brightness /* 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%. * when moving the brightness slider rapidly from a lower setting to 100%.
* This is not a slider bug (data was debug-traced) */ * This is not a slider bug (data was debug-traced) */
if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) { if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) {
LOGGER.error("Backlight init failed"); LOG_E(TAG, "Backlight init failed");
return false; return false;
} }
@@ -45,9 +45,9 @@ bool tpagerInit() {
.baudRate = 38400, .baudRate = 38400,
.model = tt::hal::gps::GpsModel::UBLOX10 .model = tt::hal::gps::GpsModel::UBLOX10
})) { })) {
LOGGER.info("Configured internal GPS"); LOG_I(TAG, "Configured internal GPS");
} else { } else {
LOGGER.error("Failed to configure internal GPS"); LOG_E(TAG, "Failed to configure internal GPS");
} }
} }
} }
@@ -1,9 +1,9 @@
#include "TpagerEncoder.h" #include "TpagerEncoder.h"
#include <Tactility/Logger.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("TpagerEncoder"); constexpr auto* TAG = "TpagerEncoder";
constexpr auto ENCODER_A = GPIO_NUM_40; constexpr auto ENCODER_A = GPIO_NUM_40;
constexpr auto ENCODER_B = GPIO_NUM_41; constexpr auto ENCODER_B = GPIO_NUM_41;
@@ -58,7 +58,7 @@ bool TpagerEncoder::initEncoder() {
}; };
if (pcnt_new_unit(&unit_config, &encPcntUnit) != ESP_OK) { if (pcnt_new_unit(&unit_config, &encPcntUnit) != ESP_OK) {
LOGGER.error("Pulsecounter initialization failed"); LOG_E(TAG, "Pulsecounter initialization failed");
return false; return false;
} }
@@ -67,7 +67,7 @@ bool TpagerEncoder::initEncoder() {
}; };
if (pcnt_unit_set_glitch_filter(encPcntUnit, &filter_config) != ESP_OK) { if (pcnt_unit_set_glitch_filter(encPcntUnit, &filter_config) != ESP_OK) {
LOGGER.error("Pulsecounter glitch filter config failed"); LOG_E(TAG, "Pulsecounter glitch filter config failed");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
@@ -102,7 +102,7 @@ bool TpagerEncoder::initEncoder() {
if ((pcnt_new_channel(encPcntUnit, &chan_1_config, &pcnt_chan_1) != ESP_OK) || 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)) { (pcnt_new_channel(encPcntUnit, &chan_2_config, &pcnt_chan_2) != ESP_OK)) {
LOGGER.error("Pulsecounter channel config failed"); LOG_E(TAG, "Pulsecounter channel config failed");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
@@ -111,7 +111,7 @@ bool TpagerEncoder::initEncoder() {
// Second argument is rising edge, third argument is falling edge // 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) || 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)) { (pcnt_channel_set_edge_action(pcnt_chan_2, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_DECREASE) != ESP_OK)) {
LOGGER.error("Pulsecounter edge action config failed"); LOG_E(TAG, "Pulsecounter edge action config failed");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
@@ -120,7 +120,7 @@ bool TpagerEncoder::initEncoder() {
// Second argument is low level, third argument is high level // 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) || 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)) { (pcnt_channel_set_level_action(pcnt_chan_2, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK)) {
LOGGER.error("Pulsecounter level action config failed"); LOG_E(TAG, "Pulsecounter level action config failed");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
@@ -128,28 +128,28 @@ bool TpagerEncoder::initEncoder() {
if ((pcnt_unit_add_watch_point(encPcntUnit, LOW_LIMIT) != ESP_OK) || if ((pcnt_unit_add_watch_point(encPcntUnit, LOW_LIMIT) != ESP_OK) ||
(pcnt_unit_add_watch_point(encPcntUnit, HIGH_LIMIT) != ESP_OK)) { (pcnt_unit_add_watch_point(encPcntUnit, HIGH_LIMIT) != ESP_OK)) {
LOGGER.error("Pulsecounter watch point config failed"); LOG_E(TAG, "Pulsecounter watch point config failed");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
} }
if (pcnt_unit_enable(encPcntUnit) != ESP_OK) { if (pcnt_unit_enable(encPcntUnit) != ESP_OK) {
LOGGER.error("Pulsecounter could not be enabled"); LOG_E(TAG, "Pulsecounter could not be enabled");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
} }
if (pcnt_unit_clear_count(encPcntUnit) != ESP_OK) { if (pcnt_unit_clear_count(encPcntUnit) != ESP_OK) {
LOGGER.error("Pulsecounter could not be cleared"); LOG_E(TAG, "Pulsecounter could not be cleared");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
} }
if (pcnt_unit_start(encPcntUnit) != ESP_OK) { if (pcnt_unit_start(encPcntUnit) != ESP_OK) {
LOGGER.error("Pulsecounter could not be started"); LOG_E(TAG, "Pulsecounter could not be started");
pcnt_del_unit(encPcntUnit); pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
@@ -168,16 +168,16 @@ bool TpagerEncoder::deinitEncoder() {
assert(encPcntUnit != nullptr); assert(encPcntUnit != nullptr);
if (pcnt_unit_stop(encPcntUnit) != ESP_OK) { if (pcnt_unit_stop(encPcntUnit) != ESP_OK) {
LOGGER.warn("Failed to stop encoder"); LOG_W(TAG, "Failed to stop encoder");
} }
if (pcnt_del_unit(encPcntUnit) != ESP_OK) { if (pcnt_del_unit(encPcntUnit) != ESP_OK) {
LOGGER.warn("Failed to delete encoder"); LOG_W(TAG, "Failed to delete encoder");
encPcntUnit = nullptr; encPcntUnit = nullptr;
return false; return false;
} }
LOGGER.info("Deinitialized"); LOG_I(TAG, "Deinitialized");
return true; return true;
} }
@@ -206,7 +206,7 @@ bool TpagerEncoder::stopLvgl() {
if (encPcntUnit != nullptr && !deinitEncoder()) { if (encPcntUnit != nullptr && !deinitEncoder()) {
// We're not returning false as LVGL as effectively deinitialized // We're not returning false as LVGL as effectively deinitialized
LOGGER.warn("Deinitialization failed"); LOG_W(TAG, "Deinitialization failed");
} }
return true; return true;
@@ -1,11 +1,10 @@
#include "TpagerKeyboard.h" #include "TpagerKeyboard.h"
#include <Tactility/Logger.h>
#include <driver/i2c.h> #include <driver/i2c.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("TpagerKeyboard"); constexpr auto* TAG = "TpagerKeyboard";
constexpr auto BACKLIGHT = GPIO_NUM_46; constexpr auto BACKLIGHT = GPIO_NUM_46;
@@ -173,7 +172,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
}; };
if (ledc_timer_config(&ledc_timer) != ESP_OK) { if (ledc_timer_config(&ledc_timer) != ESP_OK) {
LOGGER.error("Backlight timer config failed"); LOG_E(TAG, "Backlight timer config failed");
return false; return false;
} }
@@ -192,7 +191,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
}; };
if (ledc_channel_config(&ledc_channel) != ESP_OK) { if (ledc_channel_config(&ledc_channel) != ESP_OK) {
LOGGER.error("Backlight channel config failed"); LOG_E(TAG, "Backlight channel config failed");
} }
return true; return true;
@@ -200,7 +199,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
bool TpagerKeyboard::setBacklightDuty(uint8_t duty) { bool TpagerKeyboard::setBacklightDuty(uint8_t duty) {
if (!backlightOkay) { if (!backlightOkay) {
LOGGER.error("Backlight not ready"); LOG_E(TAG, "Backlight not ready");
return false; return false;
} }
return (ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK) && return (ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK) &&
@@ -1,9 +1,9 @@
#include "TpagerPower.h" #include "TpagerPower.h"
#include <Bq25896.h> #include <Bq25896.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("TpagerPower"); constexpr auto* TAG = "TpagerPower";
TpagerPower::~TpagerPower() {} TpagerPower::~TpagerPower() {}
@@ -66,7 +66,7 @@ void TpagerPower::powerOff() {
}); });
if (device == nullptr) { if (device == nullptr) {
LOGGER.error("BQ25896 not found"); LOG_E(TAG, "BQ25896 not found");
return; return;
} }
@@ -1,24 +1,24 @@
#include "CardputerPower.h" #include "CardputerPower.h"
#include <Tactility/Logger.h>
#include <driver/adc.h> #include <driver/adc.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("CardputerPower"); constexpr auto* TAG = "CardputerPower";
bool CardputerPower::adcInitCalibration() { bool CardputerPower::adcInitCalibration() {
bool calibrated = false; bool calibrated = false;
esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT); esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT);
if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) { if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) {
LOGGER.warn("Calibration scheme not supported, skip software calibration"); LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) { } else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
LOGGER.warn("eFuse not burnt, skip software calibration"); LOG_W(TAG, "eFuse not burnt, skip software calibration");
} else if (efuse_read_result == ESP_OK) { } else if (efuse_read_result == ESP_OK) {
calibrated = true; calibrated = true;
LOGGER.info("Calibration success"); LOG_I(TAG, "Calibration success");
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics); esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics);
} else { } else {
LOGGER.warn("eFuse read failed, skipping calibration"); LOG_W(TAG, "eFuse read failed, skipping calibration");
} }
return calibrated; return calibrated;
@@ -26,11 +26,11 @@ bool CardputerPower::adcInitCalibration() {
uint32_t CardputerPower::adcReadValue() const { uint32_t CardputerPower::adcReadValue() const {
int adc_raw = adc1_get_raw(ADC1_CHANNEL_9); int adc_raw = adc1_get_raw(ADC1_CHANNEL_9);
LOGGER.debug("Raw data: {}", adc_raw); LOG_D(TAG, "Raw data: %d", adc_raw);
float voltage; float voltage;
if (calibrated) { if (calibrated) {
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics); voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
LOGGER.debug("Calibrated data: {} mV", voltage); LOG_D(TAG, "Calibrated data: %f mV", voltage);
} else { } else {
voltage = 0.0f; voltage = 0.0f;
} }
@@ -42,11 +42,11 @@ bool CardputerPower::ensureInitialized() {
calibrated = adcInitCalibration(); calibrated = adcInitCalibration();
if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) { if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) {
LOGGER.error("ADC1 config width failed"); LOG_E(TAG, "ADC1 config width failed");
return false; return false;
} }
if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) { if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) {
LOGGER.error("ADC1 config attenuation failed"); LOG_E(TAG, "ADC1 config attenuation failed");
return false; return false;
} }
@@ -1,8 +1,8 @@
#include "CardputerKeyboard.h" #include "CardputerKeyboard.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("Keyboard"); constexpr auto* TAG = "Keyboard";
bool CardputerKeyboard::startLvgl(lv_display_t* display) { bool CardputerKeyboard::startLvgl(lv_display_t* display) {
keyboard.init(); keyboard.init();
@@ -56,7 +56,7 @@ void CardputerKeyboard::readCallback(lv_indev_t* indev, lv_indev_data_t* data) {
} }
} else { } else {
if (self->keyboard.keysState().del) { if (self->keyboard.keysState().del) {
LOGGER.info("del"); LOG_I(TAG, "del");
data->key = LV_KEY_DEL; data->key = LV_KEY_DEL;
data->state = LV_INDEV_STATE_PRESSED; data->state = LV_INDEV_STATE_PRESSED;
} else { } else {
@@ -1,24 +1,24 @@
#include "CardputerPower.h" #include "CardputerPower.h"
#include <Tactility/Logger.h>
#include <driver/adc.h> #include <driver/adc.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("CardputerPower"); constexpr auto* TAG = "CardputerPower";
bool CardputerPower::adcInitCalibration() { bool CardputerPower::adcInitCalibration() {
bool calibrated = false; bool calibrated = false;
esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT); esp_err_t efuse_read_result = esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT);
if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) { if (efuse_read_result == ESP_ERR_NOT_SUPPORTED) {
LOGGER.warn("Calibration scheme not supported, skip software calibration"); LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) { } else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
LOGGER.warn("eFuse not burnt, skip software calibration"); LOG_W(TAG, "eFuse not burnt, skip software calibration");
} else if (efuse_read_result == ESP_OK) { } else if (efuse_read_result == ESP_OK) {
calibrated = true; calibrated = true;
LOGGER.info("Calibration success"); LOG_I(TAG, "Calibration success");
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics); esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT), 0, &adcCharacteristics);
} else { } else {
LOGGER.warn("eFuse read failed, skipping calibration"); LOG_W(TAG, "eFuse read failed, skipping calibration");
} }
return calibrated; return calibrated;
@@ -26,11 +26,11 @@ bool CardputerPower::adcInitCalibration() {
uint32_t CardputerPower::adcReadValue() const { uint32_t CardputerPower::adcReadValue() const {
int adc_raw = adc1_get_raw(ADC1_CHANNEL_9); int adc_raw = adc1_get_raw(ADC1_CHANNEL_9);
LOGGER.debug("Raw data: {}", adc_raw); LOG_D(TAG, "Raw data: %d", adc_raw);
float voltage; float voltage;
if (calibrated) { if (calibrated) {
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics); voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
LOGGER.debug("Calibrated data: {} mV", voltage); LOG_D(TAG, "Calibrated data: %f mV", voltage);
} else { } else {
voltage = 0.0f; voltage = 0.0f;
} }
@@ -42,11 +42,11 @@ bool CardputerPower::ensureInitialized() {
calibrated = adcInitCalibration(); calibrated = adcInitCalibration();
if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) { if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) {
LOGGER.error("ADC1 config width failed"); LOG_E(TAG, "ADC1 config width failed");
return false; return false;
} }
if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) { if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) {
LOGGER.error("ADC1 config attenuation failed"); LOG_E(TAG, "ADC1 config attenuation failed");
return false; return false;
} }
+12 -12
View File
@@ -1,9 +1,9 @@
#include "InitBoot.h" #include "InitBoot.h"
#include <Tactility/Logger.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("CoreS3"); constexpr auto* TAG = "CoreS3";
std::shared_ptr<Axp2101> axp2101; std::shared_ptr<Axp2101> axp2101;
std::shared_ptr<Aw9523> aw9523; std::shared_ptr<Aw9523> aw9523;
@@ -13,7 +13,7 @@ std::shared_ptr<Aw9523> aw9523;
* and schematic: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/K128%20CoreS3/Sch_M5_CoreS3_v1.0.pdf * and schematic: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/K128%20CoreS3/Sch_M5_CoreS3_v1.0.pdf
*/ */
bool initGpioExpander() { bool initGpioExpander() {
LOGGER.info("AW9523 init"); LOG_I(TAG, "AW9523 init");
/** /**
* P0 pins: * P0 pins:
@@ -58,33 +58,33 @@ bool initGpioExpander() {
/* AW9523 P0 is in push-pull mode */ /* AW9523 P0 is in push-pull mode */
if (!aw9523->writeCTL(0x10)) { if (!aw9523->writeCTL(0x10)) {
LOGGER.error("AW9523: Failed to set CTL"); LOG_E(TAG, "AW9523: Failed to set CTL");
return false; return false;
} }
if (!aw9523->writeP0(p0_state)) { if (!aw9523->writeP0(p0_state)) {
LOGGER.error("AW9523: Failed to set P0"); LOG_E(TAG, "AW9523: Failed to set P0");
return false; return false;
} }
if (!aw9523->writeP1(p1_state)) { if (!aw9523->writeP1(p1_state)) {
LOGGER.error("AW9523: Failed to set P1"); LOG_E(TAG, "AW9523: Failed to set P1");
return false; return false;
} }
if (axp2101->isVBus()) { if (axp2101->isVBus()) {
float voltage = 0.0f; float voltage = 0.0f;
axp2101->getVBusVoltage(voltage); axp2101->getVBusVoltage(voltage);
LOGGER.info("AXP2101: VBus at {:.2f}", voltage); LOG_I(TAG, "AXP2101: VBus at %.2f", voltage);
} else { } else {
LOGGER.warn("AXP2101: VBus disabled"); LOG_W(TAG, "AXP2101: VBus disabled");
} }
return true; return true;
} }
bool initPowerControl() { bool initPowerControl() {
LOGGER.info("Init power control (AXP2101)"); LOG_I(TAG, "Init power control (AXP2101)");
// Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61 // Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61
aw9523->bitOnP1(0b10000000); // SY7088 boost enable aw9523->bitOnP1(0b10000000); // SY7088 boost enable
@@ -135,16 +135,16 @@ bool initPowerControl() {
}; };
if (axp2101->setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) { if (axp2101->setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) {
LOGGER.info("AXP2101 initialized with {} registers", sizeof(reg_data_array) / 2); LOG_I(TAG, "AXP2101 initialized with %d registers", (int)(sizeof(reg_data_array) / 2));
return true; return true;
} else { } else {
LOGGER.error("AXP2101: Failed to set registers"); LOG_E(TAG, "AXP2101: Failed to set registers");
return false; return false;
} }
} }
bool initBoot() { bool initBoot() {
LOGGER.info("initBoot()"); LOG_I(TAG, "initBoot()");
auto controller = device_find_by_name("i2c_internal"); auto controller = device_find_by_name("i2c_internal");
axp2101 = std::make_shared<Axp2101>(controller); axp2101 = std::make_shared<Axp2101>(controller);
@@ -3,11 +3,11 @@
#include <Axp2101.h> #include <Axp2101.h>
#include <Ft5x06Touch.h> #include <Ft5x06Touch.h>
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <Tactility/Logger.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("CoreS3Display"); constexpr auto* TAG = "CoreS3Display";
static void setBacklightDuty(uint8_t backlightDuty) { static void setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
@@ -15,7 +15,7 @@ static void setBacklightDuty(uint8_t backlightDuty) {
auto controller = device_find_by_name("i2c_internal"); auto controller = device_find_by_name("i2c_internal");
check(controller); check(controller);
if (i2c_controller_write_register(controller, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000) != ERROR_NONE) { // Sets DLD01 if (i2c_controller_write_register(controller, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000) != ERROR_NONE) { // Sets DLD01
LOGGER.error("Failed to set display backlight voltage"); LOG_E(TAG, "Failed to set display backlight voltage");
} }
} }
+9 -9
View File
@@ -1,7 +1,7 @@
#include <Tactility/Logger.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("Paper S3"); constexpr auto* TAG = "Paper S3";
constexpr gpio_num_t VBAT_PIN = GPIO_NUM_3; constexpr gpio_num_t VBAT_PIN = GPIO_NUM_3;
constexpr gpio_num_t CHARGE_STATUS_PIN = GPIO_NUM_4; constexpr gpio_num_t CHARGE_STATUS_PIN = GPIO_NUM_4;
@@ -9,38 +9,38 @@ constexpr gpio_num_t USB_DETECT_PIN = GPIO_NUM_5;
static bool powerOn() { static bool powerOn() {
if (gpio_reset_pin(CHARGE_STATUS_PIN) != ESP_OK) { if (gpio_reset_pin(CHARGE_STATUS_PIN) != ESP_OK) {
LOGGER.error("Failed to reset CHARGE_STATUS_PIN"); LOG_E(TAG, "Failed to reset CHARGE_STATUS_PIN");
return false; return false;
} }
if (gpio_set_direction(CHARGE_STATUS_PIN, GPIO_MODE_INPUT) != ESP_OK) { if (gpio_set_direction(CHARGE_STATUS_PIN, GPIO_MODE_INPUT) != ESP_OK) {
LOGGER.error("Failed to set direction for CHARGE_STATUS_PIN"); LOG_E(TAG, "Failed to set direction for CHARGE_STATUS_PIN");
return false; return false;
} }
if (gpio_reset_pin(USB_DETECT_PIN) != ESP_OK) { if (gpio_reset_pin(USB_DETECT_PIN) != ESP_OK) {
LOGGER.error("Failed to reset USB_DETECT_PIN"); LOG_E(TAG, "Failed to reset USB_DETECT_PIN");
return false; return false;
} }
if (gpio_set_direction(USB_DETECT_PIN, GPIO_MODE_INPUT) != ESP_OK) { if (gpio_set_direction(USB_DETECT_PIN, GPIO_MODE_INPUT) != ESP_OK) {
LOGGER.error("Failed to set direction for USB_DETECT_PIN"); LOG_E(TAG, "Failed to set direction for USB_DETECT_PIN");
return false; return false;
} }
// VBAT_PIN is used as ADC input; only reset it here to clear any previous // VBAT_PIN is used as ADC input; only reset it here to clear any previous
// configuration. The ADC driver (ChargeFromAdcVoltage) configures it for ADC use. // configuration. The ADC driver (ChargeFromAdcVoltage) configures it for ADC use.
if (gpio_reset_pin(VBAT_PIN) != ESP_OK) { if (gpio_reset_pin(VBAT_PIN) != ESP_OK) {
LOGGER.error("Failed to reset VBAT_PIN"); LOG_E(TAG, "Failed to reset VBAT_PIN");
return false; return false;
} }
return true; return true;
} }
bool initBoot() { bool initBoot() {
LOGGER.info("Power on"); LOG_I(TAG, "Power on");
if (!powerOn()) { if (!powerOn()) {
LOGGER.error("Power on failed"); LOG_E(TAG, "Power on failed");
return false; return false;
} }
@@ -3,18 +3,18 @@
#include <Axp2101.h> #include <Axp2101.h>
#include <Ft6x36Touch.h> #include <Ft6x36Touch.h>
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <Tactility/Logger.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("StackChanDisplay"); constexpr auto* TAG = "StackChanDisplay";
static void setBacklightDuty(uint8_t backlightDuty) { static void setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100]
auto controller = device_find_by_name("i2c_internal"); auto controller = device_find_by_name("i2c_internal");
check(controller); check(controller);
if (i2c_controller_write_register(controller, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000) != ERROR_NONE) { // Sets DLD01 if (i2c_controller_write_register(controller, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000) != ERROR_NONE) { // Sets DLD01
LOGGER.error("Failed to set display backlight voltage"); LOG_E(TAG, "Failed to set display backlight voltage");
} }
} }
@@ -1,14 +1,14 @@
#include "Detect.h" #include "Detect.h"
#include <Tactility/Logger.h>
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/drivers/i2c_controller.h> #include <tactility/drivers/i2c_controller.h>
#include <tactility/log.h>
#include <esp_lcd_touch_gt911.h> #include <esp_lcd_touch_gt911.h>
#include <esp_lcd_touch_st7123.h> #include <esp_lcd_touch_st7123.h>
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/task.h> #include <freertos/task.h>
static const auto LOGGER = tt::Logger("Tab5Detect"); constexpr auto* TAG = "Tab5Detect";
Tab5Variant detectVariant() { Tab5Variant detectVariant() {
// Allow time for touch IC to fully boot after expander reset in initBoot(). // Allow time for touch IC to fully boot after expander reset in initBoot().
@@ -27,19 +27,19 @@ Tab5Variant detectVariant() {
// It may also appear at 0x14 (backup) if the pin happened to be driven low // It may also appear at 0x14 (backup) if the pin happened to be driven low
if (i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS, PROBE_TIMEOUT) == ERROR_NONE || if (i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS, PROBE_TIMEOUT) == ERROR_NONE ||
i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP, PROBE_TIMEOUT) == ERROR_NONE) { i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP, PROBE_TIMEOUT) == ERROR_NONE) {
LOGGER.info("Detected GT911 touch — using ILI9881C display"); LOG_I(TAG, "Detected GT911 touch — using ILI9881C display");
return Tab5Variant::Ili9881c_Gt911; return Tab5Variant::Ili9881c_Gt911;
} }
// Probe for ST7123 touch (new variant) // Probe for ST7123 touch (new variant)
if (i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_ST7123_ADDRESS, PROBE_TIMEOUT) == ERROR_NONE) { if (i2c_controller_has_device_at_address(i2c0, ESP_LCD_TOUCH_IO_I2C_ST7123_ADDRESS, PROBE_TIMEOUT) == ERROR_NONE) {
LOGGER.info("Detected ST7123 touch — using ST7123 display"); LOG_I(TAG, "Detected ST7123 touch — using ST7123 display");
return Tab5Variant::St7123; return Tab5Variant::St7123;
} }
vTaskDelay(pdMS_TO_TICKS(100)); vTaskDelay(pdMS_TO_TICKS(100));
} }
LOGGER.warn("No known touch controller detected, defaulting to ST7123"); LOG_W(TAG, "No known touch controller detected, defaulting to ST7123");
return Tab5Variant::St7123; return Tab5Variant::St7123;
} }
@@ -6,14 +6,14 @@
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/gpio/Gpio.h> #include <Tactility/hal/gpio/Gpio.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/log.h>
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/task.h> #include <freertos/task.h>
static const auto LOGGER = tt::Logger("Tab5Display"); constexpr auto* TAG = "Tab5Display";
// LCD reset is wired to the PI4IOE5V6408 IO expander (io_expander0, bit 4), pulsed in // LCD reset is wired to the PI4IOE5V6408 IO expander (io_expander0, bit 4), pulsed in
// Configuration.cpp's initExpander0() before display creation - not a direct SoC GPIO. // Configuration.cpp's initExpander0() before display creation - not a direct SoC GPIO.
@@ -55,7 +55,7 @@ static std::shared_ptr<tt::hal::touch::TouchDevice> createSt7123Touch() {
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
// Initialize PWM backlight // Initialize PWM backlight
if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT, 5000, LEDC_TIMER_1, LEDC_CHANNEL_0)) { if (!driver::pwmbacklight::init(LCD_PIN_BACKLIGHT, 5000, LEDC_TIMER_1, LEDC_CHANNEL_0)) {
LOGGER.warn("Failed to initialize backlight"); LOG_W(TAG, "Failed to initialize backlight");
} }
Tab5Variant variant = detectVariant(); Tab5Variant variant = detectVariant();
@@ -1,10 +1,10 @@
#include "Ili9881cDisplay.h" #include "Ili9881cDisplay.h"
#include "ili9881_init_data.h" #include "ili9881_init_data.h"
#include <Tactility/Logger.h>
#include <esp_lcd_ili9881c.h> #include <esp_lcd_ili9881c.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("ILI9881C"); constexpr auto* TAG = "ILI9881C";
Ili9881cDisplay::~Ili9881cDisplay() { Ili9881cDisplay::~Ili9881cDisplay() {
// TODO: This should happen during ::stop(), but this isn't currently exposed // TODO: This should happen during ::stop(), but this isn't currently exposed
@@ -30,11 +30,11 @@ bool Ili9881cDisplay::createMipiDsiBus() {
}; };
if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) { if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) {
LOGGER.error("Failed to acquire LDO channel for MIPI DSI PHY"); LOG_E(TAG, "Failed to acquire LDO channel for MIPI DSI PHY");
return false; return false;
} }
LOGGER.info("Powered on"); LOG_I(TAG, "Powered on");
// Create bus // Create bus
// TODO: use MIPI_DSI_PHY_CLK_SRC_DEFAULT() in future ESP-IDF 6.0.0 update with esp_lcd_jd9165 library version 2.x // TODO: use MIPI_DSI_PHY_CLK_SRC_DEFAULT() in future ESP-IDF 6.0.0 update with esp_lcd_jd9165 library version 2.x
@@ -46,13 +46,13 @@ bool Ili9881cDisplay::createMipiDsiBus() {
}; };
if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) { if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) {
LOGGER.error("Failed to create bus"); LOG_E(TAG, "Failed to create bus");
esp_ldo_release_channel(ldoChannel); esp_ldo_release_channel(ldoChannel);
ldoChannel = nullptr; ldoChannel = nullptr;
return false; return false;
} }
LOGGER.info("Bus created"); LOG_I(TAG, "Bus created");
return true; return true;
} }
@@ -68,7 +68,7 @@ bool Ili9881cDisplay::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
esp_lcd_dbi_io_config_t dbi_config = ILI9881C_PANEL_IO_DBI_CONFIG(); esp_lcd_dbi_io_config_t dbi_config = ILI9881C_PANEL_IO_DBI_CONFIG();
if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) { if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) {
LOGGER.error("Failed to create panel IO"); LOG_E(TAG, "Failed to create panel IO");
esp_lcd_del_dsi_bus(mipiDsiBus); esp_lcd_del_dsi_bus(mipiDsiBus);
mipiDsiBus = nullptr; mipiDsiBus = nullptr;
esp_ldo_release_channel(ldoChannel); esp_ldo_release_channel(ldoChannel);
@@ -135,11 +135,11 @@ bool Ili9881cDisplay::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, cons
mutable_panel_config.vendor_config = &vendor_config; mutable_panel_config.vendor_config = &vendor_config;
if (esp_lcd_new_panel_ili9881c(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_ili9881c(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
LOGGER.info("Panel created successfully"); LOG_I(TAG, "Panel created successfully");
// Defer reset/init to base class applyConfiguration to avoid double initialization // Defer reset/init to base class applyConfiguration to avoid double initialization
return true; return true;
} }
@@ -1,10 +1,10 @@
#include "St7123Display.h" #include "St7123Display.h"
#include "st7123_init_data.h" #include "st7123_init_data.h"
#include <Tactility/Logger.h>
#include <esp_lcd_st7123.h> #include <esp_lcd_st7123.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("St7123"); constexpr auto* TAG = "St7123";
St7123Display::~St7123Display() { St7123Display::~St7123Display() {
// TODO: This should happen during ::stop(), but this isn't currently exposed // TODO: This should happen during ::stop(), but this isn't currently exposed
@@ -30,11 +30,11 @@ bool St7123Display::createMipiDsiBus() {
}; };
if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) { if (esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldoChannel) != ESP_OK) {
LOGGER.error("Failed to acquire LDO channel for MIPI DSI PHY"); LOG_E(TAG, "Failed to acquire LDO channel for MIPI DSI PHY");
return false; return false;
} }
LOGGER.info("Powered on"); LOG_I(TAG, "Powered on");
const esp_lcd_dsi_bus_config_t bus_config = { const esp_lcd_dsi_bus_config_t bus_config = {
.bus_id = 0, .bus_id = 0,
@@ -44,13 +44,13 @@ bool St7123Display::createMipiDsiBus() {
}; };
if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) { if (esp_lcd_new_dsi_bus(&bus_config, &mipiDsiBus) != ESP_OK) {
LOGGER.error("Failed to create bus"); LOG_E(TAG, "Failed to create bus");
esp_ldo_release_channel(ldoChannel); esp_ldo_release_channel(ldoChannel);
ldoChannel = nullptr; ldoChannel = nullptr;
return false; return false;
} }
LOGGER.info("Bus created"); LOG_I(TAG, "Bus created");
return true; return true;
} }
@@ -69,7 +69,7 @@ bool St7123Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
}; };
if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) { if (esp_lcd_new_panel_io_dbi(mipiDsiBus, &dbi_config, &ioHandle) != ESP_OK) {
LOGGER.error("Failed to create panel IO"); LOG_E(TAG, "Failed to create panel IO");
esp_lcd_del_dsi_bus(mipiDsiBus); esp_lcd_del_dsi_bus(mipiDsiBus);
mipiDsiBus = nullptr; mipiDsiBus = nullptr;
esp_ldo_release_channel(ldoChannel); esp_ldo_release_channel(ldoChannel);
@@ -130,11 +130,11 @@ bool St7123Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, const
mutable_panel_config.vendor_config = &vendor_config; mutable_panel_config.vendor_config = &vendor_config;
if (esp_lcd_new_panel_st7123(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_st7123(ioHandle, &mutable_panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
LOGGER.info("Panel created successfully"); LOG_I(TAG, "Panel created successfully");
return true; return true;
} }
@@ -1,11 +1,11 @@
#include "St7123Touch.h" #include "St7123Touch.h"
#include <Tactility/Logger.h>
#include <tactility/drivers/esp32_i2c_master.h> #include <tactility/drivers/esp32_i2c_master.h>
#include <tactility/log.h>
#include <esp_lcd_touch_st7123.h> #include <esp_lcd_touch_st7123.h>
#include <esp_err.h> #include <esp_err.h>
static const auto LOGGER = tt::Logger("ST7123Touch"); constexpr auto* TAG = "ST7123Touch";
bool St7123Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool St7123Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_ST7123_CONFIG(); esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_ST7123_CONFIG();
+5 -3
View File
@@ -5,7 +5,9 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "task.h" #include "task.h"
static const auto LOGGER = tt::Logger("FreeRTOS"); #include <tactility/log.h>
constexpr auto* TAG = "FreeRTOS";
namespace simulator { namespace simulator {
@@ -16,10 +18,10 @@ void setMain(MainFunction newMainFunction) {
} }
static void freertosMainTask(void* parameter) { static void freertosMainTask(void* parameter) {
LOGGER.info("starting app_main()"); LOG_I(TAG, "starting app_main()");
assert(simulator::mainFunction); assert(simulator::mainFunction);
mainFunction(); mainFunction();
LOGGER.info("returned from app_main()"); LOG_I(TAG, "returned from app_main()");
vTaskDelete(nullptr); vTaskDelete(nullptr);
} }
+13 -13
View File
@@ -1,12 +1,12 @@
#include "UnPhoneFeatures.h" #include "UnPhoneFeatures.h"
#include <tactility/device.h> #include <tactility/device.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/Preferences.h> #include <Tactility/Preferences.h>
#include <Tactility/TactilityCore.h> #include <Tactility/TactilityCore.h>
#include <esp_sleep.h> #include <esp_sleep.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("unPhone"); constexpr auto* TAG = "unPhone";
std::shared_ptr<UnPhoneFeatures> unPhoneFeatures; std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
static std::unique_ptr<tt::Thread> powerThread; static std::unique_ptr<tt::Thread> powerThread;
@@ -49,10 +49,10 @@ public:
} }
void printInfo() { void printInfo() {
LOGGER.info("Device stats:"); LOG_I(TAG, "Device stats:");
LOGGER.info(" boot: {}", getValue(bootCountKey)); LOG_I(TAG, " boot: %d", (int)getValue(bootCountKey));
LOGGER.info(" power off: {}", getValue(powerOffCountKey)); LOG_I(TAG, " power off: %d", (int)getValue(powerOffCountKey));
LOGGER.info(" power sleep: {}", getValue(powerSleepKey)); LOG_I(TAG, " power sleep: %d", (int)getValue(powerSleepKey));
} }
}; };
@@ -92,11 +92,11 @@ static void updatePowerSwitch() {
if (!unPhoneFeatures->isPowerSwitchOn()) { if (!unPhoneFeatures->isPowerSwitchOn()) {
if (last_state != PowerState::Off) { if (last_state != PowerState::Off) {
last_state = PowerState::Off; last_state = PowerState::Off;
LOGGER.warn("Power off"); LOG_W(TAG, "Power off");
} }
if (!unPhoneFeatures->isUsbPowerConnected()) { // and usb unplugged we go into shipping mode if (!unPhoneFeatures->isUsbPowerConnected()) { // and usb unplugged we go into shipping mode
LOGGER.warn("Shipping mode until USB connects"); LOG_W(TAG, "Shipping mode until USB connects");
#if DEBUG_POWER_STATES #if DEBUG_POWER_STATES
unPhoneFeatures.setExpanderPower(true); unPhoneFeatures.setExpanderPower(true);
@@ -110,7 +110,7 @@ static void updatePowerSwitch() {
unPhoneFeatures->setShipping(true); // tell BM to stop supplying power until USB connects unPhoneFeatures->setShipping(true); // tell BM to stop supplying power until USB connects
} else { // When power switch is off, but USB is plugged in, we wait (deep sleep) until USB is unplugged. } else { // When power switch is off, but USB is plugged in, we wait (deep sleep) until USB is unplugged.
LOGGER.warn("Waiting for USB disconnect to power off"); LOG_W(TAG, "Waiting for USB disconnect to power off");
#if DEBUG_POWER_STATES #if DEBUG_POWER_STATES
powerInfoBuzz(2); powerInfoBuzz(2);
@@ -129,7 +129,7 @@ static void updatePowerSwitch() {
} else { } else {
if (last_state != PowerState::On) { if (last_state != PowerState::On) {
last_state = PowerState::On; last_state = PowerState::On;
LOGGER.warn("Power on"); LOG_W(TAG, "Power on");
#if DEBUG_POWER_STATES #if DEBUG_POWER_STATES
powerInfoBuzz(1); powerInfoBuzz(1);
@@ -166,7 +166,7 @@ static bool unPhonePowerOn() {
unPhoneFeatures = std::make_shared<UnPhoneFeatures>(bq24295); unPhoneFeatures = std::make_shared<UnPhoneFeatures>(bq24295);
if (!unPhoneFeatures->init()) { if (!unPhoneFeatures->init()) {
LOGGER.error("UnPhoneFeatures init failed"); LOG_E(TAG, "UnPhoneFeatures init failed");
return false; return false;
} }
@@ -186,10 +186,10 @@ static bool unPhonePowerOn() {
} }
bool initBoot() { bool initBoot() {
LOGGER.info(LOG_MESSAGE_POWER_ON_START); LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
if (!unPhonePowerOn()) { if (!unPhonePowerOn()) {
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED); LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
return false; return false;
} }
+18 -18
View File
@@ -1,6 +1,5 @@
#include "UnPhoneFeatures.h" #include "UnPhoneFeatures.h"
#include <Tactility/Logger.h>
#include <Tactility/app/App.h> #include <Tactility/app/App.h>
#include <Tactility/kernel/Kernel.h> #include <Tactility/kernel/Kernel.h>
@@ -8,8 +7,9 @@
#include <driver/rtc_io.h> #include <driver/rtc_io.h>
#include <esp_io_expander.h> #include <esp_io_expander.h>
#include <esp_sleep.h> #include <esp_sleep.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("unPhoneFeatures"); constexpr auto* TAG = "unPhoneFeatures";
namespace pin { namespace pin {
static const gpio_num_t BUTTON1 = GPIO_NUM_45; // left button static const gpio_num_t BUTTON1 = GPIO_NUM_45; // left button
@@ -42,7 +42,7 @@ static int32_t buttonHandlingThreadMain(const bool* interrupted) {
while (!*interrupted) { while (!*interrupted) {
if (xQueueReceive(interruptQueue, &pinNumber, portMAX_DELAY)) { if (xQueueReceive(interruptQueue, &pinNumber, portMAX_DELAY)) {
// The buttons might generate more than 1 click because of how they are built // The buttons might generate more than 1 click because of how they are built
LOGGER.info("Pressed button {}", pinNumber); LOG_I(TAG, "Pressed button %d", pinNumber);
if (pinNumber == pin::BUTTON1) { if (pinNumber == pin::BUTTON1) {
tt::app::stop(); tt::app::stop();
} }
@@ -75,7 +75,7 @@ bool UnPhoneFeatures::initPowerSwitch() {
}; };
if (gpio_config(&config) != ESP_OK) { if (gpio_config(&config) != ESP_OK) {
LOGGER.error("Power pin init failed"); LOG_E(TAG, "Power pin init failed");
return false; return false;
} }
@@ -83,14 +83,14 @@ bool UnPhoneFeatures::initPowerSwitch() {
rtc_gpio_pulldown_en(pin::POWER_SWITCH) == ESP_OK) { rtc_gpio_pulldown_en(pin::POWER_SWITCH) == ESP_OK) {
return true; return true;
} else { } else {
LOGGER.error("Failed to set RTC for power switch"); LOG_E(TAG, "Failed to set RTC for power switch");
return false; return false;
} }
} }
bool UnPhoneFeatures::initNavButtons() { bool UnPhoneFeatures::initNavButtons() {
if (!initGpioExpander()) { if (!initGpioExpander()) {
LOGGER.error("GPIO expander init failed"); LOG_E(TAG, "GPIO expander init failed");
return false; return false;
} }
@@ -125,7 +125,7 @@ bool UnPhoneFeatures::initNavButtons() {
}; };
if (gpio_config(&config) != ESP_OK) { if (gpio_config(&config) != ESP_OK) {
LOGGER.error("Nav button pin init failed"); LOG_E(TAG, "Nav button pin init failed");
return false; return false;
} }
@@ -135,7 +135,7 @@ bool UnPhoneFeatures::initNavButtons() {
gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON2)) != ESP_OK || gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON2)) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON3)) != ESP_OK gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON3)) != ESP_OK
) { ) {
LOGGER.error("Nav buttons ISR init failed"); LOG_E(TAG, "Nav buttons ISR init failed");
return false; return false;
} }
@@ -156,7 +156,7 @@ bool UnPhoneFeatures::initOutputPins() {
}; };
if (gpio_config(&config) != ESP_OK) { if (gpio_config(&config) != ESP_OK) {
LOGGER.error("Output pin init failed"); LOG_E(TAG, "Output pin init failed");
return false; return false;
} }
@@ -167,7 +167,7 @@ bool UnPhoneFeatures::initGpioExpander() {
// ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110 corresponds with 0x26 from the docs at // ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110 corresponds with 0x26 from the docs at
// https://gitlab.com/hamishcunningham/unphonelibrary/-/blob/main/unPhone.h?ref_type=heads#L206 // https://gitlab.com/hamishcunningham/unphonelibrary/-/blob/main/unPhone.h?ref_type=heads#L206
if (esp_io_expander_new_i2c_tca95xx_16bit(I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110, &ioExpander) != ESP_OK) { if (esp_io_expander_new_i2c_tca95xx_16bit(I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110, &ioExpander) != ESP_OK) {
LOGGER.error("IO expander init failed"); LOG_E(TAG, "IO expander init failed");
return false; return false;
} }
assert(ioExpander != nullptr); assert(ioExpander != nullptr);
@@ -201,25 +201,25 @@ bool UnPhoneFeatures::initGpioExpander() {
} }
bool UnPhoneFeatures::init() { bool UnPhoneFeatures::init() {
LOGGER.info("init"); LOG_I(TAG, "init");
if (!initGpioExpander()) { if (!initGpioExpander()) {
LOGGER.error("GPIO expander init failed"); LOG_E(TAG, "GPIO expander init failed");
return false; return false;
} }
if (!initNavButtons()) { if (!initNavButtons()) {
LOGGER.error("Input pin init failed"); LOG_E(TAG, "Input pin init failed");
return false; return false;
} }
if (!initOutputPins()) { if (!initOutputPins()) {
LOGGER.error("Output pin init failed"); LOG_E(TAG, "Output pin init failed");
return false; return false;
} }
if (!initPowerSwitch()) { if (!initPowerSwitch()) {
LOGGER.error("Power button init failed"); LOG_E(TAG, "Power button init failed");
return false; return false;
} }
@@ -231,7 +231,7 @@ void UnPhoneFeatures::printInfo() const {
batteryManagement->printInfo(); batteryManagement->printInfo();
bool backlight_power; bool backlight_power;
const char* backlight_power_state = getBacklightPower(backlight_power) && backlight_power ? "on" : "off"; const char* backlight_power_state = getBacklightPower(backlight_power) && backlight_power ? "on" : "off";
LOGGER.info("Backlight: {}", backlight_power_state); LOG_I(TAG, "Backlight: %s", backlight_power_state);
} }
bool UnPhoneFeatures::setRgbLed(bool red, bool green, bool blue) const { bool UnPhoneFeatures::setRgbLed(bool red, bool green, bool blue) const {
@@ -286,11 +286,11 @@ void UnPhoneFeatures::turnPeripheralsOff() const {
bool UnPhoneFeatures::setShipping(bool on) const { bool UnPhoneFeatures::setShipping(bool on) const {
if (on) { if (on) {
LOGGER.warn("setShipping: on"); LOG_W(TAG, "setShipping: on");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Disabled); batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Disabled);
batteryManagement->setBatFetOn(false); batteryManagement->setBatFetOn(false);
} else { } else {
LOGGER.warn("setShipping: off"); LOG_W(TAG, "setShipping: off");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s); batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s);
batteryManagement->setBatFetOn(true); batteryManagement->setBatFetOn(true);
} }
@@ -2,19 +2,19 @@
#include "Touch.h" #include "Touch.h"
#include <UnPhoneFeatures.h> #include <UnPhoneFeatures.h>
#include <Tactility/Logger.h>
#include <hx8357/disp_spi.h> #include <hx8357/disp_spi.h>
#include <hx8357/hx8357.h> #include <hx8357/hx8357.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("Hx8357Display"); constexpr auto* TAG = "Hx8357Display";
constexpr auto BUFFER_SIZE = (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_DRAW_BUFFER_HEIGHT * LV_COLOR_DEPTH / 8); constexpr auto BUFFER_SIZE = (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_DRAW_BUFFER_HEIGHT * LV_COLOR_DEPTH / 8);
extern std::shared_ptr<UnPhoneFeatures> unPhoneFeatures; extern std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
bool Hx8357Display::start() { bool Hx8357Display::start() {
LOGGER.info("start"); LOG_I(TAG, "start");
disp_spi_add_device(SPI2_HOST); disp_spi_add_device(SPI2_HOST);
@@ -27,16 +27,16 @@ bool Hx8357Display::start() {
} }
bool Hx8357Display::stop() { bool Hx8357Display::stop() {
LOGGER.info("stop"); LOG_I(TAG, "stop");
disp_spi_remove_device(); disp_spi_remove_device();
return true; return true;
} }
bool Hx8357Display::startLvgl() { bool Hx8357Display::startLvgl() {
LOGGER.info("startLvgl"); LOG_I(TAG, "startLvgl");
if (lvglDisplay != nullptr) { if (lvglDisplay != nullptr) {
LOGGER.warn("LVGL was already started"); LOG_W(TAG, "LVGL was already started");
return false; return false;
} }
@@ -59,7 +59,7 @@ bool Hx8357Display::startLvgl() {
lv_display_set_flush_cb(lvglDisplay, hx8357_flush); lv_display_set_flush_cb(lvglDisplay, hx8357_flush);
if (lvglDisplay == nullptr) { if (lvglDisplay == nullptr) {
LOGGER.info("Failed"); LOG_I(TAG, "Failed");
return false; return false;
} }
@@ -74,10 +74,10 @@ bool Hx8357Display::startLvgl() {
} }
bool Hx8357Display::stopLvgl() { bool Hx8357Display::stopLvgl() {
LOGGER.info("stopLvgl"); LOG_I(TAG, "stopLvgl");
if (lvglDisplay == nullptr) { if (lvglDisplay == nullptr) {
LOGGER.warn("LVGL was already stopped"); LOG_W(TAG, "LVGL was already stopped");
return false; return false;
} }
@@ -86,7 +86,7 @@ bool Hx8357Display::stopLvgl() {
auto touch_device = getTouchDevice(); auto touch_device = getTouchDevice();
if (touch_device != nullptr && touch_device->getLvglIndev() != nullptr) { if (touch_device != nullptr && touch_device->getLvglIndev() != nullptr) {
LOGGER.info("Stopping touch device"); LOG_I(TAG, "Stopping touch device");
touch_device->stopLvgl(); touch_device->stopLvgl();
} }
@@ -102,7 +102,7 @@ bool Hx8357Display::stopLvgl() {
std::shared_ptr<tt::hal::touch::TouchDevice> Hx8357Display::getTouchDevice() { std::shared_ptr<tt::hal::touch::TouchDevice> Hx8357Display::getTouchDevice() {
if (touchDevice == nullptr) { if (touchDevice == nullptr) {
touchDevice = std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(createTouch()); touchDevice = std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(createTouch());
LOGGER.info("Created touch device"); LOG_I(TAG, "Created touch device");
} }
return touchDevice; return touchDevice;
@@ -1,5 +1,6 @@
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/TactilityCore.h> #include <Tactility/TactilityCore.h>
#include <tactility/log.h>
#include <driver/ledc.h> #include <driver/ledc.h>
constexpr auto* TAG = "Waveshare"; constexpr auto* TAG = "Waveshare";
@@ -38,7 +39,7 @@ void initBacklight() {
} }
bool initBoot() { bool initBoot() {
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START); LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
initBacklight(); initBacklight();
return true; return true;
} }
@@ -1,12 +1,11 @@
#include "Jd9853Display.h" #include "Jd9853Display.h"
#include <Tactility/Logger.h>
#include <esp_lcd_jd9853.h> #include <esp_lcd_jd9853.h>
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("JD9853"); constexpr auto* TAG = "JD9853";
bool Jd9853Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool Jd9853Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
const esp_lcd_panel_io_spi_config_t panel_io_config = { const esp_lcd_panel_io_spi_config_t panel_io_config = {
@@ -54,42 +53,42 @@ bool Jd9853Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
}; };
if (esp_lcd_new_panel_jd9853(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_jd9853(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY"); LOG_E(TAG, "Failed to swap XY");
return false; return false;
} }
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
if (esp_lcd_panel_set_gap(panelHandle, 34, 0) != ESP_OK) { if (esp_lcd_panel_set_gap(panelHandle, 34, 0) != ESP_OK) {
LOGGER.error("Failed to set panel gap"); LOG_E(TAG, "Failed to set panel gap");
return false; return false;
} }
@@ -157,6 +156,6 @@ void Jd9853Display::setGammaCurve(uint8_t index) {
}; };
if (esp_lcd_panel_io_tx_param(getIoHandle() , LCD_CMD_GAMSET, param, 1) != ESP_OK) { if (esp_lcd_panel_io_tx_param(getIoHandle() , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
LOGGER.error("Failed to set gamma"); LOG_E(TAG, "Failed to set gamma");
} }
} }
+5 -5
View File
@@ -1,7 +1,7 @@
#include "Bq24295.h" #include "Bq24295.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("BQ24295"); constexpr auto* TAG = "BQ24295";
/** Reference: /** Reference:
* https://www.ti.com/lit/ds/symlink/bq24295.pdf * https://www.ti.com/lit/ds/symlink/bq24295.pdf
@@ -50,7 +50,7 @@ bool Bq24295::setWatchDogTimer(WatchDogTimer in) const {
uint8_t bits_to_set = 0b00110000 & static_cast<uint8_t>(in); uint8_t bits_to_set = 0b00110000 & static_cast<uint8_t>(in);
uint8_t value_cleared = value & 0b11001111; uint8_t value_cleared = value & 0b11001111;
uint8_t to_set = bits_to_set | value_cleared; uint8_t to_set = bits_to_set | value_cleared;
LOGGER.info("WatchDogTimer: {:02x} -> {:02x}", value, to_set); LOG_I(TAG, "WatchDogTimer: %02X -> %02X", value, to_set);
return writeRegister8(registers::CHARGE_TERMINATION, to_set); return writeRegister8(registers::CHARGE_TERMINATION, to_set);
} }
@@ -96,9 +96,9 @@ bool Bq24295::getVersion(uint8_t& value) const {
void Bq24295::printInfo() const { void Bq24295::printInfo() const {
uint8_t version, status, charge_termination; uint8_t version, status, charge_termination;
if (getStatus(status) && getVersion(version) && readChargeTermination(charge_termination)) { if (getStatus(status) && getVersion(version) && readChargeTermination(charge_termination)) {
LOGGER.info("Version {}, status {:02x}, charge termination {:02x}", version, status, charge_termination); LOG_I(TAG, "Version %d, status %02X, charge termination %02X", version, status, charge_termination);
} else { } else {
LOGGER.error("Failed to retrieve version and/or status"); LOG_E(TAG, "Failed to retrieve version and/or status");
} }
} }
+4 -4
View File
@@ -1,15 +1,15 @@
#include "Bq25896.h" #include "Bq25896.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("BQ25896"); constexpr auto* TAG = "BQ25896";
void Bq25896::powerOff() { void Bq25896::powerOff() {
LOGGER.info("Power off"); LOG_I(TAG, "Power off");
bitOn(0x09, BIT(5)); bitOn(0x09, BIT(5));
} }
void Bq25896::powerOn() { void Bq25896::powerOn() {
LOGGER.info("Power on"); LOG_I(TAG, "Power on");
bitOff(0x09, BIT(5)); bitOff(0x09, BIT(5));
} }
+12 -12
View File
@@ -1,9 +1,9 @@
#include "Bq27220.h" #include "Bq27220.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include "esp_sleep.h" #include "esp_sleep.h"
static const auto LOGGER = tt::Logger("BQ27220"); constexpr auto* TAG = "BQ27220";
#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a))) #define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
@@ -93,14 +93,14 @@ bool Bq27220::configureCapacity(uint16_t designCapacity, uint16_t fullChargeCapa
return performConfigUpdate([this, designCapacity, fullChargeCapacity]() { return performConfigUpdate([this, designCapacity, fullChargeCapacity]() {
// Set the design capacity // Set the design capacity
if (!writeConfig16(registers::ROM_DESIGN_CAPACITY, designCapacity)) { if (!writeConfig16(registers::ROM_DESIGN_CAPACITY, designCapacity)) {
LOGGER.error("Failed to set design capacity!"); LOG_E(TAG, "Failed to set design capacity!");
return false; return false;
} }
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
// Set full charge capacity // Set full charge capacity
if (!writeConfig16(registers::ROM_FULL_CHARGE_CAPACITY, fullChargeCapacity)) { if (!writeConfig16(registers::ROM_FULL_CHARGE_CAPACITY, fullChargeCapacity)) {
LOGGER.error("Failed to set full charge capacity!"); LOG_E(TAG, "Failed to set full charge capacity!");
return false; return false;
} }
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
@@ -260,7 +260,7 @@ bool Bq27220::sendSubCommand(uint16_t subCmd, bool waitConfirm)
} }
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
} }
LOGGER.error("Subcommand 0x{:04X} failed!", subCmd); LOG_E(TAG, "Subcommand 0x%04X failed!", subCmd);
return false; return false;
} }
@@ -298,28 +298,28 @@ bool Bq27220::configPreamble(bool &isSealed) {
// Check access settings // Check access settings
if(!getOperationStatus(status)) { if(!getOperationStatus(status)) {
LOGGER.error("Cannot read initial operation status!"); LOG_E(TAG, "Cannot read initial operation status!");
return false; return false;
} }
if (status.reg.SEC == OperationStatusSecSealed) { if (status.reg.SEC == OperationStatusSecSealed) {
isSealed = true; isSealed = true;
if (!unsealDevice()) { if (!unsealDevice()) {
LOGGER.error("Unsealing device failure!"); LOG_E(TAG, "Unsealing device failure!");
return false; return false;
} }
} }
if (status.reg.SEC != OperationStatusSecFull) { if (status.reg.SEC != OperationStatusSecFull) {
if (!unsealFullAccess()) { if (!unsealFullAccess()) {
LOGGER.error("Unsealing full access failure!"); LOG_E(TAG, "Unsealing full access failure!");
return false; return false;
} }
} }
// Send ENTER_CFG_UPDATE command (0x0090) // Send ENTER_CFG_UPDATE command (0x0090)
if (!sendSubCommand(registers::SUBCMD_ENTER_CFG_UPDATE)) { if (!sendSubCommand(registers::SUBCMD_ENTER_CFG_UPDATE)) {
LOGGER.error("Config Update Subcommand failure!"); LOG_E(TAG, "Config Update Subcommand failure!");
} }
// Confirm CFUPDATE mode by polling the OperationStatus() register until Bit 2 is set. // Confirm CFUPDATE mode by polling the OperationStatus() register until Bit 2 is set.
@@ -333,7 +333,7 @@ bool Bq27220::configPreamble(bool &isSealed) {
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
} }
if (!isConfigUpdate) { if (!isConfigUpdate) {
LOGGER.error("Update Mode timeout, maybe the access key for full permissions is invalid!"); LOG_E(TAG, "Update Mode timeout, maybe the access key for full permissions is invalid!");
return false; return false;
} }
@@ -357,13 +357,13 @@ bool Bq27220::configEpilouge(const bool isSealed) {
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
} }
if (timeout == 0) { if (timeout == 0) {
LOGGER.error("Timed out waiting to exit update mode."); LOG_E(TAG, "Timed out waiting to exit update mode.");
return false; return false;
} }
// If the device was previously in SEALED state, return to SEALED mode by sending the Control(0x0030) subcommand // If the device was previously in SEALED state, return to SEALED mode by sending the Control(0x0030) subcommand
if (isSealed) { if (isSealed) {
LOGGER.debug("Restore Safe Mode!"); LOG_D(TAG, "Restore Safe Mode!");
exitSealMode(); exitSealMode();
} }
return true; return true;
+10 -10
View File
@@ -1,11 +1,11 @@
#include "ButtonControl.h" #include "ButtonControl.h"
#include <Tactility/app/App.h> #include <Tactility/app/App.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ButtonControl"); constexpr auto* TAG = "ButtonControl";
ButtonControl::ButtonControl(const std::vector<PinConfiguration>& pinConfigurations) ButtonControl::ButtonControl(const std::vector<PinConfiguration>& pinConfigurations)
: buttonQueue(20, sizeof(ButtonEvent)), : buttonQueue(20, sizeof(ButtonEvent)),
@@ -34,7 +34,7 @@ ButtonControl::ButtonControl(const std::vector<PinConfiguration>& pinConfigurati
}; };
esp_err_t err = gpio_config(&io_conf); esp_err_t err = gpio_config(&io_conf);
if (err != ESP_OK) { if (err != ESP_OK) {
LOGGER.error("Failed to configure GPIO {}: {}", static_cast<int>(pin), esp_err_to_name(err)); LOG_E(TAG, "Failed to configure GPIO %d: %s", static_cast<int>(pin), esp_err_to_name(err));
continue; continue;
} }
@@ -103,10 +103,10 @@ void ButtonControl::updatePin(std::vector<PinConfiguration>::const_reference con
if (state.pressState) { if (state.pressState) {
auto time_passed = now - state.pressStartTime; auto time_passed = now - state.pressStartTime;
if (time_passed < 500) { if (time_passed < 500) {
LOGGER.info("Short press ({}ms)", time_passed); LOG_I(TAG, "Short press (%dms)", (int)time_passed);
state.triggerShortPress = true; state.triggerShortPress = true;
} else { } else {
LOGGER.info("Long press ({}ms)", time_passed); LOG_I(TAG, "Long press (%dms)", (int)time_passed);
state.triggerLongPress = true; state.triggerLongPress = true;
} }
state.pressState = false; state.pressState = false;
@@ -131,7 +131,7 @@ void ButtonControl::driverThreadMain() {
if (event.pin == GPIO_NUM_NC) { if (event.pin == GPIO_NUM_NC) {
break; // shutdown sentinel break; // shutdown sentinel
} }
LOGGER.info("Pin {} {}", static_cast<int>(event.pin), event.pressed ? "down" : "up"); LOG_I(TAG, "Pin %d %s", static_cast<int>(event.pin), event.pressed ? "down" : "up");
if (mutex.lock(portMAX_DELAY)) { if (mutex.lock(portMAX_DELAY)) {
// Update ALL PinConfiguration entries that share this physical pin. // Update ALL PinConfiguration entries that share this physical pin.
for (size_t i = 0; i < pinConfigurations.size(); i++) { for (size_t i = 0; i < pinConfigurations.size(); i++) {
@@ -145,11 +145,11 @@ void ButtonControl::driverThreadMain() {
} }
bool ButtonControl::startThread() { bool ButtonControl::startThread() {
LOGGER.info("Start"); LOG_I(TAG, "Start");
esp_err_t err = gpio_install_isr_service(ESP_INTR_FLAG_IRAM); esp_err_t err = gpio_install_isr_service(ESP_INTR_FLAG_IRAM);
if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) { if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
LOGGER.error("Failed to install GPIO ISR service: {}", esp_err_to_name(err)); LOG_E(TAG, "Failed to install GPIO ISR service: %s", esp_err_to_name(err));
return false; return false;
} }
@@ -159,7 +159,7 @@ bool ButtonControl::startThread() {
for (auto& arg : isrArgs) { for (auto& arg : isrArgs) {
err = gpio_isr_handler_add(arg.pin, gpioIsrHandler, &arg); err = gpio_isr_handler_add(arg.pin, gpioIsrHandler, &arg);
if (err != ESP_OK) { if (err != ESP_OK) {
LOGGER.error("Failed to add ISR for GPIO {}: {}", static_cast<int>(arg.pin), esp_err_to_name(err)); LOG_E(TAG, "Failed to add ISR for GPIO %d: %s", static_cast<int>(arg.pin), esp_err_to_name(err));
for (int i = 0; i < handlersAdded; i++) { for (int i = 0; i < handlersAdded; i++) {
gpio_isr_handler_remove(isrArgs[i].pin); gpio_isr_handler_remove(isrArgs[i].pin);
} }
@@ -178,7 +178,7 @@ bool ButtonControl::startThread() {
} }
void ButtonControl::stopThread() { void ButtonControl::stopThread() {
LOGGER.info("Stop"); LOG_I(TAG, "Stop");
for (const auto& arg : isrArgs) { for (const auto& arg : isrArgs) {
gpio_isr_handler_remove(arg.pin); gpio_isr_handler_remove(arg.pin);
+5 -5
View File
@@ -1,9 +1,9 @@
#include "Drv2605.h" #include "Drv2605.h"
#include <tactility/check.h> #include <tactility/check.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("DRV2605"); constexpr auto* TAG = "DRV2605";
Drv2605::Drv2605(::Device* controller, bool autoPlayStartupBuzz) : I2cDevice(controller, ADDRESS), autoPlayStartupBuzz(autoPlayStartupBuzz) { Drv2605::Drv2605(::Device* controller, bool autoPlayStartupBuzz) : I2cDevice(controller, ADDRESS), autoPlayStartupBuzz(autoPlayStartupBuzz) {
check(init(), "Initialize DRV2605"); check(init(), "Initialize DRV2605");
@@ -17,14 +17,14 @@ Drv2605::Drv2605(::Device* controller, bool autoPlayStartupBuzz) : I2cDevice(con
bool Drv2605::init() { bool Drv2605::init() {
uint8_t status; uint8_t status;
if (!readRegister8(static_cast<uint8_t>(Register::Status), status)) { if (!readRegister8(static_cast<uint8_t>(Register::Status), status)) {
LOGGER.error("Failed to read status"); LOG_E(TAG, "Failed to read status");
return false; return false;
} }
status >>= 5; status >>= 5;
ChipId chip_id = static_cast<ChipId>(status); ChipId chip_id = static_cast<ChipId>(status);
if (chip_id != ChipId::DRV2604 && chip_id != ChipId::DRV2604L && chip_id != ChipId::DRV2605 && chip_id != ChipId::DRV2605L) { if (chip_id != ChipId::DRV2604 && chip_id != ChipId::DRV2604L && chip_id != ChipId::DRV2605 && chip_id != ChipId::DRV2605L) {
LOGGER.error("Unknown chip id {:02x}", static_cast<uint8_t>(chip_id)); LOG_E(TAG, "Unknown chip id %02X", static_cast<uint8_t>(chip_id));
return false; return false;
} }
@@ -39,7 +39,7 @@ bool Drv2605::init() {
uint8_t feedback; uint8_t feedback;
if (!readRegister(Register::Feedback, feedback)) { if (!readRegister(Register::Feedback, feedback)) {
LOGGER.error("Failed to read feedback"); LOG_E(TAG, "Failed to read feedback");
return false; return false;
} }
@@ -1,13 +1,13 @@
#include "EspLcdDisplay.h" #include "EspLcdDisplay.h"
#include "EspLcdDisplayDriver.h" #include "EspLcdDisplayDriver.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <Tactility/hal/touch/TouchDevice.h> #include <Tactility/hal/touch/TouchDevice.h>
#include <cassert> #include <cassert>
#include <esp_lvgl_port_disp.h> #include <esp_lvgl_port_disp.h>
static const auto LOGGER = tt::Logger("EspLcdDisplay"); constexpr auto* TAG = "EspLcdDisplay";
EspLcdDisplay::~EspLcdDisplay() { EspLcdDisplay::~EspLcdDisplay() {
check( check(
@@ -18,12 +18,12 @@ EspLcdDisplay::~EspLcdDisplay() {
bool EspLcdDisplay::start() { bool EspLcdDisplay::start() {
if (!createIoHandle(ioHandle)) { if (!createIoHandle(ioHandle)) {
LOGGER.error("Failed to create IO handle"); LOG_E(TAG, "Failed to create IO handle");
return false; return false;
} }
if (!createPanelHandle(ioHandle, panelHandle)) { if (!createPanelHandle(ioHandle, panelHandle)) {
LOGGER.error("Failed to create panel handle"); LOG_E(TAG, "Failed to create panel handle");
esp_lcd_panel_io_del(ioHandle); esp_lcd_panel_io_del(ioHandle);
return false; return false;
} }
@@ -46,7 +46,7 @@ bool EspLcdDisplay::stop() {
} }
if (displayDriver != nullptr && displayDriver.use_count() > 1) { if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use."); LOG_W(TAG, "DisplayDriver is still in use.");
} }
return true; return true;
@@ -56,7 +56,7 @@ bool EspLcdDisplay::startLvgl() {
assert(lvglDisplay == nullptr); assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) { if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use."); LOG_W(TAG, "DisplayDriver is still in use.");
} }
auto lvgl_port_config = getLvglPortDisplayConfig(ioHandle, panelHandle); auto lvgl_port_config = getLvglPortDisplayConfig(ioHandle, panelHandle);
+14 -14
View File
@@ -1,13 +1,13 @@
#include "EspLcdDisplayV2.h" #include "EspLcdDisplayV2.h"
#include "EspLcdDisplayDriver.h" #include "EspLcdDisplayDriver.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <Tactility/hal/touch/TouchDevice.h> #include <Tactility/hal/touch/TouchDevice.h>
#include <cassert> #include <cassert>
#include <esp_lvgl_port_disp.h> #include <esp_lvgl_port_disp.h>
static const auto LOGGER = tt::Logger("EspLcdDispV2"); constexpr auto* TAG = "EspLcdDispV2";
inline unsigned int getBufferSize(const std::shared_ptr<EspLcdConfiguration>& configuration) { inline unsigned int getBufferSize(const std::shared_ptr<EspLcdConfiguration>& configuration) {
if (configuration->bufferSize != DEFAULT_BUFFER_SIZE) { if (configuration->bufferSize != DEFAULT_BUFFER_SIZE) {
@@ -26,17 +26,17 @@ EspLcdDisplayV2::~EspLcdDisplayV2() {
bool EspLcdDisplayV2::applyConfiguration() const { bool EspLcdDisplayV2::applyConfiguration() const {
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
@@ -45,28 +45,28 @@ bool EspLcdDisplayV2::applyConfiguration() const {
int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY; int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY;
bool should_set_gap = gap_x != 0 || gap_y != 0; bool should_set_gap = gap_x != 0 || gap_y != 0;
if (should_set_gap && esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) { if (should_set_gap && esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) {
LOGGER.error("Failed to set panel gap"); LOG_E(TAG, "Failed to set panel gap");
return false; return false;
} }
if (configuration->swapXY && esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (configuration->swapXY && esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY "); LOG_E(TAG, "Failed to swap XY ");
return false; return false;
} }
bool should_set_mirror = configuration->mirrorX || configuration->mirrorY; bool should_set_mirror = configuration->mirrorX || configuration->mirrorY;
if (should_set_mirror && esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (should_set_mirror && esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
@@ -75,14 +75,14 @@ bool EspLcdDisplayV2::applyConfiguration() const {
bool EspLcdDisplayV2::start() { bool EspLcdDisplayV2::start() {
if (!createIoHandle(ioHandle)) { if (!createIoHandle(ioHandle)) {
LOGGER.error("Failed to create IO handle"); LOG_E(TAG, "Failed to create IO handle");
return false; return false;
} }
esp_lcd_panel_dev_config_t panel_config = createPanelConfig(configuration, configuration->resetPin); esp_lcd_panel_dev_config_t panel_config = createPanelConfig(configuration, configuration->resetPin);
if (!createPanelHandle(ioHandle, panel_config, panelHandle)) { if (!createPanelHandle(ioHandle, panel_config, panelHandle)) {
LOGGER.error("Failed to create panel handle"); LOG_E(TAG, "Failed to create panel handle");
esp_lcd_panel_io_del(ioHandle); esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr; ioHandle = nullptr;
return false; return false;
@@ -114,7 +114,7 @@ bool EspLcdDisplayV2::stop() {
} }
if (displayDriver != nullptr && displayDriver.use_count() > 1) { if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use."); LOG_W(TAG, "DisplayDriver is still in use.");
} }
return true; return true;
@@ -124,7 +124,7 @@ bool EspLcdDisplayV2::startLvgl() {
assert(lvglDisplay == nullptr); assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) { if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use."); LOG_W(TAG, "DisplayDriver is still in use.");
} }
auto lvgl_port_config = getLvglPortDisplayConfig(configuration, ioHandle, panelHandle); auto lvgl_port_config = getLvglPortDisplayConfig(configuration, ioHandle, panelHandle);
@@ -1,12 +1,12 @@
#include "EspLcdSpiDisplay.h" #include "EspLcdSpiDisplay.h"
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("EspLcdSpiDisplay"); constexpr auto* TAG = "EspLcdSpiDisplay";
bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
LOGGER.info("createIoHandle"); LOG_I(TAG, "createIoHandle");
const esp_lcd_panel_io_spi_config_t panel_io_config = { const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = spiConfiguration->csPin, .cs_gpio_num = spiConfiguration->csPin,
@@ -33,7 +33,7 @@ bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
}; };
if (esp_lcd_new_panel_io_spi(spiConfiguration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) { if (esp_lcd_new_panel_io_spi(spiConfiguration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
@@ -65,6 +65,6 @@ void EspLcdSpiDisplay::setGammaCurve(uint8_t index) {
auto io_handle = getIoHandle(); auto io_handle = getIoHandle();
assert(io_handle != nullptr); assert(io_handle != nullptr);
if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) { if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) {
LOGGER.error("Failed to set gamma"); LOG_E(TAG, "Failed to set gamma");
} }
} }
+7 -7
View File
@@ -2,21 +2,21 @@
#include <EspLcdTouchDriver.h> #include <EspLcdTouchDriver.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lvgl_port_touch.h> #include <esp_lvgl_port_touch.h>
static const auto LOGGER = tt::Logger("EspLcdTouch"); constexpr auto* TAG = "EspLcdTouch";
bool EspLcdTouch::start() { bool EspLcdTouch::start() {
if (!createIoHandle(ioHandle) != ESP_OK) { if (!createIoHandle(ioHandle) != ESP_OK) {
LOGGER.error("Touch IO failed"); LOG_E(TAG, "Touch IO failed");
return false; return false;
} }
config = createEspLcdTouchConfig(); config = createEspLcdTouchConfig();
if (!createTouchHandle(ioHandle, config, touchHandle)) { if (!createTouchHandle(ioHandle, config, touchHandle)) {
LOGGER.error("Driver init failed"); LOG_E(TAG, "Driver init failed");
esp_lcd_panel_io_del(ioHandle); esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr; ioHandle = nullptr;
return false; return false;
@@ -49,7 +49,7 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
} }
if (touchDriver != nullptr && touchDriver.use_count() > 1) { if (touchDriver != nullptr && touchDriver.use_count() > 1) {
LOGGER.warn("TouchDriver is still in use."); LOG_W(TAG, "TouchDriver is still in use.");
} }
const lvgl_port_touch_cfg_t touch_cfg = { const lvgl_port_touch_cfg_t touch_cfg = {
@@ -57,10 +57,10 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
.handle = touchHandle, .handle = touchHandle,
}; };
LOGGER.info("Adding touch to LVGL"); LOG_I(TAG, "Adding touch to LVGL");
lvglDevice = lvgl_port_add_touch(&touch_cfg); lvglDevice = lvgl_port_add_touch(&touch_cfg);
if (lvglDevice == nullptr) { if (lvglDevice == nullptr) {
LOGGER.error("Adding touch failed"); LOG_E(TAG, "Adding touch failed");
return false; return false;
} }
@@ -1,12 +1,12 @@
#include "EspLcdTouchDriver.h" #include "EspLcdTouchDriver.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("EspLcdTouchDriver"); constexpr auto* TAG = "EspLcdTouchDriver";
bool EspLcdTouchDriver::getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* _Nullable strength, uint8_t* pointCount, uint8_t maxPointCount) { bool EspLcdTouchDriver::getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* _Nullable strength, uint8_t* pointCount, uint8_t maxPointCount) {
if (esp_lcd_touch_read_data(handle) != ESP_OK) { if (esp_lcd_touch_read_data(handle) != ESP_OK) {
LOGGER.error("Read data failed"); LOG_E(TAG, "Read data failed");
return false; return false;
} }
return esp_lcd_touch_get_coordinates(handle, x, y, strength, pointCount, maxPointCount); return esp_lcd_touch_get_coordinates(handle, x, y, strength, pointCount, maxPointCount);
@@ -1,7 +1,7 @@
#include "ChargeFromAdcVoltage.h" #include "ChargeFromAdcVoltage.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("ChargeFromAdcV"); constexpr auto* TAG = "ChargeFromAdcV";
constexpr auto MAX_VOLTAGE_SAMPLES = 15; constexpr auto MAX_VOLTAGE_SAMPLES = 15;
ChargeFromAdcVoltage::ChargeFromAdcVoltage( ChargeFromAdcVoltage::ChargeFromAdcVoltage(
@@ -10,12 +10,12 @@ ChargeFromAdcVoltage::ChargeFromAdcVoltage(
float voltageMax float voltageMax
) : configuration(configuration), chargeFromVoltage(voltageMin, voltageMax) { ) : configuration(configuration), chargeFromVoltage(voltageMin, voltageMax) {
if (adc_oneshot_new_unit(&configuration.adcConfig, &adcHandle) != ESP_OK) { if (adc_oneshot_new_unit(&configuration.adcConfig, &adcHandle) != ESP_OK) {
LOGGER.error("ADC config failed"); LOG_E(TAG, "ADC config failed");
return; return;
} }
if (adc_oneshot_config_channel(adcHandle, configuration.adcChannel, &configuration.adcChannelConfig) != ESP_OK) { if (adc_oneshot_config_channel(adcHandle, configuration.adcChannel, &configuration.adcChannelConfig) != ESP_OK) {
LOGGER.error("ADC channel config failed"); LOG_E(TAG, "ADC channel config failed");
adc_oneshot_del_unit(adcHandle); adc_oneshot_del_unit(adcHandle);
adcHandle = nullptr; adcHandle = nullptr;
@@ -36,12 +36,10 @@ bool ChargeFromAdcVoltage::readBatteryVoltageOnce(uint32_t& output) const {
int raw; int raw;
if (adc_oneshot_read(adcHandle, configuration.adcChannel, &raw) == ESP_OK) { if (adc_oneshot_read(adcHandle, configuration.adcChannel, &raw) == ESP_OK) {
output = configuration.adcMultiplier * ((1000.f * configuration.adcRefVoltage) / 4096.f) * (float)raw; output = configuration.adcMultiplier * ((1000.f * configuration.adcRefVoltage) / 4096.f) * (float)raw;
if (LOGGER.isLoggingVerbose()) { LOG_V(TAG, "Raw = %d, voltage = %u", raw, (unsigned)output);
LOGGER.verbose("Raw = {}, voltage = {}", raw, output);
}
return true; return true;
} else { } else {
LOGGER.error("Read failed"); LOG_E(TAG, "Read failed");
return false; return false;
} }
} }
@@ -1,9 +1,9 @@
#include "ChargeFromVoltage.h" #include "ChargeFromVoltage.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <algorithm> #include <algorithm>
const static auto LOGGER = tt::Logger("ChargeFromVoltage"); constexpr auto* TAG = "ChargeFromVoltage";
uint8_t ChargeFromVoltage::estimateCharge(uint32_t milliVolt) const { uint8_t ChargeFromVoltage::estimateCharge(uint32_t milliVolt) const {
const float volts = std::min((float)milliVolt / 1000.f, batteryVoltageMax); const float volts = std::min((float)milliVolt / 1000.f, batteryVoltageMax);
@@ -13,6 +13,6 @@ uint8_t ChargeFromVoltage::estimateCharge(uint32_t milliVolt) const {
const float voltage_percentage = (volts - batteryVoltageMin) / (batteryVoltageMax - batteryVoltageMin); const float voltage_percentage = (volts - batteryVoltageMin) / (batteryVoltageMax - batteryVoltageMin);
const float voltage_factor = std::min(1.0f, voltage_percentage); const float voltage_factor = std::min(1.0f, voltage_percentage);
const auto charge_level = (uint8_t) (voltage_factor * 100.f); const auto charge_level = (uint8_t) (voltage_factor * 100.f);
LOGGER.debug("mV = {}, scaled = {}, factor = {:.2f}, result = {}", milliVolt, volts, voltage_factor, charge_level); LOG_D(TAG, "mV = %u, scaled = %f, factor = %.2f, result = %d", (unsigned)milliVolt, volts, voltage_factor, charge_level);
return charge_level; return charge_level;
} }
+11 -11
View File
@@ -1,15 +1,15 @@
#include "Gc9a01Display.h" #include "Gc9a01Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lcd_gc9a01.h> #include <esp_lcd_gc9a01.h>
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("GC9A01"); constexpr auto* TAG = "GC9A01";
bool Gc9a01Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool Gc9a01Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
LOGGER.info("Starting"); LOG_I(TAG, "Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = { const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = configuration->csPin, .cs_gpio_num = configuration->csPin,
@@ -36,7 +36,7 @@ bool Gc9a01Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
}; };
if (esp_lcd_new_panel_io_spi(configuration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) { if (esp_lcd_new_panel_io_spi(configuration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
@@ -56,37 +56,37 @@ bool Gc9a01Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
}; };
if (esp_lcd_new_panel_gc9a01(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_gc9a01(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY "); LOG_E(TAG, "Failed to swap XY ");
return false; return false;
} }
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
+4 -4
View File
@@ -1,6 +1,6 @@
#include "Gt911Touch.h" #include "Gt911Touch.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lcd_io_i2c.h> #include <esp_lcd_io_i2c.h>
#include <esp_lcd_touch_gt911.h> #include <esp_lcd_touch_gt911.h>
@@ -11,7 +11,7 @@
#include <tactility/drivers/esp32_i2c_master.h> #include <tactility/drivers/esp32_i2c_master.h>
#include <tactility/drivers/i2c_controller.h> #include <tactility/drivers/i2c_controller.h>
static const auto LOGGER = tt::Logger("GT911"); constexpr auto* TAG = "GT911";
bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG(); esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
@@ -23,7 +23,7 @@ bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
} else if (i2c_controller_has_device_at_address(i2c, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP, pdMS_TO_TICKS(10)) == ERROR_NONE) { } else if (i2c_controller_has_device_at_address(i2c, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP, pdMS_TO_TICKS(10)) == ERROR_NONE) {
io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP; io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP;
} else { } else {
LOGGER.error("No device found on I2C bus"); LOG_E(TAG, "No device found on I2C bus");
return false; return false;
} }
@@ -38,7 +38,7 @@ bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
return esp_lcd_new_panel_io_i2c_v2(bus, &io_config, &outHandle) == ESP_OK; return esp_lcd_new_panel_io_i2c_v2(bus, &io_config, &outHandle) == ESP_OK;
} }
LOGGER.error("Unsupported I2C driver"); LOG_E(TAG, "Unsupported I2C driver");
return false; return false;
} }
+9 -9
View File
@@ -1,12 +1,12 @@
#include "Ili9488Display.h" #include "Ili9488Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lcd_ili9488.h> #include <esp_lcd_ili9488.h>
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ILI9488"); constexpr auto* TAG = "ILI9488";
bool Ili9488Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool Ili9488Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
const esp_lcd_panel_io_spi_config_t panel_io_config = { const esp_lcd_panel_io_spi_config_t panel_io_config = {
@@ -50,37 +50,37 @@ bool Ili9488Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
}; };
if (esp_lcd_new_panel_ili9488(ioHandle, &panel_config, configuration->bufferSize, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_ili9488(ioHandle, &panel_config, configuration->bufferSize, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY "); LOG_E(TAG, "Failed to swap XY ");
return false; return false;
} }
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
+6 -6
View File
@@ -1,8 +1,8 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
static const auto LOGGER = tt::Logger("PwmBacklight"); constexpr auto* TAG = "PwmBacklight";
namespace driver::pwmbacklight { namespace driver::pwmbacklight {
@@ -16,7 +16,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
backlightTimer = timer; backlightTimer = timer;
backlightChannel = channel; backlightChannel = channel;
LOGGER.info("Init"); LOG_I(TAG, "Init");
ledc_timer_config_t ledc_timer = { ledc_timer_config_t ledc_timer = {
.speed_mode = LEDC_LOW_SPEED_MODE, .speed_mode = LEDC_LOW_SPEED_MODE,
.duty_resolution = LEDC_TIMER_8_BIT, .duty_resolution = LEDC_TIMER_8_BIT,
@@ -27,7 +27,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
}; };
if (ledc_timer_config(&ledc_timer) != ESP_OK) { if (ledc_timer_config(&ledc_timer) != ESP_OK) {
LOGGER.error("Timer config failed"); LOG_E(TAG, "Timer config failed");
return false; return false;
} }
@@ -46,7 +46,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
}; };
if (ledc_channel_config(&ledc_channel) != ESP_OK) { if (ledc_channel_config(&ledc_channel) != ESP_OK) {
LOGGER.error("Channel config failed"); LOG_E(TAG, "Channel config failed");
return false; return false;
} }
@@ -57,7 +57,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
bool setBacklightDuty(uint8_t duty) { bool setBacklightDuty(uint8_t duty) {
if (!isBacklightInitialized) { if (!isBacklightInitialized) {
LOGGER.error("Not initialized"); LOG_E(TAG, "Not initialized");
return false; return false;
} }
return ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK && return ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK &&
+12 -12
View File
@@ -2,14 +2,14 @@
#include <tactility/check.h> #include <tactility/check.h>
#include <Tactility/hal/touch/TouchDevice.h> #include <Tactility/hal/touch/TouchDevice.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_lcd_panel_rgb.h> #include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h> #include <esp_lcd_panel_ops.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("RgbDisplay"); constexpr auto* TAG = "RgbDisplay";
RgbDisplay::~RgbDisplay() { RgbDisplay::~RgbDisplay() {
check( check(
@@ -19,35 +19,35 @@ RgbDisplay::~RgbDisplay() {
} }
bool RgbDisplay::start() { bool RgbDisplay::start() {
LOGGER.info("Starting"); LOG_I(TAG, "Starting");
if (esp_lcd_new_rgb_panel(&configuration->panelConfig, &panelHandle) != ESP_OK) { if (esp_lcd_new_rgb_panel(&configuration->panelConfig, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY"); LOG_E(TAG, "Failed to swap XY");
return false; return false;
} }
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
@@ -65,7 +65,7 @@ bool RgbDisplay::stop() {
} }
if (displayDriver != nullptr && displayDriver.use_count() > 1) { if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use."); LOG_W(TAG, "DisplayDriver is still in use.");
} }
auto touch_device = getTouchDevice(); auto touch_device = getTouchDevice();
@@ -81,7 +81,7 @@ bool RgbDisplay::startLvgl() {
assert(lvglDisplay == nullptr); assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) { if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use."); LOG_W(TAG, "DisplayDriver is still in use.");
} }
auto display_config = getLvglPortDisplayConfig(); auto display_config = getLvglPortDisplayConfig();
@@ -94,7 +94,7 @@ bool RgbDisplay::startLvgl() {
}; };
lvglDisplay = lvgl_port_add_disp_rgb(&display_config, &rgb_config); lvglDisplay = lvgl_port_add_disp_rgb(&display_config, &rgb_config);
LOGGER.info("Finished"); LOG_I(TAG, "Finished");
auto touch_device = getTouchDevice(); auto touch_device = getTouchDevice();
if (touch_device != nullptr) { if (touch_device != nullptr) {
+7 -7
View File
@@ -1,6 +1,6 @@
#include "Ssd1306Display.h" #include "Ssd1306Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <esp_lcd_panel_dev.h> #include <esp_lcd_panel_dev.h>
#include <esp_lcd_panel_ssd1306.h> #include <esp_lcd_panel_ssd1306.h>
@@ -10,7 +10,7 @@
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/task.h> #include <freertos/task.h>
static const auto LOGGER = tt::Logger("Ssd1306Display"); constexpr auto* TAG = "Ssd1306Display";
// SSD1306 commands // SSD1306 commands
#define SSD1306_CMD_SET_CLOCK 0xD5 #define SSD1306_CMD_SET_CLOCK 0xD5
@@ -38,7 +38,7 @@ static bool ssd1306_i2c_send_cmd(i2c_port_t port, uint8_t addr, uint8_t cmd) {
uint8_t data[2] = {0x00, cmd}; // 0x00 = command mode uint8_t data[2] = {0x00, cmd}; // 0x00 = command mode
esp_err_t ret = i2c_master_write_to_device(port, addr, data, sizeof(data), pdMS_TO_TICKS(1000)); esp_err_t ret = i2c_master_write_to_device(port, addr, data, sizeof(data), pdMS_TO_TICKS(1000));
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to send command 0x{:02X}: {}", cmd, ret); LOG_E(TAG, "Failed to send command 0x%02X: %d", cmd, (int)ret);
return false; return false;
} }
return true; return true;
@@ -61,7 +61,7 @@ bool Ssd1306Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
}; };
if (esp_lcd_new_panel_io_i2c(static_cast<esp_lcd_i2c_bus_handle_t>(configuration->port), &io_config, &ioHandle) != ESP_OK) { if (esp_lcd_new_panel_io_i2c(static_cast<esp_lcd_i2c_bus_handle_t>(configuration->port), &io_config, &ioHandle) != ESP_OK) {
LOGGER.error("Failed to create IO handle"); LOG_E(TAG, "Failed to create IO handle");
return false; return false;
} }
@@ -106,7 +106,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
#endif #endif
if (esp_lcd_new_panel_ssd1306(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_ssd1306(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
@@ -116,7 +116,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
auto port = configuration->port; auto port = configuration->port;
auto addr = configuration->deviceAddress; auto addr = configuration->deviceAddress;
LOGGER.info("Sending Heltec V3 custom init sequence"); LOG_I(TAG, "Sending Heltec V3 custom init sequence");
// Display off while configuring // Display off while configuring
ssd1306_i2c_send_cmd(port, addr, SSD1306_CMD_DISPLAY_OFF); ssd1306_i2c_send_cmd(port, addr, SSD1306_CMD_DISPLAY_OFF);
@@ -182,7 +182,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
vTaskDelay(pdMS_TO_TICKS(100)); // Let display stabilize vTaskDelay(pdMS_TO_TICKS(100)); // Let display stabilize
LOGGER.info("Heltec V3 display initialized successfully"); LOG_I(TAG, "Heltec V3 display initialized successfully");
return true; return true;
} }
+13 -13
View File
@@ -1,16 +1,16 @@
#include "St7735Display.h" #include "St7735Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lcd_panel_commands.h> #include <esp_lcd_panel_commands.h>
#include <esp_lcd_panel_dev.h> #include <esp_lcd_panel_dev.h>
#include <esp_lcd_st7735.h> #include <esp_lcd_st7735.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ST7735"); constexpr auto* TAG = "ST7735";
bool St7735Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { bool St7735Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
LOGGER.info("Starting"); LOG_I(TAG, "Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = { const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = configuration->csPin, .cs_gpio_num = configuration->csPin,
@@ -37,7 +37,7 @@ bool St7735Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
}; };
if (esp_lcd_new_panel_io_spi(configuration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) { if (esp_lcd_new_panel_io_spi(configuration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
@@ -58,22 +58,22 @@ bool St7735Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
}; };
if (esp_lcd_new_panel_st7735(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_st7735(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
@@ -81,22 +81,22 @@ bool St7735Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
int gap_x = configuration->swapXY ? configuration->gapY : configuration->gapX; int gap_x = configuration->swapXY ? configuration->gapY : configuration->gapX;
int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY; int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY;
if (esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) { if (esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) {
LOGGER.error("Failed to set panel gap"); LOG_E(TAG, "Failed to set panel gap");
return false; return false;
} }
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY "); LOG_E(TAG, "Failed to swap XY ");
return false; return false;
} }
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
@@ -165,6 +165,6 @@ void St7735Display::setGammaCurve(uint8_t index) {
auto io_handle = getIoHandle(); auto io_handle = getIoHandle();
assert(io_handle != nullptr); assert(io_handle != nullptr);
if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) { if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) {
LOGGER.error("Failed to set gamma"); LOG_E(TAG, "Failed to set gamma");
} }
} }
@@ -1,5 +1,5 @@
#include "St7789i8080Display.h" #include "St7789i8080Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <esp_lcd_panel_io.h> #include <esp_lcd_panel_io.h>
#include <esp_lcd_panel_ops.h> #include <esp_lcd_panel_ops.h>
@@ -8,7 +8,7 @@
#include <freertos/task.h> #include <freertos/task.h>
#include <lvgl.h> #include <lvgl.h>
static const auto LOGGER = tt::Logger("St7789i8080Display"); constexpr auto* TAG = "St7789i8080Display";
static St7789i8080Display* g_display_instance = nullptr; static St7789i8080Display* g_display_instance = nullptr;
// ST7789 initialization commands // ST7789 initialization commands
@@ -51,13 +51,13 @@ St7789i8080Display::St7789i8080Display(const Configuration& config)
// Validate configuration // Validate configuration
if (!configuration.isValid()) { if (!configuration.isValid()) {
LOGGER.error("Invalid configuration: resolution must be set"); LOG_E(TAG, "Invalid configuration: resolution must be set");
return; return;
} }
} }
bool St7789i8080Display::createI80Bus() { bool St7789i8080Display::createI80Bus() {
LOGGER.info("Creating I80 bus"); LOG_I(TAG, "Creating I80 bus");
// Create I80 bus configuration // Create I80 bus configuration
esp_lcd_i80_bus_config_t bus_cfg = { esp_lcd_i80_bus_config_t bus_cfg = {
@@ -78,7 +78,7 @@ bool St7789i8080Display::createI80Bus() {
esp_err_t ret = esp_lcd_new_i80_bus(&bus_cfg, &i80BusHandle); esp_err_t ret = esp_lcd_new_i80_bus(&bus_cfg, &i80BusHandle);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to create I80 bus: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to create I80 bus: %s", esp_err_to_name(ret));
return false; return false;
} }
@@ -86,7 +86,7 @@ bool St7789i8080Display::createI80Bus() {
} }
bool St7789i8080Display::createPanelIO() { bool St7789i8080Display::createPanelIO() {
LOGGER.info("Creating panel IO"); LOG_I(TAG, "Creating panel IO");
// Create panel IO with proper callback // Create panel IO with proper callback
esp_lcd_panel_io_i80_config_t io_cfg = { esp_lcd_panel_io_i80_config_t io_cfg = {
@@ -114,7 +114,7 @@ bool St7789i8080Display::createPanelIO() {
esp_err_t ret = esp_lcd_new_panel_io_i80(i80BusHandle, &io_cfg, &ioHandle); esp_err_t ret = esp_lcd_new_panel_io_i80(i80BusHandle, &io_cfg, &ioHandle);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to create panel IO: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to create panel IO: %s", esp_err_to_name(ret));
return false; return false;
} }
@@ -122,7 +122,7 @@ bool St7789i8080Display::createPanelIO() {
} }
bool St7789i8080Display::createPanel() { bool St7789i8080Display::createPanel() {
LOGGER.info("Configuring panel"); LOG_I(TAG, "Configuring panel");
// Create ST7789 panel // Create ST7789 panel
esp_lcd_panel_dev_config_t panel_config = { esp_lcd_panel_dev_config_t panel_config = {
@@ -138,49 +138,49 @@ bool St7789i8080Display::createPanel() {
esp_err_t ret = esp_lcd_new_panel_st7789(ioHandle, &panel_config, &panelHandle); esp_err_t ret = esp_lcd_new_panel_st7789(ioHandle, &panel_config, &panelHandle);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to create ST7789 panel: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to create ST7789 panel: %s", esp_err_to_name(ret));
return false; return false;
} }
// Reset panel // Reset panel
ret = esp_lcd_panel_reset(panelHandle); ret = esp_lcd_panel_reset(panelHandle);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to reset panel: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to reset panel: %s", esp_err_to_name(ret));
return false; return false;
} }
// Initialize panel // Initialize panel
ret = esp_lcd_panel_init(panelHandle); ret = esp_lcd_panel_init(panelHandle);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to init panel: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to init panel: %s", esp_err_to_name(ret));
return false; return false;
} }
// Set gap // Set gap
ret = esp_lcd_panel_set_gap(panelHandle, configuration.gapX, configuration.gapY); ret = esp_lcd_panel_set_gap(panelHandle, configuration.gapX, configuration.gapY);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to set panel gap: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to set panel gap: %s", esp_err_to_name(ret));
return false; return false;
} }
// Set inversion // Set inversion
ret = esp_lcd_panel_invert_color(panelHandle, configuration.invertColor); ret = esp_lcd_panel_invert_color(panelHandle, configuration.invertColor);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to set panel inversion: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to set panel inversion: %s", esp_err_to_name(ret));
return false; return false;
} }
// Set mirror // Set mirror
ret = esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY); ret = esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to set panel mirror: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to set panel mirror: %s", esp_err_to_name(ret));
return false; return false;
} }
// Turn on display // Turn on display
ret = esp_lcd_panel_disp_on_off(panelHandle, true); ret = esp_lcd_panel_disp_on_off(panelHandle, true);
if (ret != ESP_OK) { if (ret != ESP_OK) {
LOGGER.error("Failed to turn display on: {}", esp_err_to_name(ret)); LOG_E(TAG, "Failed to turn display on: %s", esp_err_to_name(ret));
return false; return false;
} }
@@ -188,7 +188,7 @@ bool St7789i8080Display::createPanel() {
} }
void St7789i8080Display::sendInitCommands() { void St7789i8080Display::sendInitCommands() {
LOGGER.info("Sending ST7789 init commands"); LOG_I(TAG, "Sending ST7789 init commands");
for (const auto& cmd : st7789_init_cmds) { for (const auto& cmd : st7789_init_cmds) {
esp_lcd_panel_io_tx_param(ioHandle, cmd.cmd, cmd.data, cmd.len & 0x7F); esp_lcd_panel_io_tx_param(ioHandle, cmd.cmd, cmd.data, cmd.len & 0x7F);
if (cmd.len & 0x80) { if (cmd.len & 0x80) {
@@ -198,7 +198,7 @@ void St7789i8080Display::sendInitCommands() {
} }
bool St7789i8080Display::start() { bool St7789i8080Display::start() {
LOGGER.info("Initializing I8080 ST7789 Display hardware..."); LOG_I(TAG, "Initializing I8080 ST7789 Display hardware...");
// Configure RD pin if needed // Configure RD pin if needed
if (configuration.rdPin != GPIO_NUM_NC) { if (configuration.rdPin != GPIO_NUM_NC) {
@@ -220,7 +220,7 @@ bool St7789i8080Display::start() {
size_t buffer_size = configuration.bufferSize * LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565); size_t buffer_size = configuration.bufferSize * LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565);
buf1 = (uint8_t*)heap_caps_malloc(buffer_size, MALLOC_CAP_DMA); buf1 = (uint8_t*)heap_caps_malloc(buffer_size, MALLOC_CAP_DMA);
if (!buf1) { if (!buf1) {
LOGGER.error("Failed to allocate display buffer"); LOG_E(TAG, "Failed to allocate display buffer");
return false; return false;
} }
@@ -239,7 +239,7 @@ bool St7789i8080Display::start() {
return false; return false;
} }
LOGGER.info("Display hardware initialized"); LOG_I(TAG, "Display hardware initialized");
return true; return true;
} }
@@ -278,17 +278,17 @@ bool St7789i8080Display::stop() {
} }
bool St7789i8080Display::startLvgl() { bool St7789i8080Display::startLvgl() {
LOGGER.info("Initializing LVGL for ST7789 display"); LOG_I(TAG, "Initializing LVGL for ST7789 display");
// Don't reinitialize hardware if it's already done // Don't reinitialize hardware if it's already done
if (!ioHandle) { if (!ioHandle) {
LOGGER.info("Hardware not initialized, calling start()"); LOG_I(TAG, "Hardware not initialized, calling start()");
if (!start()) { if (!start()) {
LOGGER.error("Hardware initialization failed"); LOG_E(TAG, "Hardware initialization failed");
return false; return false;
} }
} else { } else {
LOGGER.info("Hardware already initialized, skipping"); LOG_I(TAG, "Hardware already initialized, skipping");
} }
// Create LVGL display using lvgl_port // Create LVGL display using lvgl_port
@@ -321,7 +321,7 @@ bool St7789i8080Display::startLvgl() {
// Create the LVGL display // Create the LVGL display
lvglDisplay = lvgl_port_add_disp(&display_cfg); lvglDisplay = lvgl_port_add_disp(&display_cfg);
if (!lvglDisplay) { if (!lvglDisplay) {
LOGGER.error("Failed to create LVGL display"); LOG_E(TAG, "Failed to create LVGL display");
return false; return false;
} }
@@ -332,7 +332,7 @@ bool St7789i8080Display::startLvgl() {
esp_lcd_panel_io_register_event_callbacks(ioHandle, &cbs, lvglDisplay); esp_lcd_panel_io_register_event_callbacks(ioHandle, &cbs, lvglDisplay);
g_display_instance = this; g_display_instance = this;
LOGGER.info("LVGL display created successfully"); LOG_I(TAG, "LVGL display created successfully");
return true; return true;
} }
@@ -1,5 +1,5 @@
#include "St7796i8080Display.h" #include "St7796i8080Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <esp_lcd_panel_io.h> #include <esp_lcd_panel_io.h>
#include <esp_lcd_panel_ops.h> #include <esp_lcd_panel_ops.h>
@@ -8,7 +8,7 @@
#include <freertos/task.h> #include <freertos/task.h>
#include <lvgl.h> #include <lvgl.h>
static const auto LOGGER = tt::Logger("St7796i8080Display"); constexpr auto* TAG = "St7796i8080Display";
static St7796i8080Display* g_display_instance = nullptr; static St7796i8080Display* g_display_instance = nullptr;
St7796i8080Display::St7796i8080Display(const Configuration& config) St7796i8080Display::St7796i8080Display(const Configuration& config)
@@ -16,13 +16,13 @@ St7796i8080Display::St7796i8080Display(const Configuration& config)
// Validate configuration // Validate configuration
if (!configuration.isValid()) { if (!configuration.isValid()) {
LOGGER.error("Invalid configuration: resolution must be set"); LOG_E(TAG, "Invalid configuration: resolution must be set");
return; return;
} }
} }
bool St7796i8080Display::createI80Bus() { bool St7796i8080Display::createI80Bus() {
LOGGER.info("Creating I80 bus"); LOG_I(TAG, "Creating I80 bus");
// Create I80 bus configuration // Create I80 bus configuration
esp_lcd_i80_bus_config_t bus_cfg = { esp_lcd_i80_bus_config_t bus_cfg = {
@@ -42,7 +42,7 @@ bool St7796i8080Display::createI80Bus() {
}; };
if (esp_lcd_new_i80_bus(&bus_cfg, &i80BusHandle) != ESP_OK) { if (esp_lcd_new_i80_bus(&bus_cfg, &i80BusHandle) != ESP_OK) {
LOGGER.error("Failed to create I80 bus"); LOG_E(TAG, "Failed to create I80 bus");
return false; return false;
} }
@@ -50,7 +50,7 @@ bool St7796i8080Display::createI80Bus() {
} }
bool St7796i8080Display::createPanelIO() { bool St7796i8080Display::createPanelIO() {
LOGGER.info("Creating panel IO"); LOG_I(TAG, "Creating panel IO");
// Create panel IO // Create panel IO
esp_lcd_panel_io_i80_config_t io_cfg = { esp_lcd_panel_io_i80_config_t io_cfg = {
@@ -77,7 +77,7 @@ bool St7796i8080Display::createPanelIO() {
}; };
if (esp_lcd_new_panel_io_i80(i80BusHandle, &io_cfg, &ioHandle) != ESP_OK) { if (esp_lcd_new_panel_io_i80(i80BusHandle, &io_cfg, &ioHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
@@ -85,7 +85,7 @@ bool St7796i8080Display::createPanelIO() {
} }
bool St7796i8080Display::createPanel() { bool St7796i8080Display::createPanel() {
LOGGER.info("Configuring panel"); LOG_I(TAG, "Configuring panel");
// Create ST7796 panel // Create ST7796 panel
esp_lcd_panel_dev_config_t panel_config = { esp_lcd_panel_dev_config_t panel_config = {
@@ -100,43 +100,43 @@ bool St7796i8080Display::createPanel() {
}; };
if (esp_lcd_new_panel_st7796(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_st7796(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
// Reset panel // Reset panel
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
// Initialize panel // Initialize panel
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
// Set swap XY // Set swap XY
if (esp_lcd_panel_swap_xy(panelHandle, configuration.swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration.swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY "); LOG_E(TAG, "Failed to swap XY ");
return false; return false;
} }
// Set mirror // Set mirror
if (esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
// Set inversion // Set inversion
if (esp_lcd_panel_invert_color(panelHandle, configuration.invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration.invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
// Turn on display // Turn on display
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
@@ -144,7 +144,7 @@ bool St7796i8080Display::createPanel() {
} }
bool St7796i8080Display::start() { bool St7796i8080Display::start() {
LOGGER.info("Initializing I8080 ST7796 Display hardware..."); LOG_I(TAG, "Initializing I8080 ST7796 Display hardware...");
// Calculate buffer size if needed // Calculate buffer size if needed
configuration.calculateBufferSize(); configuration.calculateBufferSize();
@@ -153,7 +153,7 @@ bool St7796i8080Display::start() {
size_t buffer_size = configuration.bufferSize * LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565); size_t buffer_size = configuration.bufferSize * LV_COLOR_FORMAT_GET_SIZE(LV_COLOR_FORMAT_RGB565);
displayBuffer = (uint8_t*)heap_caps_malloc(buffer_size, MALLOC_CAP_DMA); displayBuffer = (uint8_t*)heap_caps_malloc(buffer_size, MALLOC_CAP_DMA);
if (!displayBuffer) { if (!displayBuffer) {
LOGGER.error("Failed to allocate display buffer"); LOG_E(TAG, "Failed to allocate display buffer");
return false; return false;
} }
@@ -175,7 +175,7 @@ bool St7796i8080Display::start() {
return false; return false;
} }
LOGGER.info("Display hardware initialized"); LOG_I(TAG, "Display hardware initialized");
return true; return true;
} }
@@ -214,17 +214,17 @@ bool St7796i8080Display::stop() {
} }
bool St7796i8080Display::startLvgl() { bool St7796i8080Display::startLvgl() {
LOGGER.info("Initializing LVGL for ST7796 display"); LOG_I(TAG, "Initializing LVGL for ST7796 display");
// Don't reinitialize hardware if it's already done // Don't reinitialize hardware if it's already done
if (!ioHandle) { if (!ioHandle) {
LOGGER.info("Hardware not initialized, calling start()"); LOG_I(TAG, "Hardware not initialized, calling start()");
if (!start()) { if (!start()) {
LOGGER.error("Hardware initialization failed"); LOG_E(TAG, "Hardware initialization failed");
return false; return false;
} }
} else { } else {
LOGGER.info("Hardware already initialized, skipping"); LOG_I(TAG, "Hardware already initialized, skipping");
} }
// Create LVGL display using lvgl_port // Create LVGL display using lvgl_port
@@ -257,12 +257,12 @@ bool St7796i8080Display::startLvgl() {
// Create the LVGL display // Create the LVGL display
lvglDisplay = lvgl_port_add_disp(&display_cfg); lvglDisplay = lvgl_port_add_disp(&display_cfg);
if (!lvglDisplay) { if (!lvglDisplay) {
LOGGER.error("Failed to create LVGL display"); LOG_E(TAG, "Failed to create LVGL display");
return false; return false;
} }
g_display_instance = this; g_display_instance = this;
LOGGER.info("LVGL display created successfully"); LOG_I(TAG, "LVGL display created successfully");
return true; return true;
} }
+11 -11
View File
@@ -1,12 +1,12 @@
#include "St7796Display.h" #include "St7796Display.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <esp_lcd_panel_dev.h> #include <esp_lcd_panel_dev.h>
#include <esp_lcd_st7796.h> #include <esp_lcd_st7796.h>
#include <esp_lvgl_port.h> #include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ST7796"); constexpr auto* TAG = "ST7796";
bool St7796Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) { bool St7796Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
const esp_lcd_panel_io_spi_config_t panel_io_config = { const esp_lcd_panel_io_spi_config_t panel_io_config = {
@@ -74,42 +74,42 @@ bool St7796Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
}; };
if (esp_lcd_new_panel_st7796(ioHandle, &panel_config, &panelHandle) != ESP_OK) { if (esp_lcd_new_panel_st7796(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel"); LOG_E(TAG, "Failed to create panel");
return false; return false;
} }
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel"); LOG_E(TAG, "Failed to reset panel");
return false; return false;
} }
if (esp_lcd_panel_init(panelHandle) != ESP_OK) { if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel"); LOG_E(TAG, "Failed to init panel");
return false; return false;
} }
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert"); LOG_E(TAG, "Failed to set panel to invert");
return false; return false;
} }
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY "); LOG_E(TAG, "Failed to swap XY ");
return false; return false;
} }
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror"); LOG_E(TAG, "Failed to set panel to mirror");
return false; return false;
} }
if (esp_lcd_panel_set_gap(panelHandle, configuration->gapX, configuration->gapY) != ESP_OK) { if (esp_lcd_panel_set_gap(panelHandle, configuration->gapX, configuration->gapY) != ESP_OK) {
LOGGER.error("Failed to set panel gap"); LOG_E(TAG, "Failed to set panel gap");
return false; return false;
} }
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on"); LOG_E(TAG, "Failed to turn display on");
return false; return false;
} }
@@ -168,6 +168,6 @@ void St7796Display::setGammaCurve(uint8_t index) {
}; };
/*if (esp_lcd_panel_io_tx_param(ioHandle , LCD_CMD_GAMSET, param, 1) != ESP_OK) { /*if (esp_lcd_panel_io_tx_param(ioHandle , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
LOGGER.error("Failed to set gamma"); LOG_E(TAG, "Failed to set gamma");
}*/ }*/
} }
@@ -1,6 +1,6 @@
#include "Xpt2046SoftSpi.h" #include "Xpt2046SoftSpi.h"
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <Tactility/settings/TouchCalibrationSettings.h> #include <Tactility/settings/TouchCalibrationSettings.h>
#include <algorithm> #include <algorithm>
@@ -11,7 +11,7 @@
#include <freertos/task.h> #include <freertos/task.h>
#include <rom/ets_sys.h> #include <rom/ets_sys.h>
static const auto LOGGER = tt::Logger("Xpt2046SoftSpi"); constexpr auto* TAG = "Xpt2046SoftSpi";
constexpr auto CMD_READ_Y = 0x90; constexpr auto CMD_READ_Y = 0x90;
constexpr auto CMD_READ_X = 0xD0; constexpr auto CMD_READ_X = 0xD0;
@@ -27,7 +27,7 @@ Xpt2046SoftSpi::Xpt2046SoftSpi(std::unique_ptr<Configuration> inConfiguration)
} }
bool Xpt2046SoftSpi::start() { bool Xpt2046SoftSpi::start() {
LOGGER.info("Starting Xpt2046SoftSpi touch driver"); LOG_I(TAG, "Starting Xpt2046SoftSpi touch driver");
// Configure GPIO pins // Configure GPIO pins
gpio_config_t io_conf = {}; gpio_config_t io_conf = {};
@@ -42,7 +42,7 @@ bool Xpt2046SoftSpi::start() {
io_conf.pull_up_en = GPIO_PULLUP_DISABLE; io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
if (gpio_config(&io_conf) != ESP_OK) { if (gpio_config(&io_conf) != ESP_OK) {
LOGGER.error("Failed to configure output pins"); LOG_E(TAG, "Failed to configure output pins");
return false; return false;
} }
@@ -52,7 +52,7 @@ bool Xpt2046SoftSpi::start() {
io_conf.pull_up_en = GPIO_PULLUP_ENABLE; io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
if (gpio_config(&io_conf) != ESP_OK) { if (gpio_config(&io_conf) != ESP_OK) {
LOGGER.error("Failed to configure input pin"); LOG_E(TAG, "Failed to configure input pin");
return false; return false;
} }
@@ -61,8 +61,9 @@ bool Xpt2046SoftSpi::start() {
gpio_set_level(configuration->clkPin, 0); // CLK low gpio_set_level(configuration->clkPin, 0); // CLK low
gpio_set_level(configuration->mosiPin, 0); // MOSI low gpio_set_level(configuration->mosiPin, 0); // MOSI low
LOGGER.info( LOG_I(
"GPIO configured: MOSI={}, MISO={}, CLK={}, CS={}", TAG,
"GPIO configured: MOSI=%d, MISO=%d, CLK=%d, CS=%d",
static_cast<int>(configuration->mosiPin), static_cast<int>(configuration->mosiPin),
static_cast<int>(configuration->misoPin), static_cast<int>(configuration->misoPin),
static_cast<int>(configuration->clkPin), static_cast<int>(configuration->clkPin),
@@ -73,7 +74,7 @@ bool Xpt2046SoftSpi::start() {
} }
bool Xpt2046SoftSpi::stop() { bool Xpt2046SoftSpi::stop() {
LOGGER.info("Stopping Xpt2046SoftSpi touch driver"); LOG_I(TAG, "Stopping Xpt2046SoftSpi touch driver");
// Stop LVLG if needed // Stop LVLG if needed
if (lvglDevice != nullptr) { if (lvglDevice != nullptr) {
@@ -86,13 +87,13 @@ bool Xpt2046SoftSpi::stop() {
bool Xpt2046SoftSpi::startLvgl(lv_display_t* display) { bool Xpt2046SoftSpi::startLvgl(lv_display_t* display) {
(void)display; (void)display;
if (lvglDevice != nullptr) { if (lvglDevice != nullptr) {
LOGGER.error("LVGL was already started"); LOG_E(TAG, "LVGL was already started");
return false; return false;
} }
lvglDevice = lv_indev_create(); lvglDevice = lv_indev_create();
if (lvglDevice == nullptr) { if (lvglDevice == nullptr) {
LOGGER.error("Failed to create LVGL input device"); LOG_E(TAG, "Failed to create LVGL input device");
return false; return false;
} }
@@ -100,7 +101,7 @@ bool Xpt2046SoftSpi::startLvgl(lv_display_t* display) {
lv_indev_set_read_cb(lvglDevice, touchReadCallback); lv_indev_set_read_cb(lvglDevice, touchReadCallback);
lv_indev_set_user_data(lvglDevice, this); lv_indev_set_user_data(lvglDevice, this);
LOGGER.info("Xpt2046SoftSpi touch driver started successfully"); LOG_I(TAG, "Xpt2046SoftSpi touch driver started successfully");
return true; return true;
} }
@@ -1,24 +1,26 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#include <tactility/hal/Device.h>
#include <tactility/driver.h> #include <tactility/driver.h>
#include <tactility/drivers/hal_device.hpp> #include <tactility/drivers/hal_device.hpp>
#include <tactility/hal/Device.h>
#include <tactility/log.h>
#include <Tactility/Logger.h>
#include <Tactility/RecursiveMutex.h> #include <Tactility/RecursiveMutex.h>
#include <algorithm> #include <algorithm>
#include <format>
namespace tt::hal { namespace tt::hal {
RecursiveMutex mutex; RecursiveMutex mutex;
static Device::Id nextId = 0; static Device::Id nextId = 0;
static const auto LOGGER = Logger("Devices"); constexpr auto* TAG = "Devices";
Device::Device() : id(nextId++) {} Device::Device() : id(nextId++) {}
static std::shared_ptr<Device::KernelDeviceHolder> createKernelDeviceHolder(const std::shared_ptr<Device>& device) { static std::shared_ptr<Device::KernelDeviceHolder> createKernelDeviceHolder(const std::shared_ptr<Device>& device) {
auto kernel_device_name = std::format("hal-device-{}", device->getId()); auto kernel_device_name = std::format("hal-device-{}", device->getId());
LOGGER.info("Registering {} with id {} as kernel device {}", device->getName(), device->getId(), kernel_device_name); LOG_I(TAG, "Registering %s with id %u as kernel device %s", device->getName().c_str(), (unsigned)device->getId(), kernel_device_name.c_str());
auto kernel_device_holder = std::make_shared<Device::KernelDeviceHolder>(kernel_device_name); auto kernel_device_holder = std::make_shared<Device::KernelDeviceHolder>(kernel_device_name);
auto* kernel_device = kernel_device_holder->device.get(); auto* kernel_device = kernel_device_holder->device.get();
check(device_construct(kernel_device) == ERROR_NONE); check(device_construct(kernel_device) == ERROR_NONE);
@@ -49,7 +51,7 @@ void registerDevice(const std::shared_ptr<Device>& device) {
auto kernel_device_holder = createKernelDeviceHolder(device); auto kernel_device_holder = createKernelDeviceHolder(device);
device->setKernelDeviceHolder(kernel_device_holder); device->setKernelDeviceHolder(kernel_device_holder);
} else { } else {
LOGGER.warn("Device {} with id {} was already registered", device->getName(), device->getId()); LOG_W(TAG, "Device %s with id %u was already registered", device->getName().c_str(), (unsigned)device->getId());
} }
} }
@@ -63,7 +65,7 @@ void deregisterDevice(const std::shared_ptr<Device>& device) {
destroyKernelDeviceHolder(kernel_device_holder); destroyKernelDeviceHolder(kernel_device_holder);
device->setKernelDeviceHolder(nullptr); device->setKernelDeviceHolder(nullptr);
} else { } else {
LOGGER.warn("Device {} with id {} was not registered", device->getName(), device->getId()); LOG_W(TAG, "Device %s with id %u was not registered", device->getName().c_str(), (unsigned)device->getId());
} }
} }
@@ -9,11 +9,11 @@
// Alloc // Alloc
#define LOG_MESSAGE_ALLOC_FAILED "Out of memory" #define LOG_MESSAGE_ALLOC_FAILED "Out of memory"
#define LOG_MESSAGE_ALLOC_FAILED_FMT "Out of memory (failed to allocated {} bytes)" #define LOG_MESSAGE_ALLOC_FAILED_FMT "Out of memory (failed to allocated %d bytes)"
// Mutex // Mutex
#define LOG_MESSAGE_MUTEX_LOCK_FAILED "Mutex acquisition timeout" #define LOG_MESSAGE_MUTEX_LOCK_FAILED "Mutex acquisition timeout"
#define LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT "Mutex acquisition timeout ({})" #define LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT "Mutex acquisition timeout (%s)"
// Power on // Power on
#define LOG_MESSAGE_POWER_ON_START "Power on" #define LOG_MESSAGE_POWER_ON_START "Power on"
@@ -3,13 +3,13 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <esp_http_client.h> #include <esp_http_client.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
namespace tt::network { namespace tt::network {
class EspHttpClient { class EspHttpClient {
const Logger logger = Logger("EspHttpClient"); static constexpr auto* TAG = "EspHttpClient";
std::unique_ptr<esp_http_client_config_t> config = nullptr; std::unique_ptr<esp_http_client_config_t> config = nullptr;
esp_http_client_handle_t client = nullptr; esp_http_client_handle_t client = nullptr;
@@ -28,7 +28,7 @@ public:
} }
bool init(std::unique_ptr<esp_http_client_config_t> inConfig) { bool init(std::unique_ptr<esp_http_client_config_t> inConfig) {
logger.info("init({})", inConfig->url); LOG_I(TAG, "init(%s)", inConfig->url);
assert(this->config == nullptr); assert(this->config == nullptr);
config = std::move(inConfig); config = std::move(inConfig);
client = esp_http_client_init(config.get()); client = esp_http_client_init(config.get());
@@ -37,11 +37,11 @@ public:
bool open() { bool open() {
assert(client != nullptr); assert(client != nullptr);
logger.info("open()"); LOG_I(TAG, "open()");
auto result = esp_http_client_open(client, 0); auto result = esp_http_client_open(client, 0);
if (result != ESP_OK) { if (result != ESP_OK) {
logger.error("open() failed: {}", esp_err_to_name(result)); LOG_E(TAG, "open() failed: %s", esp_err_to_name(result));
return false; return false;
} }
@@ -51,7 +51,7 @@ public:
bool fetchHeaders() const { bool fetchHeaders() const {
assert(client != nullptr); assert(client != nullptr);
logger.info("fetchHeaders()"); LOG_I(TAG, "fetchHeaders()");
return esp_http_client_fetch_headers(client) >= 0; return esp_http_client_fetch_headers(client) >= 0;
} }
@@ -64,7 +64,7 @@ public:
int getStatusCode() const { int getStatusCode() const {
assert(client != nullptr); assert(client != nullptr);
const auto status_code = esp_http_client_get_status_code(client); const auto status_code = esp_http_client_get_status_code(client);
logger.info("Status code {}", status_code); LOG_I(TAG, "Status code %d", status_code);
return status_code; return status_code;
} }
@@ -75,19 +75,19 @@ public:
int read(char* bytes, int size) const { int read(char* bytes, int size) const {
assert(client != nullptr); assert(client != nullptr);
logger.info("read({})", size); LOG_I(TAG, "read(%d)", size);
return esp_http_client_read(client, bytes, size); return esp_http_client_read(client, bytes, size);
} }
int readResponse(char* bytes, int size) const { int readResponse(char* bytes, int size) const {
assert(client != nullptr); assert(client != nullptr);
logger.info("readResponse({})", size); LOG_I(TAG, "readResponse(%d)", size);
return esp_http_client_read_response(client, bytes, size); return esp_http_client_read_response(client, bytes, size);
} }
bool close() { bool close() {
assert(client != nullptr); assert(client != nullptr);
logger.info("close()"); LOG_I(TAG, "close()");
if (esp_http_client_close(client) == ESP_OK) { if (esp_http_client_close(client) == ESP_OK) {
isOpen = false; isOpen = false;
} }
@@ -97,7 +97,7 @@ public:
bool cleanup() { bool cleanup() {
assert(client != nullptr); assert(client != nullptr);
assert(!isOpen); assert(!isOpen);
logger.info("cleanup()"); LOG_I(TAG, "cleanup()");
const auto result = esp_http_client_cleanup(client); const auto result = esp_http_client_cleanup(client);
client = nullptr; client = nullptr;
return result == ESP_OK; return result == ESP_OK;
@@ -6,7 +6,7 @@
#include <Tactility/Bundle.h> #include <Tactility/Bundle.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
#include <Tactility/Mutex.h> #include <Tactility/Mutex.h>
#include <memory> #include <memory>
@@ -48,7 +48,7 @@ class AppInstance : public AppContext {
return manifest->createApp(); return manifest->createApp();
} else if (manifest->appLocation.isExternal()) { } else if (manifest->appLocation.isExternal()) {
if (manifest->createApp != nullptr) { if (manifest->createApp != nullptr) {
Logger("AppInstance").warn("Manifest specifies createApp, but this is not used with external apps"); LOG_W("AppInstance", "Manifest specifies createApp, but this is not used with external apps");
} }
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
return createElfApp(manifest); return createElfApp(manifest);
+7 -7
View File
@@ -4,14 +4,14 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <Tactility/Logger.h> #include <tactility/log.h>
namespace tt::json { namespace tt::json {
class Reader { class Reader {
const cJSON* root; const cJSON* root;
Logger logger = Logger("json::Reader"); static constexpr auto* TAG = "json::Reader";
public: public:
@@ -20,7 +20,7 @@ public:
bool readString(const char* key, std::string& output) const { bool readString(const char* key, std::string& output) const {
const auto* child = cJSON_GetObjectItemCaseSensitive(root, key); const auto* child = cJSON_GetObjectItemCaseSensitive(root, key);
if (!cJSON_IsString(child)) { if (!cJSON_IsString(child)) {
logger.error("{} is not a string", key); LOG_E(TAG, "%s is not a string", key);
return false; return false;
} }
output = cJSON_GetStringValue(child); output = cJSON_GetStringValue(child);
@@ -48,7 +48,7 @@ public:
bool readNumber(const char* key, double& output) const { bool readNumber(const char* key, double& output) const {
const auto* child = cJSON_GetObjectItemCaseSensitive(root, key); const auto* child = cJSON_GetObjectItemCaseSensitive(root, key);
if (!cJSON_IsNumber(child)) { if (!cJSON_IsNumber(child)) {
logger.error("{} is not a number", key); LOG_E(TAG, "%s is not a number", key);
return false; return false;
} }
output = cJSON_GetNumberValue(child); output = cJSON_GetNumberValue(child);
@@ -58,16 +58,16 @@ public:
bool readStringArray(const char* key, std::vector<std::string>& output) const { bool readStringArray(const char* key, std::vector<std::string>& output) const {
const auto* child = cJSON_GetObjectItemCaseSensitive(root, key); const auto* child = cJSON_GetObjectItemCaseSensitive(root, key);
if (!cJSON_IsArray(child)) { if (!cJSON_IsArray(child)) {
logger.error("{} is not an array", key); LOG_E(TAG, "%s is not an array", key);
return false; return false;
} }
const auto size = cJSON_GetArraySize(child); const auto size = cJSON_GetArraySize(child);
logger.info("Processing {} array children", size); LOG_I(TAG, "Processing %d array children", size);
output.resize(size); output.resize(size);
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
const auto string_json = cJSON_GetArrayItem(child, i); const auto string_json = cJSON_GetArrayItem(child, i);
if (!cJSON_IsString(string_json)) { if (!cJSON_IsString(string_json)) {
logger.error("Array child of {} is not a string", key); LOG_E(TAG, "Array child of %s is not a string", key);
return false; return false;
} }
output[i] = cJSON_GetStringValue(string_json); output[i] = cJSON_GetStringValue(string_json);
+8 -8
View File
@@ -1,16 +1,16 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/PartitionsEsp.h> #include <Tactility/PartitionsEsp.h>
#include <Tactility/Logger.h>
#include <esp_vfs_fat.h> #include <esp_vfs_fat.h>
#include <nvs_flash.h> #include <nvs_flash.h>
#include <tactility/error.h> #include <tactility/error.h>
#include <tactility/filesystem/file_system.h> #include <tactility/filesystem/file_system.h>
#include <tactility/log.h>
namespace tt { namespace tt {
static const auto LOGGER = Logger("Partitions"); constexpr auto* TAG = "Partitions";
// region file_system stub // region file_system stub
@@ -47,7 +47,7 @@ FileSystemApi partition_fs_api = {
// endregion file_system stub // endregion file_system stub
static esp_err_t initNvsFlashSafely() { static esp_err_t initNvsFlashSafely() {
LOGGER.info("Init NVS"); LOG_I(TAG, "Init NVS");
esp_err_t result = nvs_flash_init(); esp_err_t result = nvs_flash_init();
if (result == ESP_ERR_NVS_NO_FREE_PAGES || result == ESP_ERR_NVS_NEW_VERSION_FOUND) { if (result == ESP_ERR_NVS_NO_FREE_PAGES || result == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase()); ESP_ERROR_CHECK(nvs_flash_erase());
@@ -77,7 +77,7 @@ size_t getSectorSize() {
} }
bool initPartitionsEsp() { bool initPartitionsEsp() {
LOGGER.info("Init partitions"); LOG_I(TAG, "Init partitions");
ESP_ERROR_CHECK(initNvsFlashSafely()); ESP_ERROR_CHECK(initNvsFlashSafely());
const esp_vfs_fat_mount_config_t mount_config = { const esp_vfs_fat_mount_config_t mount_config = {
@@ -90,21 +90,21 @@ bool initPartitionsEsp() {
auto system_result = esp_vfs_fat_spiflash_mount_ro("/system", "system", &mount_config); auto system_result = esp_vfs_fat_spiflash_mount_ro("/system", "system", &mount_config);
if (system_result != ESP_OK) { if (system_result != ESP_OK) {
LOGGER.error("Failed to mount /system ({})", esp_err_to_name(system_result)); LOG_E(TAG, "Failed to mount /system (%s)", esp_err_to_name(system_result));
return false; return false;
} }
LOGGER.info("Mounted /system"); LOG_I(TAG, "Mounted /system");
static auto system_fs_data = PartitionFsData("/system"); static auto system_fs_data = PartitionFsData("/system");
file_system_add(&partition_fs_api, &system_fs_data); file_system_add(&partition_fs_api, &system_fs_data);
#ifdef CONFIG_TT_USER_DATA_LOCATION_INTERNAL #ifdef CONFIG_TT_USER_DATA_LOCATION_INTERNAL
auto data_result = esp_vfs_fat_spiflash_mount_rw_wl("/data", "data", &mount_config, &data_wl_handle); auto data_result = esp_vfs_fat_spiflash_mount_rw_wl("/data", "data", &mount_config, &data_wl_handle);
if (data_result != ESP_OK) { if (data_result != ESP_OK) {
LOGGER.error("Failed to mount /data ({})", esp_err_to_name(data_result)); LOG_E(TAG, "Failed to mount /data (%s)", esp_err_to_name(data_result));
return false; return false;
} }
LOGGER.info("Mounted /data"); LOG_I(TAG, "Mounted /data");
static auto data_fs_data = PartitionFsData("/data"); static auto data_fs_data = PartitionFsData("/data");
file_system_add(&partition_fs_api, &data_fs_data); file_system_add(&partition_fs_api, &data_fs_data);
#endif #endif
+18 -18
View File
@@ -1,19 +1,19 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Logger.h>
#include <Tactility/Preferences.h> #include <Tactility/Preferences.h>
#include <Tactility/TactilityCore.h> #include <Tactility/TactilityCore.h>
#include <nvs_flash.h> #include <nvs_flash.h>
#include <tactility/log.h>
namespace tt { namespace tt {
static const auto LOGGER = Logger("Preferences"); constexpr auto* TAG = "Preferences";
bool Preferences::optBool(const std::string& key, bool& out) const { bool Preferences::optBool(const std::string& key, bool& out) const {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
return false; return false;
} else { } else {
uint8_t out_number; uint8_t out_number;
@@ -29,7 +29,7 @@ bool Preferences::optBool(const std::string& key, bool& out) const {
bool Preferences::optInt32(const std::string& key, int32_t& out) const { bool Preferences::optInt32(const std::string& key, int32_t& out) const {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
return false; return false;
} else { } else {
bool success = nvs_get_i32(handle, key.c_str(), &out) == ESP_OK; bool success = nvs_get_i32(handle, key.c_str(), &out) == ESP_OK;
@@ -41,7 +41,7 @@ bool Preferences::optInt32(const std::string& key, int32_t& out) const {
bool Preferences::optInt64(const std::string& key, int64_t& out) const { bool Preferences::optInt64(const std::string& key, int64_t& out) const {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
return false; return false;
} else { } else {
bool success = nvs_get_i64(handle, key.c_str(), &out) == ESP_OK; bool success = nvs_get_i64(handle, key.c_str(), &out) == ESP_OK;
@@ -53,7 +53,7 @@ bool Preferences::optInt64(const std::string& key, int64_t& out) const {
bool Preferences::optString(const std::string& key, std::string& out) const { bool Preferences::optString(const std::string& key, std::string& out) const {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
return false; return false;
} else { } else {
size_t out_size = 256; size_t out_size = 256;
@@ -90,13 +90,13 @@ void Preferences::putBool(const std::string& key, bool value) {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_u8(handle, key.c_str(), value) != ESP_OK) { if (nvs_set_u8(handle, key.c_str(), value) != ESP_OK) {
LOGGER.error("Failed to set {}:{}", namespace_, key); LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
} else if (nvs_commit(handle) != ESP_OK) { } else if (nvs_commit(handle) != ESP_OK) {
LOGGER.error("Failed to commit {}:{}", namespace_, key); LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
} }
nvs_close(handle); nvs_close(handle);
} else { } else {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
} }
} }
@@ -104,13 +104,13 @@ void Preferences::putInt32(const std::string& key, int32_t value) {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_i32(handle, key.c_str(), value) != ESP_OK) { if (nvs_set_i32(handle, key.c_str(), value) != ESP_OK) {
LOGGER.error("Failed to set {}:{}", namespace_, key); LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
} else if (nvs_commit(handle) != ESP_OK) { } else if (nvs_commit(handle) != ESP_OK) {
LOGGER.error("Failed to commit {}:{}", namespace_, key); LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
} }
nvs_close(handle); nvs_close(handle);
} else { } else {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
} }
} }
@@ -118,13 +118,13 @@ void Preferences::putInt64(const std::string& key, int64_t value) {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_i64(handle, key.c_str(), value) != ESP_OK) { if (nvs_set_i64(handle, key.c_str(), value) != ESP_OK) {
LOGGER.error("Failed to set {}:{}", namespace_, key); LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
} else if (nvs_commit(handle) != ESP_OK) { } else if (nvs_commit(handle) != ESP_OK) {
LOGGER.error("Failed to commit {}:{}", namespace_, key); LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
} }
nvs_close(handle); nvs_close(handle);
} else { } else {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
} }
} }
@@ -132,13 +132,13 @@ void Preferences::putString(const std::string& key, const std::string& text) {
nvs_handle_t handle; nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) { if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_str(handle, key.c_str(), text.c_str()) != ESP_OK) { if (nvs_set_str(handle, key.c_str(), text.c_str()) != ESP_OK) {
LOGGER.error("Failed to set {}:{}", namespace_, key.c_str()); LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
} else if (nvs_commit(handle) != ESP_OK) { } else if (nvs_commit(handle) != ESP_OK) {
LOGGER.error("Failed to commit {}:{}", namespace_, key); LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
} }
nvs_close(handle); nvs_close(handle);
} else { } else {
LOGGER.error("Failed to open namespace {}", namespace_); LOG_E(TAG, "Failed to open namespace %s", namespace_);
} }
} }
+22 -22
View File
@@ -7,10 +7,9 @@
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <Tactility/TactilityConfig.h> #include <Tactility/TactilityConfig.h>
#include <Tactility/LogMessages.h>
#include <Tactility/CpuAffinity.h> #include <Tactility/CpuAffinity.h>
#include <Tactility/DispatcherThread.h> #include <Tactility/DispatcherThread.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/MountPoints.h> #include <Tactility/MountPoints.h>
#include <Tactility/app/AppManifestParsing.h> #include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppRegistration.h> #include <Tactility/app/AppRegistration.h>
@@ -29,6 +28,7 @@
#include <tactility/filesystem/file_system.h> #include <tactility/filesystem/file_system.h>
#include <tactility/hal_device_module.h> #include <tactility/hal_device_module.h>
#include <tactility/kernel_init.h> #include <tactility/kernel_init.h>
#include <tactility/log.h>
#include <tactility/lvgl_module.h> #include <tactility/lvgl_module.h>
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
@@ -42,7 +42,7 @@
namespace tt { namespace tt {
static auto LOGGER = Logger("Tactility"); constexpr auto* TAG = "Tactility";
static const Configuration* config_instance = nullptr; static const Configuration* config_instance = nullptr;
static Dispatcher mainDispatcher; static Dispatcher mainDispatcher;
@@ -139,7 +139,7 @@ namespace app {
// List of all apps excluding Boot app (as Boot app calls this function indirectly) // List of all apps excluding Boot app (as Boot app calls this function indirectly)
static void registerInternalApps() { static void registerInternalApps() {
LOGGER.info("Registering internal apps"); LOG_I(TAG, "Registering internal apps");
addAppManifest(app::alertdialog::manifest); addAppManifest(app::alertdialog::manifest);
addAppManifest(app::appdetails::manifest); addAppManifest(app::appdetails::manifest);
@@ -210,16 +210,16 @@ static void registerInternalApps() {
} }
static void registerInstalledApp(std::string path) { static void registerInstalledApp(std::string path) {
LOGGER.info("Registering app at {}", path); LOG_I(TAG, "Registering app at %s", path.c_str());
std::string manifest_path = path + "/manifest.properties"; std::string manifest_path = path + "/manifest.properties";
if (!file::isFile(manifest_path)) { if (!file::isFile(manifest_path)) {
LOGGER.error("Manifest not found at {}", manifest_path); LOG_E(TAG, "Manifest not found at %s", manifest_path.c_str());
return; return;
} }
app::AppManifest manifest; app::AppManifest manifest;
if (!app::parseManifest(manifest_path, manifest)) { if (!app::parseManifest(manifest_path, manifest)) {
LOGGER.error("Failed to parse manifest at {}", manifest_path); LOG_E(TAG, "Failed to parse manifest at %s", manifest_path.c_str());
return; return;
} }
@@ -230,7 +230,7 @@ static void registerInstalledApp(std::string path) {
} }
static void registerInstalledApps(const std::string& path) { static void registerInstalledApps(const std::string& path) {
LOGGER.info("Registering apps from {}", path); LOG_I(TAG, "Registering apps from %s", path.c_str());
file::listDirectory(path, [&path](const auto& entry) { file::listDirectory(path, [&path](const auto& entry) {
auto absolute_path = std::format("{}/{}", path, entry.d_name); auto absolute_path = std::format("{}/{}", path, entry.d_name);
@@ -247,7 +247,7 @@ static void registerInstalledAppsFromFileSystems() {
if (file_system_get_path(fs, path, sizeof(path)) != ERROR_NONE) return true; if (file_system_get_path(fs, path, sizeof(path)) != ERROR_NONE) return true;
const auto app_path = std::format("{}/tactility/app", path); const auto app_path = std::format("{}/tactility/app", path);
if (!app_path.starts_with(file::MOUNT_POINT_SYSTEM) && file::isDirectory(app_path)) { if (!app_path.starts_with(file::MOUNT_POINT_SYSTEM) && file::isDirectory(app_path)) {
LOGGER.info("Registering apps from {}", app_path); LOG_I(TAG, "Registering apps from %s", app_path.c_str());
registerInstalledApps(app_path); registerInstalledApps(app_path);
} }
return true; return true;
@@ -255,7 +255,7 @@ static void registerInstalledAppsFromFileSystems() {
} }
static void registerAndStartSecondaryServices() { static void registerAndStartSecondaryServices() {
LOGGER.info("Registering and starting secondary system services"); LOG_I(TAG, "Registering and starting secondary system services");
addService(service::loader::manifest); addService(service::loader::manifest);
addService(service::gui::manifest); addService(service::gui::manifest);
addService(service::statusbar::manifest); addService(service::statusbar::manifest);
@@ -272,7 +272,7 @@ static void registerAndStartSecondaryServices() {
} }
static void registerAndStartPrimaryServices() { static void registerAndStartPrimaryServices() {
LOGGER.info("Registering and starting primary system services"); LOG_I(TAG, "Registering and starting primary system services");
addService(service::gps::manifest); addService(service::gps::manifest);
addService(service::wifi::manifest); addService(service::wifi::manifest);
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
@@ -294,17 +294,17 @@ void createTempDirectory() {
auto lock = file::getLock(data_path)->asScopedLock(); auto lock = file::getLock(data_path)->asScopedLock();
if (lock.lock(1000 / portTICK_PERIOD_MS)) { if (lock.lock(1000 / portTICK_PERIOD_MS)) {
if (!file::findOrCreateParentDirectory(temp_path, 0777)) { if (!file::findOrCreateParentDirectory(temp_path, 0777)) {
LOGGER.error("Failed to create {}", data_path); LOG_E(TAG, "Failed to create %s", data_path.c_str());
} else if (mkdir(temp_path.c_str(), 0777) == 0) { } else if (mkdir(temp_path.c_str(), 0777) == 0) {
LOGGER.info("Created {}", temp_path); LOG_I(TAG, "Created %s", temp_path.c_str());
} else { } else {
LOGGER.error("Failed to create {}", temp_path); LOG_E(TAG, "Failed to create %s", temp_path.c_str());
} }
} else { } else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, data_path); LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, data_path.c_str());
} }
} else { } else {
LOGGER.info("Found existing {}", temp_path); LOG_I(TAG, "Found existing %s", temp_path.c_str());
} }
} }
@@ -318,13 +318,13 @@ void registerApps() {
} }
void run(const Configuration& config, Module* dtsModules[], DtsDevice dtsDevices[]) { void run(const Configuration& config, Module* dtsModules[], DtsDevice dtsDevices[]) {
LOGGER.info("Tactility v{} on {} ({})", TT_VERSION, CONFIG_TT_DEVICE_NAME, CONFIG_TT_DEVICE_ID); LOG_I(TAG, "Tactility v%s on %s (%s)", TT_VERSION, CONFIG_TT_DEVICE_NAME, CONFIG_TT_DEVICE_ID);
assert(config.hardware); assert(config.hardware);
LOGGER.info("Initializing kernel"); LOG_I(TAG, "Initializing kernel");
if (kernel_init(dtsModules, dtsDevices) != ERROR_NONE) { if (kernel_init(dtsModules, dtsDevices) != ERROR_NONE) {
LOGGER.error("Failed to initialize kernel"); LOG_E(TAG, "Failed to initialize kernel");
return; return;
} }
@@ -363,14 +363,14 @@ void run(const Configuration& config, Module* dtsModules[], DtsDevice dtsDevices
registerAndStartSecondaryServices(); registerAndStartSecondaryServices();
LOGGER.info("Core systems ready"); LOG_I(TAG, "Core systems ready");
LOGGER.info("Starting boot app"); LOG_I(TAG, "Starting boot app");
// The boot app takes care of registering system apps, user services and user apps // The boot app takes care of registering system apps, user services and user apps
addAppManifest(app::boot::manifest); addAppManifest(app::boot::manifest);
app::start(app::boot::manifest.appId); app::start(app::boot::manifest.appId);
LOGGER.info("Main dispatcher ready"); LOG_I(TAG, "Main dispatcher ready");
while (true) { while (true) {
mainDispatcher.consume(); mainDispatcher.consume();
} }
+26 -26
View File
@@ -5,7 +5,6 @@
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h> #include <Tactility/file/FileLock.h>
#include <tactility/hal/Device.h> #include <tactility/hal/Device.h>
#include <Tactility/Logger.h>
#include <Tactility/Paths.h> #include <Tactility/Paths.h>
#include <cerrno> #include <cerrno>
@@ -16,21 +15,22 @@
#include <unistd.h> #include <unistd.h>
#include <minitar.h> #include <minitar.h>
#include <tactility/log.h>
namespace tt::app { namespace tt::app {
static const auto LOGGER = Logger("App"); constexpr auto* TAG = "App";
static bool untarFile(minitar* mp, const minitar_entry* entry, const std::string& destinationPath) { static bool untarFile(minitar* mp, const minitar_entry* entry, const std::string& destinationPath) {
const auto absolute_path = destinationPath + "/" + entry->metadata.path; const auto absolute_path = destinationPath + "/" + entry->metadata.path;
if (!file::findOrCreateDirectory(destinationPath, 0777)) { if (!file::findOrCreateDirectory(destinationPath, 0777)) {
LOGGER.error("Can't find or create directory {}", destinationPath.c_str()); LOG_E(TAG, "Can't find or create directory %s", destinationPath.c_str());
return false; return false;
} }
// minitar_read_contents(&mp, &entry, file_buffer, entry.metadata.size); // minitar_read_contents(&mp, &entry, file_buffer, entry.metadata.size);
if (!minitar_read_contents_to_file(mp, entry, absolute_path.c_str())) { if (!minitar_read_contents_to_file(mp, entry, absolute_path.c_str())) {
LOGGER.error("Failed to write data to {}", absolute_path.c_str()); LOG_E(TAG, "Failed to write data to %s", absolute_path.c_str());
return false; return false;
} }
@@ -59,32 +59,32 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
do { do {
if (minitar_read_entry(&mp, &entry) == 0) { if (minitar_read_entry(&mp, &entry) == 0) {
LOGGER.info("Extracting {}", entry.metadata.path); LOG_I(TAG, "Extracting %s", entry.metadata.path);
if (entry.metadata.type == MTAR_DIRECTORY) { if (entry.metadata.type == MTAR_DIRECTORY) {
if (!strcmp(entry.metadata.name, ".") || !strcmp(entry.metadata.name, "..") || !strcmp(entry.metadata.name, "/")) continue; if (!strcmp(entry.metadata.name, ".") || !strcmp(entry.metadata.name, "..") || !strcmp(entry.metadata.name, "/")) continue;
if (!untarDirectory(&entry, destinationPath)) { if (!untarDirectory(&entry, destinationPath)) {
LOGGER.error("Failed to create directory {}/{}: {}", destinationPath, entry.metadata.name, strerror(errno)); LOG_E(TAG, "Failed to create directory %s/%s: %s", destinationPath.c_str(), entry.metadata.name, strerror(errno));
success = false; success = false;
break; break;
} }
} else if (entry.metadata.type == MTAR_REGULAR) { } else if (entry.metadata.type == MTAR_REGULAR) {
if (!untarFile(&mp, &entry, destinationPath)) { if (!untarFile(&mp, &entry, destinationPath)) {
LOGGER.error("Failed to extract file {}: {}", entry.metadata.path, strerror(errno)); LOG_E(TAG, "Failed to extract file %s: %s", entry.metadata.path, strerror(errno));
success = false; success = false;
break; break;
} }
} else if (entry.metadata.type == MTAR_SYMLINK) { } else if (entry.metadata.type == MTAR_SYMLINK) {
LOGGER.error("SYMLINK not supported"); LOG_E(TAG, "SYMLINK not supported");
} else if (entry.metadata.type == MTAR_HARDLINK) { } else if (entry.metadata.type == MTAR_HARDLINK) {
LOGGER.error("HARDLINK not supported"); LOG_E(TAG, "HARDLINK not supported");
} else if (entry.metadata.type == MTAR_FIFO) { } else if (entry.metadata.type == MTAR_FIFO) {
LOGGER.error("FIFO not supported"); LOG_E(TAG, "FIFO not supported");
} else if (entry.metadata.type == MTAR_BLKDEV) { } else if (entry.metadata.type == MTAR_BLKDEV) {
LOGGER.error("BLKDEV not supported"); LOG_E(TAG, "BLKDEV not supported");
} else if (entry.metadata.type == MTAR_CHRDEV) { } else if (entry.metadata.type == MTAR_CHRDEV) {
LOGGER.error("CHRDEV not supported"); LOG_E(TAG, "CHRDEV not supported");
} else { } else {
LOGGER.error("Unknown entry type: {}", static_cast<int>(entry.metadata.type)); LOG_E(TAG, "Unknown entry type: %d", static_cast<int>(entry.metadata.type));
success = false; success = false;
break; break;
} }
@@ -96,7 +96,7 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
void cleanupInstallDirectory(const std::string& path) { void cleanupInstallDirectory(const std::string& path) {
if (!file::deleteRecursively(path)) { if (!file::deleteRecursively(path)) {
LOGGER.warn("Failed to delete existing installation at {}", path); LOG_W(TAG, "Failed to delete existing installation at %s", path.c_str());
} }
} }
@@ -105,16 +105,16 @@ bool install(const std::string& path) {
// the lock with the display. We don't want to lock the display for very long. // the lock with the display. We don't want to lock the display for very long.
auto app_parent_path = getAppInstallPath(); auto app_parent_path = getAppInstallPath();
LOGGER.info("Installing app {} to {}", path, app_parent_path); LOG_I(TAG, "Installing app %s to %s", path.c_str(), app_parent_path.c_str());
auto filename = file::getLastPathSegment(path); auto filename = file::getLastPathSegment(path);
const std::string app_target_path = std::format("{}/{}", app_parent_path, filename); const std::string app_target_path = std::format("{}/{}", app_parent_path, filename);
if (file::isDirectory(app_target_path) && !file::deleteRecursively(app_target_path)) { if (file::isDirectory(app_target_path) && !file::deleteRecursively(app_target_path)) {
LOGGER.warn("Failed to delete {}", app_target_path); LOG_W(TAG, "Failed to delete %s", app_target_path.c_str());
} }
if (!file::findOrCreateDirectory(app_target_path, 0777)) { if (!file::findOrCreateDirectory(app_target_path, 0777)) {
LOGGER.info("Failed to create directory {}", app_target_path); LOG_I(TAG, "Failed to create directory %s", app_target_path.c_str());
return false; return false;
} }
@@ -122,9 +122,9 @@ bool install(const std::string& path) {
auto source_path_lock = file::getLock(path)->asScopedLock(); auto source_path_lock = file::getLock(path)->asScopedLock();
target_path_lock.lock(); target_path_lock.lock();
source_path_lock.lock(); source_path_lock.lock();
LOGGER.info("Extracting app from {} to {}", path, app_target_path); LOG_I(TAG, "Extracting app from %s to %s", path.c_str(), app_target_path.c_str());
if (!untar(path, app_target_path)) { if (!untar(path, app_target_path)) {
LOGGER.error("Failed to extract"); LOG_E(TAG, "Failed to extract");
return false; return false;
} }
source_path_lock.unlock(); source_path_lock.unlock();
@@ -132,14 +132,14 @@ bool install(const std::string& path) {
auto manifest_path = app_target_path + "/manifest.properties"; auto manifest_path = app_target_path + "/manifest.properties";
if (!file::isFile(manifest_path)) { if (!file::isFile(manifest_path)) {
LOGGER.error("Manifest not found at {}", manifest_path); LOG_E(TAG, "Manifest not found at %s", manifest_path.c_str());
cleanupInstallDirectory(app_target_path); cleanupInstallDirectory(app_target_path);
return false; return false;
} }
AppManifest manifest; AppManifest manifest;
if (!parseManifest(manifest_path, manifest)) { if (!parseManifest(manifest_path, manifest)) {
LOGGER.warn("Invalid manifest"); LOG_W(TAG, "Invalid manifest");
cleanupInstallDirectory(app_target_path); cleanupInstallDirectory(app_target_path);
return false; return false;
} }
@@ -152,7 +152,7 @@ bool install(const std::string& path) {
const std::string renamed_target_path = std::format("{}/{}", app_parent_path, manifest.appId); const std::string renamed_target_path = std::format("{}/{}", app_parent_path, manifest.appId);
if (file::isDirectory(renamed_target_path)) { if (file::isDirectory(renamed_target_path)) {
if (!file::deleteRecursively(renamed_target_path)) { if (!file::deleteRecursively(renamed_target_path)) {
LOGGER.warn("Failed to delete existing installation at {}", renamed_target_path); LOG_W(TAG, "Failed to delete existing installation at %s", renamed_target_path.c_str());
cleanupInstallDirectory(app_target_path); cleanupInstallDirectory(app_target_path);
return false; return false;
} }
@@ -163,7 +163,7 @@ bool install(const std::string& path) {
target_path_lock.unlock(); target_path_lock.unlock();
if (!rename_success) { if (!rename_success) {
LOGGER.error(R"(Failed to rename "{}" to "{}")", app_target_path, manifest.appId); LOG_E(TAG, R"(Failed to rename "%s" to "%s")", app_target_path.c_str(), manifest.appId.c_str());
cleanupInstallDirectory(app_target_path); cleanupInstallDirectory(app_target_path);
return false; return false;
} }
@@ -176,7 +176,7 @@ bool install(const std::string& path) {
} }
bool uninstall(const std::string& appId) { bool uninstall(const std::string& appId) {
LOGGER.info("Uninstalling app {}", appId); LOG_I(TAG, "Uninstalling app %s", appId.c_str());
// If the app was running, then stop it // If the app was running, then stop it
if (isRunning(appId)) { if (isRunning(appId)) {
@@ -185,7 +185,7 @@ bool uninstall(const std::string& appId) {
auto app_path = getAppInstallPath(appId); auto app_path = getAppInstallPath(appId);
if (!file::isDirectory(app_path)) { if (!file::isDirectory(app_path)) {
LOGGER.error("App {} not found at {}", appId, app_path); LOG_E(TAG, "App %s not found at %s", appId.c_str(), app_path.c_str());
return false; return false;
} }
@@ -194,7 +194,7 @@ bool uninstall(const std::string& appId) {
} }
if (!removeAppManifest(appId)) { if (!removeAppManifest(appId)) {
LOGGER.warn("Failed to remove app {} from registry", appId); LOG_W(TAG, "Failed to remove app %s from registry", appId.c_str());
} }
return true; return true;
+5 -5
View File
@@ -1,16 +1,16 @@
#include <Tactility/app/AppManifestParsing.h> #include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppManifestParsingInternal.h> #include <Tactility/app/AppManifestParsingInternal.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h> #include <Tactility/file/PropertiesFile.h>
#include <algorithm> #include <algorithm>
#include <tactility/log.h>
namespace tt::app { namespace tt::app {
static const auto LOGGER = Logger("AppManifest"); constexpr auto* TAG = "AppManifest";
constexpr bool validateString(const std::string& value, const std::function<bool(char)>& isValidChar) { constexpr bool validateString(const std::string& value, const std::function<bool(char)>& isValidChar) {
return std::ranges::all_of(value, isValidChar); return std::ranges::all_of(value, isValidChar);
@@ -19,7 +19,7 @@ constexpr bool validateString(const std::string& value, const std::function<bool
bool getValueFromManifest(const std::map<std::string, std::string>& map, const std::string& key, std::string& output) { bool getValueFromManifest(const std::map<std::string, std::string>& map, const std::string& key, std::string& output) {
const auto iterator = map.find(key); const auto iterator = map.find(key);
if (iterator == map.end()) { if (iterator == map.end()) {
LOGGER.error("Failed to find {} in manifest", key); LOG_E(TAG, "Failed to find %s in manifest", key.c_str());
return false; return false;
} }
output = iterator->second; output = iterator->second;
@@ -70,13 +70,13 @@ static bool detectIsV1Format(const std::string& filePath) {
} }
bool parseManifest(const std::string& filePath, AppManifest& manifest) { bool parseManifest(const std::string& filePath, AppManifest& manifest) {
LOGGER.info("Parsing manifest {}", filePath); LOG_I(TAG, "Parsing manifest %s", filePath.c_str());
bool is_v1_format = detectIsV1Format(filePath); bool is_v1_format = detectIsV1Format(filePath);
std::map<std::string, std::string> properties; std::map<std::string, std::string> properties;
if (!file::loadPropertiesFile(filePath, properties)) { if (!file::loadPropertiesFile(filePath, properties)) {
LOGGER.error("Failed to load manifest at {}", filePath); LOG_E(TAG, "Failed to load manifest at %s", filePath.c_str());
return false; return false;
} }
@@ -1,11 +1,11 @@
#include <Tactility/app/AppManifestParsing.h> #include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppManifestParsingInternal.h> #include <Tactility/app/AppManifestParsingInternal.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
namespace tt::app { namespace tt::app {
static const auto LOGGER = Logger("AppManifestV1"); constexpr auto* TAG = "AppManifestV1";
bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest& manifest) { bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest& manifest) {
// [manifest] // [manifest]
@@ -16,7 +16,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidManifestVersion(manifest_version)) { if (!isValidManifestVersion(manifest_version)) {
LOGGER.error("Invalid version"); LOG_E(TAG, "Invalid version");
return false; return false;
} }
@@ -27,7 +27,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidId(manifest.appId)) { if (!isValidId(manifest.appId)) {
LOGGER.error("Invalid app id"); LOG_E(TAG, "Invalid app id");
return false; return false;
} }
@@ -36,7 +36,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidName(manifest.appName)) { if (!isValidName(manifest.appName)) {
LOGGER.error("Invalid app name"); LOG_E(TAG, "Invalid app name");
return false; return false;
} }
@@ -45,7 +45,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidAppVersionName(manifest.appVersionName)) { if (!isValidAppVersionName(manifest.appVersionName)) {
LOGGER.error("Invalid app version name"); LOG_E(TAG, "Invalid app version name");
return false; return false;
} }
@@ -55,7 +55,7 @@ bool parseManifestV1(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidAppVersionCode(version_code_string)) { if (!isValidAppVersionCode(version_code_string)) {
LOGGER.error("Invalid app version code"); LOG_E(TAG, "Invalid app version code");
return false; return false;
} }
@@ -1,11 +1,11 @@
#include <Tactility/app/AppManifestParsing.h> #include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppManifestParsingInternal.h> #include <Tactility/app/AppManifestParsingInternal.h>
#include <Tactility/Logger.h> #include <tactility/log.h>
namespace tt::app { namespace tt::app {
static const auto LOGGER = Logger("AppManifestV2"); constexpr auto* TAG = "AppManifestV2";
bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest& manifest) { bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest& manifest) {
// manifest // manifest
@@ -16,7 +16,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidManifestVersion(manifest_version)) { if (!isValidManifestVersion(manifest_version)) {
LOGGER.error("Invalid version"); LOG_E(TAG, "Invalid version");
return false; return false;
} }
@@ -27,7 +27,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidId(manifest.appId)) { if (!isValidId(manifest.appId)) {
LOGGER.error("Invalid app id"); LOG_E(TAG, "Invalid app id");
return false; return false;
} }
@@ -36,7 +36,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidName(manifest.appName)) { if (!isValidName(manifest.appName)) {
LOGGER.error("Invalid app name"); LOG_E(TAG, "Invalid app name");
return false; return false;
} }
@@ -45,7 +45,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidAppVersionName(manifest.appVersionName)) { if (!isValidAppVersionName(manifest.appVersionName)) {
LOGGER.error("Invalid app version name"); LOG_E(TAG, "Invalid app version name");
return false; return false;
} }
@@ -55,7 +55,7 @@ bool parseManifestV2(const std::map<std::string, std::string>& map, AppManifest&
} }
if (!isValidAppVersionCode(version_code_string)) { if (!isValidAppVersionCode(version_code_string)) {
LOGGER.error("Invalid app version code"); LOG_E(TAG, "Invalid app version code");
return false; return false;
} }
+5 -5
View File
@@ -1,15 +1,15 @@
#include <Tactility/app/AppRegistration.h> #include <Tactility/app/AppRegistration.h>
#include <Tactility/app/AppManifest.h> #include <Tactility/app/AppManifest.h>
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h> #include <Tactility/Mutex.h>
#include <unordered_map> #include <unordered_map>
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <tactility/log.h>
namespace tt::app { namespace tt::app {
static const auto LOGGER = Logger("AppRegistration"); constexpr auto* TAG = "AppRegistration";
typedef std::unordered_map<std::string, std::shared_ptr<AppManifest>> AppManifestMap; typedef std::unordered_map<std::string, std::shared_ptr<AppManifest>> AppManifestMap;
@@ -17,12 +17,12 @@ static AppManifestMap app_manifest_map;
static Mutex hash_mutex; static Mutex hash_mutex;
void addAppManifest(const AppManifest& manifest) { void addAppManifest(const AppManifest& manifest) {
LOGGER.info("Registering manifest {}", manifest.appId); LOG_I(TAG, "Registering manifest %s", manifest.appId.c_str());
hash_mutex.lock(); hash_mutex.lock();
if (app_manifest_map.contains(manifest.appId)) { if (app_manifest_map.contains(manifest.appId)) {
LOGGER.warn("Overwriting existing manifest for {}", manifest.appId); LOG_W(TAG, "Overwriting existing manifest for %s", manifest.appId.c_str());
} }
app_manifest_map[manifest.appId] = std::make_shared<AppManifest>(manifest); app_manifest_map[manifest.appId] = std::make_shared<AppManifest>(manifest);
@@ -31,7 +31,7 @@ void addAppManifest(const AppManifest& manifest) {
} }
bool removeAppManifest(const std::string& id) { bool removeAppManifest(const std::string& id) {
LOGGER.info("Removing manifest for {}", id); LOG_I(TAG, "Removing manifest for %s", id.c_str());
auto lock = hash_mutex.asScopedLock(); auto lock = hash_mutex.asScopedLock();
lock.lock(); lock.lock();
+9 -9
View File
@@ -4,17 +4,17 @@
#include <Tactility/app/ElfApp.h> #include <Tactility/app/ElfApp.h>
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h> #include <Tactility/file/FileLock.h>
#include <Tactility/Logger.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <esp_elf.h> #include <esp_elf.h>
#include <string> #include <string>
#include <tactility/log.h>
#include <utility> #include <utility>
namespace tt::app { namespace tt::app {
static auto LOGGER = Logger("ElfApp"); constexpr auto* TAG = "ElfApp";
static std::string getErrorCodeString(int error_code) { static std::string getErrorCodeString(int error_code) {
switch (error_code) { switch (error_code) {
@@ -71,7 +71,7 @@ private:
bool startElf() { bool startElf() {
const std::string elf_path = std::format("{}/elf/{}.elf", appPath, CONFIG_IDF_TARGET); const std::string elf_path = std::format("{}/elf/{}.elf", appPath, CONFIG_IDF_TARGET);
LOGGER.info("Starting ELF {}", elf_path); LOG_I(TAG, "Starting ELF %s", elf_path.c_str());
assert(elfFileData == nullptr); assert(elfFileData == nullptr);
size_t size = 0; size_t size = 0;
@@ -85,7 +85,7 @@ private:
if (esp_elf_init(&elf) != ESP_OK) { if (esp_elf_init(&elf) != ESP_OK) {
lastError = "Failed to initialize"; lastError = "Failed to initialize";
LOGGER.error("{}", lastError); LOG_E(TAG, "%s", lastError.c_str());
elfFileData = nullptr; elfFileData = nullptr;
return false; return false;
} }
@@ -94,7 +94,7 @@ private:
if (relocate_result != 0) { if (relocate_result != 0) {
// Note: the result code maps to values from cstdlib's errno.h // Note: the result code maps to values from cstdlib's errno.h
lastError = getErrorCodeString(-relocate_result); lastError = getErrorCodeString(-relocate_result);
LOGGER.error("Application failed to load: {}", lastError); LOG_E(TAG, "Application failed to load: %s", lastError.c_str());
elfFileData = nullptr; elfFileData = nullptr;
return false; return false;
} }
@@ -104,7 +104,7 @@ private:
if (esp_elf_request(&elf, 0, argc, argv) != ESP_OK) { if (esp_elf_request(&elf, 0, argc, argv) != ESP_OK) {
lastError = "Executable returned error code"; lastError = "Executable returned error code";
LOGGER.error("{}", lastError); LOG_E(TAG, "%s", lastError.c_str());
esp_elf_deinit(&elf); esp_elf_deinit(&elf);
elfFileData = nullptr; elfFileData = nullptr;
return false; return false;
@@ -115,7 +115,7 @@ private:
} }
void stopElf() { void stopElf() {
LOGGER.info("Cleaning up ELF"); LOG_I(TAG, "Cleaning up ELF");
if (shouldCleanupElf) { if (shouldCleanupElf) {
esp_elf_deinit(&elf); esp_elf_deinit(&elf);
@@ -163,7 +163,7 @@ public:
} }
void onDestroy(AppContext& appContext) override { void onDestroy(AppContext& appContext) override {
LOGGER.info("Cleaning up app"); LOG_I(TAG, "Cleaning up app");
if (manifest != nullptr) { if (manifest != nullptr) {
if (manifest->onDestroy != nullptr) { if (manifest->onDestroy != nullptr) {
manifest->onDestroy(&appContext, data); manifest->onDestroy(&appContext, data);
@@ -222,7 +222,7 @@ void setElfAppParameters(
} }
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) { std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
LOGGER.info("createElfApp"); LOG_I(TAG, "createElfApp");
assert(manifest != nullptr); assert(manifest != nullptr);
assert(manifest->appLocation.isExternal()); assert(manifest->appLocation.isExternal());
return std::make_shared<ElfApp>(manifest->appLocation.getPath()); return std::make_shared<ElfApp>(manifest->appLocation.getPath());
+3 -3
View File
@@ -1,4 +1,3 @@
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <Tactility/app/AppManifest.h> #include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h> #include <Tactility/app/alertdialog/AlertDialog.h>
@@ -10,11 +9,12 @@
#include "tactility/drivers/uart_controller.h" #include "tactility/drivers/uart_controller.h"
#include <cstring> #include <cstring>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
namespace tt::app::addgps { namespace tt::app::addgps {
static const auto LOGGER = Logger("AddGps"); constexpr auto* TAG = "AddGps";
class AddGpsApp final : public App { class AddGpsApp final : public App {
@@ -50,7 +50,7 @@ class AddGpsApp final : public App {
return; return;
} }
LOGGER.info("Saving: uart={}, model={}, baud={}", new_configuration.uartName, (uint32_t)new_configuration.model, new_configuration.baudRate); LOG_I(TAG, "Saving: uart=%s, model=%d, baud=%u", new_configuration.uartName, (int)new_configuration.model, (unsigned)new_configuration.baudRate);
auto service = service::gps::findGpsService(); auto service = service::gps::findGpsService();
std::vector<tt::hal::gps::GpsConfiguration> configurations; std::vector<tt::hal::gps::GpsConfiguration> configurations;
@@ -3,10 +3,10 @@
#include "Tactility/lvgl/Toolbar.h" #include "Tactility/lvgl/Toolbar.h"
#include "Tactility/service/loader/Loader.h" #include "Tactility/service/loader/Loader.h"
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
namespace tt::app::alertdialog { namespace tt::app::alertdialog {
@@ -18,7 +18,7 @@ namespace tt::app::alertdialog {
#define PARAMETER_ITEM_CONCATENATION_TOKEN ";;" #define PARAMETER_ITEM_CONCATENATION_TOKEN ";;"
#define DEFAULT_TITLE "" #define DEFAULT_TITLE ""
static const auto LOGGER = Logger("AlertDialog"); constexpr auto* TAG = "AlertDialog";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -74,7 +74,7 @@ class AlertDialogApp : public App {
void onButtonClicked(lv_event_t* e) { void onButtonClicked(lv_event_t* e) {
auto index = reinterpret_cast<std::size_t>(lv_event_get_user_data(e)); auto index = reinterpret_cast<std::size_t>(lv_event_get_user_data(e));
LOGGER.info("Selected item at index {}", index); LOG_I(TAG, "Selected item at index %d", (int)index);
auto bundle = std::make_unique<Bundle>(); auto bundle = std::make_unique<Bundle>();
bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index); bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index);
+5 -5
View File
@@ -5,20 +5,20 @@
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Spinner.h> #include <Tactility/lvgl/Spinner.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/network/Http.h> #include <Tactility/network/Http.h>
#include <Tactility/Paths.h> #include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h> #include <Tactility/service/wifi/Wifi.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
#include <algorithm> #include <algorithm>
#include <format> #include <format>
namespace tt::app::apphub { namespace tt::app::apphub {
static const auto LOGGER = Logger("AppHub"); constexpr auto* TAG = "AppHub";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -57,7 +57,7 @@ class AppHubApp final : public App {
} }
void onRefreshSuccess() { void onRefreshSuccess() {
LOGGER.info("Request success"); LOG_I(TAG, "Request success");
auto lock = lvgl::getSyncLock()->asScopedLock(); auto lock = lvgl::getSyncLock()->asScopedLock();
lock.lock(); lock.lock();
@@ -65,7 +65,7 @@ class AppHubApp final : public App {
} }
void onRefreshError(const char* error) { void onRefreshError(const char* error) {
LOGGER.error("Request failed: {}", error); LOG_E(TAG, "Request failed: %s", error);
auto lock = lvgl::getSyncLock()->asScopedLock(); auto lock = lvgl::getSyncLock()->asScopedLock();
lock.lock(); lock.lock();
@@ -108,7 +108,7 @@ class AppHubApp final : public App {
lv_obj_set_size(list, LV_PCT(100), LV_SIZE_CONTENT); lv_obj_set_size(list, LV_PCT(100), LV_SIZE_CONTENT);
for (int i = 0; i < entries.size(); i++) { for (int i = 0; i < entries.size(); i++) {
auto& entry = entries[i]; auto& entry = entries[i];
LOGGER.info("Adding {}", entry.appName.c_str()); LOG_I(TAG, "Adding %s", entry.appName.c_str());
const char* icon = findAppManifestById(entry.appId) != nullptr ? LV_SYMBOL_OK : nullptr; const char* icon = findAppManifestById(entry.appId) != nullptr ? LV_SYMBOL_OK : nullptr;
auto* entry_button = lv_list_add_button(list, icon, entry.appName.c_str()); auto* entry_button = lv_list_add_button(list, icon, entry.appName.c_str());
auto int_as_voidptr = reinterpret_cast<void*>(i); auto int_as_voidptr = reinterpret_cast<void*>(i);
+7 -6
View File
@@ -1,11 +1,12 @@
#include <Tactility/app/apphub/AppHubEntry.h> #include <Tactility/app/apphub/AppHubEntry.h>
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/json/Reader.h> #include <Tactility/json/Reader.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
namespace tt::app::apphub { namespace tt::app::apphub {
static const auto LOGGER = Logger("AppHubJson"); constexpr auto* TAG = "AppHubJson";
static bool parseEntry(const cJSON* object, AppHubEntry& entry) { static bool parseEntry(const cJSON* object, AppHubEntry& entry) {
const json::Reader reader(object); const json::Reader reader(object);
@@ -25,21 +26,21 @@ bool parseJson(const std::string& filePath, std::vector<AppHubEntry>& entries) {
auto data = file::readString(filePath); auto data = file::readString(filePath);
if (data == nullptr) { if (data == nullptr) {
LOGGER.error("Failed to read {}", filePath); LOG_E(TAG, "Failed to read %s", filePath.c_str());
return false; return false;
} }
auto data_ptr = reinterpret_cast<const char*>(data.get()); auto data_ptr = reinterpret_cast<const char*>(data.get());
auto* json = cJSON_Parse(data_ptr); auto* json = cJSON_Parse(data_ptr);
if (json == nullptr) { if (json == nullptr) {
LOGGER.error("Failed to parse {}", filePath); LOG_E(TAG, "Failed to parse %s", filePath.c_str());
return false; return false;
} }
const cJSON* apps_json = cJSON_GetObjectItemCaseSensitive(json, "apps"); const cJSON* apps_json = cJSON_GetObjectItemCaseSensitive(json, "apps");
if (!cJSON_IsArray(apps_json)) { if (!cJSON_IsArray(apps_json)) {
cJSON_Delete(json); cJSON_Delete(json);
LOGGER.error("apps is not an array"); LOG_E(TAG, "apps is not an array");
return false; return false;
} }
@@ -49,7 +50,7 @@ bool parseJson(const std::string& filePath, std::vector<AppHubEntry>& entries) {
auto& entry = entries.at(i); auto& entry = entries.at(i);
auto* entry_json = cJSON_GetArrayItem(apps_json, i); auto* entry_json = cJSON_GetArrayItem(apps_json, i);
if (!parseEntry(entry_json, entry)) { if (!parseEntry(entry_json, entry)) {
LOGGER.error("Failed to read entry"); LOG_E(TAG, "Failed to read entry");
cJSON_Delete(json); cJSON_Delete(json);
return false; return false;
} }
@@ -5,18 +5,18 @@
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/network/Http.h> #include <Tactility/network/Http.h>
#include <Tactility/Paths.h> #include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
#include <format> #include <format>
namespace tt::app::apphubdetails { namespace tt::app::apphubdetails {
static const auto LOGGER = Logger("AppHubDetails"); constexpr auto* TAG = "AppHubDetails";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -85,7 +85,7 @@ class AppHubDetailsApp final : public App {
} }
void uninstallApp() { void uninstallApp() {
LOGGER.info("Uninstall"); LOG_I(TAG, "Uninstall");
lvgl::getSyncLock()->lock(); lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
@@ -110,9 +110,9 @@ class AppHubDetailsApp final : public App {
install(temp_file_path); install(temp_file_path);
if (!file::deleteFile(temp_file_path)) { if (!file::deleteFile(temp_file_path)) {
LOGGER.warn("Failed to remove {}", temp_file_path); LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
} else { } else {
LOGGER.info("Deleted temporary file {}", temp_file_path); LOG_I(TAG, "Deleted temporary file %s", temp_file_path.c_str());
} }
lvgl::getSyncLock()->lock(); lvgl::getSyncLock()->lock();
@@ -120,18 +120,18 @@ class AppHubDetailsApp final : public App {
lvgl::getSyncLock()->unlock(); lvgl::getSyncLock()->unlock();
}, },
[temp_file_path](const char* errorMessage) { [temp_file_path](const char* errorMessage) {
LOGGER.error("Download failed: {}", errorMessage); LOG_E(TAG, "Download failed: %s", errorMessage);
alertdialog::start("Error", "Failed to install app"); alertdialog::start("Error", "Failed to install app");
if (file::isFile(temp_file_path) && !file::deleteFile(temp_file_path.c_str())) { if (file::isFile(temp_file_path) && !file::deleteFile(temp_file_path.c_str())) {
LOGGER.warn("Failed to remove {}", temp_file_path); LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
} }
} }
); );
} }
void installApp() { void installApp() {
LOGGER.info("Install"); LOG_I(TAG, "Install");
lvgl::getSyncLock()->lock(); lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
@@ -141,15 +141,15 @@ class AppHubDetailsApp final : public App {
} }
void updateApp() { void updateApp() {
LOGGER.info("Update"); LOG_I(TAG, "Update");
lvgl::getSyncLock()->lock(); lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
lvgl::getSyncLock()->unlock(); lvgl::getSyncLock()->unlock();
LOGGER.info("Removing previous version"); LOG_I(TAG, "Removing previous version");
uninstall(entry.appId); uninstall(entry.appId);
LOGGER.info("Installing new version"); LOG_I(TAG, "Installing new version");
doInstall(); doInstall();
} }
@@ -175,13 +175,13 @@ public:
void onCreate(AppContext& appContext) override { void onCreate(AppContext& appContext) override {
auto parameters = appContext.getParameters(); auto parameters = appContext.getParameters();
if (parameters == nullptr) { if (parameters == nullptr) {
LOGGER.error("No parameters"); LOG_E(TAG, "No parameters");
stop(); stop();
return; return;
} }
if (!fromBundle(*parameters.get(), entry)) { if (!fromBundle(*parameters.get(), entry)) {
LOGGER.error("Invalid parameters"); LOG_E(TAG, "Invalid parameters");
stop(); stop();
} }
} }
@@ -1,6 +1,5 @@
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
#include <Tactility/Logger.h>
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <Tactility/app/App.h> #include <Tactility/app/App.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
@@ -8,10 +7,11 @@
#include <Tactility/settings/WebServerSettings.h> #include <Tactility/settings/WebServerSettings.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
namespace tt::app::apwebserver { namespace tt::app::apwebserver {
static const auto LOGGER = tt::Logger("ApWebServerApp"); constexpr auto* TAG = "ApWebServerApp";
class ApWebServerApp final : public App { class ApWebServerApp final : public App {
lv_obj_t* labelSsidValue = nullptr; lv_obj_t* labelSsidValue = nullptr;
@@ -91,7 +91,7 @@ public:
// Apply settings and start services // Apply settings and start services
getMainDispatcher().dispatch([apSettings] { getMainDispatcher().dispatch([apSettings] {
if (!settings::webserver::save(apSettings)) { if (!settings::webserver::save(apSettings)) {
LOGGER.error("Failed to save AP settings"); LOG_E(TAG, "Failed to save AP settings");
return; return;
} }
service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged); service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged);
@@ -106,13 +106,13 @@ public:
getMainDispatcher().dispatch([copy, webServerChanged] { getMainDispatcher().dispatch([copy, webServerChanged] {
if (!settings::webserver::save(copy)) { if (!settings::webserver::save(copy)) {
LOGGER.warn("Failed to persist WebServer settings; changes may be lost on reboot"); LOG_W(TAG, "Failed to persist WebServer settings; changes may be lost on reboot");
} }
service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged); service::webserver::getPubsub()->publish(service::webserver::WebServerEvent::WebServerSettingsChanged);
if (webServerChanged) { if (webServerChanged) {
LOGGER.info("WebServer {}", copy.webServerEnabled ? "enabling..." : "disabling..."); LOG_I(TAG, "WebServer %s", copy.webServerEnabled ? "enabling..." : "disabling...");
service::webserver::setWebServerEnabled(copy.webServerEnabled); service::webserver::setWebServerEnabled(copy.webServerEnabled);
} }
}); });
+16 -16
View File
@@ -9,7 +9,6 @@
#include <Tactility/hal/display/DisplayDevice.h> #include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/usb/Usb.h> #include <Tactility/hal/usb/Usb.h>
#include <Tactility/kernel/SystemEvents.h> #include <Tactility/kernel/SystemEvents.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Style.h> #include <Tactility/lvgl/Style.h>
#include <Tactility/Paths.h> #include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
@@ -17,6 +16,7 @@
#include <Tactility/settings/DisplaySettings.h> #include <Tactility/settings/DisplaySettings.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
#include <atomic> #include <atomic>
@@ -31,7 +31,7 @@
namespace tt::app::boot { namespace tt::app::boot {
static const auto LOGGER = Logger("Boot"); constexpr auto* TAG = "Boot";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -67,17 +67,17 @@ class BootApp : public App {
if (settings::display::load(settings)) { if (settings::display::load(settings)) {
if (hal_display->getGammaCurveCount() > 0) { if (hal_display->getGammaCurveCount() > 0) {
hal_display->setGammaCurve(settings.gammaCurve); hal_display->setGammaCurve(settings.gammaCurve);
LOGGER.info("Gamma curve {}", settings.gammaCurve); LOG_I(TAG, "Gamma curve %d", settings.gammaCurve);
} }
} else { } else {
settings = settings::display::getDefault(); settings = settings::display::getDefault();
} }
if (hal_display->supportsBacklightDuty()) { if (hal_display->supportsBacklightDuty()) {
LOGGER.info("Backlight {}", settings.backlightDuty); LOG_I(TAG, "Backlight %d", settings.backlightDuty);
hal_display->setBacklightDuty(settings.backlightDuty); hal_display->setBacklightDuty(settings.backlightDuty);
} else { } else {
LOGGER.info("No backlight"); LOG_I(TAG, "No backlight");
} }
} }
@@ -86,17 +86,17 @@ class BootApp : public App {
return false; return false;
} }
LOGGER.info("Rebooting into mass storage device mode"); LOG_I(TAG, "Rebooting into mass storage device mode");
auto mode = hal::usb::getUsbBootMode(); // Get mode before reset auto mode = hal::usb::getUsbBootMode(); // Get mode before reset
hal::usb::resetUsbBootMode(); hal::usb::resetUsbBootMode();
if (mode == hal::usb::BootMode::Flash) { if (mode == hal::usb::BootMode::Flash) {
if (!hal::usb::startMassStorageWithFlash(true)) { if (!hal::usb::startMassStorageWithFlash(true)) {
LOGGER.error("Unable to start flash mass storage"); LOG_E(TAG, "Unable to start flash mass storage");
return false; return false;
} }
} else if (mode == hal::usb::BootMode::Sdmmc) { } else if (mode == hal::usb::BootMode::Sdmmc) {
if (!hal::usb::startMassStorageWithSdmmc(true)) { if (!hal::usb::startMassStorageWithSdmmc(true)) {
LOGGER.error("Unable to start SD mass storage"); LOG_E(TAG, "Unable to start SD mass storage");
return false; return false;
} }
} }
@@ -114,7 +114,7 @@ class BootApp : public App {
} }
static int32_t bootThreadCallback() { static int32_t bootThreadCallback() {
LOGGER.info("Starting boot thread"); LOG_I(TAG, "Starting boot thread");
const auto start_time = kernel::getTicks(); const auto start_time = kernel::getTicks();
// Give the UI some time to redraw // Give the UI some time to redraw
@@ -124,20 +124,20 @@ class BootApp : public App {
kernel::delayMillis(10); kernel::delayMillis(10);
// TODO: Support for multiple displays // TODO: Support for multiple displays
LOGGER.info("Setup display"); LOG_I(TAG, "Setup display");
setupDisplay(); // Set backlight setupDisplay(); // Set backlight
prepareFileSystems(); prepareFileSystems();
#ifdef CONFIG_TT_USER_DATA_LOCATION_SD #ifdef CONFIG_TT_USER_DATA_LOCATION_SD
std::string sd_path; std::string sd_path;
if (!findFirstMountedSdCardPath(sd_path)) { if (!findFirstMountedSdCardPath(sd_path)) {
LOGGER.error("SD card not found"); LOG_E(TAG, "SD card not found");
sdCardMissing = true; sdCardMissing = true;
} }
#endif #endif
if (!setupUsbBootMode()) { if (!setupUsbBootMode()) {
LOGGER.info("initFromBootApp"); LOG_I(TAG, "initFromBootApp");
registerApps(); registerApps();
waitForMinimalSplashDuration(start_time); waitForMinimalSplashDuration(start_time);
// When SD card is missing, wait for dialog result // When SD card is missing, wait for dialog result
@@ -147,7 +147,7 @@ class BootApp : public App {
// This event will likely block as other systems are initialized // This event will likely block as other systems are initialized
// e.g. Wi-Fi reads AP configs from SD card // e.g. Wi-Fi reads AP configs from SD card
LOGGER.info("Publish event"); LOG_I(TAG, "Publish event");
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash); kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
return 0; return 0;
@@ -162,13 +162,13 @@ class BootApp : public App {
// When boot properties didn't specify an override, return default // When boot properties didn't specify an override, return default
if (boot_properties.launcherAppId.empty()) { if (boot_properties.launcherAppId.empty()) {
LOGGER.error("Failed to load launcher configuration, or launcher not configured"); LOG_E(TAG, "Failed to load launcher configuration, or launcher not configured");
return CONFIG_TT_LAUNCHER_APP_ID; return CONFIG_TT_LAUNCHER_APP_ID;
} }
// If the app in the boot.properties does not exist, return default // If the app in the boot.properties does not exist, return default
if (findAppManifestById(boot_properties.launcherAppId) == nullptr) { if (findAppManifestById(boot_properties.launcherAppId) == nullptr) {
LOGGER.error("Launcher app {} not found", boot_properties.launcherAppId); LOG_E(TAG, "Launcher app %s not found", boot_properties.launcherAppId.c_str());
return CONFIG_TT_LAUNCHER_APP_ID; return CONFIG_TT_LAUNCHER_APP_ID;
} }
@@ -239,7 +239,7 @@ public:
logo = isUsbBootSplash ? "logo_usb.png" : "logo.png"; logo = isUsbBootSplash ? "logo_usb.png" : "logo.png";
} }
const auto logo_path = lvgl::PATH_PREFIX + paths->getAssetsPath(logo); const auto logo_path = lvgl::PATH_PREFIX + paths->getAssetsPath(logo);
LOGGER.info("{}", logo_path); LOG_I(TAG, "%s", logo_path.c_str());
lv_image_set_src(image, logo_path.c_str()); lv_image_set_src(image, logo_path.c_str());
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
+9 -9
View File
@@ -1,18 +1,18 @@
#include <Tactility/app/btmanage/BtManagePrivate.h> #include <Tactility/app/btmanage/BtManagePrivate.h>
#include <Tactility/app/btmanage/View.h> #include <Tactility/app/btmanage/View.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/AppContext.h> #include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h> #include <Tactility/app/AppManifest.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/Tactility.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
namespace tt::app::btmanage { namespace tt::app::btmanage {
static const auto LOGGER = Logger("BtManage"); constexpr auto* TAG = "BtManage";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -83,7 +83,7 @@ void BtManage::requestViewUpdate() {
view.update(); view.update();
lvgl::unlock(); lvgl::unlock();
} else { } else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL"); LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
} }
} }
unlock(); unlock();
@@ -91,7 +91,7 @@ void BtManage::requestViewUpdate() {
void BtManage::onBtEvent(const struct BtEvent& event) { void BtManage::onBtEvent(const struct BtEvent& event) {
auto radio_state = bluetooth::getRadioState(); auto radio_state = bluetooth::getRadioState();
LOGGER.info("Update with state {}", bluetooth::radioStateToString(radio_state)); LOG_I(TAG, "Update with state %s", bluetooth::radioStateToString(radio_state));
getState().setRadioState(radio_state); getState().setRadioState(radio_state);
switch (event.type) { switch (event.type) {
case BT_EVENT_SCAN_STARTED: case BT_EVENT_SCAN_STARTED:
@@ -162,10 +162,10 @@ void BtManage::onShow(AppContext& app, lv_obj_t* parent) {
auto radio_state = bluetooth::getRadioState(); auto radio_state = bluetooth::getRadioState();
bool can_scan = radio_state == bluetooth::RadioState::On; bool can_scan = radio_state == bluetooth::RadioState::On;
LOGGER.info("Radio: {}, Scanning: {}, Can scan: {}", LOG_I(TAG, "Radio: %s, Scanning: %d, Can scan: %d",
bluetooth::radioStateToString(radio_state), bluetooth::radioStateToString(radio_state),
dev ? bluetooth_is_scanning(dev) : false, (int)(dev ? bluetooth_is_scanning(dev) : false),
can_scan); (int)can_scan);
if (can_scan && dev && !bluetooth_is_scanning(dev)) { if (can_scan && dev && !bluetooth_is_scanning(dev)) {
bluetooth_scan_start(dev); bluetooth_scan_start(dev);
} }
-1
View File
@@ -6,7 +6,6 @@
#include <Tactility/app/btmanage/View.h> #include <Tactility/app/btmanage/View.h>
#include <Tactility/app/btmanage/BtManagePrivate.h> #include <Tactility/app/btmanage/BtManagePrivate.h>
#include <Tactility/app/btpeersettings/BtPeerSettings.h> #include <Tactility/app/btpeersettings/BtPeerSettings.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Style.h> #include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/bluetooth/Bluetooth.h> #include <Tactility/bluetooth/Bluetooth.h>
@@ -3,7 +3,6 @@
#include "tactility/device.h" #include "tactility/device.h"
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/app/App.h> #include <Tactility/app/App.h>
#include <Tactility/app/AppContext.h> #include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h> #include <Tactility/app/AppManifest.h>
@@ -15,12 +14,13 @@
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <tactility/check.h> #include <tactility/check.h>
#include <tactility/drivers/bluetooth.h> #include <tactility/drivers/bluetooth.h>
#include <tactility/log.h>
#include <lvgl.h> #include <lvgl.h>
namespace tt::app::btpeersettings { namespace tt::app::btpeersettings {
static const auto LOGGER = Logger("BtPeerSettings"); constexpr auto* TAG = "BtPeerSettings";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -77,7 +77,7 @@ class BtPeerSettings : public App {
if (bluetooth::settings::load(self->addrHex, device)) { if (bluetooth::settings::load(self->addrHex, device)) {
device.autoConnect = is_on; device.autoConnect = is_on;
if (!bluetooth::settings::save(device)) { if (!bluetooth::settings::save(device)) {
LOGGER.error("Failed to save auto-connect setting"); LOG_E(TAG, "Failed to save auto-connect setting");
} }
} }
} }
@@ -88,7 +88,7 @@ class BtPeerSettings : public App {
updateViews(); updateViews();
lvgl::unlock(); lvgl::unlock();
} else { } else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL"); LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
} }
} }
} }
+6 -6
View File
@@ -8,18 +8,18 @@
#include <Tactility/app/chat/ChatProtocol.h> #include <Tactility/app/chat/ChatProtocol.h>
#include <Tactility/app/AppManifest.h> #include <Tactility/app/AppManifest.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <cstdlib> #include <cstdlib>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
#include <vector> #include <vector>
namespace tt::app::chat { namespace tt::app::chat {
static const auto LOGGER = Logger("ChatApp"); constexpr auto* TAG = "ChatApp";
static constexpr uint8_t BROADCAST_ADDRESS[ESP_NOW_ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static constexpr uint8_t BROADCAST_ADDRESS[ESP_NOW_ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
void ChatApp::enableEspNow() { void ChatApp::enableEspNow() {
@@ -98,12 +98,12 @@ void ChatApp::sendMessage(const std::string& text) {
std::vector<uint8_t> wireMsg; std::vector<uint8_t> wireMsg;
if (!serializeTextMessage(settings.senderId, BROADCAST_ID, nickname, channel, text, wireMsg)) { if (!serializeTextMessage(settings.senderId, BROADCAST_ID, nickname, channel, text, wireMsg)) {
LOGGER.error("Failed to serialize message"); LOG_E(TAG, "Failed to serialize message");
return; return;
} }
if (!service::espnow::send(BROADCAST_ADDRESS, wireMsg.data(), wireMsg.size())) { if (!service::espnow::send(BROADCAST_ADDRESS, wireMsg.data(), wireMsg.size())) {
LOGGER.error("Failed to send message"); LOG_E(TAG, "Failed to send message");
return; return;
} }
@@ -144,7 +144,7 @@ void ChatApp::applySettings(const std::string& nickname, const std::string& keyH
} }
settings.hasEncryptionKey = true; settings.hasEncryptionKey = true;
} else { } else {
LOGGER.warn("Invalid hex characters in encryption key"); LOG_W(TAG, "Invalid hex characters in encryption key");
} }
} else if (keyHex.empty()) { } else if (keyHex.empty()) {
if (settings.hasEncryptionKey) { if (settings.hasEncryptionKey) {
@@ -153,7 +153,7 @@ void ChatApp::applySettings(const std::string& nickname, const std::string& keyH
needRestart = true; needRestart = true;
} }
} else { } else {
LOGGER.warn("Key must be exactly {} hex characters, got {}", ESP_NOW_KEY_LEN * 2, keyHex.size()); LOG_W(TAG, "Key must be exactly %d hex characters, got %d", (int)(ESP_NOW_KEY_LEN * 2), (int)keyHex.size());
} }
state.setLocalNickname(settings.nickname); state.setLocalNickname(settings.nickname);
+7 -7
View File
@@ -10,7 +10,6 @@
#include <Tactility/crypt/Crypt.h> #include <Tactility/crypt/Crypt.h>
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/file/PropertiesFile.h> #include <Tactility/file/PropertiesFile.h>
#include <Tactility/Logger.h>
#include <Tactility/Paths.h> #include <Tactility/Paths.h>
#include <esp_random.h> #include <esp_random.h>
@@ -20,11 +19,12 @@
#include <iomanip> #include <iomanip>
#include <map> #include <map>
#include <sstream> #include <sstream>
#include <tactility/log.h>
#include <unistd.h> #include <unistd.h>
namespace tt::app::chat { namespace tt::app::chat {
static const auto LOGGER = Logger("ChatSettings"); constexpr auto* TAG = "ChatSettings";
static std::string getSettingsFilePath() { static std::string getSettingsFilePath() {
return getUserDataPath() + "/settings/chat.properties"; return getUserDataPath() + "/settings/chat.properties";
@@ -52,7 +52,7 @@ static std::string toHexString(const uint8_t* data, size_t length) {
static bool readHex(const std::string& input, uint8_t* buffer, size_t length) { static bool readHex(const std::string& input, uint8_t* buffer, size_t length) {
if (input.size() != length * 2) { if (input.size() != length * 2) {
LOGGER.error("readHex() length mismatch"); LOG_E(TAG, "readHex() length mismatch");
return false; return false;
} }
@@ -63,7 +63,7 @@ static bool readHex(const std::string& input, uint8_t* buffer, size_t length) {
char* endptr; char* endptr;
unsigned long val = strtoul(hex, &endptr, 16); unsigned long val = strtoul(hex, &endptr, 16);
if (endptr != hex + 2) { if (endptr != hex + 2) {
LOGGER.error("readHex() invalid hex character"); LOG_E(TAG, "readHex() invalid hex character");
return false; return false;
} }
buffer[i] = static_cast<uint8_t>(val); buffer[i] = static_cast<uint8_t>(val);
@@ -77,7 +77,7 @@ static bool encryptKey(const uint8_t key[ESP_NOW_KEY_LEN], std::string& hexOutpu
uint8_t encrypted[ESP_NOW_KEY_LEN]; uint8_t encrypted[ESP_NOW_KEY_LEN];
if (crypt::encrypt(iv, key, encrypted, ESP_NOW_KEY_LEN) != 0) { if (crypt::encrypt(iv, key, encrypted, ESP_NOW_KEY_LEN) != 0) {
LOGGER.error("Failed to encrypt key"); LOG_E(TAG, "Failed to encrypt key");
return false; return false;
} }
@@ -99,7 +99,7 @@ static bool decryptKey(const std::string& hexInput, uint8_t key[ESP_NOW_KEY_LEN]
crypt::getIv(IV_SEED, std::strlen(IV_SEED), iv); crypt::getIv(IV_SEED, std::strlen(IV_SEED), iv);
if (crypt::decrypt(iv, encrypted, key, ESP_NOW_KEY_LEN) != 0) { if (crypt::decrypt(iv, encrypted, key, ESP_NOW_KEY_LEN) != 0) {
LOGGER.error("Failed to decrypt key"); LOG_E(TAG, "Failed to decrypt key");
return false; return false;
} }
return true; return true;
@@ -188,7 +188,7 @@ bool saveSettings(const ChatSettingsData& settings) {
auto settings_path = getSettingsFilePath(); auto settings_path = getSettingsFilePath();
if (!file::findOrCreateParentDirectory(settings_path, 0755)) { if (!file::findOrCreateParentDirectory(settings_path, 0755)) {
LOGGER.error("Failed to create parent dir for {}", settings_path); LOG_E(TAG, "Failed to create parent dir for %s", settings_path.c_str());
return false; return false;
} }
return file::savePropertiesFile(settings_path, map); return file::savePropertiesFile(settings_path, map);
@@ -4,16 +4,16 @@
#include <Tactility/app/crashdiagnostics/QrUrl.h> #include <Tactility/app/crashdiagnostics/QrUrl.h>
#include <Tactility/app/launcher/Launcher.h> #include <Tactility/app/launcher/Launcher.h>
#include <tactility/hal/Device.h> #include <tactility/hal/Device.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Statusbar.h> #include <Tactility/lvgl/Statusbar.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <lvgl.h> #include <lvgl.h>
#include <qrcode.h> #include <qrcode.h>
#include <tactility/log.h>
namespace tt::app::crashdiagnostics { namespace tt::app::crashdiagnostics {
static const auto LOGGER = Logger("CrashDiagnostics"); constexpr auto* TAG = "CrashDiagnostics";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -44,38 +44,38 @@ public:
lv_obj_align(bottom_label, LV_ALIGN_BOTTOM_MID, 0, -2); lv_obj_align(bottom_label, LV_ALIGN_BOTTOM_MID, 0, -2);
std::string url = getUrlFromCrashData(); std::string url = getUrlFromCrashData();
LOGGER.info("{}", url); LOG_I(TAG, "%s", url.c_str());
size_t url_length = url.length(); size_t url_length = url.length();
int qr_version; int qr_version;
if (!getQrVersionForBinaryDataLength(url_length, qr_version)) { if (!getQrVersionForBinaryDataLength(url_length, qr_version)) {
LOGGER.error("QR is too large"); LOG_E(TAG, "QR is too large");
stop(manifest.appId); stop(manifest.appId);
return; return;
} }
LOGGER.info("QR version {} (length: {})", qr_version, url_length); LOG_I(TAG, "QR version %d (length: %d)", qr_version, (int)url_length);
auto qrcodeData = std::make_shared<uint8_t[]>(qrcode_getBufferSize(qr_version)); auto qrcodeData = std::make_shared<uint8_t[]>(qrcode_getBufferSize(qr_version));
if (qrcodeData == nullptr) { if (qrcodeData == nullptr) {
LOGGER.error("Failed to allocate QR buffer"); LOG_E(TAG, "Failed to allocate QR buffer");
stop(manifest.appId); stop(manifest.appId);
return; return;
} }
QRCode qrcode; QRCode qrcode;
LOGGER.info("QR init text"); LOG_I(TAG, "QR init text");
if (qrcode_initText(&qrcode, qrcodeData.get(), qr_version, ECC_LOW, url.c_str()) != 0) { if (qrcode_initText(&qrcode, qrcodeData.get(), qr_version, ECC_LOW, url.c_str()) != 0) {
LOGGER.error("QR init text failed"); LOG_E(TAG, "QR init text failed");
stop(manifest.appId); stop(manifest.appId);
return; return;
} }
LOGGER.info("QR size: {}", qrcode.size); LOG_I(TAG, "QR size: %d", qrcode.size);
// Calculate QR dot size // Calculate QR dot size
int32_t top_label_height = lv_obj_get_height(top_label) + 2; int32_t top_label_height = lv_obj_get_height(top_label) + 2;
int32_t bottom_label_height = lv_obj_get_height(bottom_label) + 2; int32_t bottom_label_height = lv_obj_get_height(bottom_label) + 2;
LOGGER.info("Create canvas"); LOG_I(TAG, "Create canvas");
int32_t available_height = parent_height - top_label_height - bottom_label_height; int32_t available_height = parent_height - top_label_height - bottom_label_height;
int32_t available_width = lv_display_get_horizontal_resolution(display); int32_t available_width = lv_display_get_horizontal_resolution(display);
int32_t smallest_size = std::min(available_height, available_width); int32_t smallest_size = std::min(available_height, available_width);
@@ -85,7 +85,7 @@ public:
} else if (qrcode.size <= smallest_size) { } else if (qrcode.size <= smallest_size) {
pixel_size = 1; pixel_size = 1;
} else { } else {
LOGGER.error("QR code won't fit screen"); LOG_E(TAG, "QR code won't fit screen");
stop(manifest.appId); stop(manifest.appId);
return; return;
} }
@@ -97,10 +97,10 @@ public:
lv_obj_set_content_height(canvas, qrcode.size * pixel_size); lv_obj_set_content_height(canvas, qrcode.size * pixel_size);
lv_obj_set_content_width(canvas, qrcode.size * pixel_size); lv_obj_set_content_width(canvas, qrcode.size * pixel_size);
LOGGER.info("Create draw buffer"); LOG_I(TAG, "Create draw buffer");
auto* draw_buf = lv_draw_buf_create(pixel_size * qrcode.size, pixel_size * qrcode.size, LV_COLOR_FORMAT_RGB565, LV_STRIDE_AUTO); auto* draw_buf = lv_draw_buf_create(pixel_size * qrcode.size, pixel_size * qrcode.size, LV_COLOR_FORMAT_RGB565, LV_STRIDE_AUTO);
if (draw_buf == nullptr) { if (draw_buf == nullptr) {
LOGGER.error("Failed to allocate draw buffer"); LOG_E(TAG, "Failed to allocate draw buffer");
stop(manifest.appId); stop(manifest.appId);
return; return;
} }
@@ -7,12 +7,12 @@
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Style.h> #include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/service/development/DevelopmentService.h> #include <Tactility/service/development/DevelopmentService.h>
#include <Tactility/service/development/DevelopmentSettings.h> #include <Tactility/service/development/DevelopmentSettings.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h> #include <Tactility/service/wifi/Wifi.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
#include <cstring> #include <cstring>
@@ -20,7 +20,7 @@
namespace tt::app::development { namespace tt::app::development {
static const auto LOGGER = Logger("Development"); constexpr auto* TAG = "Development";
extern const AppManifest manifest; extern const AppManifest manifest;
class DevelopmentApp final : public App { class DevelopmentApp final : public App {
@@ -87,7 +87,7 @@ public:
void onCreate(AppContext& appContext) override { void onCreate(AppContext& appContext) override {
service = service::development::findService(); service = service::development::findService();
if (service == nullptr) { if (service == nullptr) {
LOGGER.error("Service not found"); LOG_E(TAG, "Service not found");
stop(manifest.appId); stop(manifest.appId);
} }
} }
+3 -3
View File
@@ -6,7 +6,6 @@
#include <Tactility/service/displayidle/DisplayIdleService.h> #include <Tactility/service/displayidle/DisplayIdleService.h>
#endif #endif
#include <Tactility/Logger.h>
#include <Tactility/app/App.h> #include <Tactility/app/App.h>
#include <Tactility/hal/display/DisplayDevice.h> #include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/touch/TouchDevice.h> #include <Tactility/hal/touch/TouchDevice.h>
@@ -14,11 +13,12 @@
#include <Tactility/settings/DisplaySettings.h> #include <Tactility/settings/DisplaySettings.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_module.h> #include <tactility/lvgl_module.h>
namespace tt::app::display { namespace tt::app::display {
static const auto LOGGER = Logger("Display"); constexpr auto* TAG = "Display";
static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() { static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() {
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display); return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
@@ -74,7 +74,7 @@ class DisplayApp final : public App {
auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event)); auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event));
auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event)); auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event));
uint32_t selected_index = lv_dropdown_get_selected(dropdown); uint32_t selected_index = lv_dropdown_get_selected(dropdown);
LOGGER.info("Selected {}", selected_index); LOG_I(TAG, "Selected %u", (unsigned)selected_index);
auto selected_orientation = static_cast<settings::display::Orientation>(selected_index); auto selected_orientation = static_cast<settings::display::Orientation>(selected_index);
if (selected_orientation != app->displaySettings.orientation) { if (selected_orientation != app->displaySettings.orientation) {
app->displaySettings.orientation = selected_orientation; app->displaySettings.orientation = selected_orientation;
+11 -11
View File
@@ -1,11 +1,11 @@
#include <Tactility/app/files/State.h> #include <Tactility/app/files/State.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/MountPoints.h> #include <Tactility/MountPoints.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/kernel/Platform.h> #include <Tactility/kernel/Platform.h>
#include <tactility/log.h>
#include <cstring> #include <cstring>
#include <dirent.h> #include <dirent.h>
@@ -14,7 +14,7 @@
namespace tt::app::files { namespace tt::app::files {
static const auto LOGGER = Logger("Files"); constexpr auto* TAG = "Files";
State::State() { State::State() {
if (kernel::getPlatform() == kernel::PlatformSimulator) { if (kernel::getPlatform() == kernel::PlatformSimulator) {
@@ -22,7 +22,7 @@ State::State() {
if (getcwd(cwd, sizeof(cwd)) != nullptr) { if (getcwd(cwd, sizeof(cwd)) != nullptr) {
setEntriesForPath(cwd); setEntriesForPath(cwd);
} else { } else {
LOGGER.error("Failed to get current work directory files"); LOG_E(TAG, "Failed to get current work directory files");
setEntriesForPath("/"); setEntriesForPath("/");
} }
} else { } else {
@@ -37,11 +37,11 @@ std::string State::getSelectedChildPath() const {
bool State::setEntriesForPath(const std::string& path) { bool State::setEntriesForPath(const std::string& path) {
auto lock = mutex.asScopedLock(); auto lock = mutex.asScopedLock();
if (!lock.lock(100)) { if (!lock.lock(100)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath"); LOG_E(TAG, "Mutex acquisition timeout (%s)", "setEntriesForPath");
return false; return false;
} }
LOGGER.info("Changing path: {} -> {}", current_path, path); LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
/** /**
* On PC, the root entry point ("/") is a folder. * On PC, the root entry point ("/") is a folder.
@@ -49,7 +49,7 @@ bool State::setEntriesForPath(const std::string& path) {
*/ */
bool get_mount_points = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/"); bool get_mount_points = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
if (get_mount_points) { if (get_mount_points) {
LOGGER.info("Setting custom root"); LOG_I(TAG, "Setting custom root");
dir_entries = file::getFileSystemDirents(); dir_entries = file::getFileSystemDirents();
current_path = path; current_path = path;
selected_child_entry = ""; selected_child_entry = "";
@@ -59,13 +59,13 @@ bool State::setEntriesForPath(const std::string& path) {
dir_entries.clear(); dir_entries.clear();
int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType); int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
if (count >= 0) { if (count >= 0) {
LOGGER.info("{} has {} entries", path, count); LOG_I(TAG, "%s has %d entries", path.c_str(), count);
current_path = path; current_path = path;
selected_child_entry = ""; selected_child_entry = "";
action = ActionNone; action = ActionNone;
return true; return true;
} else { } else {
LOGGER.error("Failed to fetch entries for {}", path); LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
return false; return false;
} }
} }
@@ -73,7 +73,7 @@ bool State::setEntriesForPath(const std::string& path) {
bool State::setEntriesForChildPath(const std::string& childPath) { bool State::setEntriesForChildPath(const std::string& childPath) {
auto path = file::getChildPath(current_path, childPath); auto path = file::getChildPath(current_path, childPath);
LOGGER.info("Navigating from {} to {}", current_path, path); LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
return setEntriesForPath(path); return setEntriesForPath(path);
} }
+37 -37
View File
@@ -2,7 +2,6 @@
#include <Tactility/app/files/View.h> #include <Tactility/app/files/View.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <Tactility/app/ElfApp.h> #include <Tactility/app/ElfApp.h>
@@ -18,6 +17,7 @@
#include <tactility/device.h> #include <tactility/device.h>
#include <tactility/drivers/usb_host_msc.h> #include <tactility/drivers/usb_host_msc.h>
#include <tactility/log.h>
#include <cctype> #include <cctype>
#include <cstdio> #include <cstdio>
@@ -30,7 +30,7 @@
namespace tt::app::files { namespace tt::app::files {
static const auto LOGGER = Logger("Files"); constexpr auto* TAG = "Files";
// region Callbacks // region Callbacks
@@ -202,11 +202,11 @@ void View::viewFile(const std::string& path, const std::string& filename) {
if (kernel::getPlatform() == kernel::PlatformSimulator) { if (kernel::getPlatform() == kernel::PlatformSimulator) {
char cwd[PATH_MAX]; char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == nullptr) { if (getcwd(cwd, sizeof(cwd)) == nullptr) {
LOGGER.error("Failed to get current working directory"); LOG_E(TAG, "Failed to get current working directory");
return; return;
} }
if (!file_path.starts_with(cwd)) { if (!file_path.starts_with(cwd)) {
LOGGER.error("Can only work with files in working directory {}", cwd); LOG_E(TAG, "Can only work with files in working directory %s", cwd);
return; return;
} }
processed_filepath = file_path.substr(strlen(cwd)); processed_filepath = file_path.substr(strlen(cwd));
@@ -214,7 +214,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
processed_filepath = file_path; processed_filepath = file_path;
} }
LOGGER.info("Clicked {}", file_path); LOG_I(TAG, "Clicked %s", file_path.c_str());
if (isSupportedAppFile(filename)) { if (isSupportedAppFile(filename)) {
#ifdef ESP_PLATFORM #ifdef ESP_PLATFORM
@@ -234,7 +234,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
notes::start(processed_filepath.substr(1)); notes::start(processed_filepath.substr(1));
} }
} else { } else {
LOGGER.warn("Opening files of this type is not supported"); LOG_W(TAG, "Opening files of this type is not supported");
} }
onNavigate(); onNavigate();
@@ -260,7 +260,7 @@ void View::onDirEntryPressed(uint32_t index) {
return; return;
} }
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type); LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, (int)dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name); state->setSelectedChildEntry(dir_entry.d_name);
using namespace tt::file; using namespace tt::file;
@@ -273,7 +273,7 @@ void View::onDirEntryPressed(uint32_t index) {
break; break;
case TT_DT_LNK: case TT_DT_LNK:
LOGGER.warn("opening links is not supported"); LOG_W(TAG, "opening links is not supported");
break; break;
default: default:
@@ -289,7 +289,7 @@ void View::onDirEntryLongPressed(int32_t index) {
return; return;
} }
LOGGER.info("Long-pressed {} {}", dir_entry.d_name, dir_entry.d_type); LOG_I(TAG, "Long-pressed %s %d", dir_entry.d_name, (int)dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name); state->setSelectedChildEntry(dir_entry.d_name);
if (state->getCurrentPath() == "/") { if (state->getCurrentPath() == "/") {
@@ -310,7 +310,7 @@ void View::onDirEntryLongPressed(int32_t index) {
break; break;
case TT_DT_LNK: case TT_DT_LNK:
LOGGER.warn("Opening links is not supported"); LOG_W(TAG, "Opening links is not supported");
break; break;
default: default:
@@ -369,7 +369,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
void View::onNavigateUpPressed() { void View::onNavigateUpPressed() {
if (state->getCurrentPath() != "/") { if (state->getCurrentPath() != "/") {
LOGGER.info("Navigating upwards"); LOG_I(TAG, "Navigating upwards");
std::string new_absolute_path; std::string new_absolute_path;
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) { if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
state->setEntriesForPath(new_absolute_path); state->setEntriesForPath(new_absolute_path);
@@ -381,14 +381,14 @@ void View::onNavigateUpPressed() {
void View::onRenamePressed() { void View::onRenamePressed() {
std::string entry_name = state->getSelectedChildEntry(); std::string entry_name = state->getSelectedChildEntry();
LOGGER.info("Pending rename {}", entry_name); LOG_I(TAG, "Pending rename %s", entry_name.c_str());
state->setPendingAction(State::ActionRename); state->setPendingAction(State::ActionRename);
inputdialog::start("Rename", "", entry_name); inputdialog::start("Rename", "", entry_name);
} }
void View::onDeletePressed() { void View::onDeletePressed() {
std::string file_path = state->getSelectedChildPath(); std::string file_path = state->getSelectedChildPath();
LOGGER.info("Pending delete {}", file_path); LOG_I(TAG, "Pending delete %s", file_path.c_str());
state->setPendingAction(State::ActionDelete); state->setPendingAction(State::ActionDelete);
std::string message = "Do you want to delete this?\n" + file_path; std::string message = "Do you want to delete this?\n" + file_path;
const std::vector<std::string> choices = {"Yes", "No"}; const std::vector<std::string> choices = {"Yes", "No"};
@@ -396,13 +396,13 @@ void View::onDeletePressed() {
} }
void View::onNewFilePressed() { void View::onNewFilePressed() {
LOGGER.info("Creating new file"); LOG_I(TAG, "Creating new file");
state->setPendingAction(State::ActionCreateFile); state->setPendingAction(State::ActionCreateFile);
inputdialog::start("New File", "Enter filename:", ""); inputdialog::start("New File", "Enter filename:", "");
} }
void View::onNewFolderPressed() { void View::onNewFolderPressed() {
LOGGER.info("Creating new folder"); LOG_I(TAG, "Creating new folder");
state->setPendingAction(State::ActionCreateFolder); state->setPendingAction(State::ActionCreateFolder);
inputdialog::start("New Folder", "Enter folder name:", ""); inputdialog::start("New Folder", "Enter folder name:", "");
} }
@@ -436,11 +436,11 @@ void View::showActionsForMountPoint() {
void View::onEjectPressed() { void View::onEjectPressed() {
std::string mount_path = state->getSelectedChildPath(); std::string mount_path = state->getSelectedChildPath();
LOGGER.info("Ejecting {}", mount_path); LOG_I(TAG, "Ejecting %s", mount_path.c_str());
struct Device* msc_dev = device_find_first_active_by_type(&USB_HOST_MSC_TYPE); struct Device* msc_dev = device_find_first_active_by_type(&USB_HOST_MSC_TYPE);
if (!msc_dev || !usb_msc_eject(msc_dev, mount_path.c_str())) { if (!msc_dev || !usb_msc_eject(msc_dev, mount_path.c_str())) {
LOGGER.warn("usb_msc_eject: {} not found", mount_path); LOG_W(TAG, "usb_msc_eject: %s not found", mount_path.c_str());
alertdialog::start("Eject failed", "Could not eject \"" + file::getLastPathSegment(mount_path) + "\"."); alertdialog::start("Eject failed", "Could not eject \"" + file::getLastPathSegment(mount_path) + "\".");
} }
@@ -454,7 +454,7 @@ void View::update(size_t start_index) {
auto scoped_lockable = lvgl::getSyncLock()->asScopedLock(); auto scoped_lockable = lvgl::getSyncLock()->asScopedLock();
if (!scoped_lockable.lock(lvgl::defaultLockTime)) { if (!scoped_lockable.lock(lvgl::defaultLockTime)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl"); LOG_E(TAG, "Mutex acquisition timeout (%s)", "lvgl");
return; return;
} }
@@ -580,20 +580,20 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
} }
std::string filepath = state->getSelectedChildPath(); std::string filepath = state->getSelectedChildPath();
LOGGER.info("Result for {}", filepath); LOG_I(TAG, "Result for %s", filepath.c_str());
switch (state->getPendingAction()) { switch (state->getPendingAction()) {
case State::ActionDelete: { case State::ActionDelete: {
if (alertdialog::getResultIndex(*bundle) == 0) { if (alertdialog::getResultIndex(*bundle) == 0) {
if (file::isDirectory(filepath)) { if (file::isDirectory(filepath)) {
if (!file::deleteRecursively(filepath)) { if (!file::deleteRecursively(filepath)) {
LOGGER.warn("Failed to delete {}", filepath); LOG_W(TAG, "Failed to delete %s", filepath.c_str());
} }
} else if (file::isFile(filepath)) { } else if (file::isFile(filepath)) {
auto lock = file::getLock(filepath); auto lock = file::getLock(filepath);
lock->lock(); lock->lock();
if (remove(filepath.c_str()) != 0) { if (remove(filepath.c_str()) != 0) {
LOGGER.warn("Failed to delete {}", filepath); LOG_W(TAG, "Failed to delete %s", filepath.c_str());
} }
lock->unlock(); lock->unlock();
} }
@@ -611,16 +611,16 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
std::string rename_to = file::getChildPath(state->getCurrentPath(), new_name); std::string rename_to = file::getChildPath(state->getCurrentPath(), new_name);
struct stat st; struct stat st;
if (stat(rename_to.c_str(), &st) == 0) { if (stat(rename_to.c_str(), &st) == 0) {
LOGGER.warn("Rename: destination already exists: \"{}\"", rename_to); LOG_W(TAG, "Rename: destination already exists: \"%s\"", rename_to.c_str());
lock->unlock(); lock->unlock();
state->setPendingAction(State::ActionNone); state->setPendingAction(State::ActionNone);
alertdialog::start("Rename failed", "\"" + new_name + "\" already exists."); alertdialog::start("Rename failed", "\"" + new_name + "\" already exists.");
break; break;
} }
if (rename(filepath.c_str(), rename_to.c_str()) == 0) { if (rename(filepath.c_str(), rename_to.c_str()) == 0) {
LOGGER.info("Renamed \"{}\" to \"{}\"", filepath, rename_to); LOG_I(TAG, "Renamed \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
} else { } else {
LOGGER.error("Failed to rename \"{}\" to \"{}\"", filepath, rename_to); LOG_E(TAG, "Failed to rename \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
} }
lock->unlock(); lock->unlock();
@@ -639,7 +639,7 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
struct stat st; struct stat st;
if (stat(new_file_path.c_str(), &st) == 0) { if (stat(new_file_path.c_str(), &st) == 0) {
LOGGER.warn("File already exists: \"{}\"", new_file_path); LOG_W(TAG, "File already exists: \"%s\"", new_file_path.c_str());
lock->unlock(); lock->unlock();
break; break;
} }
@@ -647,9 +647,9 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
FILE* new_file = fopen(new_file_path.c_str(), "w"); FILE* new_file = fopen(new_file_path.c_str(), "w");
if (new_file) { if (new_file) {
fclose(new_file); fclose(new_file);
LOGGER.info("Created file \"{}\"", new_file_path); LOG_I(TAG, "Created file \"%s\"", new_file_path.c_str());
} else { } else {
LOGGER.error("Failed to create file \"{}\"", new_file_path); LOG_E(TAG, "Failed to create file \"%s\"", new_file_path.c_str());
} }
lock->unlock(); lock->unlock();
@@ -668,15 +668,15 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
struct stat st; struct stat st;
if (stat(new_folder_path.c_str(), &st) == 0) { if (stat(new_folder_path.c_str(), &st) == 0) {
LOGGER.warn("Folder already exists: \"{}\"", new_folder_path); LOG_W(TAG, "Folder already exists: \"%s\"", new_folder_path.c_str());
lock->unlock(); lock->unlock();
break; break;
} }
if (mkdir(new_folder_path.c_str(), 0755) == 0) { if (mkdir(new_folder_path.c_str(), 0755) == 0) {
LOGGER.info("Created folder \"{}\"", new_folder_path); LOG_I(TAG, "Created folder \"%s\"", new_folder_path.c_str());
} else { } else {
LOGGER.error("Failed to create folder \"{}\"", new_folder_path); LOG_E(TAG, "Failed to create folder \"%s\"", new_folder_path.c_str());
} }
lock->unlock(); lock->unlock();
@@ -698,7 +698,7 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
if (file::deleteRecursively(dst)) { if (file::deleteRecursively(dst)) {
doPaste(clipboard->first, clipboard->second, dst); doPaste(clipboard->first, clipboard->second, dst);
} else { } else {
LOGGER.error("Overwrite: failed to remove existing destination: \"{}\"", dst); LOG_E(TAG, "Overwrite: failed to remove existing destination: \"%s\"", dst.c_str());
state->setPendingAction(State::ActionNone); state->setPendingAction(State::ActionNone);
alertdialog::start( alertdialog::start(
"Overwrite failed", "Overwrite failed",
@@ -717,7 +717,7 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
void View::onCopyPressed() { void View::onCopyPressed() {
std::string path = state->getSelectedChildPath(); std::string path = state->getSelectedChildPath();
state->setClipboard(path, false); state->setClipboard(path, false);
LOGGER.info("Copied to clipboard: {}", path); LOG_I(TAG, "Copied to clipboard: %s", path.c_str());
onNavigate(); onNavigate();
update(); update();
} }
@@ -725,7 +725,7 @@ void View::onCopyPressed() {
void View::onCutPressed() { void View::onCutPressed() {
std::string path = state->getSelectedChildPath(); std::string path = state->getSelectedChildPath();
state->setClipboard(path, true); state->setClipboard(path, true);
LOGGER.info("Cut to clipboard: {}", path); LOG_I(TAG, "Cut to clipboard: %s", path.c_str());
onNavigate(); onNavigate();
update(); update();
} }
@@ -744,7 +744,7 @@ void View::onPastePressed() {
// between this check and the write inside doPaste. Acceptable on a // between this check and the write inside doPaste. Acceptable on a
// single-user embedded device; locking dst instead would be more correct. // single-user embedded device; locking dst instead would be more correct.
if (src == dst) { if (src == dst) {
LOGGER.info("Paste: source and destination are the same path, skipping"); LOG_I(TAG, "Paste: source and destination are the same path, skipping");
return; return;
} }
auto lock = file::getLock(src); auto lock = file::getLock(src);
@@ -783,7 +783,7 @@ void View::doPaste(const std::string& src, bool is_cut, const std::string& dst)
success = true; success = true;
} else { } else {
src_delete_failed = true; src_delete_failed = true;
LOGGER.error("Cut: copied \"{}\" to \"{}\" but failed to remove source — manual cleanup required", src, dst); LOG_E(TAG, "Cut: copied \"%s\" to \"%s\" but failed to remove source — manual cleanup required", src.c_str(), dst.c_str());
} }
} }
} }
@@ -793,7 +793,7 @@ void View::doPaste(const std::string& src, bool is_cut, const std::string& dst)
const std::string filename = file::getLastPathSegment(src); const std::string filename = file::getLastPathSegment(src);
if (success) { if (success) {
LOGGER.info("{} \"{}\" to \"{}\"", is_cut ? "Moved" : "Copied", src, dst); LOG_I(TAG, "%s \"%s\" to \"%s\"", is_cut ? "Moved" : "Copied", src.c_str(), dst.c_str());
if (is_cut) { if (is_cut) {
state->clearClipboard(); state->clearClipboard();
} }
@@ -801,7 +801,7 @@ void View::doPaste(const std::string& src, bool is_cut, const std::string& dst)
state->setPendingAction(State::ActionNone); // prevent re-trigger on dialog dismiss state->setPendingAction(State::ActionNone); // prevent re-trigger on dialog dismiss
alertdialog::start("Move incomplete", "\"" + filename + "\" was copied but the original could not be removed.\nPlease delete it manually."); alertdialog::start("Move incomplete", "\"" + filename + "\" was copied but the original could not be removed.\nPlease delete it manually.");
} else { } else {
LOGGER.error("Failed to {} \"{}\" to \"{}\"", is_cut ? "move" : "copy", src, dst); LOG_E(TAG, "Failed to %s \"%s\" to \"%s\"", is_cut ? "move" : "copy", src.c_str(), dst.c_str());
state->setPendingAction(State::ActionNone); // prevent re-trigger on dialog dismiss state->setPendingAction(State::ActionNone); // prevent re-trigger on dialog dismiss
alertdialog::start( alertdialog::start(
std::string("Failed to ") + (is_cut ? "move" : "copy"), std::string("Failed to ") + (is_cut ? "move" : "copy"),
+9 -9
View File
@@ -1,19 +1,19 @@
#include "Tactility/app/fileselection/State.h" #include "Tactility/app/fileselection/State.h"
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/Logger.h>
#include <Tactility/MountPoints.h> #include <Tactility/MountPoints.h>
#include <Tactility/kernel/Platform.h> #include <Tactility/kernel/Platform.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <cstring> #include <cstring>
#include <dirent.h> #include <dirent.h>
#include <tactility/log.h>
#include <unistd.h> #include <unistd.h>
#include <vector> #include <vector>
namespace tt::app::fileselection { namespace tt::app::fileselection {
static const auto LOGGER = Logger("FileSelection"); constexpr auto* TAG = "FileSelection";
State::State() { State::State() {
if (kernel::getPlatform() == kernel::PlatformSimulator) { if (kernel::getPlatform() == kernel::PlatformSimulator) {
@@ -21,7 +21,7 @@ State::State() {
if (getcwd(cwd, sizeof(cwd)) != nullptr) { if (getcwd(cwd, sizeof(cwd)) != nullptr) {
setEntriesForPath(cwd); setEntriesForPath(cwd);
} else { } else {
LOGGER.error("Failed to get current work directory files"); LOG_E(TAG, "Failed to get current work directory files");
setEntriesForPath("/"); setEntriesForPath("/");
} }
} else { } else {
@@ -34,11 +34,11 @@ std::string State::getSelectedChildPath() const {
} }
bool State::setEntriesForPath(const std::string& path) { bool State::setEntriesForPath(const std::string& path) {
LOGGER.info("Changing path: {} -> {}", current_path, path); LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
auto lock = mutex.asScopedLock(); auto lock = mutex.asScopedLock();
if (!lock.lock(100)) { if (!lock.lock(100)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath"); LOG_E(TAG, "Mutex acquisition timeout (%s)", "setEntriesForPath");
return false; return false;
} }
@@ -48,7 +48,7 @@ bool State::setEntriesForPath(const std::string& path) {
*/ */
bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/"); bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
if (show_custom_root) { if (show_custom_root) {
LOGGER.info("Setting custom root"); LOG_I(TAG, "Setting custom root");
dir_entries = file::getFileSystemDirents(); dir_entries = file::getFileSystemDirents();
current_path = path; current_path = path;
selected_child_entry = ""; selected_child_entry = "";
@@ -57,12 +57,12 @@ bool State::setEntriesForPath(const std::string& path) {
dir_entries.clear(); dir_entries.clear();
int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType); int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
if (count >= 0) { if (count >= 0) {
LOGGER.info("{} has {} entries", path, count); LOG_I(TAG, "%s has %d entries", path.c_str(), count);
current_path = path; current_path = path;
selected_child_entry = ""; selected_child_entry = "";
return true; return true;
} else { } else {
LOGGER.error("Failed to fetch entries for {}", path); LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
return false; return false;
} }
} }
@@ -70,7 +70,7 @@ bool State::setEntriesForPath(const std::string& path) {
bool State::setEntriesForChildPath(const std::string& childPath) { bool State::setEntriesForChildPath(const std::string& childPath) {
auto path = file::getChildPath(current_path, childPath); auto path = file::getChildPath(current_path, childPath);
LOGGER.info("Navigating from {} to {}", current_path, path); LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
return setEntriesForPath(path); return setEntriesForPath(path);
} }
+12 -12
View File
@@ -1,15 +1,15 @@
#include <Tactility/app/fileselection/View.h> #include <Tactility/app/fileselection/View.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h> #include <Tactility/Tactility.h>
#include <Tactility/app/alertdialog/AlertDialog.h> #include <Tactility/app/alertdialog/AlertDialog.h>
#include <tactility/check.h>
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <Tactility/kernel/Platform.h> #include <Tactility/kernel/Platform.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <tactility/check.h>
#include <tactility/log.h>
#include <cstring> #include <cstring>
#include <unistd.h> #include <unistd.h>
@@ -20,7 +20,7 @@
namespace tt::app::fileselection { namespace tt::app::fileselection {
const static Logger LOGGER = Logger("FileSelection"); constexpr auto* TAG = "FileSelection";
// region Callbacks // region Callbacks
@@ -47,11 +47,11 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
if (kernel::getPlatform() == kernel::PlatformSimulator) { if (kernel::getPlatform() == kernel::PlatformSimulator) {
char cwd[PATH_MAX]; char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == nullptr) { if (getcwd(cwd, sizeof(cwd)) == nullptr) {
LOGGER.error("Failed to get current working directory"); LOG_E(TAG, "Failed to get current working directory");
return; return;
} }
if (!file_path.starts_with(cwd)) { if (!file_path.starts_with(cwd)) {
LOGGER.error("Can only work with files in working directory {}", cwd); LOG_E(TAG, "Can only work with files in working directory %s", cwd);
return; return;
} }
processed_filepath = file_path.substr(strlen(cwd)); processed_filepath = file_path.substr(strlen(cwd));
@@ -59,7 +59,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
processed_filepath = file_path; processed_filepath = file_path;
} }
LOGGER.info("Clicked {}", processed_filepath); LOG_I(TAG, "Clicked %s", processed_filepath.c_str());
lv_textarea_set_text(path_textarea, processed_filepath.c_str()); lv_textarea_set_text(path_textarea, processed_filepath.c_str());
} }
@@ -67,7 +67,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
void View::onDirEntryPressed(uint32_t index) { void View::onDirEntryPressed(uint32_t index) {
dirent dir_entry; dirent dir_entry;
if (state->getDirent(index, dir_entry)) { if (state->getDirent(index, dir_entry)) {
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type); LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, (int)dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name); state->setSelectedChildEntry(dir_entry.d_name);
using namespace tt::file; using namespace tt::file;
switch (dir_entry.d_type) { switch (dir_entry.d_type) {
@@ -78,7 +78,7 @@ void View::onDirEntryPressed(uint32_t index) {
update(); update();
break; break;
case TT_DT_LNK: case TT_DT_LNK:
LOGGER.warn("Opening links is not supported"); LOG_W(TAG, "Opening links is not supported");
break; break;
case TT_DT_REG: case TT_DT_REG:
onTapFile(state->getCurrentPath(), dir_entry.d_name); onTapFile(state->getCurrentPath(), dir_entry.d_name);
@@ -96,7 +96,7 @@ void View::onSelectButtonPressed(lv_event_t* event) {
auto* view = static_cast<View*>(lv_event_get_user_data(event)); auto* view = static_cast<View*>(lv_event_get_user_data(event));
const char* path = lv_textarea_get_text(view->path_textarea); const char* path = lv_textarea_get_text(view->path_textarea);
if (path == nullptr || strlen(path) == 0) { if (path == nullptr || strlen(path) == 0) {
LOGGER.warn("Select pressed, but not path found in textarea"); LOG_W(TAG, "Select pressed, but not path found in textarea");
return; return;
} }
@@ -140,7 +140,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
void View::onNavigateUpPressed() { void View::onNavigateUpPressed() {
if (state->getCurrentPath() != "/") { if (state->getCurrentPath() != "/") {
LOGGER.info("Navigating upwards"); LOG_I(TAG, "Navigating upwards");
std::string new_absolute_path; std::string new_absolute_path;
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) { if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
state->setEntriesForPath(new_absolute_path); state->setEntriesForPath(new_absolute_path);
@@ -161,7 +161,7 @@ void View::update() {
state->withEntries([this](const std::vector<dirent>& entries) { state->withEntries([this](const std::vector<dirent>& entries) {
for (auto entry : entries) { for (auto entry : entries) {
LOGGER.debug("Entry: {} {}", entry.d_name, entry.d_type); LOG_D(TAG, "Entry: %s %d", entry.d_name, (int)entry.d_type);
createDirEntryWidget(dir_entry_list, entry); createDirEntryWidget(dir_entry_list, entry);
} }
}); });
@@ -172,7 +172,7 @@ void View::update() {
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
} }
} else { } else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl"); LOG_E(TAG, "Mutex acquisition timeout (%s)", "lvgl");
} }
} }
@@ -5,11 +5,11 @@
#include <Tactility/app/alertdialog/AlertDialog.h> #include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/service/gps/GpsService.h> #include <Tactility/service/gps/GpsService.h>
#include <Tactility/service/gps/GpsState.h> #include <Tactility/service/gps/GpsState.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
#include <cstring> #include <cstring>
@@ -26,7 +26,7 @@ extern const AppManifest manifest;
class GpsSettingsApp final : public App { class GpsSettingsApp final : public App {
const Logger logger = Logger("GpsSettings"); static constexpr auto* TAG = "GpsSettings";
std::unique_ptr<Timer> timer; std::unique_ptr<Timer> timer;
std::shared_ptr<GpsSettingsApp*> appReference = std::make_shared<GpsSettingsApp*>(this); std::shared_ptr<GpsSettingsApp*> appReference = std::make_shared<GpsSettingsApp*>(this);
@@ -101,7 +101,7 @@ class GpsSettingsApp final : public App {
std::vector<tt::hal::gps::GpsConfiguration> configurations; std::vector<tt::hal::gps::GpsConfiguration> configurations;
auto gps_service = service::gps::findGpsService(); auto gps_service = service::gps::findGpsService();
if (gps_service && gps_service->getGpsConfigurations(configurations)) { if (gps_service && gps_service->getGpsConfigurations(configurations)) {
Logger("GpsSettings").info("Found service and configs {} {}", index, configurations.size()); LOG_I(TAG, "Found service and configs %d %d", index, (int)configurations.size());
if (index < configurations.size()) { if (index < configurations.size()) {
if (gps_service->removeGpsConfiguration(configurations[index])) { if (gps_service->removeGpsConfiguration(configurations[index])) {
app->updateViews(); app->updateViews();
@@ -163,7 +163,7 @@ class GpsSettingsApp final : public App {
// Update toolbar // Update toolbar
switch (state) { switch (state) {
case service::gps::State::OnPending: case service::gps::State::OnPending:
logger.debug("OnPending"); LOG_D(TAG, "OnPending");
lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_state(switchWidget, LV_STATE_CHECKED); lv_obj_add_state(switchWidget, LV_STATE_CHECKED);
lv_obj_add_state(switchWidget, LV_STATE_DISABLED); lv_obj_add_state(switchWidget, LV_STATE_DISABLED);
@@ -172,7 +172,7 @@ class GpsSettingsApp final : public App {
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break; break;
case service::gps::State::On: case service::gps::State::On:
logger.debug("On"); LOG_D(TAG, "On");
lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_state(switchWidget, LV_STATE_CHECKED); lv_obj_add_state(switchWidget, LV_STATE_CHECKED);
lv_obj_remove_state(switchWidget, LV_STATE_DISABLED); lv_obj_remove_state(switchWidget, LV_STATE_DISABLED);
@@ -181,7 +181,7 @@ class GpsSettingsApp final : public App {
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break; break;
case service::gps::State::OffPending: case service::gps::State::OffPending:
logger.debug("OffPending"); LOG_D(TAG, "OffPending");
lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_remove_state(switchWidget, LV_STATE_CHECKED); lv_obj_remove_state(switchWidget, LV_STATE_CHECKED);
lv_obj_add_state(switchWidget, LV_STATE_DISABLED); lv_obj_add_state(switchWidget, LV_STATE_DISABLED);
@@ -190,7 +190,7 @@ class GpsSettingsApp final : public App {
lv_obj_remove_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break; break;
case service::gps::State::Off: case service::gps::State::Off:
logger.debug("Off"); LOG_D(TAG, "Off");
lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_remove_state(switchWidget, LV_STATE_CHECKED); lv_obj_remove_state(switchWidget, LV_STATE_CHECKED);
lv_obj_remove_state(switchWidget, LV_STATE_DISABLED); lv_obj_remove_state(switchWidget, LV_STATE_DISABLED);
+22 -22
View File
@@ -1,19 +1,19 @@
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h> #include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
#include <Tactility/app/i2cscanner/I2cHelpers.h> #include <Tactility/app/i2cscanner/I2cHelpers.h>
#include <Tactility/app/AppContext.h>
#include <tactility/drivers/i2c_controller.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h> #include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Preferences.h> #include <Tactility/Preferences.h>
#include <Tactility/RecursiveMutex.h> #include <Tactility/RecursiveMutex.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Timer.h> #include <Tactility/Timer.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <tactility/drivers/i2c_controller.h>
#include <format> #include <format>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
namespace tt::app::i2cscanner { namespace tt::app::i2cscanner {
@@ -22,7 +22,7 @@ extern const AppManifest manifest;
class I2cScannerApp final : public App { class I2cScannerApp final : public App {
const Logger logger = Logger("I2cScanner"); static constexpr auto* TAG = "I2cScanner";
static constexpr auto* START_SCAN_TEXT = "Scan"; static constexpr auto* START_SCAN_TEXT = "Scan";
static constexpr auto* STOP_SCAN_TEXT = "Stop scan"; static constexpr auto* STOP_SCAN_TEXT = "Stop scan";
@@ -190,7 +190,7 @@ bool I2cScannerApp::getPort(struct Device** outPort) {
mutex.unlock(); mutex.unlock();
return true; return true;
} else { } else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort"); LOG_W(TAG, "Mutex acquisition timeout (%s)", "getPort");
return false; return false;
} }
} }
@@ -201,7 +201,7 @@ bool I2cScannerApp::addAddressToList(uint8_t address) {
mutex.unlock(); mutex.unlock();
return true; return true;
} else { } else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList"); LOG_W(TAG, "Mutex acquisition timeout (%s)", "addAddressToList");
return false; return false;
} }
} }
@@ -217,24 +217,24 @@ bool I2cScannerApp::shouldStopScanTimer() {
} }
void I2cScannerApp::onScanTimer() { void I2cScannerApp::onScanTimer() {
logger.info("Scan thread started"); LOG_I(TAG, "Scan thread started");
Device* safe_port; Device* safe_port;
if (!getPort(&safe_port)) { if (!getPort(&safe_port)) {
logger.error("Failed to get I2C port"); LOG_E(TAG, "Failed to get I2C port");
onScanTimerFinished(); onScanTimerFinished();
return; return;
} }
if (!device_is_ready(safe_port)) { if (!device_is_ready(safe_port)) {
logger.error("I2C port not started"); LOG_E(TAG, "I2C port not started");
onScanTimerFinished(); onScanTimerFinished();
return; return;
} }
for (uint8_t address = 1; address < 128; ++address) { for (uint8_t address = 1; address < 128; ++address) {
if (i2c_controller_has_device_at_address(safe_port, address, 10 / portTICK_PERIOD_MS) == ERROR_NONE) { if (i2c_controller_has_device_at_address(safe_port, address, 10 / portTICK_PERIOD_MS) == ERROR_NONE) {
logger.info("Found device at address 0x{:02X}", address); LOG_I(TAG, "Found device at address 0x%02X", address);
if (!shouldStopScanTimer()) { if (!shouldStopScanTimer()) {
addAddressToList(address); addAddressToList(address);
} else { } else {
@@ -247,11 +247,11 @@ void I2cScannerApp::onScanTimer() {
} }
} }
logger.info("Scan thread finalizing"); LOG_I(TAG, "Scan thread finalizing");
onScanTimerFinished(); onScanTimerFinished();
logger.info("Scan timer done"); LOG_I(TAG, "Scan timer done");
} }
bool I2cScannerApp::hasScanThread() { bool I2cScannerApp::hasScanThread() {
@@ -262,7 +262,7 @@ bool I2cScannerApp::hasScanThread() {
return has_thread; return has_thread;
} else { } else {
// Unsafe way // Unsafe way
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "hasScanTimer"); LOG_W(TAG, "Mutex acquisition timeout (%s)", "hasScanTimer");
return scanTimer != nullptr; return scanTimer != nullptr;
} }
} }
@@ -285,7 +285,7 @@ void I2cScannerApp::startScanning() {
scanTimer->start(); scanTimer->start();
mutex.unlock(); mutex.unlock();
} else { } else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning"); LOG_W(TAG, "Mutex acquisition timeout (%s)", "startScanning");
} }
} }
void I2cScannerApp::stopScanning() { void I2cScannerApp::stopScanning() {
@@ -294,7 +294,7 @@ void I2cScannerApp::stopScanning() {
scanState = ScanStateStopped; scanState = ScanStateStopped;
mutex.unlock(); mutex.unlock();
} else { } else {
logger.error(LOG_MESSAGE_MUTEX_LOCK_FAILED); LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
} }
} }
@@ -317,7 +317,7 @@ void I2cScannerApp::selectBus(int32_t selected) {
mutex.unlock(); mutex.unlock();
} }
logger.info("Selected {}", selected); LOG_I(TAG, "Selected %d", (int)selected);
setLastBusIndex(selected); setLastBusIndex(selected);
startScanning(); startScanning();
@@ -362,7 +362,7 @@ void I2cScannerApp::updateViews() {
mutex.unlock(); mutex.unlock();
} else { } else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViews"); LOG_W(TAG, "Mutex acquisition timeout (%s)", "updateViews");
} }
} }
@@ -371,7 +371,7 @@ void I2cScannerApp::updateViewsSafely() {
updateViews(); updateViews();
lvgl::unlock(); lvgl::unlock();
} else { } else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViewsSafely"); LOG_W(TAG, "Mutex acquisition timeout (%s)", "updateViewsSafely");
} }
} }
@@ -384,7 +384,7 @@ void I2cScannerApp::onScanTimerFinished() {
updateViewsSafely(); updateViewsSafely();
} else { } else {
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "onScanTimerFinished"); LOG_W(TAG, "Mutex acquisition timeout (%s)", "onScanTimerFinished");
} }
} }
@@ -2,8 +2,8 @@
#include <Tactility/lvgl/Style.h> #include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <tactility/log.h>
#include <lvgl.h> #include <lvgl.h>
@@ -11,7 +11,7 @@ namespace tt::app::imageviewer {
extern const AppManifest manifest; extern const AppManifest manifest;
static const auto LOGGER = Logger("ImageViewer"); constexpr auto* TAG = "ImageViewer";
constexpr auto* IMAGE_VIEWER_FILE_ARGUMENT = "file"; constexpr auto* IMAGE_VIEWER_FILE_ARGUMENT = "file";
class ImageViewerApp final : public App { class ImageViewerApp final : public App {
@@ -49,7 +49,7 @@ class ImageViewerApp final : public App {
std::string file_argument; std::string file_argument;
if (bundle->optString(IMAGE_VIEWER_FILE_ARGUMENT, file_argument)) { if (bundle->optString(IMAGE_VIEWER_FILE_ARGUMENT, file_argument)) {
std::string prefixed_path = lvgl::PATH_PREFIX + file_argument; std::string prefixed_path = lvgl::PATH_PREFIX + file_argument;
LOGGER.info("Opening {}", prefixed_path); LOG_I(TAG, "Opening %s", prefixed_path.c_str());
lv_img_set_src(image, prefixed_path.c_str()); lv_img_set_src(image, prefixed_path.c_str());
auto path = string::getLastPathSegment(file_argument); auto path = string::getLastPathSegment(file_argument);
lv_label_set_text(file_label, path.c_str()); lv_label_set_text(file_label, path.c_str());
@@ -3,6 +3,7 @@
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <Tactility/TactilityCore.h> #include <Tactility/TactilityCore.h>
#include <tactility/log.h>
#include <lvgl.h> #include <lvgl.h>
@@ -15,7 +16,7 @@ constexpr auto* RESULT_BUNDLE_KEY_RESULT = "result";
constexpr auto* DEFAULT_TITLE = "Input"; constexpr auto* DEFAULT_TITLE = "Input";
static const auto LOGGER = Logger("InputDialog"); constexpr auto* TAG = "InputDialog";
extern const AppManifest manifest; extern const AppManifest manifest;
class InputDialogApp; class InputDialogApp;
@@ -62,7 +63,7 @@ class InputDialogApp final : public App {
void onButtonClicked(lv_event_t* e) { void onButtonClicked(lv_event_t* e) {
auto user_data = lv_event_get_user_data(e); auto user_data = lv_event_get_user_data(e);
int index = (user_data != 0) ? 0 : 1; int index = (user_data != 0) ? 0 : 1;
LOGGER.info("Selected item at index {}", index); LOG_I(TAG, "Selected item at index %d", index);
if (index == 0) { if (index == 0) {
auto bundle = std::make_unique<Bundle>(); auto bundle = std::make_unique<Bundle>();
const char* text = lv_textarea_get_text((lv_obj_t*)user_data); const char* text = lv_textarea_get_text((lv_obj_t*)user_data);
+4 -3
View File
@@ -11,13 +11,14 @@
#include <cstring> #include <cstring>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_fonts.h> #include <tactility/lvgl_fonts.h>
#include <tactility/lvgl_icon_launcher.h> #include <tactility/lvgl_icon_launcher.h>
#include <tactility/lvgl_module.h> #include <tactility/lvgl_module.h>
namespace tt::app::launcher { namespace tt::app::launcher {
static const auto LOGGER = Logger("Launcher"); constexpr auto* TAG = "Launcher";
static uint32_t getButtonPadding(UiDensity density, uint32_t buttonSize) { static uint32_t getButtonPadding(UiDensity density, uint32_t buttonSize) {
if (density == LVGL_UI_DENSITY_COMPACT) { if (density == LVGL_UI_DENSITY_COMPACT) {
@@ -143,7 +144,7 @@ public:
strcmp(CONFIG_TT_AUTO_START_APP_ID, "") != 0 && strcmp(CONFIG_TT_AUTO_START_APP_ID, "") != 0 &&
findAppManifestById(CONFIG_TT_AUTO_START_APP_ID) != nullptr findAppManifestById(CONFIG_TT_AUTO_START_APP_ID) != nullptr
) { ) {
LOGGER.info("Starting {}", CONFIG_TT_AUTO_START_APP_ID); LOG_I(TAG, "Starting %s", CONFIG_TT_AUTO_START_APP_ID);
start(CONFIG_TT_AUTO_START_APP_ID); start(CONFIG_TT_AUTO_START_APP_ID);
} else if ( } else if (
// Auto-start due to user configuration // Auto-start due to user configuration
@@ -151,7 +152,7 @@ public:
!boot_properties.autoStartAppId.empty() && !boot_properties.autoStartAppId.empty() &&
findAppManifestById(boot_properties.autoStartAppId) != nullptr findAppManifestById(boot_properties.autoStartAppId) != nullptr
) { ) {
LOGGER.info("Starting {}", boot_properties.autoStartAppId); LOG_I(TAG, "Starting %s", boot_properties.autoStartAppId.c_str());
start(boot_properties.autoStartAppId); start(boot_properties.autoStartAppId);
} else { } else {
// No auto-start, consider running system setup // No auto-start, consider running system setup
+8 -7
View File
@@ -8,11 +8,12 @@
#include <Tactility/file/File.h> #include <Tactility/file/File.h>
#include <lvgl.h> #include <lvgl.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
namespace tt::app::notes { namespace tt::app::notes {
static const auto LOGGER = Logger("Notes"); constexpr auto* TAG = "Notes";
constexpr auto* NOTES_FILE_ARGUMENT = "file"; constexpr auto* NOTES_FILE_ARGUMENT = "file";
class NotesApp final : public App { class NotesApp final : public App {
@@ -52,11 +53,11 @@ class NotesApp final : public App {
saveBuffer = lv_textarea_get_text(uiNoteText); saveBuffer = lv_textarea_get_text(uiNoteText);
lvgl::getSyncLock()->unlock(); lvgl::getSyncLock()->unlock();
saveFileLaunchId = fileselection::startForExistingOrNewFile(); saveFileLaunchId = fileselection::startForExistingOrNewFile();
LOGGER.info("launched with id {}", saveFileLaunchId); LOG_I(TAG, "launched with id %u", saveFileLaunchId);
break; break;
case 3: // Load case 3: // Load
loadFileLaunchId = fileselection::startForExistingFile(); loadFileLaunchId = fileselection::startForExistingFile();
LOGGER.info("launched with id {}", loadFileLaunchId); LOG_I(TAG, "launched with id %u", loadFileLaunchId);
break; break;
} }
} else { } else {
@@ -64,7 +65,7 @@ class NotesApp final : public App {
if (obj == cont) return; if (obj == cont) return;
if (lv_obj_get_child(cont, 1)) { if (lv_obj_get_child(cont, 1)) {
saveFileLaunchId = fileselection::startForExistingOrNewFile(); saveFileLaunchId = fileselection::startForExistingOrNewFile();
LOGGER.info("launched with id {}", saveFileLaunchId); LOG_I(TAG, "launched with id %u", saveFileLaunchId);
} else { //Reset } else { //Reset
resetFileContent(); resetFileContent();
} }
@@ -91,7 +92,7 @@ class NotesApp final : public App {
lv_textarea_set_text(uiNoteText, reinterpret_cast<const char*>(data.get())); lv_textarea_set_text(uiNoteText, reinterpret_cast<const char*>(data.get()));
lv_label_set_text(uiCurrentFileName, path.c_str()); lv_label_set_text(uiCurrentFileName, path.c_str());
filePath = path; filePath = path;
LOGGER.info("Loaded from {}", path); LOG_I(TAG, "Loaded from %s", path.c_str());
} }
}); });
} }
@@ -101,7 +102,7 @@ class NotesApp final : public App {
bool result = false; bool result = false;
file::getLock(path)->withLock([&result, this, path] { file::getLock(path)->withLock([&result, this, path] {
if (file::writeString(path, saveBuffer.c_str())) { if (file::writeString(path, saveBuffer.c_str())) {
LOGGER.info("Saved to {}", path); LOG_I(TAG, "Saved to %s", path.c_str());
filePath = path; filePath = path;
result = true; result = true;
} }
@@ -193,7 +194,7 @@ class NotesApp final : public App {
} }
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> resultData) override { void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> resultData) override {
LOGGER.info("Result for launch id {}", launchId); LOG_I(TAG, "Result for launch id %u", launchId);
if (launchId == loadFileLaunchId) { if (launchId == loadFileLaunchId) {
loadFileLaunchId = 0; loadFileLaunchId = 0;
if (result == Result::Ok && resultData != nullptr) { if (result == Result::Ok && resultData != nullptr) {
@@ -6,7 +6,6 @@
#include <Tactility/app/App.h> #include <Tactility/app/App.h>
#include <Tactility/app/AppManifest.h> #include <Tactility/app/AppManifest.h>
#include <Tactility/kernel/Platform.h> #include <Tactility/kernel/Platform.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Lvgl.h> #include <Tactility/lvgl/Lvgl.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
@@ -15,11 +14,12 @@
#include <Tactility/Paths.h> #include <Tactility/Paths.h>
#include <Tactility/Timer.h> #include <Tactility/Timer.h>
#include <tactility/log.h>
#include <tactility/lvgl_icon_shared.h> #include <tactility/lvgl_icon_shared.h>
namespace tt::app::screenshot { namespace tt::app::screenshot {
static const auto LOGGER = Logger("Screenshot"); constexpr auto* TAG = "Screenshot";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -100,27 +100,27 @@ void ScreenshotApp::onModeSet() {
void ScreenshotApp::onStartPressed() { void ScreenshotApp::onStartPressed() {
auto service = service::screenshot::optScreenshotService(); auto service = service::screenshot::optScreenshotService();
if (service == nullptr) { if (service == nullptr) {
LOGGER.error("Service not found/running"); LOG_E(TAG, "Service not found/running");
return; return;
} }
if (service->isTaskStarted()) { if (service->isTaskStarted()) {
LOGGER.info("Stop screenshot"); LOG_I(TAG, "Stop screenshot");
service->stop(); service->stop();
} else { } else {
uint32_t selected = lv_dropdown_get_selected(modeDropdown); uint32_t selected = lv_dropdown_get_selected(modeDropdown);
const char* path = lv_textarea_get_text(pathTextArea); const char* path = lv_textarea_get_text(pathTextArea);
if (selected == 0) { if (selected == 0) {
LOGGER.info("Start timed screenshots"); LOG_I(TAG, "Start timed screenshots");
const char* delay_text = lv_textarea_get_text(delayTextArea); const char* delay_text = lv_textarea_get_text(delayTextArea);
int delay = atoi(delay_text); int delay = atoi(delay_text);
if (delay > 0) { if (delay > 0) {
service->startTimed(path, delay, 1); service->startTimed(path, delay, 1);
} else { } else {
LOGGER.warn("Ignored screenshot start because delay was 0"); LOG_W(TAG, "Ignored screenshot start because delay was 0");
} }
} else { } else {
LOGGER.info("Start app screenshots"); LOG_I(TAG, "Start app screenshots");
service->startApps(path); service->startApps(path);
} }
} }
@@ -131,7 +131,7 @@ void ScreenshotApp::onStartPressed() {
void ScreenshotApp::updateScreenshotMode() { void ScreenshotApp::updateScreenshotMode() {
auto service = service::screenshot::optScreenshotService(); auto service = service::screenshot::optScreenshotService();
if (service == nullptr) { if (service == nullptr) {
LOGGER.error("Service not found/running"); LOG_E(TAG, "Service not found/running");
return; return;
} }
@@ -154,7 +154,7 @@ void ScreenshotApp::updateScreenshotMode() {
void ScreenshotApp::createModeSettingWidgets(lv_obj_t* parent) { void ScreenshotApp::createModeSettingWidgets(lv_obj_t* parent) {
auto service = service::screenshot::optScreenshotService(); auto service = service::screenshot::optScreenshotService();
if (service == nullptr) { if (service == nullptr) {
LOGGER.error("Service not found/running"); LOG_E(TAG, "Service not found/running");
return; return;
} }
@@ -1,9 +1,9 @@
#include <Tactility/app/selectiondialog/SelectionDialog.h> #include <Tactility/app/selectiondialog/SelectionDialog.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h> #include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h> #include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h> #include <Tactility/StringUtils.h>
#include <tactility/log.h>
#include <lvgl.h> #include <lvgl.h>
@@ -16,7 +16,7 @@ constexpr auto* RESULT_BUNDLE_KEY_INDEX = "index";
constexpr auto* PARAMETER_ITEM_CONCATENATION_TOKEN = ";;"; constexpr auto* PARAMETER_ITEM_CONCATENATION_TOKEN = ";;";
constexpr auto* DEFAULT_TITLE = "Select..."; constexpr auto* DEFAULT_TITLE = "Select...";
static const auto LOGGER = Logger("SelectionDialog"); constexpr auto* TAG = "SelectionDialog";
extern const AppManifest manifest; extern const AppManifest manifest;
@@ -53,7 +53,7 @@ class SelectionDialogApp final : public App {
void onListItemSelected(lv_event_t* e) { void onListItemSelected(lv_event_t* e) {
auto index = reinterpret_cast<std::size_t>(lv_event_get_user_data(e)); auto index = reinterpret_cast<std::size_t>(lv_event_get_user_data(e));
LOGGER.info("Selected item at index {}", index); LOG_I(TAG, "Selected item at index %d", (int)index);
auto bundle = std::make_unique<Bundle>(); auto bundle = std::make_unique<Bundle>();
bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index); bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index);
setResult(Result::Ok, std::move(bundle)); setResult(Result::Ok, std::move(bundle));
@@ -85,7 +85,7 @@ public:
if (parameters->optString(PARAMETER_BUNDLE_KEY_ITEMS, items_concatenated)) { if (parameters->optString(PARAMETER_BUNDLE_KEY_ITEMS, items_concatenated)) {
std::vector<std::string> items = string::split(items_concatenated, PARAMETER_ITEM_CONCATENATION_TOKEN); std::vector<std::string> items = string::split(items_concatenated, PARAMETER_ITEM_CONCATENATION_TOKEN);
if (items.empty() || items.front().empty()) { if (items.empty() || items.front().empty()) {
LOGGER.error("No items provided"); LOG_E(TAG, "No items provided");
setResult(Result::Error); setResult(Result::Error);
stop(manifest.appId); stop(manifest.appId);
} else if (items.size() == 1) { } else if (items.size() == 1) {
@@ -93,7 +93,7 @@ public:
result_bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, 0); result_bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, 0);
setResult(Result::Ok, std::move(result_bundle)); setResult(Result::Ok, std::move(result_bundle));
stop(manifest.appId); stop(manifest.appId);
LOGGER.warn("Auto-selecting single item"); LOG_W(TAG, "Auto-selecting single item");
} else { } else {
size_t index = 0; size_t index = 0;
for (const auto& item: items) { for (const auto& item: items) {
@@ -101,7 +101,7 @@ public:
} }
} }
} else { } else {
LOGGER.error("No items provided"); LOG_E(TAG, "No items provided");
setResult(Result::Error); setResult(Result::Error);
stop(manifest.appId); stop(manifest.appId);
} }

Some files were not shown because too many files have changed in this diff Show More