New logging and more (#446)

- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
Ken Van Hoeylandt 2026-01-06 22:35:39 +01:00 committed by GitHub
parent 719f7bcece
commit f620255c41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
188 changed files with 1973 additions and 1755 deletions

View File

@ -7,7 +7,6 @@ CONFIG_IDF_EXPERIMENTAL_FEATURES=y
# Free up IRAM
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y
CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y
CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y
# EmbedTLS
CONFIG_MBEDTLS_SSL_PROTO_TLS1_3=y

View File

@ -2,4 +2,4 @@ language=en-US
timeFormat24h=true
dateFormat=MM/DD/YYYY
region=US
timezone=America/Los_Angeles
timezone=Europe/Amsterdam

View File

@ -3,7 +3,6 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
// Note for future changes: Reset pin is 41 and interrupt pin is 40

View File

@ -2,7 +2,7 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/gpio.h>
#include <esp_err.h>
@ -11,7 +11,7 @@
#include <esp_lcd_panel_io_additions.h>
#include <esp_lcd_st7701.h>
constexpr auto TAG = "St7701Display";
static const auto LOGGER = tt::Logger("St7701Display");
static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
// {cmd, { data }, data_size, delay_ms}
@ -153,28 +153,30 @@ bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
};
if (esp_lcd_new_panel_st7701(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, false) != ESP_OK) {
TT_LOG_E(TAG, "Failed to invert color");
LOGGER.error("Failed to invert color");
return false;
}
esp_lcd_panel_set_gap(panelHandle, 0, 0);
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return false;
}
return true;

View File

@ -3,7 +3,6 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18

View File

@ -3,7 +3,6 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18

View File

@ -2,7 +2,6 @@
#include <Gt911Touch.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18

View File

@ -3,7 +3,6 @@
#include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
// Note for future changes: Reset pin is 38 and interrupt pin is 18

View File

@ -4,11 +4,11 @@
#include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/Logger.h>
#include <ButtonControl.h>
#include "driver/gpio.h"
#include "driver/i2c.h"
#include <Tactility/Log.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@ -24,7 +24,7 @@ static void enableOledPower() {
gpio_set_level(DISPLAY_PIN_POWER, 0); // Active low
vTaskDelay(pdMS_TO_TICKS(500)); // Add a small delay for power to stabilize
TT_LOG_I("OLED_POWER", "OLED power enabled");
tt::Logger("HeltecV3").info("OLED power enabled");
}
static bool initBoot() {

View File

@ -1,20 +1,21 @@
#include "PwmBacklight.h"
#include "Tactility/kernel/SystemEvents.h"
#include "Tactility/service/gps/GpsService.h"
#include <Tactility/TactilityCore.h>
#include <Tactility/hal/gps/GpsConfiguration.h>
#include <Tactility/settings/KeyboardSettings.h>
#include "devices/KeyboardBacklight.h"
#include "devices/TrackballDevice.h"
#include <KeyboardBacklight/KeyboardBacklight.h>
#include <Tactility/hal/gps/GpsConfiguration.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/settings/KeyboardSettings.h>
#include <Trackball/Trackball.h>
#define TAG "tdeck"
#include <KeyboardBacklight/KeyboardBacklight.h>
static const auto LOGGER = tt::Logger("T-Deck");
// Power on
#define TDECK_POWERON_GPIO GPIO_NUM_10
constexpr auto TDECK_POWERON_GPIO = GPIO_NUM_10;
static bool powerOn() {
gpio_config_t device_power_signal_config = {
@ -37,9 +38,9 @@ static bool powerOn() {
}
bool initBoot() {
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
if (!powerOn()) {
TT_LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED);
return false;
}
@ -47,7 +48,7 @@ bool initBoot() {
* when moving the brightness slider rapidly from a lower setting to 100%.
* This is not a slider bug (data was debug-traced) */
if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) {
TT_LOG_E(TAG, "Backlight init failed");
LOGGER.error("Backlight init failed");
return false;
}
@ -58,9 +59,9 @@ bool initBoot() {
gps_service->getGpsConfigurations(gps_configurations);
if (gps_configurations.empty()) {
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {.uartName = "Grove", .baudRate = 38400, .model = tt::hal::gps::GpsModel::UBLOX10})) {
TT_LOG_I(TAG, "Configured internal GPS");
LOGGER.info("Configured internal GPS");
} else {
TT_LOG_E(TAG, "Failed to configure internal GPS");
LOGGER.error("Failed to configure internal GPS");
}
}
}
@ -69,23 +70,23 @@ bool initBoot() {
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event) {
auto kbBacklight = tt::hal::findDevice("Keyboard Backlight");
if (kbBacklight != nullptr) {
TT_LOG_I(TAG, "%s starting", kbBacklight->getName().c_str());
LOGGER.info("{} starting", kbBacklight->getName());
auto kbDevice = std::static_pointer_cast<KeyboardBacklightDevice>(kbBacklight);
if (kbDevice->start()) {
TT_LOG_I(TAG, "%s started", kbBacklight->getName().c_str());
LOGGER.info("{} started", kbBacklight->getName());
} else {
TT_LOG_E(TAG, "%s start failed", kbBacklight->getName().c_str());
LOGGER.error("{} start failed", kbBacklight->getName());
}
}
auto trackball = tt::hal::findDevice("Trackball");
if (trackball != nullptr) {
TT_LOG_I(TAG, "%s starting", trackball->getName().c_str());
LOGGER.info("{} starting", trackball->getName());
auto tbDevice = std::static_pointer_cast<TrackballDevice>(trackball);
if (tbDevice->start()) {
TT_LOG_I(TAG, "%s started", trackball->getName().c_str());
LOGGER.info("{} started", trackball->getName());
} else {
TT_LOG_E(TAG, "%s start failed", trackball->getName().c_str());
LOGGER.error("{} start failed", trackball->getName());
}
}
@ -99,7 +100,7 @@ bool initBoot() {
auto kbSettings = tt::settings::keyboard::loadOrGetDefault();
bool result = keyboardbacklight::setBrightness(kbSettings.backlightEnabled ? kbSettings.backlightBrightness : 0);
if (!result) {
TT_LOG_W(TAG, "Failed to set keyboard backlight brightness");
LOGGER.warn("Failed to set keyboard backlight brightness");
}
trackball::setEnabled(kbSettings.trackballEnabled);

View File

@ -1,8 +1,11 @@
#include "KeyboardBacklight.h"
#include <esp_log.h>
#include <cstring>
static const char* TAG = "KeyboardBacklight";
#include <Tactility/Logger.h>
#include <cstring>
#include <esp_log.h>
static const auto LOGGER = tt::Logger("KeyboardBacklight");
namespace keyboardbacklight {
@ -18,16 +21,16 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
g_i2cPort = i2cPort;
g_slaveAddress = slaveAddress;
ESP_LOGI(TAG, "Keyboard backlight initialized on I2C port %d, address 0x%02X", g_i2cPort, g_slaveAddress);
LOGGER.info("Initialized on I2C port {}, address 0x{:02X}", static_cast<int>(g_i2cPort), g_slaveAddress);
// Set a reasonable default brightness
if (!setDefaultBrightness(127)) {
ESP_LOGE(TAG, "Failed to set default brightness");
LOGGER.error("Failed to set default brightness");
return false;
}
if (!setBrightness(127)) {
ESP_LOGE(TAG, "Failed to set brightness");
LOGGER.error("Failed to set brightness");
return false;
}
@ -36,7 +39,7 @@ bool init(i2c_port_t i2cPort, uint8_t slaveAddress) {
bool setBrightness(uint8_t brightness) {
if (g_i2cPort >= I2C_NUM_MAX) {
ESP_LOGE(TAG, "Keyboard backlight not initialized");
LOGGER.error("Not initialized");
return false;
}
@ -45,7 +48,7 @@ bool setBrightness(uint8_t brightness) {
return true;
}
ESP_LOGI(TAG, "Setting brightness to %d on I2C port %d, address 0x%02X", brightness, g_i2cPort, g_slaveAddress);
LOGGER.info("Setting brightness to {} on I2C port {}, address 0x{:02X}", brightness, static_cast<int>(g_i2cPort), g_slaveAddress);
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
@ -59,17 +62,17 @@ bool setBrightness(uint8_t brightness) {
if (ret == ESP_OK) {
g_currentBrightness = brightness;
ESP_LOGI(TAG, "Successfully set brightness to %d", brightness);
LOGGER.info("Successfully set brightness to {}", brightness);
return true;
} else {
ESP_LOGE(TAG, "Failed to set brightness: %s (0x%x)", esp_err_to_name(ret), ret);
LOGGER.error("Failed to set brightness: {} (0x{:02X})", esp_err_to_name(ret), ret);
return false;
}
}
bool setDefaultBrightness(uint8_t brightness) {
if (g_i2cPort >= I2C_NUM_MAX) {
ESP_LOGE(TAG, "Keyboard backlight not initialized");
LOGGER.error("Not initialized");
return false;
}
@ -89,17 +92,17 @@ bool setDefaultBrightness(uint8_t brightness) {
i2c_cmd_link_delete(cmd);
if (ret == ESP_OK) {
ESP_LOGD(TAG, "Set default brightness to %d", brightness);
LOGGER.debug("Set default brightness to {}", brightness);
return true;
} else {
ESP_LOGE(TAG, "Failed to set default brightness: %s", esp_err_to_name(ret));
LOGGER.error("Failed to set default brightness: {}", esp_err_to_name(ret));
return false;
}
}
uint8_t getBrightness() {
if (g_i2cPort >= I2C_NUM_MAX) {
ESP_LOGE(TAG, "Keyboard backlight not initialized");
LOGGER.error("Not initialized");
return 0;
}

View File

@ -1,7 +1,8 @@
#include "Trackball.h"
#include <esp_log.h>
static const char* TAG = "Trackball";
#include <Tactility/Logger.h>
static const auto LOGGER = tt::Logger("Trackball");
namespace trackball {
@ -72,7 +73,7 @@ static void read_cb(lv_indev_t* indev, lv_indev_data_t* data) {
lv_indev_t* init(const TrackballConfig& config) {
if (g_initialized) {
ESP_LOGW(TAG, "Trackball already initialized");
LOGGER.warn("Already initialized");
return g_indev;
}
@ -109,16 +110,19 @@ lv_indev_t* init(const TrackballConfig& config) {
lv_indev_set_type(g_indev, LV_INDEV_TYPE_ENCODER);
lv_indev_set_read_cb(g_indev, read_cb);
if (g_indev) {
if (g_indev != nullptr) {
g_initialized = true;
ESP_LOGI(TAG, "Trackball initialized as encoder (R:%d U:%d L:%d D:%d Click:%d)",
config.pinRight, config.pinUp, config.pinLeft, config.pinDown,
config.pinClick);
return g_indev;
LOGGER.info("Initialized as encoder (R:{} U:{} L:{} D:{} Click:{})",
static_cast<int>(config.pinRight),
static_cast<int>(config.pinUp),
static_cast<int>(config.pinLeft),
static_cast<int>(config.pinDown),
static_cast<int>(config.pinClick));
} else {
ESP_LOGE(TAG, "Failed to register LVGL input device");
return nullptr;
LOGGER.error("Failed to register LVGL input device");
}
return g_indev;
}
void deinit() {
@ -127,19 +131,19 @@ void deinit() {
g_indev = nullptr;
}
g_initialized = false;
ESP_LOGI(TAG, "Trackball deinitialized");
LOGGER.info("Deinitialized");
}
void setMovementStep(uint8_t step) {
if (step > 0) {
g_config.movementStep = step;
ESP_LOGD(TAG, "Movement step set to %d", step);
LOGGER.debug("Movement step set to {}", step);
}
}
void setEnabled(bool enabled) {
g_enabled = enabled;
ESP_LOGI(TAG, "Trackball %s", enabled ? "enabled" : "disabled");
LOGGER.info("{}", enabled ? "Enabled" : "Disabled");
}
}

View File

@ -6,11 +6,13 @@
#include <Tactility/settings/DisplaySettings.h>
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/Device.h>
#include <Tactility/Logger.h>
#include <KeyboardBacklight/KeyboardBacklight.h>
using tt::hal::findFirstDevice;
constexpr auto* TAG = "TdeckKeyboard";
static const auto LOGGER = tt::Logger("TdeckKeyboard");
constexpr auto TDECK_KEYBOARD_I2C_BUS_HANDLE = I2C_NUM_0;
constexpr auto TDECK_KEYBOARD_SLAVE_ADDRESS = 0x55;
@ -37,11 +39,15 @@ static void keyboard_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t*
if (keyboard_i2c_read(&read_buffer)) {
if (read_buffer == 0 && read_buffer != last_buffer) {
TT_LOG_D(TAG, "Released %d", last_buffer);
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("Released {}", last_buffer);
}
data->key = last_buffer;
data->state = LV_INDEV_STATE_RELEASED;
} else if (read_buffer != 0) {
TT_LOG_D(TAG, "Pressed %d", read_buffer);
if (LOGGER.isLoggingDebug()) {
LOGGER.debug("Pressed {}", read_buffer);
}
data->key = read_buffer;
data->state = LV_INDEV_STATE_PRESSED;
// TODO: Avoid performance hit by calling loadOrGetDefault() on each key press

View File

@ -1,13 +1,14 @@
#include "PwmBacklight.h"
#include "Tactility/service/gps/GpsService.h"
#include <Tactility/Logger.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/TactilityCore.h>
#define TAG "T-Dongle"
static const auto LOGGER = tt::Logger("T-Dongle S3");
bool initBoot() {
if (!driver::pwmbacklight::init(GPIO_NUM_38, 12000)) {
TT_LOG_E(TAG, "Backlight init failed");
LOGGER.error("Backlight init failed");
return false;
}

View File

@ -1,5 +1,6 @@
#include <Bq27220.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/hal/gps/GpsConfiguration.h>
@ -8,16 +9,16 @@
#include <PwmBacklight.h>
constexpr auto* TAG = "TLoraPager";
static const auto LOGGER = tt::Logger("T-Lora Pager");
bool tpagerInit() {
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
/* 32 Khz and higher gives an issue where the screen starts dimming again above 80% brightness
* when moving the brightness slider rapidly from a lower setting to 100%.
* This is not a slider bug (data was debug-traced) */
if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) {
TT_LOG_E(TAG, "Backlight init failed");
LOGGER.error("Backlight init failed");
return false;
}
@ -44,9 +45,9 @@ bool tpagerInit() {
.baudRate = 38400,
.model = tt::hal::gps::GpsModel::UBLOX10
})) {
TT_LOG_I(TAG, "Configured internal GPS");
LOGGER.info("Configured internal GPS");
} else {
TT_LOG_E(TAG, "Failed to configure internal GPS");
LOGGER.error("Failed to configure internal GPS");
}
}
}

View File

@ -1,9 +1,10 @@
#include "TpagerEncoder.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/gpio.h>
constexpr auto* TAG = "TpagerEncoder";
static const auto LOGGER = tt::Logger("TpagerEncoder");
constexpr auto ENCODER_A = GPIO_NUM_40;
constexpr auto ENCODER_B = GPIO_NUM_41;
constexpr auto ENCODER_ENTER = GPIO_NUM_7;
@ -39,7 +40,9 @@ void TpagerEncoder::readCallback(lv_indev_t* indev, lv_indev_data_t* data) {
}
}
void TpagerEncoder::initEncoder() {
bool TpagerEncoder::initEncoder() {
assert(encPcntUnit == nullptr);
constexpr int LOW_LIMIT = -127;
constexpr int HIGH_LIMIT = 126;
@ -48,11 +51,15 @@ void TpagerEncoder::initEncoder() {
pcnt_unit_config_t unit_config = {
.low_limit = LOW_LIMIT,
.high_limit = HIGH_LIMIT,
.flags = {.accum_count = 1},
.intr_priority = 0,
.flags = {
.accum_count = 1
},
};
if (pcnt_new_unit(&unit_config, &encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter intialization failed");
LOGGER.error("Pulsecounter initialization failed");
return false;
}
pcnt_glitch_filter_config_t filter_config = {
@ -60,17 +67,34 @@ void TpagerEncoder::initEncoder() {
};
if (pcnt_unit_set_glitch_filter(encPcntUnit, &filter_config) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter glitch filter config failed");
LOGGER.error("Pulsecounter glitch filter config failed");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
pcnt_chan_config_t chan_1_config = {
.edge_gpio_num = ENCODER_B,
.level_gpio_num = ENCODER_A,
.flags {
.invert_edge_input = 0,
.invert_level_input = 0,
.virt_edge_io_level = 0,
.virt_level_io_level = 0,
.io_loop_back = 0
}
};
pcnt_chan_config_t chan_2_config = {
.edge_gpio_num = ENCODER_A,
.level_gpio_num = ENCODER_B,
.flags {
.invert_edge_input = 0,
.invert_level_input = 0,
.virt_edge_io_level = 0,
.virt_level_io_level = 0,
.io_loop_back = 0
}
};
pcnt_channel_handle_t pcnt_chan_1 = nullptr;
@ -78,37 +102,60 @@ void TpagerEncoder::initEncoder() {
if ((pcnt_new_channel(encPcntUnit, &chan_1_config, &pcnt_chan_1) != ESP_OK) ||
(pcnt_new_channel(encPcntUnit, &chan_2_config, &pcnt_chan_2) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter channel config failed");
LOGGER.error("Pulsecounter channel config failed");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
// Second argument is rising edge, third argument is falling edge
if ((pcnt_channel_set_edge_action(pcnt_chan_1, PCNT_CHANNEL_EDGE_ACTION_DECREASE, PCNT_CHANNEL_EDGE_ACTION_INCREASE) != ESP_OK) ||
(pcnt_channel_set_edge_action(pcnt_chan_2, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_DECREASE) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter edge action config failed");
LOGGER.error("Pulsecounter edge action config failed");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
// Second argument is low level, third argument is high level
if ((pcnt_channel_set_level_action(pcnt_chan_1, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK) ||
(pcnt_channel_set_level_action(pcnt_chan_2, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter level action config failed");
LOGGER.error("Pulsecounter level action config failed");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
if ((pcnt_unit_add_watch_point(encPcntUnit, LOW_LIMIT) != ESP_OK) ||
(pcnt_unit_add_watch_point(encPcntUnit, HIGH_LIMIT) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter watch point config failed");
LOGGER.error("Pulsecounter watch point config failed");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
if (pcnt_unit_enable(encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter could not be enabled");
LOGGER.error("Pulsecounter could not be enabled");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
if (pcnt_unit_clear_count(encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter could not be cleared");
LOGGER.error("Pulsecounter could not be cleared");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
if (pcnt_unit_start(encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter could not be started");
LOGGER.error("Pulsecounter could not be started");
pcnt_del_unit(encPcntUnit);
encPcntUnit = nullptr;
return false;
}
return true;
}
int TpagerEncoder::getEncoderPulses() const {
@ -117,9 +164,29 @@ int TpagerEncoder::getEncoderPulses() const {
return pulses;
}
bool TpagerEncoder::deinitEncoder() {
assert(encPcntUnit != nullptr);
if (pcnt_unit_stop(encPcntUnit) != ESP_OK) {
LOGGER.warn("Failed to stop encoder");
}
if (pcnt_del_unit(encPcntUnit) != ESP_OK) {
LOGGER.warn("Failed to delete encoder");
encPcntUnit = nullptr;
return false;
}
LOGGER.info("Deinitialized");
return true;
}
bool TpagerEncoder::startLvgl(lv_display_t* display) {
initEncoder();
if (encPcntUnit == nullptr && !initEncoder()) {
return false;
}
gpio_input_enable(ENCODER_ENTER);
@ -137,5 +204,10 @@ bool TpagerEncoder::stopLvgl() {
lv_indev_delete(encHandle);
encHandle = nullptr;
if (encPcntUnit != nullptr && !deinitEncoder()) {
// We're not returning false as LVGL as effectively deinitialized
LOGGER.warn("Deinitialization failed");
}
return true;
}

View File

@ -8,7 +8,8 @@ class TpagerEncoder final : public tt::hal::encoder::EncoderDevice {
lv_indev_t* _Nullable encHandle = nullptr;
pcnt_unit_handle_t encPcntUnit = nullptr;
void initEncoder();
bool initEncoder();
bool deinitEncoder();
static void readCallback(lv_indev_t* indev, lv_indev_data_t* data);

View File

@ -1,12 +1,12 @@
#include "TpagerKeyboard.h"
#include <Tactility/hal/i2c/I2c.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/i2c.h>
#include <driver/gpio.h>
constexpr auto* TAG = "TpagerKeyboard";
static const auto LOGGER = tt::Logger("TpagerKeyboard");
constexpr auto BACKLIGHT = GPIO_NUM_46;
@ -174,7 +174,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
};
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
TT_LOG_E(TAG, "Backlight timer config failed");
LOGGER.error("Backlight timer config failed");
return false;
}
@ -193,7 +193,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
};
if (ledc_channel_config(&ledc_channel) != ESP_OK) {
TT_LOG_E(TAG, "Backlight channel config failed");
LOGGER.error("Backlight channel config failed");
}
return true;
@ -201,7 +201,7 @@ bool TpagerKeyboard::initBacklight(gpio_num_t pin, uint32_t frequencyHz, ledc_ti
bool TpagerKeyboard::setBacklightDuty(uint8_t duty) {
if (!backlightOkay) {
TT_LOG_E(TAG, "Backlight not ready");
LOGGER.error("Backlight not ready");
return false;
}
return (ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK) &&

View File

@ -1,9 +1,9 @@
#include "TpagerPower.h"
#include <Bq25896.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
constexpr auto* TAG = "TpagerPower";
static const auto LOGGER = tt::Logger("TpagerPower");
constexpr auto TPAGER_GAUGE_I2C_BUS_HANDLE = I2C_NUM_0;
@ -68,7 +68,7 @@ void TpagerPower::powerOff() {
});
if (device == nullptr) {
TT_LOG_E(TAG, "BQ25896 not found");
LOGGER.error("BQ25896 not found");
return;
}

View File

@ -1,24 +1,24 @@
#include "CardputerPower.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/adc.h>
constexpr auto* TAG = "CardputerPower";
static const auto LOGGER = tt::Logger("CardputerPower");
bool CardputerPower::adcInitCalibration() {
bool calibrated = false;
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) {
TT_LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
LOGGER.warn("Calibration scheme not supported, skip software calibration");
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
TT_LOG_W(TAG, "eFuse not burnt, skip software calibration");
LOGGER.warn("eFuse not burnt, skip software calibration");
} else if (efuse_read_result == ESP_OK) {
calibrated = true;
TT_LOG_I(TAG, "Calibration success");
LOGGER.info("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);
} else {
TT_LOG_W(TAG, "eFuse read failed, skipping calibration");
LOGGER.warn("eFuse read failed, skipping calibration");
}
return calibrated;
@ -26,11 +26,11 @@ bool CardputerPower::adcInitCalibration() {
uint32_t CardputerPower::adcReadValue() const {
int adc_raw = adc1_get_raw(ADC1_CHANNEL_9);
TT_LOG_D(TAG, "Raw data: %d", adc_raw);
LOGGER.debug("Raw data: {}", adc_raw);
float voltage;
if (calibrated) {
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
TT_LOG_D(TAG, "Calibrated data: %d mV", voltage);
LOGGER.debug("Calibrated data: {} mV", voltage);
} else {
voltage = 0.0f;
}
@ -42,11 +42,11 @@ bool CardputerPower::ensureInitialized() {
calibrated = adcInitCalibration();
if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) {
TT_LOG_E(TAG, "ADC1 config width failed");
LOGGER.error("ADC1 config width failed");
return false;
}
if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) {
TT_LOG_E(TAG, "ADC1 config attenuation failed");
LOGGER.error("ADC1 config attenuation failed");
return false;
}

View File

@ -1,8 +1,8 @@
#include "CardputerKeyboard.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
constexpr auto* TAG = "Keyboard";
static const auto LOGGER = tt::Logger("Keyboard");
bool CardputerKeyboard::startLvgl(lv_display_t* display) {
keyboard.init();
@ -56,7 +56,7 @@ void CardputerKeyboard::readCallback(lv_indev_t* indev, lv_indev_data_t* data) {
}
} else {
if (self->keyboard.keysState().del) {
TT_LOG_I(TAG, "del");
LOGGER.info("del");
data->key = LV_KEY_DEL;
data->state = LV_INDEV_STATE_PRESSED;
} else {

View File

@ -1,24 +1,24 @@
#include "CardputerPower.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/adc.h>
constexpr auto* TAG = "CardputerPower";
static const auto LOGGER = tt::Logger("CardputerPower");
bool CardputerPower::adcInitCalibration() {
bool calibrated = false;
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) {
TT_LOG_W(TAG, "Calibration scheme not supported, skip software calibration");
LOGGER.warn("Calibration scheme not supported, skip software calibration");
} else if (efuse_read_result == ESP_ERR_INVALID_VERSION) {
TT_LOG_W(TAG, "eFuse not burnt, skip software calibration");
LOGGER.warn("eFuse not burnt, skip software calibration");
} else if (efuse_read_result == ESP_OK) {
calibrated = true;
TT_LOG_I(TAG, "Calibration success");
LOGGER.info("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);
} else {
TT_LOG_W(TAG, "eFuse read failed, skipping calibration");
LOGGER.warn("eFuse read failed, skipping calibration");
}
return calibrated;
@ -26,11 +26,11 @@ bool CardputerPower::adcInitCalibration() {
uint32_t CardputerPower::adcReadValue() const {
int adc_raw = adc1_get_raw(ADC1_CHANNEL_9);
TT_LOG_D(TAG, "Raw data: %d", adc_raw);
LOGGER.debug("Raw data: {}", adc_raw);
float voltage;
if (calibrated) {
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &adcCharacteristics);
TT_LOG_D(TAG, "Calibrated data: %d mV", voltage);
LOGGER.debug("Calibrated data: {} mV", voltage);
} else {
voltage = 0.0f;
}
@ -42,11 +42,11 @@ bool CardputerPower::ensureInitialized() {
calibrated = adcInitCalibration();
if (adc1_config_width(static_cast<adc_bits_width_t>(ADC_WIDTH_BIT_DEFAULT)) != ESP_OK) {
TT_LOG_E(TAG, "ADC1 config width failed");
LOGGER.error("ADC1 config width failed");
return false;
}
if (adc1_config_channel_atten(ADC1_CHANNEL_9, ADC_ATTEN_DB_11) != ESP_OK) {
TT_LOG_E(TAG, "ADC1 config attenuation failed");
LOGGER.error("ADC1 config attenuation failed");
return false;
}

View File

@ -1,9 +1,9 @@
#include "InitBoot.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/kernel/Kernel.h>
constexpr auto* TAG = "CoreS3";
static const auto LOGGER = tt::Logger("CoreS3");
std::shared_ptr<Axp2101> axp2101;
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
*/
bool initGpioExpander() {
TT_LOG_I(TAG, "AW9523 init");
LOGGER.info("AW9523 init");
/**
* P0 pins:
@ -58,33 +58,33 @@ bool initGpioExpander() {
/* AW9523 P0 is in push-pull mode */
if (!aw9523->writeCTL(0x10)) {
TT_LOG_E(TAG, "AW9523: Failed to set CTL");
LOGGER.error("AW9523: Failed to set CTL");
return false;
}
if (!aw9523->writeP0(p0_state)) {
TT_LOG_E(TAG, "AW9523: Failed to set P0");
LOGGER.error("AW9523: Failed to set P0");
return false;
}
if (!aw9523->writeP1(p1_state)) {
TT_LOG_E(TAG, "AW9523: Failed to set P1");
LOGGER.error("AW9523: Failed to set P1");
return false;
}
if (axp2101->isVBus()) {
float voltage = 0.0f;
axp2101->getVBusVoltage(voltage);
TT_LOG_I(TAG, "AXP2101: VBus at %.2f", voltage);
LOGGER.info("AXP2101: VBus at {:.2f}", voltage);
} else {
TT_LOG_W(TAG, "AXP2101: VBus disabled");
LOGGER.warn("AXP2101: VBus disabled");
}
return true;
}
bool initPowerControl() {
TT_LOG_I(TAG, "Init power control (AXP2101)");
LOGGER.info("Init power control (AXP2101)");
// Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61
aw9523->bitOnP1(0b10000000); // SY7088 boost enable
@ -135,16 +135,16 @@ bool initPowerControl() {
};
if (axp2101->setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) {
TT_LOG_I(TAG, "AXP2101 initialized with %d registers", sizeof(reg_data_array) / 2);
LOGGER.info("AXP2101 initialized with {} registers", sizeof(reg_data_array) / 2);
return true;
} else {
TT_LOG_E(TAG, "AXP2101: Failed to set registers");
LOGGER.error("AXP2101: Failed to set registers");
return false;
}
}
bool initBoot() {
TT_LOG_I(TAG, "initBoot()");
LOGGER.info("initBoot()");
axp2101 = std::make_shared<Axp2101>(I2C_NUM_0);
aw9523 = std::make_shared<Aw9523>(I2C_NUM_0);

View File

@ -3,16 +3,16 @@
#include <Axp2101.h>
#include <Ft5x06Touch.h>
#include <Ili934xDisplay.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/i2c/I2c.h>
constexpr auto* TAG = "CoreS3Display";
static const auto LOGGER = tt::Logger("CoreS3Display");
static void setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
// TODO: Refactor to use Axp2102 driver subproject. Reference: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42
if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01
TT_LOG_E(TAG, "Failed to set display backlight voltage");
LOGGER.error("Failed to set display backlight voltage");
}
}

View File

@ -1,18 +1,19 @@
#include "Display.h"
#include "Power.h"
#include <Tactility/Logger.h>
#include <St7789Display.h>
#include <bitset>
constexpr auto* TAG = "StickCPlus";
static const auto LOGGER = tt::Logger("StickCPlus");
static void setBacklightOn(bool on) {
const auto axp = getAxp192();
const auto* driver = axp->getAxp192();
uint8_t state;
if (axp192_read(driver, AXP192_DCDC13_LDO23_CONTROL, &state) != AXP192_OK) {
TT_LOG_I(TAG, "Failed to read LCD brightness state");
LOGGER.info("Failed to read LCD brightness state");
return;
}
std::bitset<8> new_state = state;

View File

@ -1,14 +1,14 @@
#include "LvglTask.h"
#include <Tactility/Check.h>
#include <Tactility/Thread.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/Check.h>
#include <lvgl.h>
constexpr auto TAG = "lvgl_task";
static const auto LOGGER = tt::Logger("LvglTask");
// Mutex for LVGL drawing
static tt::RecursiveMutex lvgl_mutex;
@ -58,7 +58,7 @@ void lvgl_task_interrupt() {
}
void lvgl_task_start() {
TT_LOG_I(TAG, "lvgl task starting");
LOGGER.info("LVGL task starting");
tt::lvgl::syncSet(&lvgl_lock, &lvgl_unlock);
@ -76,7 +76,7 @@ void lvgl_task_start() {
}
static void lvgl_task(TT_UNUSED void* arg) {
TT_LOG_I(TAG, "lvgl task started");
LOGGER.info("LVGL task started");
/** Ideally. the display handle would be created during Simulator.start(),
* but somehow that doesn't work. Waiting here from a ThreadFlag when that happens

View File

@ -5,7 +5,7 @@
#include "FreeRTOS.h"
#include "task.h"
#define TAG "freertos"
static const auto LOGGER = tt::Logger("FreeRTOS");
namespace simulator {
@ -16,10 +16,10 @@ void setMain(MainFunction newMainFunction) {
}
static void freertosMainTask(TT_UNUSED void* parameter) {
TT_LOG_I(TAG, "starting app_main()");
LOGGER.info("starting app_main()");
assert(simulator::mainFunction);
mainFunction();
TT_LOG_I(TAG, "returned from app_main()");
LOGGER.info("returned from app_main()");
vTaskDelete(nullptr);
}
@ -46,10 +46,8 @@ void freertosMain() {
* It allows you to set breakpoints and debug asserts.
*/
void vAssertCalled(unsigned long line, const char* const file) {
static portBASE_TYPE xPrinted = pdFALSE;
volatile uint32_t set_to_nonzero_in_debugger_to_continue = 0;
TT_LOG_E(TAG, "assert triggered at %s:%d", file, line);
LOGGER.error("Assert triggered at {}:{}", file, line);
taskENTER_CRITICAL();
{
// Step out by attaching a debugger and setting set_to_nonzero_in_debugger_to_continue

View File

@ -1,9 +1,11 @@
#include "UnPhoneFeatures.h"
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Preferences.h>
#include <Tactility/TactilityCore.h>
#include <esp_sleep.h>
constexpr auto* TAG = "unPhone";
static const auto LOGGER = tt::Logger("unPhone");
std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
static std::unique_ptr<tt::Thread> powerThread;
@ -46,10 +48,10 @@ public:
}
void printInfo() {
TT_LOG_I("TAG", "Device stats:");
TT_LOG_I("TAG", " boot: %ld", getValue(bootCountKey));
TT_LOG_I("TAG", " power off: %ld", getValue(powerOffCountKey));
TT_LOG_I("TAG", " power sleep: %ld", getValue(powerSleepKey));
LOGGER.info("Device stats:");
LOGGER.info(" boot: {}", getValue(bootCountKey));
LOGGER.info(" power off: {}", getValue(powerOffCountKey));
LOGGER.info(" power sleep: {}", getValue(powerSleepKey));
}
};
@ -89,11 +91,11 @@ static void updatePowerSwitch() {
if (!unPhoneFeatures->isPowerSwitchOn()) {
if (last_state != PowerState::Off) {
last_state = PowerState::Off;
TT_LOG_W(TAG, "Power off");
LOGGER.warn("Power off");
}
if (!unPhoneFeatures->isUsbPowerConnected()) { // and usb unplugged we go into shipping mode
TT_LOG_W(TAG, "Shipping mode until USB connects");
LOGGER.warn("Shipping mode until USB connects");
#if DEBUG_POWER_STATES
unPhoneFeatures.setExpanderPower(true);
@ -107,7 +109,7 @@ static void updatePowerSwitch() {
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.
TT_LOG_W(TAG, "Waiting for USB disconnect to power off");
LOGGER.warn("Waiting for USB disconnect to power off");
#if DEBUG_POWER_STATES
powerInfoBuzz(2);
@ -126,7 +128,7 @@ static void updatePowerSwitch() {
} else {
if (last_state != PowerState::On) {
last_state = PowerState::On;
TT_LOG_W(TAG, "Power on");
LOGGER.warn("Power on");
#if DEBUG_POWER_STATES
powerInfoBuzz(1);
@ -163,7 +165,7 @@ static bool unPhonePowerOn() {
unPhoneFeatures = std::make_shared<UnPhoneFeatures>(bq24295);
if (!unPhoneFeatures->init()) {
TT_LOG_E(TAG, "UnPhoneFeatures init failed");
LOGGER.error("UnPhoneFeatures init failed");
return false;
}
@ -183,10 +185,10 @@ static bool unPhonePowerOn() {
}
bool initBoot() {
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
if (!unPhonePowerOn()) {
TT_LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED);
return false;
}

View File

@ -1,6 +1,6 @@
#include "UnPhoneFeatures.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/app/App.h>
#include <Tactility/kernel/Kernel.h>
@ -9,6 +9,8 @@
#include <esp_io_expander.h>
#include <esp_sleep.h>
static const auto LOGGER = tt::Logger("unPhoneFeatures");
namespace pin {
static const gpio_num_t BUTTON1 = GPIO_NUM_45; // left button
static const gpio_num_t BUTTON2 = GPIO_NUM_0; // middle button
@ -27,8 +29,6 @@ namespace expanderpin {
static const esp_io_expander_pin_num_t VIBE = IO_EXPANDER_PIN_NUM_7;
} // namespace expanderpin
#define TAG "unhpone_features"
// TODO: Make part of a new type of UnPhoneFeatures data struct that holds all the thread-related data
QueueHandle_t interruptQueue;
@ -42,7 +42,7 @@ static int32_t buttonHandlingThreadMain(const bool* interrupted) {
while (!*interrupted) {
if (xQueueReceive(interruptQueue, &pinNumber, portMAX_DELAY)) {
// The buttons might generate more than 1 click because of how they are built
TT_LOG_I(TAG, "Pressed button %d", pinNumber);
LOGGER.info("Pressed button {}", pinNumber);
if (pinNumber == pin::BUTTON1) {
tt::app::stop();
}
@ -75,7 +75,7 @@ bool UnPhoneFeatures::initPowerSwitch() {
};
if (gpio_config(&config) != ESP_OK) {
TT_LOG_E(TAG, "Power pin init failed");
LOGGER.error("Power pin init failed");
return false;
}
@ -83,14 +83,14 @@ bool UnPhoneFeatures::initPowerSwitch() {
rtc_gpio_pulldown_en(pin::POWER_SWITCH) == ESP_OK) {
return true;
} else {
TT_LOG_E(TAG, "Failed to set RTC for power switch");
LOGGER.error("Failed to set RTC for power switch");
return false;
}
}
bool UnPhoneFeatures::initNavButtons() {
if (!initGpioExpander()) {
TT_LOG_E(TAG, "GPIO expander init failed");
LOGGER.error("GPIO expander init failed");
return false;
}
@ -125,17 +125,17 @@ bool UnPhoneFeatures::initNavButtons() {
};
if (gpio_config(&config) != ESP_OK) {
TT_LOG_E(TAG, "Nav button pin init failed");
LOGGER.error("Nav button pin init failed");
return false;
}
if (
gpio_install_isr_service(0) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON1, navButtonInterruptHandler, (void*)pin::BUTTON1) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, (void*)pin::BUTTON2) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, (void*)pin::BUTTON3) != ESP_OK
gpio_isr_handler_add(pin::BUTTON1, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON1)) != 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
) {
TT_LOG_E(TAG, "Nav buttons ISR init failed");
LOGGER.error("Nav buttons ISR init failed");
return false;
}
@ -156,7 +156,7 @@ bool UnPhoneFeatures::initOutputPins() {
};
if (gpio_config(&config) != ESP_OK) {
TT_LOG_E(TAG, "Output pin init failed");
LOGGER.error("Output pin init failed");
return false;
}
@ -167,7 +167,7 @@ bool UnPhoneFeatures::initGpioExpander() {
// 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
if (esp_io_expander_new_i2c_tca95xx_16bit(I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110, &ioExpander) != ESP_OK) {
TT_LOG_E(TAG, "IO expander init failed");
LOGGER.error("IO expander init failed");
return false;
}
assert(ioExpander != nullptr);
@ -201,25 +201,25 @@ bool UnPhoneFeatures::initGpioExpander() {
}
bool UnPhoneFeatures::init() {
TT_LOG_I(TAG, "init");
LOGGER.info("init");
if (!initGpioExpander()) {
TT_LOG_E(TAG, "GPIO expander init failed");
LOGGER.error("GPIO expander init failed");
return false;
}
if (!initNavButtons()) {
TT_LOG_E(TAG, "Input pin init failed");
LOGGER.error("Input pin init failed");
return false;
}
if (!initOutputPins()) {
TT_LOG_E(TAG, "Output pin init failed");
LOGGER.error("Output pin init failed");
return false;
}
if (!initPowerSwitch()) {
TT_LOG_E(TAG, "Power button init failed");
LOGGER.error("Power button init failed");
return false;
}
@ -231,7 +231,7 @@ void UnPhoneFeatures::printInfo() const {
batteryManagement->printInfo();
bool backlight_power;
const char* backlight_power_state = getBacklightPower(backlight_power) && backlight_power ? "on" : "off";
TT_LOG_I(TAG, "Backlight: %s", backlight_power_state);
LOGGER.info("Backlight: {}", backlight_power_state);
}
bool UnPhoneFeatures::setRgbLed(bool red, bool green, bool blue) const {
@ -286,11 +286,11 @@ void UnPhoneFeatures::turnPeripheralsOff() const {
bool UnPhoneFeatures::setShipping(bool on) const {
if (on) {
TT_LOG_W(TAG, "setShipping: on");
LOGGER.warn("setShipping: on");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Disabled);
batteryManagement->setBatFetOn(false);
} else {
TT_LOG_W(TAG, "setShipping: off");
LOGGER.warn("setShipping: off");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s);
batteryManagement->setBatFetOn(true);
}

View File

@ -2,18 +2,19 @@
#include "Touch.h"
#include <UnPhoneFeatures.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <hx8357/disp_spi.h>
#include <hx8357/hx8357.h>
constexpr auto TAG = "Hx8357Display";
static const auto LOGGER = tt::Logger("Hx8357Display");
constexpr auto BUFFER_SIZE = (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_DRAW_BUFFER_HEIGHT * LV_COLOR_DEPTH / 8);
extern std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
bool Hx8357Display::start() {
TT_LOG_I(TAG, "start");
LOGGER.info("start");
disp_spi_add_device(SPI2_HOST);
@ -26,16 +27,16 @@ bool Hx8357Display::start() {
}
bool Hx8357Display::stop() {
TT_LOG_I(TAG, "stop");
LOGGER.info("stop");
disp_spi_remove_device();
return true;
}
bool Hx8357Display::startLvgl() {
TT_LOG_I(TAG, "startLvgl");
LOGGER.info("startLvgl");
if (lvglDisplay != nullptr) {
TT_LOG_W(TAG, "LVGL was already started");
LOGGER.warn("LVGL was already started");
return false;
}
@ -58,7 +59,7 @@ bool Hx8357Display::startLvgl() {
lv_display_set_flush_cb(lvglDisplay, hx8357_flush);
if (lvglDisplay == nullptr) {
TT_LOG_I(TAG, "Failed");
LOGGER.info("Failed");
return false;
}
@ -73,10 +74,10 @@ bool Hx8357Display::startLvgl() {
}
bool Hx8357Display::stopLvgl() {
TT_LOG_I(TAG, "stopLvgl");
LOGGER.info("stopLvgl");
if (lvglDisplay == nullptr) {
TT_LOG_W(TAG, "LVGL was already stopped");
LOGGER.warn("LVGL was already stopped");
return false;
}
@ -85,7 +86,7 @@ bool Hx8357Display::stopLvgl() {
auto touch_device = getTouchDevice();
if (touch_device != nullptr && touch_device->getLvglIndev() != nullptr) {
TT_LOG_I(TAG, "Stopping touch device");
LOGGER.info("Stopping touch device");
touch_device->stopLvgl();
}
@ -101,7 +102,7 @@ bool Hx8357Display::stopLvgl() {
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable Hx8357Display::getTouchDevice() {
if (touchDevice == nullptr) {
touchDevice = std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(createTouch());
TT_LOG_I(TAG, "Created touch device");
LOGGER.info("Created touch device");
}
return touchDevice;

View File

@ -1,7 +1,5 @@
#include "Touch.h"
#include <Tactility/Log.h>
std::shared_ptr<Xpt2046Touch> createTouch() {
auto configuration = std::make_unique<Xpt2046Touch::Configuration>(
SPI2_HOST,

View File

@ -1,3 +1,4 @@
#include <Tactility/LogMessages.h>
#include <Tactility/TactilityCore.h>
#include <driver/ledc.h>

View File

@ -1,12 +1,12 @@
#include "Jd9853Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_lcd_jd9853.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h>
constexpr const char* TAG = "JD9853";
static const auto LOGGER = tt::Logger("JD9853");
bool Jd9853Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
const esp_lcd_panel_io_spi_config_t panel_io_config = {
@ -54,42 +54,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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
LOGGER.error("Failed to swap XY");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return false;
}
if (esp_lcd_panel_set_gap(panelHandle, 34, 0) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel gap");
LOGGER.error("Failed to set panel gap");
return false;
}
@ -157,6 +157,6 @@ void Jd9853Display::setGammaCurve(uint8_t index) {
};
if (esp_lcd_panel_io_tx_param(getIoHandle() , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
LOGGER.error("Failed to set gamma");
}
}

View File

@ -1,5 +1,4 @@
#include "Axp2101.h"
#include <Tactility/Log.h>
bool Axp2101::getBatteryVoltage(float& vbatMillis) const {
return readRegister14(0x34, vbatMillis);

View File

@ -1,7 +1,7 @@
#include "Bq24295.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#define TAG "bq24295"
static const auto LOGGER = tt::Logger("BQ24295");
/** Reference:
* https://www.ti.com/lit/ds/symlink/bq24295.pdf
@ -49,8 +49,8 @@ bool Bq24295::setWatchDogTimer(WatchDogTimer in) const {
if (readChargeTermination(value)) {
uint8_t bits_to_set = 0b00110000 & static_cast<uint8_t>(in);
uint8_t value_cleared = value & 0b11001111;
uint8_t to_set = bits_to_set & value_cleared;
TT_LOG_I(TAG, "WatchDogTimer: %02x -> %02x", value, to_set);
uint8_t to_set = bits_to_set | value_cleared;
LOGGER.info("WatchDogTimer: {:02x} -> {:02x}", value, to_set);
return writeRegister8(registers::CHARGE_TERMINATION, to_set);
}
@ -96,9 +96,9 @@ bool Bq24295::getVersion(uint8_t& value) const {
void Bq24295::printInfo() const {
uint8_t version, status, charge_termination;
if (getStatus(status) && getVersion(version) && readChargeTermination(charge_termination)) {
TT_LOG_I(TAG, "Version %d, status %02x, charge termination %02x", version, status, charge_termination);
LOGGER.info("Version {}, status {:02x}, charge termination {:02x}", version, status, charge_termination);
} else {
TT_LOG_E(TAG, "Failed to retrieve version and/or status");
LOGGER.error("Failed to retrieve version and/or status");
}
}

View File

@ -6,7 +6,6 @@
class Bq24295 final : public tt::hal::i2c::I2cDevice {
private:
bool readChargeTermination(uint8_t& out) const;

View File

@ -1,15 +1,15 @@
#include "Bq25896.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
constexpr auto* TAG = "BQ25896";
static const auto LOGGER = tt::Logger("BQ25896");
void Bq25896::powerOff() {
TT_LOG_I(TAG, "Power off");
LOGGER.info("Power off");
bitOn(0x09, BIT(5));
}
void Bq25896::powerOn() {
TT_LOG_I(TAG, "Power on");
LOGGER.info("Power on");
bitOff(0x09, BIT(5));
}

View File

@ -1,9 +1,9 @@
#include "Bq27220.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include "esp_sleep.h"
#define TAG "bq27220"
static const auto LOGGER = tt::Logger("BQ27220");
#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]() {
// Set the design capacity
if (!writeConfig16(registers::ROM_DESIGN_CAPACITY, designCapacity)) {
TT_LOG_E(TAG, "Failed to set design capacity!");
LOGGER.error("Failed to set design capacity!");
return false;
}
vTaskDelay(10 / portTICK_PERIOD_MS);
// Set full charge capacity
if (!writeConfig16(registers::ROM_FULL_CHARGE_CAPACITY, fullChargeCapacity)) {
TT_LOG_E(TAG, "Failed to set full charge capacity!");
LOGGER.error("Failed to set full charge capacity!");
return false;
}
vTaskDelay(10 / portTICK_PERIOD_MS);
@ -260,7 +260,7 @@ bool Bq27220::sendSubCommand(uint16_t subCmd, bool waitConfirm)
}
vTaskDelay(100 / portTICK_PERIOD_MS);
}
TT_LOG_E(TAG, "Subcommand x%X failed!", subCmd);
LOGGER.error("Subcommand 0x{:04X} failed!", subCmd);
return false;
}
@ -298,28 +298,28 @@ bool Bq27220::configPreamble(bool &isSealed) {
// Check access settings
if(!getOperationStatus(status)) {
TT_LOG_E(TAG, "Cannot read initial operation status!");
LOGGER.error("Cannot read initial operation status!");
return false;
}
if (status.reg.SEC == OperationStatusSecSealed) {
isSealed = true;
if (!unsealDevice()) {
TT_LOG_E(TAG, "Unsealing device failure!");
LOGGER.error("Unsealing device failure!");
return false;
}
}
if (status.reg.SEC != OperationStatusSecFull) {
if (!unsealFullAccess()) {
TT_LOG_E(TAG, "Unsealing full access failure!");
LOGGER.error("Unsealing full access failure!");
return false;
}
}
// Send ENTER_CFG_UPDATE command (0x0090)
if (!sendSubCommand(registers::SUBCMD_ENTER_CFG_UPDATE)) {
TT_LOG_E(TAG, "Config Update Subcommand failure!");
LOGGER.error("Config Update Subcommand failure!");
}
// 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);
}
if (!isConfigUpdate) {
TT_LOG_E(TAG, "Update Mode timeout, maybe the access key for full permissions is invalid!");
LOGGER.error("Update Mode timeout, maybe the access key for full permissions is invalid!");
return false;
}
@ -357,13 +357,13 @@ bool Bq27220::configEpilouge(const bool isSealed) {
vTaskDelay(100 / portTICK_PERIOD_MS);
}
if (timeout == 0) {
TT_LOG_E(TAG, "Timed out waiting to exit update mode.");
LOGGER.error("Timed out waiting to exit update mode.");
return false;
}
// If the device was previously in SEALED state, return to SEALED mode by sending the Control(0x0030) subcommand
if (isSealed) {
TT_LOG_D(TAG, "Restore Safe Mode!");
LOGGER.debug("Restore Safe Mode!");
exitSealMode();
}
return true;

View File

@ -1,10 +1,10 @@
#include "ButtonControl.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_lvgl_port.h>
constexpr auto* TAG = "ButtonControl";
static const auto LOGGER = tt::Logger("ButtonControl");
ButtonControl::ButtonControl(const std::vector<PinConfiguration>& pinConfigurations) : pinConfigurations(pinConfigurations) {
pinStates.resize(pinConfigurations.size());
@ -73,7 +73,7 @@ void ButtonControl::updatePin(std::vector<PinConfiguration>::const_reference con
if (state.pressState) {
auto time_passed = tt::kernel::getMillis() - state.pressStartTime;
if (time_passed < 500) {
TT_LOG_D(TAG, "Trigger short press");
LOGGER.debug("Trigger short press");
state.triggerShortPress = true;
}
state.pressState = false;
@ -103,7 +103,7 @@ bool ButtonControl::shouldInterruptDriverThread() const {
}
void ButtonControl::startThread() {
TT_LOG_I(TAG, "Start");
LOGGER.info("Start");
mutex.lock();
@ -120,7 +120,7 @@ void ButtonControl::startThread() {
}
void ButtonControl::stopThread() {
TT_LOG_I(TAG, "Stop");
LOGGER.info("Stop");
mutex.lock();
interruptDriverThread = true;

View File

@ -3,6 +3,7 @@
#include <Tactility/hal/encoder/EncoderDevice.h>
#include <Tactility/hal/gpio/Gpio.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/Thread.h>
class ButtonControl final : public tt::hal::encoder::EncoderDevice {

View File

@ -1,16 +1,33 @@
#include "Drv2605.h"
#include <Tactility/Check.h>
#include <Tactility/Logger.h>
static const auto LOGGER = tt::Logger("DRV2605");
Drv2605::Drv2605(i2c_port_t port, bool autoPlayStartupBuzz) : I2cDevice(port, ADDRESS), autoPlayStartupBuzz(autoPlayStartupBuzz) {
if (!init()) {
LOGGER.error("Failed to initialize DRV2605");
tt_crash();
}
if (autoPlayStartupBuzz) {
setWaveFormForBuzz();
startPlayback();
}
}
bool Drv2605::init() {
uint8_t status;
if (!readRegister8(static_cast<uint8_t>(Register::Status), status)) {
TT_LOG_E(TAG, "Failed to read status");
LOGGER.error("Failed to read status");
return false;
}
status >>= 5;
ChipId chip_id = static_cast<ChipId>(status);
if (chip_id != ChipId::DRV2604 && chip_id != ChipId::DRV2604L && chip_id != ChipId::DRV2605 && chip_id != ChipId::DRV2605L) {
TT_LOG_E(TAG, "Unknown chip id %02x", chip_id);
LOGGER.error("Unknown chip id {:02x}", static_cast<uint8_t>(chip_id));
return false;
}
@ -25,7 +42,7 @@ bool Drv2605::init() {
uint8_t feedback;
if (!readRegister(Register::Feedback, feedback)) {
TT_LOG_E(TAG, "Failed to read feedback");
LOGGER.error("Failed to read feedback");
return false;
}

View File

@ -1,11 +1,9 @@
#pragma once
#include <Tactility/hal/i2c/I2cDevice.h>
#include <Tactility/Log.h>
class Drv2605 : public tt::hal::i2c::I2cDevice {
static constexpr auto* TAG = "DRV2605";
static constexpr auto ADDRESS = 0x5A;
bool autoPlayStartupBuzz;
@ -64,16 +62,7 @@ class Drv2605 : public tt::hal::i2c::I2cDevice {
public:
explicit Drv2605(i2c_port_t port, bool autoPlayStartupBuzz = true) : I2cDevice(port, ADDRESS), autoPlayStartupBuzz(autoPlayStartupBuzz) {
if (!init()) {
TT_LOG_E(TAG, "Failed to initialize DRV2605");
}
if (autoPlayStartupBuzz) {
setWaveFormForBuzz();
startPlayback();
}
}
explicit Drv2605(i2c_port_t port, bool autoPlayStartupBuzz = true);
std::string getName() const final { return "DRV2605"; }
std::string getDescription() const final { return "Haptic driver for ERM/LRA with waveform library & auto-resonance tracking"; }
@ -84,7 +73,6 @@ public:
void setWaveFormForClick();
/**
*
* @param slot a value from 0 to 7
* @param waveform
*/

View File

@ -1,13 +1,13 @@
#include "EspLcdDisplay.h"
#include "EspLcdDisplayDriver.h"
#include <assert.h>
#include <cassert>
#include <esp_lvgl_port_disp.h>
#include <Tactility/Check.h>
#include <Tactility/LogEsp.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/touch/TouchDevice.h>
constexpr const char* TAG = "EspLcdDispDrv";
static const auto LOGGER = tt::Logger("EspLcdDisplay");
EspLcdDisplay::~EspLcdDisplay() {
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
@ -17,12 +17,12 @@ EspLcdDisplay::~EspLcdDisplay() {
bool EspLcdDisplay::start() {
if (!createIoHandle(ioHandle)) {
TT_LOG_E(TAG, "Failed to create IO handle");
LOGGER.error("Failed to create IO handle");
return false;
}
if (!createPanelHandle(ioHandle, panelHandle)) {
TT_LOG_E(TAG, "Failed to create panel handle");
LOGGER.error("Failed to create panel handle");
esp_lcd_panel_io_del(ioHandle);
return false;
}
@ -45,7 +45,7 @@ bool EspLcdDisplay::stop() {
}
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
TT_LOG_W(TAG, "DisplayDriver is still in use.");
LOGGER.warn("DisplayDriver is still in use.");
}
return true;
@ -55,7 +55,7 @@ bool EspLcdDisplay::startLvgl() {
assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
TT_LOG_W(TAG, "DisplayDriver is still in use.");
LOGGER.warn("DisplayDriver is still in use.");
}
auto lvgl_port_config = getLvglPortDisplayConfig(ioHandle, panelHandle);

View File

@ -1,13 +1,13 @@
#include "EspLcdDisplayV2.h"
#include "EspLcdDisplayDriver.h"
#include <assert.h>
#include <cassert>
#include <esp_lvgl_port_disp.h>
#include <Tactility/Check.h>
#include <Tactility/LogEsp.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/touch/TouchDevice.h>
constexpr auto* TAG = "EspLcdDispV2";
static const auto LOGGER = tt::Logger("EspLcdDispV2");
inline unsigned int getBufferSize(const std::shared_ptr<EspLcdConfiguration>& configuration) {
if (configuration->bufferSize != DEFAULT_BUFFER_SIZE) {
@ -25,17 +25,17 @@ EspLcdDisplayV2::~EspLcdDisplayV2() {
bool EspLcdDisplayV2::applyConfiguration() const {
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
@ -43,27 +43,27 @@ bool EspLcdDisplayV2::applyConfiguration() const {
int gap_x = configuration->swapXY ? configuration->gapY : configuration->gapX;
int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY;
if (esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel gap");
LOGGER.error("Failed to set panel gap");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
LOGGER.error("Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return false;
}
@ -72,14 +72,14 @@ bool EspLcdDisplayV2::applyConfiguration() const {
bool EspLcdDisplayV2::start() {
if (!createIoHandle(ioHandle)) {
TT_LOG_E(TAG, "Failed to create IO handle");
LOGGER.error("Failed to create IO handle");
return false;
}
esp_lcd_panel_dev_config_t panel_config = createPanelConfig(configuration, configuration->resetPin);
if (!createPanelHandle(ioHandle, panel_config, panelHandle)) {
TT_LOG_E(TAG, "Failed to create panel handle");
LOGGER.error("Failed to create panel handle");
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
return false;
@ -111,7 +111,7 @@ bool EspLcdDisplayV2::stop() {
}
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
TT_LOG_W(TAG, "DisplayDriver is still in use.");
LOGGER.warn("DisplayDriver is still in use.");
}
return true;
@ -121,7 +121,7 @@ bool EspLcdDisplayV2::startLvgl() {
assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
TT_LOG_W(TAG, "DisplayDriver is still in use.");
LOGGER.warn("DisplayDriver is still in use.");
}
auto lvgl_port_config = getLvglPortDisplayConfig(configuration, ioHandle, panelHandle);

View File

@ -1,12 +1,12 @@
#include "EspLcdSpiDisplay.h"
#include <esp_lcd_panel_commands.h>
#include <Tactility/LogEsp.h>
#include <Tactility/Logger.h>
constexpr auto* TAG = "EspLcdSpiDsp";
static const auto LOGGER = tt::Logger("EspLcdSpiDisplay");
bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
TT_LOG_I(TAG, "createIoHandle");
LOGGER.info("createIoHandle");
const esp_lcd_panel_io_spi_config_t panel_io_config = {
.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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
@ -65,6 +65,6 @@ void EspLcdSpiDisplay::setGammaCurve(uint8_t index) {
auto io_handle = getIoHandle();
assert(io_handle != nullptr);
if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
LOGGER.error("Failed to set gamma");
}
}

View File

@ -1,21 +1,22 @@
#include "EspLcdTouch.h"
#include <EspLcdTouchDriver.h>
#include <esp_lvgl_port_touch.h>
#include <Tactility/LogEsp.h>
constexpr const char* TAG = "EspLcdTouch";
#include <EspLcdTouchDriver.h>
#include <Tactility/Logger.h>
#include <esp_lvgl_port_touch.h>
static const auto LOGGER = tt::Logger("EspLcdTouch");
bool EspLcdTouch::start() {
if (!createIoHandle(ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Touch IO failed");
LOGGER.error("Touch IO failed");
return false;
}
config = createEspLcdTouchConfig();
if (!createTouchHandle(ioHandle, config, touchHandle)) {
TT_LOG_E(TAG, "Driver init failed");
LOGGER.error("Driver init failed");
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
return false;
@ -48,7 +49,7 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
}
if (touchDriver != nullptr && touchDriver.use_count() > 1) {
TT_LOG_W(TAG, "TouchDriver is still in use.");
LOGGER.warn("TouchDriver is still in use.");
}
const lvgl_port_touch_cfg_t touch_cfg = {
@ -56,10 +57,10 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
.handle = touchHandle,
};
TT_LOG_I(TAG, "Adding touch to LVGL");
LOGGER.info("Adding touch to LVGL");
lvglDevice = lvgl_port_add_touch(&touch_cfg);
if (lvglDevice == nullptr) {
TT_LOG_E(TAG, "Adding touch failed");
LOGGER.error("Adding touch failed");
return false;
}

View File

@ -1,12 +1,12 @@
#include "EspLcdTouchDriver.h"
#include <Tactility/LogEsp.h>
#include <Tactility/Logger.h>
constexpr const char* TAG = "EspLcdTouchDriver";
static const auto LOGGER = tt::Logger("EspLcdTouchDriver");
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) {
TT_LOG_E(TAG, "Read data failed");
LOGGER.error("Read data failed");
return false;
}
return esp_lcd_touch_get_coordinates(handle, x, y, strength, pointCount, maxPointCount);

View File

@ -1,8 +1,7 @@
#include "ChargeFromAdcVoltage.h"
#include <Tactility/Log.h>
#include <algorithm>
#include <Tactility/Logger.h>
constexpr auto TAG = "ChargeFromAdcV";
static const auto LOGGER = tt::Logger("ChargeFromAdcV");
constexpr auto MAX_VOLTAGE_SAMPLES = 15;
ChargeFromAdcVoltage::ChargeFromAdcVoltage(
@ -11,12 +10,12 @@ ChargeFromAdcVoltage::ChargeFromAdcVoltage(
float voltageMax
) : configuration(configuration), chargeFromVoltage(voltageMin, voltageMax) {
if (adc_oneshot_new_unit(&configuration.adcConfig, &adcHandle) != ESP_OK) {
TT_LOG_E(TAG, "ADC config failed");
LOGGER.error("ADC config failed");
return;
}
if (adc_oneshot_config_channel(adcHandle, configuration.adcChannel, &configuration.adcChannelConfig) != ESP_OK) {
TT_LOG_E(TAG, "ADC channel config failed");
LOGGER.error("ADC channel config failed");
adc_oneshot_del_unit(adcHandle);
return;
@ -33,10 +32,12 @@ bool ChargeFromAdcVoltage::readBatteryVoltageOnce(uint32_t& output) const {
int raw;
if (adc_oneshot_read(adcHandle, configuration.adcChannel, &raw) == ESP_OK) {
output = configuration.adcMultiplier * ((1000.f * configuration.adcRefVoltage) / 4096.f) * (float)raw;
TT_LOG_V(TAG, "Raw = %d, voltage = %lu", raw, output);
if (LOGGER.isLoggingVerbose()) {
LOGGER.verbose("Raw = {}, voltage = {}", raw, output);
}
return true;
} else {
TT_LOG_E(TAG, "Read failed");
LOGGER.error("Read failed");
return false;
}
}

View File

@ -1,9 +1,9 @@
#include "ChargeFromVoltage.h"
#include <Tactility/Logger.h>
#include <algorithm>
#include <Tactility/Log.h>
constexpr auto* TAG = "ChargeFromVoltage";
const static auto LOGGER = tt::Logger("ChargeFromVoltage");
uint8_t ChargeFromVoltage::estimateCharge(uint32_t milliVolt) const {
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_factor = std::min(1.0f, voltage_percentage);
const auto charge_level = (uint8_t) (voltage_factor * 100.f);
TT_LOG_D(TAG, "mV = %lu, scaled = %.2f, factor = %.2f, result = %d", milliVolt, volts, voltage_factor, charge_level);
LOGGER.debug("mV = {}, scaled = {}, factor = {:.2f}, result = {}", milliVolt, volts, voltage_factor, charge_level);
return charge_level;
}

View File

@ -1,13 +1,9 @@
#include "Ft5x06Touch.h"
#include <Tactility/Log.h>
#include <esp_lcd_touch_ft5x06.h>
#include <esp_err.h>
#include <esp_lvgl_port.h>
#define TAG "ft5x06"
bool Ft5x06Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG();
return esp_lcd_new_panel_io_i2c(configuration->port, &io_config, &outHandle) == ESP_OK;

View File

@ -1,12 +1,12 @@
#include "Ft6x36Touch.h"
#include <Ft6x36Touch.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_err.h>
#include <esp_lvgl_port.h>
#define TAG "ft6x36"
static const auto LOGGER = tt::Logger("FT6x36");
void Ft6x36Touch::touchReadCallback(lv_indev_t* indev, lv_indev_data_t* data) {
auto* touch = (Ft6x36Touch*)lv_indev_get_driver_data(indev);
@ -71,10 +71,10 @@ bool Ft6x36Touch::shouldInterruptDriverThread() const {
}
bool Ft6x36Touch::start() {
TT_LOG_I(TAG, "Start");
LOGGER.info("Start");
if (!driver.begin(FT6X36_DEFAULT_THRESHOLD, configuration->width, configuration->height)) {
TT_LOG_E(TAG, "driver.begin() failed");
LOGGER.error("driver.begin() failed");
return false;
}
@ -95,7 +95,7 @@ bool Ft6x36Touch::start() {
}
bool Ft6x36Touch::stop() {
TT_LOG_I(TAG, "Stop");
LOGGER.info("Stop");
mutex.lock();
interruptDriverThread = true;

View File

@ -2,6 +2,7 @@
#include <Tactility/hal/touch/TouchDevice.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/Thread.h>
#include <driver/i2c.h>
#include "ft6x36/FT6X36.h"

View File

@ -1,15 +1,15 @@
#include "Gc9a01Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_lcd_gc9a01.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h>
constexpr auto TAG = "GC9A01";
static const auto LOGGER = tt::Logger("GC9A01");
bool Gc9a01Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
TT_LOG_I(TAG, "Starting");
LOGGER.info("Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = {
.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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
LOGGER.error("Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return false;
}

View File

@ -1,12 +1,12 @@
#include "Gt911Touch.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/i2c/I2c.h>
#include <esp_lcd_touch_gt911.h>
#include <esp_err.h>
#define TAG "GT911"
static const auto LOGGER = tt::Logger("GT911");
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();
@ -21,7 +21,7 @@ bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
} else if (tt::hal::i2c::masterHasDeviceAtAddress(configuration->port, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP)) {
io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP;
} else {
TT_LOG_E(TAG, "No device found on I2C bus");
LOGGER.error("No device found on I2C bus");
return false;
}

View File

@ -1,12 +1,12 @@
#include "Ili9488Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_lcd_ili9488.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h>
#define TAG "ILI9488"
static const auto LOGGER = tt::Logger("ILI9488");
bool Ili9488Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
LOGGER.error("Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return false;
}

View File

@ -1,8 +1,8 @@
#include "PwmBacklight.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#define TAG "pwm_backlight"
static const auto LOGGER = tt::Logger("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;
backlightChannel = channel;
TT_LOG_I(TAG, "Init");
LOGGER.info("Init");
ledc_timer_config_t ledc_timer = {
.speed_mode = LEDC_LOW_SPEED_MODE,
.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) {
TT_LOG_E(TAG, "Timer config failed");
LOGGER.error("Timer config failed");
return false;
}
@ -46,7 +46,8 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
};
if (ledc_channel_config(&ledc_channel) != ESP_OK) {
TT_LOG_E(TAG, "Channel config failed");
LOGGER.error("Channel config failed");
return false;
}
isBacklightInitialized = true;
@ -56,7 +57,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
bool setBacklightDuty(uint8_t duty) {
if (!isBacklightInitialized) {
TT_LOG_E(TAG, "Not initialized");
LOGGER.error("Not initialized");
return false;
}
return ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK &&

View File

@ -1,15 +1,15 @@
#include "RgbDisplay.h"
#include <Tactility/Log.h>
#include <Tactility/Check.h>
#include <Tactility/hal/touch/TouchDevice.h>
#include <Tactility/Logger.h>
#include <esp_err.h>
#include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h>
#include <esp_lvgl_port.h>
#include <Tactility/Check.h>
#include <Tactility/hal/touch/TouchDevice.h>
constexpr auto TAG = "RgbDisplay";
static const auto LOGGER = tt::Logger("RgbDisplay");
RgbDisplay::~RgbDisplay() {
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
@ -18,35 +18,35 @@ RgbDisplay::~RgbDisplay() {
}
bool RgbDisplay::start() {
TT_LOG_I(TAG, "Starting");
LOGGER.info("Starting");
if (esp_lcd_new_rgb_panel(&configuration->panelConfig, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY");
LOGGER.error("Failed to swap XY");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
@ -64,7 +64,7 @@ bool RgbDisplay::stop() {
}
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
TT_LOG_W(TAG, "DisplayDriver is still in use.");
LOGGER.warn("DisplayDriver is still in use.");
}
auto touch_device = getTouchDevice();
@ -80,7 +80,7 @@ bool RgbDisplay::startLvgl() {
assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
TT_LOG_W(TAG, "DisplayDriver is still in use.");
LOGGER.warn("DisplayDriver is still in use.");
}
auto display_config = getLvglPortDisplayConfig();
@ -93,7 +93,7 @@ bool RgbDisplay::startLvgl() {
};
lvglDisplay = lvgl_port_add_disp_rgb(&display_config, &rgb_config);
TT_LOG_I(TAG, "Finished");
LOGGER.info("Finished");
auto touch_device = getTouchDevice();
if (touch_device != nullptr) {

View File

@ -1,6 +1,6 @@
#include "Ssd1306Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lcd_panel_dev.h>
#include <esp_lcd_panel_ssd1306.h>
@ -10,7 +10,7 @@
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#define TAG "ssd1306_display"
static const auto LOGGER = tt::Logger("Ssd1306Display");
// SSD1306 commands
#define SSD1306_CMD_SET_CHARGE_PUMP 0x8D
@ -31,7 +31,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
esp_err_t ret = i2c_master_write_to_device(port, addr, data, sizeof(data), pdMS_TO_TICKS(1000));
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to send command 0x%02X: %d", cmd, ret);
LOGGER.error("Failed to send command 0x{:02X}: {}", cmd, ret);
return false;
}
return true;
@ -49,7 +49,7 @@ bool Ssd1306Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
};
if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)configuration->port, &io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create IO handle");
LOGGER.error("Failed to create IO handle");
return false;
}
@ -93,7 +93,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
#endif
if (esp_lcd_new_panel_ssd1306(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
@ -103,7 +103,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
auto port = configuration->port;
auto addr = configuration->deviceAddress;
TT_LOG_I(TAG, "Sending Heltec V3 custom init sequence");
LOGGER.info("Sending Heltec V3 custom init sequence");
// Display off while configuring
ssd1306_i2c_send_cmd(port, addr, 0xAE);
@ -170,7 +170,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
vTaskDelay(pdMS_TO_TICKS(100)); // Let display stabilize
TT_LOG_I(TAG, "Heltec V3 display initialized successfully");
LOGGER.info("Heltec V3 display initialized successfully");
return true;
}

View File

@ -1,16 +1,16 @@
#include "St7735Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lcd_panel_dev.h>
#include <esp_lcd_st7735.h>
#include <esp_lvgl_port.h>
constexpr auto TAG = "ST7735";
static const auto LOGGER = tt::Logger("ST7735");
bool St7735Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
TT_LOG_I(TAG, "Starting");
LOGGER.info("Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = {
.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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
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_y = configuration->swapXY ? configuration->gapX : configuration->gapY;
if (esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel gap");
LOGGER.error("Failed to set panel gap");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
LOGGER.error("Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return false;
}
@ -165,6 +165,6 @@ void St7735Display::setGammaCurve(uint8_t index) {
auto io_handle = getIoHandle();
assert(io_handle != nullptr);
if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
LOGGER.error("Failed to set gamma");
}
}

View File

@ -1,5 +1,5 @@
#include "St7789i8080Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/gpio.h>
#include <esp_lcd_panel_io.h>
#include <esp_lcd_panel_ops.h>
@ -8,7 +8,7 @@
#include <freertos/task.h>
#include <lvgl.h>
constexpr auto TAG = "St7789i8080Display";
static const auto LOGGER = tt::Logger("St7789i8080Display");
static St7789i8080Display* g_display_instance = nullptr;
// ST7789 initialization commands
@ -51,13 +51,13 @@ St7789i8080Display::St7789i8080Display(const Configuration& config)
// Validate configuration
if (!configuration.isValid()) {
TT_LOG_E(TAG, "Invalid configuration: resolution must be set");
LOGGER.error("Invalid configuration: resolution must be set");
return;
}
}
bool St7789i8080Display::createI80Bus() {
TT_LOG_I(TAG, "Creating I80 bus");
LOGGER.info("Creating I80 bus");
// Create I80 bus configuration
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);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to create I80 bus: %s", esp_err_to_name(ret));
LOGGER.error("Failed to create I80 bus: {}", esp_err_to_name(ret));
return false;
}
@ -86,7 +86,7 @@ bool St7789i8080Display::createI80Bus() {
}
bool St7789i8080Display::createPanelIO() {
TT_LOG_I(TAG, "Creating panel IO");
LOGGER.info("Creating panel IO");
// Create panel IO with proper callback
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);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel IO: %s", esp_err_to_name(ret));
LOGGER.error("Failed to create panel IO: {}", esp_err_to_name(ret));
return false;
}
@ -122,7 +122,7 @@ bool St7789i8080Display::createPanelIO() {
}
bool St7789i8080Display::createPanel() {
TT_LOG_I(TAG, "Configuring panel");
LOGGER.info("Configuring panel");
// Create ST7789 panel
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);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to create ST7789 panel: %s", esp_err_to_name(ret));
LOGGER.error("Failed to create ST7789 panel: {}", esp_err_to_name(ret));
return false;
}
// Reset panel
ret = esp_lcd_panel_reset(panelHandle);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel: %s", esp_err_to_name(ret));
LOGGER.error("Failed to reset panel: {}", esp_err_to_name(ret));
return false;
}
// Initialize panel
ret = esp_lcd_panel_init(panelHandle);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel: %s", esp_err_to_name(ret));
LOGGER.error("Failed to init panel: {}", esp_err_to_name(ret));
return false;
}
// Set gap
ret = esp_lcd_panel_set_gap(panelHandle, configuration.gapX, configuration.gapY);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel gap: %s", esp_err_to_name(ret));
LOGGER.error("Failed to set panel gap: {}", esp_err_to_name(ret));
return false;
}
// Set inversion
ret = esp_lcd_panel_invert_color(panelHandle, configuration.invertColor);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel inversion: %s", esp_err_to_name(ret));
LOGGER.error("Failed to set panel inversion: {}", esp_err_to_name(ret));
return false;
}
// Set mirror
ret = esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel mirror: %s", esp_err_to_name(ret));
LOGGER.error("Failed to set panel mirror: {}", esp_err_to_name(ret));
return false;
}
// Turn on display
ret = esp_lcd_panel_disp_on_off(panelHandle, true);
if (ret != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on: %s", esp_err_to_name(ret));
LOGGER.error("Failed to turn display on: {}", esp_err_to_name(ret));
return false;
}
@ -188,7 +188,7 @@ bool St7789i8080Display::createPanel() {
}
void St7789i8080Display::sendInitCommands() {
TT_LOG_I(TAG, "Sending ST7789 init commands");
LOGGER.info("Sending ST7789 init commands");
for (const auto& cmd : st7789_init_cmds) {
esp_lcd_panel_io_tx_param(ioHandle, cmd.cmd, cmd.data, cmd.len & 0x7F);
if (cmd.len & 0x80) {
@ -198,7 +198,7 @@ void St7789i8080Display::sendInitCommands() {
}
bool St7789i8080Display::start() {
TT_LOG_I(TAG, "Initializing I8080 ST7789 Display hardware...");
LOGGER.info("Initializing I8080 ST7789 Display hardware...");
// Configure RD pin if needed
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);
buf1 = (uint8_t*)heap_caps_malloc(buffer_size, MALLOC_CAP_DMA);
if (!buf1) {
TT_LOG_E(TAG, "Failed to allocate display buffer");
LOGGER.error("Failed to allocate display buffer");
return false;
}
@ -239,7 +239,7 @@ bool St7789i8080Display::start() {
return false;
}
TT_LOG_I(TAG, "Display hardware initialized");
LOGGER.info("Display hardware initialized");
return true;
}
@ -278,17 +278,17 @@ bool St7789i8080Display::stop() {
}
bool St7789i8080Display::startLvgl() {
TT_LOG_I(TAG, "Initializing LVGL for ST7789 display");
LOGGER.info("Initializing LVGL for ST7789 display");
// Don't reinitialize hardware if it's already done
if (!ioHandle) {
TT_LOG_I(TAG, "Hardware not initialized, calling start()");
LOGGER.info("Hardware not initialized, calling start()");
if (!start()) {
TT_LOG_E(TAG, "Hardware initialization failed");
LOGGER.error("Hardware initialization failed");
return false;
}
} else {
TT_LOG_I(TAG, "Hardware already initialized, skipping");
LOGGER.info("Hardware already initialized, skipping");
}
// Create LVGL display using lvgl_port
@ -321,7 +321,7 @@ bool St7789i8080Display::startLvgl() {
// Create the LVGL display
lvglDisplay = lvgl_port_add_disp(&display_cfg);
if (!lvglDisplay) {
TT_LOG_E(TAG, "Failed to create LVGL display");
LOGGER.error("Failed to create LVGL display");
return false;
}
@ -332,7 +332,7 @@ bool St7789i8080Display::startLvgl() {
esp_lcd_panel_io_register_event_callbacks(ioHandle, &cbs, lvglDisplay);
g_display_instance = this;
TT_LOG_I(TAG, "LVGL display created successfully");
LOGGER.info("LVGL display created successfully");
return true;
}

View File

@ -1,5 +1,5 @@
#include "St7796i8080Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/gpio.h>
#include <esp_lcd_panel_io.h>
#include <esp_lcd_panel_ops.h>
@ -8,7 +8,7 @@
#include <freertos/task.h>
#include <lvgl.h>
constexpr auto TAG = "St7796i8080Display";
static const auto LOGGER = tt::Logger("St7796i8080Display");
static St7796i8080Display* g_display_instance = nullptr;
St7796i8080Display::St7796i8080Display(const Configuration& config)
@ -16,13 +16,13 @@ St7796i8080Display::St7796i8080Display(const Configuration& config)
// Validate configuration
if (!configuration.isValid()) {
TT_LOG_E(TAG, "Invalid configuration: resolution must be set");
LOGGER.error("Invalid configuration: resolution must be set");
return;
}
}
bool St7796i8080Display::createI80Bus() {
TT_LOG_I(TAG, "Creating I80 bus");
LOGGER.info("Creating I80 bus");
// Create I80 bus configuration
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) {
TT_LOG_E(TAG, "Failed to create I80 bus");
LOGGER.error("Failed to create I80 bus");
return false;
}
@ -50,7 +50,7 @@ bool St7796i8080Display::createI80Bus() {
}
bool St7796i8080Display::createPanelIO() {
TT_LOG_I(TAG, "Creating panel IO");
LOGGER.info("Creating panel IO");
// Create panel IO
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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
@ -85,7 +85,7 @@ bool St7796i8080Display::createPanelIO() {
}
bool St7796i8080Display::createPanel() {
TT_LOG_I(TAG, "Configuring panel");
LOGGER.info("Configuring panel");
// Create ST7796 panel
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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
// Reset panel
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
// Initialize panel
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
// Set swap XY
if (esp_lcd_panel_swap_xy(panelHandle, configuration.swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
LOGGER.error("Failed to swap XY ");
return false;
}
// Set mirror
if (esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
// Set inversion
if (esp_lcd_panel_invert_color(panelHandle, configuration.invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
// Turn on display
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return false;
}
@ -144,7 +144,7 @@ bool St7796i8080Display::createPanel() {
}
bool St7796i8080Display::start() {
TT_LOG_I(TAG, "Initializing I8080 ST7796 Display hardware...");
LOGGER.info("Initializing I8080 ST7796 Display hardware...");
// Calculate buffer size if needed
configuration.calculateBufferSize();
@ -153,7 +153,7 @@ bool St7796i8080Display::start() {
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);
if (!displayBuffer) {
TT_LOG_E(TAG, "Failed to allocate display buffer");
LOGGER.error("Failed to allocate display buffer");
return false;
}
@ -175,7 +175,7 @@ bool St7796i8080Display::start() {
return false;
}
TT_LOG_I(TAG, "Display hardware initialized");
LOGGER.info("Display hardware initialized");
return true;
}
@ -214,17 +214,17 @@ bool St7796i8080Display::stop() {
}
bool St7796i8080Display::startLvgl() {
TT_LOG_I(TAG, "Initializing LVGL for ST7796 display");
LOGGER.info("Initializing LVGL for ST7796 display");
// Don't reinitialize hardware if it's already done
if (!ioHandle) {
TT_LOG_I(TAG, "Hardware not initialized, calling start()");
LOGGER.info("Hardware not initialized, calling start()");
if (!start()) {
TT_LOG_E(TAG, "Hardware initialization failed");
LOGGER.error("Hardware initialization failed");
return false;
}
} else {
TT_LOG_I(TAG, "Hardware already initialized, skipping");
LOGGER.info("Hardware already initialized, skipping");
}
// Create LVGL display using lvgl_port
@ -257,12 +257,12 @@ bool St7796i8080Display::startLvgl() {
// Create the LVGL display
lvglDisplay = lvgl_port_add_disp(&display_cfg);
if (!lvglDisplay) {
TT_LOG_E(TAG, "Failed to create LVGL display");
LOGGER.error("Failed to create LVGL display");
return false;
}
g_display_instance = this;
TT_LOG_I(TAG, "LVGL display created successfully");
LOGGER.info("LVGL display created successfully");
return true;
}

View File

@ -1,12 +1,12 @@
#include "St7796Display.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <esp_lcd_panel_dev.h>
#include <esp_lcd_st7796.h>
#include <esp_lvgl_port.h>
constexpr auto TAG = "ST7796";
static const auto LOGGER = tt::Logger("ST7796");
bool St7796Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
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) {
TT_LOG_E(TAG, "Failed to create panel");
LOGGER.error("Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
LOGGER.error("Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
LOGGER.error("Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
LOGGER.error("Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
LOGGER.error("Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
LOGGER.error("Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_set_gap(panelHandle, configuration->gapX, configuration->gapY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel gap");
LOGGER.error("Failed to set panel gap");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
LOGGER.error("Failed to turn display on");
return 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) {
TT_LOG_E(TAG, "Failed to set gamma");
LOGGER.error("Failed to set gamma");
}*/
}

View File

@ -1,7 +1,4 @@
#include "Tca8418.h"
#include <Tactility/Log.h>
constexpr auto TAG = "TCA8418";
namespace registers {
static const uint8_t CFG = 0x01U;

View File

@ -1,10 +1,11 @@
#include "Xpt2046Power.h"
#include "Xpt2046Touch.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/Device.h>
constexpr auto TAG = "Xpt2046Power";
static const auto LOGGER = tt::Logger("Xpt2046Power");
constexpr auto BATTERY_VOLTAGE_MIN = 3.2f;
constexpr auto BATTERY_VOLTAGE_MAX = 4.2f;
constexpr auto MAX_VOLTAGE_SAMPLES = 15;
@ -13,12 +14,12 @@ static std::shared_ptr<Xpt2046Touch> findXp2046TouchDevice() {
// Make a safe copy
auto touch = tt::hal::findFirstDevice<tt::hal::touch::TouchDevice>(tt::hal::Device::Type::Touch);
if (touch == nullptr) {
TT_LOG_E(TAG, "Touch device not found");
LOGGER.error("Touch device not found");
return nullptr;
}
if (touch->getName() != "XPT2046") {
TT_LOG_E(TAG, "Touch device name mismatch");
LOGGER.error("Touch device name mismatch");
return nullptr;
}
@ -30,7 +31,7 @@ static uint8_t estimateChargeLevelFromVoltage(uint32_t milliVolt) {
float voltage_percentage = (volts - BATTERY_VOLTAGE_MIN) / (BATTERY_VOLTAGE_MAX - BATTERY_VOLTAGE_MIN);
float voltage_factor = std::min(1.0f, voltage_percentage);
auto charge_level = (uint8_t) (voltage_factor * 100.f);
TT_LOG_V(TAG, "mV = %lu, scaled = %.2f, factor = %.2f, result = %d", milliVolt, volts, voltage_factor, charge_level);
LOGGER.verbose("mV = {}, scaled = {}, factor = {}, result = {}", milliVolt, volts, voltage_factor, charge_level);
return charge_level;
}
@ -68,7 +69,7 @@ bool Xpt2046Power::readBatteryVoltageOnce(uint32_t& output) {
if (xptTouch == nullptr) {
xptTouch = findXp2046TouchDevice();
if (xptTouch == nullptr) {
TT_LOG_E(TAG, "XPT2046 touch device not found");
LOGGER.error("XPT2046 touch device not found");
return false;
}
}

View File

@ -1,6 +1,5 @@
#include "Xpt2046Touch.h"
#include <Tactility/Log.h>
#include <Tactility/lvgl/LvglSync.h>
#include <esp_err.h>

View File

@ -1,6 +1,6 @@
#include "Xpt2046SoftSpi.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/LvglSync.h>
#include <driver/gpio.h>
@ -13,7 +13,7 @@
#include <nvs_flash.h>
#include <rom/ets_sys.h>
constexpr auto* TAG = "Xpt2046SoftSpi";
static const auto LOGGER = tt::Logger("Xpt2046SoftSpi");
constexpr auto RERUN_CALIBRATE = false;
constexpr auto CMD_READ_Y = 0x90; // Try different commands if these don't work
@ -55,7 +55,7 @@ static void ensureNvsInitialized() {
bool Xpt2046SoftSpi::start() {
ensureNvsInitialized();
TT_LOG_I(TAG, "Starting Xpt2046SoftSpi touch driver");
LOGGER.info("Starting Xpt2046SoftSpi touch driver");
// Configure GPIO pins
gpio_config_t io_conf = {};
@ -70,7 +70,7 @@ bool Xpt2046SoftSpi::start() {
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
if (gpio_config(&io_conf) != ESP_OK) {
TT_LOG_E(TAG, "Failed to configure output pins");
LOGGER.error("Failed to configure output pins");
return false;
}
@ -80,7 +80,7 @@ bool Xpt2046SoftSpi::start() {
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
if (gpio_config(&io_conf) != ESP_OK) {
TT_LOG_E(TAG, "Failed to configure input pin");
LOGGER.error("Failed to configure input pin");
return false;
}
@ -89,31 +89,36 @@ bool Xpt2046SoftSpi::start() {
gpio_set_level(configuration->clkPin, 0); // CLK low
gpio_set_level(configuration->mosiPin, 0); // MOSI low
TT_LOG_I(TAG, "GPIO configured: MOSI=%d, MISO=%d, CLK=%d, CS=%d", configuration->mosiPin, configuration->misoPin, configuration->clkPin, configuration->csPin);
LOGGER.info("GPIO configured: MOSI={}, MISO={}, CLK={}, CS={}",
static_cast<int>(configuration->mosiPin),
static_cast<int>(configuration->misoPin),
static_cast<int>(configuration->clkPin),
static_cast<int>(configuration->csPin)
);
// Load or perform calibration
bool calibrationValid = true; //loadCalibration() && !RERUN_CALIBRATE;
if (calibrationValid) {
// Check if calibration values are valid (xMin != xMax, yMin != yMax)
if (cal.xMin == cal.xMax || cal.yMin == cal.yMax) {
TT_LOG_W(TAG, "Invalid calibration detected: xMin=%d, xMax=%d, yMin=%d, yMax=%d", cal.xMin, cal.xMax, cal.yMin, cal.yMax);
LOGGER.warn("Invalid calibration detected: xMin={}, xMax={}, yMin={}, yMax={}", cal.xMin, cal.xMax, cal.yMin, cal.yMax);
calibrationValid = false;
}
}
if (!calibrationValid) {
TT_LOG_W(TAG, "Calibration data not found, invalid, or forced recalibration");
LOGGER.warn("Calibration data not found, invalid, or forced recalibration");
calibrate();
saveCalibration();
} else {
TT_LOG_I(TAG, "Loaded calibration: xMin=%d, yMin=%d, xMax=%d, yMax=%d", cal.xMin, cal.yMin, cal.xMax, cal.yMax);
LOGGER.info("Loaded calibration: xMin={}, yMin={}, xMax={}, yMax={}", cal.xMin, cal.yMin, cal.xMax, cal.yMax);
}
return true;
}
bool Xpt2046SoftSpi::stop() {
TT_LOG_I(TAG, "Stopping Xpt2046SoftSpi touch driver");
LOGGER.info("Stopping Xpt2046SoftSpi touch driver");
// Stop LVLG if needed
if (lvglDevice != nullptr) {
@ -125,13 +130,13 @@ bool Xpt2046SoftSpi::stop() {
bool Xpt2046SoftSpi::startLvgl(lv_display_t* display) {
if (lvglDevice != nullptr) {
TT_LOG_E(TAG, "LVGL was already started");
LOGGER.error("LVGL was already started");
return false;
}
lvglDevice = lv_indev_create();
if (!lvglDevice) {
TT_LOG_E(TAG, "Failed to create LVGL input device");
LOGGER.error("Failed to create LVGL input device");
return false;
}
@ -139,7 +144,7 @@ bool Xpt2046SoftSpi::startLvgl(lv_display_t* display) {
lv_indev_set_read_cb(lvglDevice, touchReadCallback);
lv_indev_set_user_data(lvglDevice, this);
TT_LOG_I(TAG, "Xpt2046SoftSpi touch driver started successfully");
LOGGER.info("Xpt2046SoftSpi touch driver started successfully");
return true;
}
@ -186,9 +191,9 @@ int Xpt2046SoftSpi::readSPI(uint8_t command) {
void Xpt2046SoftSpi::calibrate() {
const int samples = 8; // More samples for better accuracy
TT_LOG_I(TAG, "Calibration starting...");
LOGGER.info("Calibration starting...");
TT_LOG_I(TAG, "Touch TOP-LEFT corner");
LOGGER.info("Touch TOP-LEFT corner");
while (!isTouched()) {
vTaskDelay(pdMS_TO_TICKS(50));
@ -203,9 +208,9 @@ void Xpt2046SoftSpi::calibrate() {
cal.xMin = sumX / samples;
cal.yMin = sumY / samples;
TT_LOG_I(TAG, "Top-left calibrated: xMin=%d, yMin=%d", cal.xMin, cal.yMin);
LOGGER.info("Top-left calibrated: xMin={}, yMin={}", cal.xMin, cal.yMin);
TT_LOG_I(TAG, "Touch BOTTOM-RIGHT corner");
LOGGER.info("Touch BOTTOM-RIGHT corner");
while (!isTouched()) {
vTaskDelay(pdMS_TO_TICKS(50));
@ -220,13 +225,13 @@ void Xpt2046SoftSpi::calibrate() {
cal.xMax = sumX / samples;
cal.yMax = sumY / samples;
TT_LOG_I(TAG, "Bottom-right calibrated: xMax=%d, yMax=%d", cal.xMax, cal.yMax);
LOGGER.info("Bottom-right calibrated: xMax={}, yMax={}", cal.xMax, cal.yMax);
TT_LOG_I(TAG, "Calibration completed! xMin=%d, yMin=%d, xMax=%d, yMax=%d", cal.xMin, cal.yMin, cal.xMax, cal.yMax);
LOGGER.info("Calibration completed! xMin={}, yMin={}, xMax={}, yMax={}", cal.xMin, cal.yMin, cal.xMax, cal.yMax);
}
bool Xpt2046SoftSpi::loadCalibration() {
TT_LOG_W(TAG, "Calibration load disabled (using fresh calibration only).");
LOGGER.warn("Calibration load disabled (using fresh calibration only).");
return false;
}
@ -234,16 +239,16 @@ void Xpt2046SoftSpi::saveCalibration() {
nvs_handle_t handle;
esp_err_t err = nvs_open("xpt2046", NVS_READWRITE, &handle);
if (err != ESP_OK) {
TT_LOG_E(TAG, "Failed to open NVS for writing (%s)", esp_err_to_name(err));
LOGGER.error("Failed to open NVS for writing ({})", esp_err_to_name(err));
return;
}
err = nvs_set_blob(handle, "cal", &cal, sizeof(cal));
if (err == ESP_OK) {
nvs_commit(handle);
TT_LOG_I(TAG, "Calibration saved to NVS");
LOGGER.info("Calibration saved to NVS");
} else {
TT_LOG_E(TAG, "Failed to write calibration data to NVS (%s)", esp_err_to_name(err));
LOGGER.error("Failed to write calibration data to NVS ({})", esp_err_to_name(err));
}
nvs_close(handle);
@ -254,7 +259,7 @@ void Xpt2046SoftSpi::setCalibration(int xMin, int yMin, int xMax, int yMax) {
cal.yMin = yMin;
cal.xMax = xMax;
cal.yMax = yMax;
TT_LOG_I(TAG, "Manual calibration set: xMin=%d, yMin=%d, xMax=%d, yMax=%d", xMin, yMin, xMax, yMax);
LOGGER.info("Manual calibration set: xMin={}, yMin={}, xMax={}, yMax={}", xMin, yMin, xMax, yMax);
}
bool Xpt2046SoftSpi::getTouchPoint(Point& point) {
@ -292,7 +297,7 @@ bool Xpt2046SoftSpi::getTouchPoint(Point& point) {
const int yRange = cal.yMax - cal.yMin;
if (xRange <= 0 || yRange <= 0) {
TT_LOG_W(TAG, "Invalid calibration: xRange=%d, yRange=%d", xRange, yRange);
LOGGER.warn("Invalid calibration: xRange={}, yRange={}", xRange, yRange);
return false;
}
@ -337,7 +342,7 @@ bool Xpt2046SoftSpi::isTouched() {
// Debug logging (remove this once working)
if (touched) {
TT_LOG_D(TAG, "Touch detected: validSamples=%d, avgX=%d, avgY=%d", validSamples, xTotal / validSamples, yTotal / validSamples);
LOGGER.debug("Touch detected: validSamples={}, avgX={}, avgY={}", validSamples, xTotal / validSamples, yTotal / validSamples);
}
return touched;

View File

@ -3,12 +3,13 @@
#ifdef ESP_PLATFORM
#include <esp_http_client.h>
#include <Tactility/Logger.h>
namespace tt::network {
class EspHttpClient {
static constexpr auto* TAG = "EspHttpClient";
const Logger logger = Logger("EspHttpClient");
std::unique_ptr<esp_http_client_config_t> config = nullptr;
esp_http_client_handle_t client = nullptr;
@ -27,7 +28,7 @@ public:
}
bool init(std::unique_ptr<esp_http_client_config_t> inConfig) {
TT_LOG_I(TAG, "init(%s)", inConfig->url);
logger.info("init({})", inConfig->url);
assert(this->config == nullptr);
config = std::move(inConfig);
client = esp_http_client_init(config.get());
@ -36,11 +37,11 @@ public:
bool open() {
assert(client != nullptr);
TT_LOG_I(TAG, "open()");
logger.info("open()");
auto result = esp_http_client_open(client, 0);
if (result != ESP_OK) {
TT_LOG_E(TAG, "open() failed: %s", esp_err_to_name(result));
logger.error("open() failed: {}", esp_err_to_name(result));
return false;
}
@ -50,7 +51,7 @@ public:
bool fetchHeaders() const {
assert(client != nullptr);
TT_LOG_I(TAG, "fetchHeaders()");
logger.info("fetchHeaders()");
return esp_http_client_fetch_headers(client) >= 0;
}
@ -63,7 +64,7 @@ public:
int getStatusCode() const {
assert(client != nullptr);
const auto status_code = esp_http_client_get_status_code(client);
TT_LOG_I(TAG, "Status code %d", status_code);
logger.info("Status code {}", status_code);
return status_code;
}
@ -74,19 +75,19 @@ public:
int read(char* bytes, int size) const {
assert(client != nullptr);
TT_LOG_I(TAG, "read(%d)", size);
logger.info("read({})", size);
return esp_http_client_read(client, bytes, size);
}
int readResponse(char* bytes, int size) const {
assert(client != nullptr);
TT_LOG_I(TAG, "readResponse(%d)", size);
logger.info("readResponse({})", size);
return esp_http_client_read_response(client, bytes, size);
}
bool close() {
assert(client != nullptr);
TT_LOG_I(TAG, "close()");
logger.info("close()");
if (esp_http_client_close(client) == ESP_OK) {
isOpen = false;
}
@ -96,7 +97,7 @@ public:
bool cleanup() {
assert(client != nullptr);
assert(!isOpen);
TT_LOG_I(TAG, "cleanup()");
logger.info("cleanup()");
const auto result = esp_http_client_cleanup(client);
client = nullptr;
return result == ESP_OK;

View File

@ -17,8 +17,8 @@ namespace tt::network::http {
const std::string& url,
const std::string& certFilePath,
const std::string &downloadFilePath,
std::function<void()> onSuccess,
std::function<void(const char* errorMessage)> onError
const std::function<void()>& onSuccess,
const std::function<void(const char* errorMessage)>& onError
);
}

View File

@ -6,7 +6,7 @@
#include <Tactility/Bundle.h>
#include <Tactility/Check.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h>
#include <memory>
@ -48,7 +48,7 @@ class AppInstance : public AppContext {
return manifest->createApp();
} else if (manifest->appLocation.isExternal()) {
if (manifest->createApp != nullptr) {
TT_LOG_W("", "Manifest specifies createApp, but this is not used with external apps");
Logger("AppInstance").warn("Manifest specifies createApp, but this is not used with external apps");
}
#ifdef ESP_PLATFORM
return createElfApp(manifest);

View File

@ -4,12 +4,14 @@
#include <string>
#include <vector>
#include <Tactility/Logger.h>
namespace tt::json {
class Reader {
const cJSON* root;
static constexpr const char* TAG = "json::Reader";
Logger logger = Logger("json::Reader");
public:
@ -18,7 +20,7 @@ public:
bool readString(const char* key, std::string& output) const {
const auto* child = cJSON_GetObjectItemCaseSensitive(root, key);
if (!cJSON_IsString(child)) {
TT_LOG_E(TAG, "%s is not a string", key);
logger.error("{} is not a string", key);
return false;
}
output = cJSON_GetStringValue(child);
@ -30,7 +32,7 @@ public:
if (!readNumber(key, buffer)) {
return false;
}
output = buffer;
output = static_cast<int32_t>(buffer);
return true;
}
@ -46,7 +48,7 @@ public:
bool readNumber(const char* key, double& output) const {
const auto* child = cJSON_GetObjectItemCaseSensitive(root, key);
if (!cJSON_IsNumber(child)) {
TT_LOG_E(TAG, "%s is not a number", key);
logger.error("{} is not a number", key);
return false;
}
output = cJSON_GetNumberValue(child);
@ -56,16 +58,16 @@ public:
bool readStringArray(const char* key, std::vector<std::string>& output) const {
const auto* child = cJSON_GetObjectItemCaseSensitive(root, key);
if (!cJSON_IsArray(child)) {
TT_LOG_E(TAG, "%s is not an array", key);
logger.error("{} is not an array", key);
return false;
}
const auto size = cJSON_GetArraySize(child);
TT_LOG_I(TAG, "Processing %d array children", size);
logger.info("Processing {} array children", size);
output.resize(size);
for (int i = 0; i < size; ++i) {
const auto string_json = cJSON_GetArrayItem(child, i);
if (!cJSON_IsString(string_json)) {
TT_LOG_E(TAG, "array child of %s is not a string", key);
logger.error("Array child of {} is not a string", key);
return false;
}
output[i] = cJSON_GetStringValue(string_json);

View File

@ -1,15 +1,14 @@
#ifdef ESP_PLATFORM
#include "Tactility/PartitionsEsp.h"
#include <Tactility/Log.h>
#include <Tactility/PartitionsEsp.h>
#include <Tactility/Logger.h>
#include <esp_vfs_fat.h>
#include <nvs_flash.h>
namespace tt {
constexpr auto* TAG = "Partitions";
static const auto LOGGER = Logger("Partitions");
static esp_err_t initNvsFlashSafely() {
esp_err_t result = nvs_flash_init();
@ -41,7 +40,7 @@ size_t getSectorSize() {
}
esp_err_t initPartitionsEsp() {
TT_LOG_I(TAG, "Init partitions");
LOGGER.info("Init partitions");
ESP_ERROR_CHECK(initNvsFlashSafely());
const esp_vfs_fat_mount_config_t mount_config = {
@ -54,16 +53,16 @@ esp_err_t initPartitionsEsp() {
auto system_result = esp_vfs_fat_spiflash_mount_ro("/system", "system", &mount_config);
if (system_result != ESP_OK) {
TT_LOG_E(TAG, "Failed to mount /system (%s)", esp_err_to_name(system_result));
LOGGER.error("Failed to mount /system ({})", esp_err_to_name(system_result));
} else {
TT_LOG_I(TAG, "Mounted /system");
LOGGER.info("Mounted /system");
}
auto data_result = esp_vfs_fat_spiflash_mount_rw_wl("/data", "data", &mount_config, &data_wl_handle);
if (data_result != ESP_OK) {
TT_LOG_E(TAG, "Failed to mount /data (%s)", esp_err_to_name(data_result));
LOGGER.error("Failed to mount /data ({})", esp_err_to_name(data_result));
} else {
TT_LOG_I(TAG, "Mounted /data");
LOGGER.info("Mounted /data");
}
return system_result == ESP_OK && data_result == ESP_OK;

View File

@ -1,5 +1,6 @@
#ifdef ESP_PLATFORM
#include <Tactility/Logger.h>
#include <Tactility/Preferences.h>
#include <Tactility/TactilityCore.h>
@ -7,12 +8,12 @@
namespace tt {
constexpr auto* TAG = "Preferences";
static const auto LOGGER = Logger("Preferences");
bool Preferences::optBool(const std::string& key, bool& out) const {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
return false;
} else {
uint8_t out_number;
@ -28,7 +29,7 @@ bool Preferences::optBool(const std::string& key, bool& out) const {
bool Preferences::optInt32(const std::string& key, int32_t& out) const {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
return false;
} else {
bool success = nvs_get_i32(handle, key.c_str(), &out) == ESP_OK;
@ -40,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 {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
return false;
} else {
bool success = nvs_get_i64(handle, key.c_str(), &out) == ESP_OK;
@ -52,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 {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
return false;
} else {
size_t out_size = 256;
@ -89,13 +90,13 @@ void Preferences::putBool(const std::string& key, bool value) {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_u8(handle, key.c_str(), value) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to set {}:{}", namespace_, key);
} else if (nvs_commit(handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to commit {}:{}", namespace_, key);
}
nvs_close(handle);
} else {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
}
}
@ -103,13 +104,13 @@ void Preferences::putInt32(const std::string& key, int32_t value) {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_i32(handle, key.c_str(), value) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to set {}:{}", namespace_, key);
} else if (nvs_commit(handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to commit {}:{}", namespace_, key);
}
nvs_close(handle);
} else {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
}
}
@ -117,13 +118,13 @@ void Preferences::putInt64(const std::string& key, int64_t value) {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_i64(handle, key.c_str(), value) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to set {}:{}", namespace_, key);
} else if (nvs_commit(handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to commit {}:{}", namespace_, key);
}
nvs_close(handle);
} else {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
}
}
@ -131,13 +132,13 @@ void Preferences::putString(const std::string& key, const std::string& text) {
nvs_handle_t handle;
if (nvs_open(namespace_, NVS_READWRITE, &handle) == ESP_OK) {
if (nvs_set_str(handle, key.c_str(), text.c_str()) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to set {}:{}", namespace_, key.c_str());
} else if (nvs_commit(handle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to commit %s:%s", namespace_, key.c_str());
LOGGER.error("Failed to commit {}:{}", namespace_, key);
}
nvs_close(handle);
} else {
TT_LOG_E(TAG, "Failed to open namespace %s", namespace_);
LOGGER.error("Failed to open namespace {}", namespace_);
}
}

View File

@ -1,7 +1,6 @@
#ifndef ESP_PLATFOM
#include "Tactility/Preferences.h"
#include <Tactility/Preferences.h>
#include <Tactility/Bundle.h>
namespace tt {

View File

@ -5,15 +5,17 @@
#include <Tactility/Tactility.h>
#include <Tactility/TactilityConfig.h>
#include <Tactility/DispatcherThread.h>
#include <Tactility/MountPoints.h>
#include <Tactility/app/AppManifestParsing.h>
#include <Tactility/app/AppRegistration.h>
#include <Tactility/DispatcherThread.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/hal/HalPrivate.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglPrivate.h>
#include <Tactility/MountPoints.h>
#include <Tactility/network/NtpPrivate.h>
#include <Tactility/service/ServiceManifest.h>
#include <Tactility/service/ServiceRegistration.h>
@ -29,7 +31,7 @@
namespace tt {
constexpr auto* TAG = "Tactility";
static auto LOGGER = Logger("Tactility");
static const Configuration* config_instance = nullptr;
static Dispatcher mainDispatcher;
@ -117,7 +119,7 @@ namespace app {
// List of all apps excluding Boot app (as Boot app calls this function indirectly)
static void registerInternalApps() {
TT_LOG_I(TAG, "Registering internal apps");
LOGGER.info("Registering internal apps");
addAppManifest(app::alertdialog::manifest);
addAppManifest(app::appdetails::manifest);
@ -178,22 +180,22 @@ static void registerInternalApps() {
}
static void registerInstalledApp(std::string path) {
TT_LOG_I(TAG, "Registering app at %s", path.c_str());
LOGGER.info("Registering app at {}", path);
std::string manifest_path = path + "/manifest.properties";
if (!file::isFile(manifest_path)) {
TT_LOG_E(TAG, "Manifest not found at %s", manifest_path.c_str());
LOGGER.error("Manifest not found at {}", manifest_path);
return;
}
std::map<std::string, std::string> properties;
if (!file::loadPropertiesFile(manifest_path, properties)) {
TT_LOG_E(TAG, "Failed to load manifest at %s", manifest_path.c_str());
LOGGER.error("Failed to load manifest at {}", manifest_path);
return;
}
app::AppManifest manifest;
if (!app::parseManifest(properties, manifest)) {
TT_LOG_E(TAG, "Failed to parse manifest at %s", manifest_path.c_str());
LOGGER.error("Failed to parse manifest at {}", manifest_path);
return;
}
@ -204,7 +206,7 @@ static void registerInstalledApp(std::string path) {
}
static void registerInstalledApps(const std::string& path) {
TT_LOG_I(TAG, "Registering apps from %s", path.c_str());
LOGGER.info("Registering apps from {}", path);
file::listDirectory(path, [&path](const auto& entry) {
auto absolute_path = std::format("{}/{}", path, entry.d_name);
@ -226,14 +228,14 @@ static void registerInstalledAppsFromSdCards() {
auto sdcard_devices = hal::findDevices<hal::sdcard::SdCardDevice>(hal::Device::Type::SdCard);
for (const auto& sdcard : sdcard_devices) {
if (sdcard->isMounted()) {
TT_LOG_I(TAG, "Registering apps from %s", sdcard->getMountPath().c_str());
LOGGER.info("Registering apps from {}", sdcard->getMountPath());
registerInstalledAppsFromSdCard(sdcard);
}
}
}
static void registerAndStartSecondaryServices() {
TT_LOG_I(TAG, "Registering and starting system services");
LOGGER.info("Registering and starting secondary system services");
addService(service::loader::manifest);
addService(service::gui::manifest);
addService(service::statusbar::manifest);
@ -248,7 +250,7 @@ static void registerAndStartSecondaryServices() {
}
static void registerAndStartPrimaryServices() {
TT_LOG_I(TAG, "Registering and starting system services");
LOGGER.info("Registering and starting primary system services");
addService(service::gps::manifest);
if (hal::hasDevice(hal::Device::Type::SdCard)) {
addService(service::sdcard::manifest);
@ -269,15 +271,15 @@ void createTempDirectory(const std::string& rootPath) {
auto lock = file::getLock(rootPath)->asScopedLock();
if (lock.lock(1000 / portTICK_PERIOD_MS)) {
if (mkdir(temp_path.c_str(), 0777) == 0) {
TT_LOG_I(TAG, "Created %s", temp_path.c_str());
LOGGER.info("Created {}", temp_path);
} else {
TT_LOG_E(TAG, "Failed to create %s", temp_path.c_str());
LOGGER.error("Failed to create {}", temp_path);
}
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, rootPath.c_str());
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, rootPath);
}
} else {
TT_LOG_I(TAG, "Found existing %s", temp_path.c_str());
LOGGER.info("Found existing {}", temp_path);
}
}
@ -305,7 +307,7 @@ void registerApps() {
}
void run(const Configuration& config) {
TT_LOG_I(TAG, "Tactility v%s on %s (%s)", TT_VERSION, CONFIG_TT_DEVICE_NAME, CONFIG_TT_DEVICE_ID);
LOGGER.info("Tactility v{} on {} ({})", TT_VERSION, CONFIG_TT_DEVICE_NAME, CONFIG_TT_DEVICE_ID);
assert(config.hardware);
const hal::Configuration& hardware = *config.hardware;
@ -325,14 +327,14 @@ void run(const Configuration& config) {
lvgl::init(hardware);
registerAndStartSecondaryServices();
TT_LOG_I(TAG, "Core systems ready");
LOGGER.info("Core systems ready");
TT_LOG_I(TAG, "Starting boot app");
LOGGER.info("Starting boot app");
// The boot app takes care of registering system apps, user services and user apps
addAppManifest(app::boot::manifest);
app::start(app::boot::manifest.appId);
TT_LOG_I(TAG, "Main dispatcher ready");
LOGGER.info("Main dispatcher ready");
while (true) {
mainDispatcher.consume();
}

View File

@ -1,7 +1,8 @@
#ifdef ESP_PLATFORM
#include "Tactility/PartitionsEsp.h"
#include "Tactility/TactilityCore.h"
#include <Tactility/Logger.h>
#include <Tactility/PartitionsEsp.h>
#include <Tactility/TactilityCore.h>
#include "esp_event.h"
#include "esp_netif.h"
@ -9,14 +10,14 @@
namespace tt {
constexpr auto* TAG = "Tactility";
static auto LOGGER = Logger("Tactility");
// Initialize NVS
static void initNvs() {
TT_LOG_I(TAG, "Init NVS");
LOGGER.info("Init NVS");
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
TT_LOG_I(TAG, "NVS erasing");
LOGGER.info("NVS erasing");
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
@ -24,7 +25,7 @@ static void initNvs() {
}
static void initNetwork() {
TT_LOG_I(TAG, "Init network");
LOGGER.info("Init network");
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
}

View File

@ -6,35 +6,32 @@
#include <Tactility/file/FileLock.h>
#include <Tactility/file/PropertiesFile.h>
#include <Tactility/hal/Device.h>
#include <Tactility/hal/sdcard/SdCardDevice.h>
#include <Tactility/Logger.h>
#include <Tactility/Paths.h>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <fcntl.h>
#include <format>
#include <libgen.h>
#include <map>
#include <sys/types.h>
#include <unistd.h>
#include <minitar.h>
constexpr auto* TAG = "App";
namespace tt::app {
static const auto LOGGER = Logger("App");
static bool untarFile(minitar* mp, const minitar_entry* entry, const std::string& destinationPath) {
const auto absolute_path = destinationPath + "/" + entry->metadata.path;
if (!file::findOrCreateDirectory(destinationPath, 0777)) {
TT_LOG_E(TAG, "Can't find or create directory %s", destinationPath.c_str());
LOGGER.error("Can't find or create directory {}", destinationPath.c_str());
return false;
}
// minitar_read_contents(&mp, &entry, file_buffer, entry.metadata.size);
if (!minitar_read_contents_to_file(mp, entry, absolute_path.c_str())) {
TT_LOG_E(TAG, "Failed to write data to %s", absolute_path.c_str());
LOGGER.error("Failed to write data to {}", absolute_path.c_str());
return false;
}
@ -63,32 +60,32 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
do {
if (minitar_read_entry(&mp, &entry) == 0) {
TT_LOG_I(TAG, "Extracting %s", entry.metadata.path);
LOGGER.info("Extracting {}", entry.metadata.path);
if (entry.metadata.type == MTAR_DIRECTORY) {
if (!strcmp(entry.metadata.name, ".") || !strcmp(entry.metadata.name, "..") || !strcmp(entry.metadata.name, "/")) continue;
if (!untarDirectory(&entry, destinationPath)) {
TT_LOG_E(TAG, "Failed to create directory %s/%s: %s", destinationPath.c_str(), entry.metadata.name, strerror(errno));
LOGGER.error("Failed to create directory {}/{}: {}", destinationPath, entry.metadata.name, strerror(errno));
success = false;
break;
}
} else if (entry.metadata.type == MTAR_REGULAR) {
if (!untarFile(&mp, &entry, destinationPath)) {
TT_LOG_E(TAG, "Failed to extract file %s: %s", entry.metadata.path, strerror(errno));
LOGGER.error("Failed to extract file {}: {}", entry.metadata.path, strerror(errno));
success = false;
break;
}
} else if (entry.metadata.type == MTAR_SYMLINK) {
TT_LOG_E(TAG, "SYMLINK not supported");
LOGGER.error("SYMLINK not supported");
} else if (entry.metadata.type == MTAR_HARDLINK) {
TT_LOG_E(TAG, "HARDLINK not supported");
LOGGER.error("HARDLINK not supported");
} else if (entry.metadata.type == MTAR_FIFO) {
TT_LOG_E(TAG, "FIFO not supported");
LOGGER.error("FIFO not supported");
} else if (entry.metadata.type == MTAR_BLKDEV) {
TT_LOG_E(TAG, "BLKDEV not supported");
LOGGER.error("BLKDEV not supported");
} else if (entry.metadata.type == MTAR_CHRDEV) {
TT_LOG_E(TAG, "CHRDEV not supported");
LOGGER.error("CHRDEV not supported");
} else {
TT_LOG_E(TAG, "Unknown entry type: %d", entry.metadata.type);
LOGGER.error("Unknown entry type: {}", static_cast<int>(entry.metadata.type));
success = false;
break;
}
@ -100,7 +97,7 @@ static bool untar(const std::string& tarPath, const std::string& destinationPath
void cleanupInstallDirectory(const std::string& path) {
if (!file::deleteRecursively(path)) {
TT_LOG_W(TAG, "Failed to delete existing installation at %s", path.c_str());
LOGGER.warn("Failed to delete existing installation at {}", path);
}
}
@ -109,16 +106,16 @@ bool install(const std::string& path) {
// the lock with the display. We don't want to lock the display for very long.
auto app_parent_path = getAppInstallPath();
TT_LOG_I(TAG, "Installing app %s to %s", path.c_str(), app_parent_path.c_str());
LOGGER.info("Installing app {} to {}", path, app_parent_path);
auto filename = file::getLastPathSegment(path);
const std::string app_target_path = std::format("{}/{}", app_parent_path, filename);
if (file::isDirectory(app_target_path) && !file::deleteRecursively(app_target_path)) {
TT_LOG_W(TAG, "Failed to delete %s", app_target_path.c_str());
LOGGER.warn("Failed to delete {}", app_target_path);
}
if (!file::findOrCreateDirectory(app_target_path, 0777)) {
TT_LOG_I(TAG, "Failed to create directory %s", app_target_path.c_str());
LOGGER.info("Failed to create directory {}", app_target_path);
return false;
}
@ -126,9 +123,9 @@ bool install(const std::string& path) {
auto source_path_lock = file::getLock(path)->asScopedLock();
target_path_lock.lock();
source_path_lock.lock();
TT_LOG_I(TAG, "Extracting app from %s to %s", path.c_str(), app_target_path.c_str());
LOGGER.info("Extracting app from {} to {}", path, app_target_path);
if (!untar(path, app_target_path)) {
TT_LOG_E(TAG, "Failed to extract");
LOGGER.error("Failed to extract");
return false;
}
source_path_lock.unlock();
@ -136,21 +133,21 @@ bool install(const std::string& path) {
auto manifest_path = app_target_path + "/manifest.properties";
if (!file::isFile(manifest_path)) {
TT_LOG_E(TAG, "Manifest not found at %s", manifest_path.c_str());
LOGGER.error("Manifest not found at {}", manifest_path);
cleanupInstallDirectory(app_target_path);
return false;
}
std::map<std::string, std::string> properties;
if (!file::loadPropertiesFile(manifest_path, properties)) {
TT_LOG_E(TAG, "Failed to load manifest at %s", manifest_path.c_str());
LOGGER.error("Failed to load manifest at {}", manifest_path);
cleanupInstallDirectory(app_target_path);
return false;
}
AppManifest manifest;
if (!parseManifest(properties, manifest)) {
TT_LOG_W(TAG, "Invalid manifest");
LOGGER.warn("Invalid manifest");
cleanupInstallDirectory(app_target_path);
return false;
}
@ -163,7 +160,7 @@ bool install(const std::string& path) {
const std::string renamed_target_path = std::format("{}/{}", app_parent_path, manifest.appId);
if (file::isDirectory(renamed_target_path)) {
if (!file::deleteRecursively(renamed_target_path)) {
TT_LOG_W(TAG, "Failed to delete existing installation at %s", renamed_target_path.c_str());
LOGGER.warn("Failed to delete existing installation at {}", renamed_target_path);
cleanupInstallDirectory(app_target_path);
return false;
}
@ -174,7 +171,7 @@ bool install(const std::string& path) {
target_path_lock.unlock();
if (!rename_success) {
TT_LOG_E(TAG, "Failed to rename \"%s\" to \"%s\"", app_target_path.c_str(), manifest.appId.c_str());
LOGGER.error(R"(Failed to rename "{}" to "{}")", app_target_path, manifest.appId);
cleanupInstallDirectory(app_target_path);
return false;
}
@ -187,7 +184,7 @@ bool install(const std::string& path) {
}
bool uninstall(const std::string& appId) {
TT_LOG_I(TAG, "Uninstalling app %s", appId.c_str());
LOGGER.info("Uninstalling app {}", appId);
// If the app was running, then stop it
if (isRunning(appId)) {
@ -196,7 +193,7 @@ bool uninstall(const std::string& appId) {
auto app_path = getAppInstallPath(appId);
if (!file::isDirectory(app_path)) {
TT_LOG_E(TAG, "App %s not found at %s", appId.c_str(), app_path.c_str());
LOGGER.error("App {} not found at {}", appId, app_path);
return false;
}
@ -205,7 +202,7 @@ bool uninstall(const std::string& appId) {
}
if (!removeAppManifest(appId)) {
TT_LOG_W(TAG, "Failed to remove app %s from registry", appId.c_str());
LOGGER.warn("Failed to remove app {} from registry", appId);
}
return true;

View File

@ -3,8 +3,6 @@
namespace tt::app {
#define TAG "app"
void AppInstance::setState(State newState) {
mutex.lock();
state = newState;

View File

@ -1,25 +1,21 @@
#include <Tactility/app/AppManifestParsing.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <algorithm>
#include <regex>
namespace tt::app {
constexpr auto* TAG = "App";
static const auto LOGGER = Logger("AppManifest");
static bool validateString(const std::string& value, const std::function<bool(const char)>& isValidChar) {
for (const auto& c : value) {
if (!isValidChar(c)) {
return false;
}
}
return true;
constexpr bool validateString(const std::string& value, const std::function<bool(char)>& isValidChar) {
return std::ranges::all_of(value, isValidChar);
}
static bool getValueFromManifest(const std::map<std::string, std::string>& map, const std::string& key, std::string& output) {
const auto iterator = map.find(key);
if (iterator == map.end()) {
TT_LOG_E(TAG, "Failed to find %s in manifest", key.c_str());
LOGGER.error("Failed to find {} in manifest", key);
return false;
}
output = iterator->second;
@ -33,19 +29,19 @@ bool isValidId(const std::string& id) {
}
static bool isValidManifestVersion(const std::string& version) {
return version.size() > 0 && validateString(version, [](const char c) {
return !version.empty() && validateString(version, [](const char c) {
return std::isalnum(c) != 0 || c == '.';
});
}
static bool isValidAppVersionName(const std::string& version) {
return version.size() > 0 && validateString(version, [](const char c) {
return !version.empty() && validateString(version, [](const char c) {
return std::isalnum(c) != 0 || c == '.' || c == '-' || c == '_';
});
}
static bool isValidAppVersionCode(const std::string& version) {
return version.size() > 0 && validateString(version, [](const char c) {
return !version.empty() && validateString(version, [](const char c) {
return std::isdigit(c) != 0;
});
}
@ -57,7 +53,7 @@ static bool isValidName(const std::string& name) {
}
bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& manifest) {
TT_LOG_I(TAG, "Parsing manifest");
LOGGER.info("Parsing manifest");
// [manifest]
@ -67,7 +63,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
}
if (!isValidManifestVersion(manifest_version)) {
TT_LOG_E(TAG, "Invalid version");
LOGGER.error("Invalid version");
return false;
}
@ -78,7 +74,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
}
if (!isValidId(manifest.appId)) {
TT_LOG_E(TAG, "Invalid app id");
LOGGER.error("Invalid app id");
return false;
}
@ -87,7 +83,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
}
if (!isValidName(manifest.appName)) {
TT_LOG_I(TAG, "Invalid app name");
LOGGER.error("Invalid app name");
return false;
}
@ -96,7 +92,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
}
if (!isValidAppVersionName(manifest.appVersionName)) {
TT_LOG_E(TAG, "Invalid app version name");
LOGGER.error("Invalid app version name");
return false;
}
@ -106,7 +102,7 @@ bool parseManifest(const std::map<std::string, std::string>& map, AppManifest& m
}
if (!isValidAppVersionCode(version_code_string)) {
TT_LOG_E(TAG, "Invalid app version code");
LOGGER.error("Invalid app version code");
return false;
}

View File

@ -1,27 +1,28 @@
#include "Tactility/app/AppRegistration.h"
#include "Tactility/app/AppManifest.h"
#include <Tactility/app/AppRegistration.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/Logger.h>
#include <Tactility/Mutex.h>
#include <unordered_map>
#include <Tactility/file/File.h>
#define TAG "app"
namespace tt::app {
static const auto LOGGER = Logger("AppRegistration");
typedef std::unordered_map<std::string, std::shared_ptr<AppManifest>> AppManifestMap;
static AppManifestMap app_manifest_map;
static Mutex hash_mutex;
void addAppManifest(const AppManifest& manifest) {
TT_LOG_I(TAG, "Registering manifest %s", manifest.appId.c_str());
LOGGER.info("Registering manifest {}", manifest.appId);
hash_mutex.lock();
if (app_manifest_map.contains(manifest.appId)) {
TT_LOG_W(TAG, "Overwriting existing manifest for %s", manifest.appId.c_str());
LOGGER.warn("Overwriting existing manifest for {}", manifest.appId);
}
app_manifest_map[manifest.appId] = std::make_shared<AppManifest>(manifest);
@ -30,7 +31,7 @@ void addAppManifest(const AppManifest& manifest) {
}
bool removeAppManifest(const std::string& id) {
TT_LOG_I(TAG, "Removing manifest for %s", id.c_str());
LOGGER.info("Removing manifest for {}", id);
auto lock = hash_mutex.asScopedLock();
lock.lock();

View File

@ -4,18 +4,17 @@
#include <Tactility/app/ElfApp.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <esp_elf.h>
#include <string>
#include <utility>
namespace tt::app {
constexpr auto* TAG = "ElfApp";
static auto LOGGER = Logger("ElfApp");
static std::string getErrorCodeString(int error_code) {
switch (error_code) {
@ -72,7 +71,7 @@ private:
bool startElf() {
const std::string elf_path = std::format("{}/elf/{}.elf", appPath, CONFIG_IDF_TARGET);
TT_LOG_I(TAG, "Starting ELF %s", elf_path.c_str());
LOGGER.info("Starting ELF {}", elf_path);
assert(elfFileData == nullptr);
size_t size = 0;
@ -86,7 +85,7 @@ private:
if (esp_elf_init(&elf) != ESP_OK) {
lastError = "Failed to initialize";
TT_LOG_E(TAG, "%s", lastError.c_str());
LOGGER.error("{}", lastError);
elfFileData = nullptr;
return false;
}
@ -95,7 +94,7 @@ private:
if (relocate_result != 0) {
// Note: the result code maps to values from cstdlib's errno.h
lastError = getErrorCodeString(-relocate_result);
TT_LOG_E(TAG, "Application failed to load: %s", lastError.c_str());
LOGGER.error("Application failed to load: {}", lastError);
elfFileData = nullptr;
return false;
}
@ -105,7 +104,7 @@ private:
if (esp_elf_request(&elf, 0, argc, argv) != ESP_OK) {
lastError = "Executable returned error code";
TT_LOG_E(TAG, "%s", lastError.c_str());
LOGGER.error("{}", lastError);
esp_elf_deinit(&elf);
elfFileData = nullptr;
return false;
@ -116,7 +115,7 @@ private:
}
void stopElf() {
TT_LOG_I(TAG, "Cleaning up ELF");
LOGGER.info("Cleaning up ELF");
if (shouldCleanupElf) {
esp_elf_deinit(&elf);
@ -164,7 +163,7 @@ public:
}
void onDestroy(AppContext& appContext) override {
TT_LOG_I(TAG, "Cleaning up app");
LOGGER.info("Cleaning up app");
if (manifest != nullptr) {
if (manifest->onDestroy != nullptr) {
manifest->onDestroy(&appContext, data);
@ -223,7 +222,7 @@ void setElfAppParameters(
}
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
TT_LOG_I(TAG, "createElfApp");
LOGGER.info("createElfApp");
assert(manifest != nullptr);
assert(manifest->appLocation.isExternal());
return std::make_shared<ElfApp>(manifest->appLocation.getPath());

View File

@ -1,23 +1,22 @@
#include "Tactility/StringUtils.h"
#include "Tactility/app/AppManifest.h"
#include "Tactility/app/alertdialog/AlertDialog.h"
#include "Tactility/hal/gps/GpsDevice.h"
#include "Tactility/hal/uart/Uart.h"
#include "Tactility/lvgl/Style.h"
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/service/gps/GpsService.h"
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/hal/gps/GpsDevice.h>
#include <Tactility/hal/uart/Uart.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/gps/GpsService.h>
#include <cstring>
#include <lvgl.h>
namespace tt::app::addgps {
constexpr const char* TAG = "AddGps";
static const auto LOGGER = Logger("AddGps");
class AddGpsApp final : public App {
private:
lv_obj_t* uartDropdown = nullptr;
lv_obj_t* modelDropdown = nullptr;
lv_obj_t* baudDropdown = nullptr;
@ -48,7 +47,7 @@ private:
return;
}
TT_LOG_I(TAG, "Saving: uart=%s, model=%lu, baud=%lu", new_configuration.uartName, (uint32_t)new_configuration.model, new_configuration.baudRate);
LOGGER.info("Saving: uart={}, model={}, baud={}", new_configuration.uartName, (uint32_t)new_configuration.model, new_configuration.baudRate);
auto service = service::gps::findGpsService();
std::vector<tt::hal::gps::GpsConfiguration> configurations;

View File

@ -3,8 +3,8 @@
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/service/loader/Loader.h"
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <Tactility/TactilityCore.h>
#include <lvgl.h>
@ -16,9 +16,9 @@ namespace tt::app::alertdialog {
#define RESULT_BUNDLE_KEY_INDEX "index"
#define PARAMETER_ITEM_CONCATENATION_TOKEN ";;"
#define DEFAULT_TITLE "Select..."
#define DEFAULT_TITLE ""
#define TAG "selection_dialog"
static const auto LOGGER = Logger("AlertDialog");
extern const AppManifest manifest;
@ -74,7 +74,7 @@ class AlertDialogApp : public App {
void onButtonClicked(lv_event_t* e) {
auto index = reinterpret_cast<std::size_t>(lv_event_get_user_data(e));
TT_LOG_I(TAG, "Selected item at index %d", index);
LOGGER.info("Selected item at index {}", index);
auto bundle = std::make_unique<Bundle>();
bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, (int32_t)index);

View File

@ -5,6 +5,7 @@
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Spinner.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
@ -16,7 +17,7 @@
namespace tt::app::apphub {
constexpr auto* TAG = "AppHub";
static const auto LOGGER = Logger("AppHub");
extern const AppManifest manifest;
@ -55,7 +56,7 @@ class AppHubApp final : public App {
}
void onRefreshSuccess() {
TT_LOG_I(TAG, "Request success");
LOGGER.info("Request success");
auto lock = lvgl::getSyncLock()->asScopedLock();
lock.lock();
@ -63,7 +64,7 @@ class AppHubApp final : public App {
}
void onRefreshError(const char* error) {
TT_LOG_E(TAG, "Request failed: %s", error);
LOGGER.error("Request failed: {}", error);
auto lock = lvgl::getSyncLock()->asScopedLock();
lock.lock();
@ -106,7 +107,7 @@ class AppHubApp final : public App {
lv_obj_set_size(list, LV_PCT(100), LV_SIZE_CONTENT);
for (int i = 0; i < entries.size(); i++) {
auto& entry = entries[i];
TT_LOG_I(TAG, "Adding %s", entry.appName.c_str());
LOGGER.info("Adding {}", entry.appName.c_str());
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 int_as_voidptr = reinterpret_cast<void*>(i);

View File

@ -1,10 +1,11 @@
#include <Tactility/app/apphub/AppHubEntry.h>
#include <Tactility/file/File.h>
#include <Tactility/json/Reader.h>
#include <Tactility/Logger.h>
namespace tt::app::apphub {
constexpr auto* TAG = "AppHubJson";
static const auto LOGGER = Logger("AppHubJson");
static bool parseEntry(const cJSON* object, AppHubEntry& entry) {
const json::Reader reader(object);
@ -24,21 +25,21 @@ bool parseJson(const std::string& filePath, std::vector<AppHubEntry>& entries) {
auto data = file::readString(filePath);
if (data == nullptr) {
TT_LOG_E(TAG, "Failed to read %s", filePath.c_str());
LOGGER.error("Failed to read {}", filePath);
return false;
}
auto data_ptr = reinterpret_cast<const char*>(data.get());
auto* json = cJSON_Parse(data_ptr);
if (json == nullptr) {
TT_LOG_E(TAG, "Failed to parse %s", filePath.c_str());
LOGGER.error("Failed to parse {}", filePath);
return false;
}
const cJSON* apps_json = cJSON_GetObjectItemCaseSensitive(json, "apps");
if (!cJSON_IsArray(apps_json)) {
cJSON_Delete(json);
TT_LOG_E(TAG, "apps is not an array");
LOGGER.error("apps is not an array");
return false;
}
@ -48,7 +49,7 @@ bool parseJson(const std::string& filePath, std::vector<AppHubEntry>& entries) {
auto& entry = entries.at(i);
auto* entry_json = cJSON_GetArrayItem(apps_json, i);
if (!parseEntry(entry_json, entry)) {
TT_LOG_E(TAG, "Failed to read entry");
LOGGER.error("Failed to read entry");
cJSON_Delete(json);
return false;
}

View File

@ -5,6 +5,7 @@
#include <Tactility/file/File.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/network/Http.h>
#include <Tactility/Paths.h>
#include <Tactility/service/loader/Loader.h>
@ -15,8 +16,9 @@
namespace tt::app::apphubdetails {
static const auto LOGGER = Logger("AppHubDetails");
extern const AppManifest manifest;
constexpr auto* TAG = "AppHubDetails";
static std::shared_ptr<Bundle> toBundle(const apphub::AppHubEntry& entry) {
auto bundle = std::make_shared<Bundle>();
@ -83,7 +85,7 @@ class AppHubDetailsApp final : public App {
}
void uninstallApp() {
TT_LOG_I(TAG, "Uninstall");
LOGGER.info("Uninstall");
lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
@ -107,10 +109,10 @@ class AppHubDetailsApp final : public App {
[this, temp_file_path] {
install(temp_file_path);
if (!file::deleteFile(temp_file_path.c_str())) {
TT_LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
if (!file::deleteFile(temp_file_path)) {
LOGGER.warn("Failed to remove {}", temp_file_path);
} else {
TT_LOG_I(TAG, "Deleted temporary file %s", temp_file_path.c_str());
LOGGER.info("Deleted temporary file {}", temp_file_path);
}
lvgl::getSyncLock()->lock();
@ -118,18 +120,18 @@ class AppHubDetailsApp final : public App {
lvgl::getSyncLock()->unlock();
},
[temp_file_path](const char* errorMessage) {
TT_LOG_E(TAG, "Download failed: %s", errorMessage);
LOGGER.error("Download failed: {}", errorMessage);
alertdialog::start("Error", "Failed to install app");
if (file::isFile(temp_file_path) && !file::deleteFile(temp_file_path.c_str())) {
TT_LOG_W(TAG, "Failed to remove %s", temp_file_path.c_str());
LOGGER.warn("Failed to remove {}", temp_file_path);
}
}
);
}
void installApp() {
TT_LOG_I(TAG, "Install");
LOGGER.info("Install");
lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
@ -139,15 +141,15 @@ class AppHubDetailsApp final : public App {
}
void updateApp() {
TT_LOG_I(TAG, "Update");
LOGGER.info("Update");
lvgl::getSyncLock()->lock();
lv_obj_remove_flag(spinner, LV_OBJ_FLAG_HIDDEN);
lvgl::getSyncLock()->unlock();
TT_LOG_I(TAG, "Removing previous version");
LOGGER.info("Removing previous version");
uninstall(entry.appId);
TT_LOG_I(TAG, "Installing new version");
LOGGER.info("Installing new version");
doInstall();
}
@ -173,13 +175,13 @@ public:
void onCreate(AppContext& appContext) override {
auto parameters = appContext.getParameters();
if (parameters == nullptr) {
TT_LOG_E(TAG, "No parameters");
LOGGER.error("No parameters");
stop();
return;
}
if (!fromBundle(*parameters.get(), entry)) {
TT_LOG_E(TAG, "Invalid parameters");
LOGGER.error("Invalid parameters");
stop();
}
}

View File

@ -8,6 +8,7 @@
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/hal/usb/Usb.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/settings/BootSettings.h>
@ -25,7 +26,8 @@
namespace tt::app::boot {
constexpr auto* TAG = "Boot";
static const auto LOGGER = Logger("Boot");
extern const AppManifest manifest;
static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() {
@ -51,17 +53,17 @@ class BootApp : public App {
if (settings::display::load(settings)) {
if (hal_display->getGammaCurveCount() > 0) {
hal_display->setGammaCurve(settings.gammaCurve);
TT_LOG_I(TAG, "Gamma curve %du", settings.gammaCurve);
LOGGER.info("Gamma curve {}", settings.gammaCurve);
}
} else {
settings = settings::display::getDefault();
}
if (hal_display->supportsBacklightDuty()) {
TT_LOG_I(TAG, "Backlight %du", settings.backlightDuty);
LOGGER.info("Backlight {}", settings.backlightDuty);
hal_display->setBacklightDuty(settings.backlightDuty);
} else {
TT_LOG_I(TAG, "no backlight");
LOGGER.info("No backlight");
}
}
@ -70,17 +72,17 @@ class BootApp : public App {
return false;
}
TT_LOG_I(TAG, "Rebooting into mass storage device mode");
LOGGER.info("Rebooting into mass storage device mode");
auto mode = hal::usb::getUsbBootMode(); // Get mode before reset
hal::usb::resetUsbBootMode();
if (mode == hal::usb::BootMode::Flash) {
if (!hal::usb::startMassStorageWithFlash()) {
TT_LOG_E(TAG, "Unable to start flash mass storage");
LOGGER.error("Unable to start flash mass storage");
return false;
}
} else if (mode == hal::usb::BootMode::Sdmmc) {
if (!hal::usb::startMassStorageWithSdmmc()) {
TT_LOG_E(TAG, "Unable to start SD mass storage");
LOGGER.error("Unable to start SD mass storage");
return false;
}
}
@ -98,23 +100,22 @@ class BootApp : public App {
}
static int32_t bootThreadCallback() {
TT_LOG_I(TAG, "Starting boot thread");
LOGGER.info("Starting boot thread");
const auto start_time = kernel::getTicks();
// Give the UI some time to redraw
// If we don't do this, various init calls will read files and block SPI IO for the display
// This would result in a blank/black screen being shown during this phase of the boot process
// This works with 5 ms on a T-Lora Pager, so we give it 10 ms to be safe
TT_LOG_I(TAG, "Delay");
kernel::delayMillis(10);
// TODO: Support for multiple displays
TT_LOG_I(TAG, "Setup display");
LOGGER.info("Setup display");
setupDisplay(); // Set backlight
prepareFileSystems();
if (!setupUsbBootMode()) {
TT_LOG_I(TAG, "initFromBootApp");
LOGGER.info("initFromBootApp");
registerApps();
waitForMinimalSplashDuration(start_time);
stop(manifest.appId);
@ -123,7 +124,7 @@ class BootApp : public App {
// This event will likely block as other systems are initialized
// e.g. Wi-Fi reads AP configs from SD card
TT_LOG_I(TAG, "Publish event");
LOGGER.info("Publish event");
kernel::publishSystemEvent(kernel::SystemEvent::BootSplash);
return 0;
@ -140,7 +141,7 @@ class BootApp : public App {
settings::BootSettings boot_properties;
std::string launcher_app_id;
if (settings::loadBootSettings(boot_properties) && boot_properties.launcherAppId.empty()) {
TT_LOG_E(TAG, "Failed to load launcher configuration, or launcher not configured");
LOGGER.error("Failed to load launcher configuration, or launcher not configured");
launcher_app_id = boot_properties.launcherAppId;
} else {
launcher_app_id = "Launcher";
@ -187,7 +188,7 @@ public:
logo = hal::usb::isUsbBootMode() ? "logo_usb.png" : "logo.png";
}
const auto logo_path = lvgl::PATH_PREFIX + paths->getAssetsPath(logo);
TT_LOG_I(TAG, "%s", logo_path.c_str());
LOGGER.info("{}", logo_path);
lv_image_set_src(image, logo_path.c_str());
}
};

View File

@ -7,6 +7,7 @@
#include <Tactility/app/AppManifest.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Assets.h>
#include <Tactility/Logger.h>
#include <Tactility/service/espnow/EspNow.h>
#include "Tactility/lvgl/LvglSync.h"
@ -18,7 +19,7 @@
namespace tt::app::chat {
constexpr const char* TAG = "ChatApp";
static const auto LOGGER = Logger("ChatApp");
constexpr uint8_t BROADCAST_ADDRESS[ESP_NOW_ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
class ChatApp : public App {
@ -46,7 +47,7 @@ class ChatApp : public App {
self->addMessage(msg);
if (!service::espnow::send(BROADCAST_ADDRESS, reinterpret_cast<const uint8_t*>(msg), msg_len)) {
TT_LOG_E(TAG, "Failed to send message");
LOGGER.error("Failed to send message");
}
lv_textarea_set_text(self->input_field, "");

View File

@ -1,20 +1,20 @@
#ifdef ESP_PLATFORM
#include "Tactility/hal/Device.h"
#include <Tactility/app/crashdiagnostics/QrHelpers.h>
#include <Tactility/app/crashdiagnostics/QrUrl.h>
#include <Tactility/app/launcher/Launcher.h>
#include <Tactility/hal/Device.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/service/loader/Loader.h>
#include <lvgl.h>
#include <qrcode.h>
#define TAG "CrashDiagnostics"
namespace tt::app::crashdiagnostics {
static const auto LOGGER = Logger("CrashDiagnostics");
extern const AppManifest manifest;
void onContinuePressed(TT_UNUSED lv_event_t* event) {
@ -44,38 +44,38 @@ public:
lv_obj_align(bottom_label, LV_ALIGN_BOTTOM_MID, 0, -2);
std::string url = getUrlFromCrashData();
TT_LOG_I(TAG, "%s", url.c_str());
LOGGER.info("{}", url);
size_t url_length = url.length();
int qr_version;
if (!getQrVersionForBinaryDataLength(url_length, qr_version)) {
TT_LOG_E(TAG, "QR is too large");
LOGGER.error("QR is too large");
stop(manifest.appId);
return;
}
TT_LOG_I(TAG, "QR version %d (length: %d)", qr_version, url_length);
LOGGER.info("QR version {} (length: {})", qr_version, url_length);
auto qrcodeData = std::make_shared<uint8_t[]>(qrcode_getBufferSize(qr_version));
if (qrcodeData == nullptr) {
TT_LOG_E(TAG, "Failed to allocate QR buffer");
stop();
LOGGER.error("Failed to allocate QR buffer");
stop(manifest.appId);
return;
}
QRCode qrcode;
TT_LOG_I(TAG, "QR init text");
LOGGER.info("QR init text");
if (qrcode_initText(&qrcode, qrcodeData.get(), qr_version, ECC_LOW, url.c_str()) != 0) {
TT_LOG_E(TAG, "QR init text failed");
LOGGER.error("QR init text failed");
stop(manifest.appId);
return;
}
TT_LOG_I(TAG, "QR size: %d", qrcode.size);
LOGGER.info("QR size: {}", qrcode.size);
// Calculate QR dot size
int32_t top_label_height = lv_obj_get_height(top_label) + 2;
int32_t bottom_label_height = lv_obj_get_height(bottom_label) + 2;
TT_LOG_I(TAG, "Create canvas");
LOGGER.info("Create canvas");
int32_t available_height = parent_height - top_label_height - bottom_label_height;
int32_t available_width = lv_display_get_horizontal_resolution(display);
int32_t smallest_size = std::min(available_height, available_width);
@ -85,7 +85,7 @@ public:
} else if (qrcode.size <= smallest_size) {
pixel_size = 1;
} else {
TT_LOG_E(TAG, "QR code won't fit screen");
LOGGER.error("QR code won't fit screen");
stop(manifest.appId);
return;
}
@ -97,10 +97,10 @@ public:
lv_obj_set_content_height(canvas, qrcode.size * pixel_size);
lv_obj_set_content_width(canvas, qrcode.size * pixel_size);
TT_LOG_I(TAG, "Create draw buffer");
LOGGER.info("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);
if (draw_buf == nullptr) {
TT_LOG_E(TAG, "Draw buffer alloc");
LOGGER.error("Failed to allocate draw buffer");
stop(manifest.appId);
return;
}

View File

@ -7,6 +7,7 @@
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/service/development/DevelopmentService.h>
#include <Tactility/service/development/DevelopmentSettings.h>
#include <Tactility/service/loader/Loader.h>
@ -17,7 +18,7 @@
namespace tt::app::development {
constexpr const char* TAG = "Development";
static const auto LOGGER = Logger("Development");
extern const AppManifest manifest;
class DevelopmentApp final : public App {
@ -84,7 +85,7 @@ public:
void onCreate(AppContext& appContext) override {
service = service::development::findService();
if (service == nullptr) {
TT_LOG_E(TAG, "Service not found");
LOGGER.error("Service not found");
stop(manifest.appId);
}
}

View File

@ -3,13 +3,14 @@
#include <Tactility/settings/DisplaySettings.h>
#include <Tactility/Assets.h>
#include <Tactility/hal/display/DisplayDevice.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h>
#include <lvgl.h>
namespace tt::app::display {
constexpr auto* TAG = "Display";
static const auto LOGGER = Logger("Display");
static std::shared_ptr<hal::display::DisplayDevice> getHalDisplay() {
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
@ -54,7 +55,7 @@ class DisplayApp final : public App {
auto* app = static_cast<DisplayApp*>(lv_event_get_user_data(event));
auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event));
uint32_t selected_index = lv_dropdown_get_selected(dropdown);
TT_LOG_I(TAG, "Selected %ld", selected_index);
LOGGER.info("Selected {}", selected_index);
auto selected_orientation = static_cast<settings::display::Orientation>(selected_index);
if (selected_orientation != app->displaySettings.orientation) {
app->displaySettings.orientation = selected_orientation;

View File

@ -3,18 +3,19 @@
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/hal/sdcard/SdCardDevice.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/MountPoints.h>
#include <Tactility/kernel/Platform.h>
#include <cstring>
#include <dirent.h>
#include <unistd.h>
#include <vector>
#include <dirent.h>
namespace tt::app::files {
constexpr auto* TAG = "Files";
static const auto LOGGER = Logger("Files");
State::State() {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
@ -22,7 +23,7 @@ State::State() {
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
setEntriesForPath(cwd);
} else {
TT_LOG_E(TAG, "Failed to get current work directory files");
LOGGER.error("Failed to get current work directory files");
setEntriesForPath("/");
}
} else {
@ -37,11 +38,11 @@ std::string State::getSelectedChildPath() const {
bool State::setEntriesForPath(const std::string& path) {
auto lock = mutex.asScopedLock();
if (!lock.lock(100)) {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "setEntriesForPath");
return false;
}
TT_LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
LOGGER.info("Changing path: {} -> {}", current_path, path);
/**
* On PC, the root entry point ("/") is a folder.
@ -49,7 +50,7 @@ bool State::setEntriesForPath(const std::string& path) {
*/
bool get_mount_points = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
if (get_mount_points) {
TT_LOG_I(TAG, "Setting custom root");
LOGGER.info("Setting custom root");
dir_entries = file::getMountPoints();
current_path = path;
selected_child_entry = "";
@ -59,13 +60,13 @@ bool State::setEntriesForPath(const std::string& path) {
dir_entries.clear();
int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
if (count >= 0) {
TT_LOG_I(TAG, "%s has %u entries", path.c_str(), count);
LOGGER.info("{} has {} entries", path, count);
current_path = path;
selected_child_entry = "";
action = ActionNone;
return true;
} else {
TT_LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
LOGGER.error("Failed to fetch entries for {}", path);
return false;
}
}
@ -73,7 +74,7 @@ bool State::setEntriesForPath(const std::string& path) {
bool State::setEntriesForChildPath(const std::string& childPath) {
auto path = file::getChildPath(current_path, childPath);
TT_LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
LOGGER.info("Navigating from {} to {}", current_path, path);
return setEntriesForPath(path);
}
@ -90,4 +91,5 @@ bool State::getDirent(uint32_t index, dirent& dirent) {
return false;
}
}
}

View File

@ -2,21 +2,21 @@
#include <Tactility/app/files/SupportedFiles.h>
#include <Tactility/file/File.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/app/imageviewer/ImageViewer.h>
#include <Tactility/app/inputdialog/InputDialog.h>
#include <Tactility/app/notes/Notes.h>
#include <Tactility/app/ElfApp.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <unistd.h>
#ifdef ESP_PLATFORM
@ -25,7 +25,7 @@
namespace tt::app::files {
constexpr auto* TAG = "Files";
static const auto LOGGER = Logger("Files");
// region Callbacks
@ -84,11 +84,11 @@ void View::viewFile(const std::string& path, const std::string& filename) {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == nullptr) {
TT_LOG_E(TAG, "Failed to get current working directory");
LOGGER.error("Failed to get current working directory");
return;
}
if (!file_path.starts_with(cwd)) {
TT_LOG_E(TAG, "Can only work with files in working directory %s", cwd);
LOGGER.error("Can only work with files in working directory {}", cwd);
return;
}
processed_filepath = file_path.substr(strlen(cwd));
@ -96,7 +96,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
processed_filepath = file_path;
}
TT_LOG_I(TAG, "Clicked %s", file_path.c_str());
LOGGER.info("Clicked {}", file_path);
if (isSupportedAppFile(filename)) {
#ifdef ESP_PLATFORM
@ -116,7 +116,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
notes::start(processed_filepath.substr(1));
}
} else {
TT_LOG_W(TAG, "opening files of this type is not supported");
LOGGER.warn("Opening files of this type is not supported");
}
onNavigate();
@ -125,7 +125,7 @@ void View::viewFile(const std::string& path, const std::string& filename) {
void View::onDirEntryPressed(uint32_t index) {
dirent dir_entry;
if (state->getDirent(index, dir_entry)) {
TT_LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, dir_entry.d_type);
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name);
using namespace tt::file;
switch (dir_entry.d_type) {
@ -136,7 +136,7 @@ void View::onDirEntryPressed(uint32_t index) {
update();
break;
case TT_DT_LNK:
TT_LOG_W(TAG, "opening links is not supported");
LOGGER.warn("opening links is not supported");
break;
case TT_DT_REG:
viewFile(state->getCurrentPath(), dir_entry.d_name);
@ -155,7 +155,7 @@ void View::onDirEntryPressed(uint32_t index) {
void View::onDirEntryLongPressed(int32_t index) {
dirent dir_entry;
if (state->getDirent(index, dir_entry)) {
TT_LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, dir_entry.d_type);
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name);
using namespace file;
switch (dir_entry.d_type) {
@ -164,7 +164,7 @@ void View::onDirEntryLongPressed(int32_t index) {
showActionsForDirectory();
break;
case TT_DT_LNK:
TT_LOG_W(TAG, "opening links is not supported");
LOGGER.warn("Opening links is not supported");
break;
case TT_DT_REG:
showActionsForFile();
@ -228,7 +228,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
void View::onNavigateUpPressed() {
if (state->getCurrentPath() != "/") {
TT_LOG_I(TAG, "Navigating upwards");
LOGGER.info("Navigating upwards");
std::string new_absolute_path;
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
state->setEntriesForPath(new_absolute_path);
@ -240,14 +240,14 @@ void View::onNavigateUpPressed() {
void View::onRenamePressed() {
std::string entry_name = state->getSelectedChildEntry();
TT_LOG_I(TAG, "Pending rename %s", entry_name.c_str());
LOGGER.info("Pending rename {}", entry_name);
state->setPendingAction(State::ActionRename);
inputdialog::start("Rename", "", entry_name);
}
void View::onDeletePressed() {
std::string file_path = state->getSelectedChildPath();
TT_LOG_I(TAG, "Pending delete %s", file_path.c_str());
LOGGER.info("Pending delete {}", file_path);
state->setPendingAction(State::ActionDelete);
std::string message = "Do you want to delete this?\n" + file_path;
const std::vector<std::string> choices = { "Yes", "No" };
@ -255,13 +255,13 @@ void View::onDeletePressed() {
}
void View::onNewFilePressed() {
TT_LOG_I(TAG, "Creating new file");
LOGGER.info("Creating new file");
state->setPendingAction(State::ActionCreateFile);
inputdialog::start("New File", "Enter filename:", "");
}
void View::onNewFolderPressed() {
TT_LOG_I(TAG, "Creating new folder");
LOGGER.info("Creating new folder");
state->setPendingAction(State::ActionCreateFolder);
inputdialog::start("New Folder", "Enter folder name:", "");
}
@ -295,7 +295,7 @@ void View::update() {
state->withEntries([this](const std::vector<dirent>& entries) {
for (auto entry : entries) {
TT_LOG_D(TAG, "Entry: %s %d", entry.d_name, entry.d_type);
LOGGER.debug("Entry: {} {}", entry.d_name, entry.d_type);
createDirEntryWidget(dir_entry_list, entry);
}
});
@ -306,7 +306,7 @@ void View::update() {
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
}
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
}
}
@ -369,20 +369,20 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
}
std::string filepath = state->getSelectedChildPath();
TT_LOG_I(TAG, "Result for %s", filepath.c_str());
LOGGER.info("Result for {}", filepath);
switch (state->getPendingAction()) {
case State::ActionDelete: {
if (alertdialog::getResultIndex(*bundle) == 0) {
if (file::isDirectory(filepath)) {
if (!file::deleteRecursively(filepath)) {
TT_LOG_W(TAG, "Failed to delete %s", filepath.c_str());
LOGGER.warn("Failed to delete {}", filepath);
}
} else if (file::isFile(filepath)) {
auto lock = file::getLock(filepath);
lock->lock();
if (remove(filepath.c_str()) <= 0) {
TT_LOG_W(TAG, "Failed to delete %s", filepath.c_str());
LOGGER.warn("Failed to delete {}", filepath);
}
lock->unlock();
}
@ -399,9 +399,9 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
lock->lock();
std::string rename_to = file::getChildPath(state->getCurrentPath(), new_name);
if (rename(filepath.c_str(), rename_to.c_str())) {
TT_LOG_I(TAG, "Renamed \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
LOGGER.info("Renamed \"{}\" to \"{}\"", filepath, rename_to);
} else {
TT_LOG_E(TAG, "Failed to rename \"%s\" to \"%s\"", filepath.c_str(), rename_to.c_str());
LOGGER.error("Failed to rename \"{}\" to \"{}\"", filepath, rename_to);
}
lock->unlock();
@ -420,7 +420,7 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
struct stat st;
if (stat(new_file_path.c_str(), &st) == 0) {
TT_LOG_W(TAG, "File already exists: \"%s\"", new_file_path.c_str());
LOGGER.warn("File already exists: \"{}\"", new_file_path);
lock->unlock();
break;
}
@ -428,9 +428,9 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
FILE* new_file = fopen(new_file_path.c_str(), "w");
if (new_file) {
fclose(new_file);
TT_LOG_I(TAG, "Created file \"%s\"", new_file_path.c_str());
LOGGER.info("Created file \"{}\"", new_file_path);
} else {
TT_LOG_E(TAG, "Failed to create file \"%s\"", new_file_path.c_str());
LOGGER.error("Failed to create file \"{}\"", new_file_path);
}
lock->unlock();
@ -449,15 +449,15 @@ void View::onResult(LaunchId launchId, Result result, std::unique_ptr<Bundle> bu
struct stat st;
if (stat(new_folder_path.c_str(), &st) == 0) {
TT_LOG_W(TAG, "Folder already exists: \"%s\"", new_folder_path.c_str());
LOGGER.warn("Folder already exists: \"{}\"", new_folder_path);
lock->unlock();
break;
}
if (mkdir(new_folder_path.c_str(), 0755) == 0) {
TT_LOG_I(TAG, "Created folder \"%s\"", new_folder_path.c_str());
LOGGER.info("Created folder \"{}\"", new_folder_path);
} else {
TT_LOG_E(TAG, "Failed to create folder \"%s\"", new_folder_path.c_str());
LOGGER.error("Failed to create folder \"{}\"", new_folder_path);
}
lock->unlock();

View File

@ -2,7 +2,7 @@
#include <Tactility/file/File.h>
#include "Tactility/hal/sdcard/SdCardDevice.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/MountPoints.h>
#include <Tactility/kernel/Platform.h>
@ -13,7 +13,7 @@
namespace tt::app::fileselection {
constexpr auto* TAG = "FileSelection";
static const auto LOGGER = Logger("FileSelection");
State::State() {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
@ -21,7 +21,7 @@ State::State() {
if (getcwd(cwd, sizeof(cwd)) != nullptr) {
setEntriesForPath(cwd);
} else {
TT_LOG_E(TAG, "Failed to get current work directory files");
LOGGER.error("Failed to get current work directory files");
setEntriesForPath("/");
}
} else {
@ -34,7 +34,7 @@ std::string State::getSelectedChildPath() const {
}
bool State::setEntriesForPath(const std::string& path) {
TT_LOG_I(TAG, "Changing path: %s -> %s", current_path.c_str(), path.c_str());
LOGGER.info("Changing path: {} -> {}", current_path, path);
/**
* ESP32 does not have a root directory, so we have to create it manually.
@ -42,7 +42,7 @@ bool State::setEntriesForPath(const std::string& path) {
*/
bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
if (show_custom_root) {
TT_LOG_I(TAG, "Setting custom root");
LOGGER.info("Setting custom root");
dir_entries = file::getMountPoints();
current_path = path;
selected_child_entry = "";
@ -51,12 +51,12 @@ bool State::setEntriesForPath(const std::string& path) {
dir_entries.clear();
int count = file::scandir(path, dir_entries, &file::direntFilterDotEntries, file::direntSortAlphaAndType);
if (count >= 0) {
TT_LOG_I(TAG, "%s has %u entries", path.c_str(), count);
LOGGER.info("{} has {} entries", path, count);
current_path = path;
selected_child_entry = "";
return true;
} else {
TT_LOG_E(TAG, "Failed to fetch entries for %s", path.c_str());
LOGGER.error("Failed to fetch entries for {}", path);
return false;
}
}
@ -64,7 +64,7 @@ bool State::setEntriesForPath(const std::string& path) {
bool State::setEntriesForChildPath(const std::string& childPath) {
auto path = file::getChildPath(current_path, childPath);
TT_LOG_I(TAG, "Navigating from %s to %s", current_path.c_str(), path.c_str());
LOGGER.info("Navigating from {} to {}", current_path, path);
return setEntriesForPath(path);
}

View File

@ -1,14 +1,15 @@
#include <Tactility/app/fileselection/View.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/file/File.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/Tactility.h>
#include <Tactility/file/File.h>
#include <Tactility/StringUtils.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Tactility.h>
#include <cstring>
#include <unistd.h>
@ -18,7 +19,7 @@
namespace tt::app::fileselection {
constexpr auto* TAG = "FileSelection";
const static Logger LOGGER = Logger("FileSelection");
// region Callbacks
@ -45,11 +46,11 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
if (kernel::getPlatform() == kernel::PlatformSimulator) {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == nullptr) {
TT_LOG_E(TAG, "Failed to get current working directory");
LOGGER.error("Failed to get current working directory");
return;
}
if (!file_path.starts_with(cwd)) {
TT_LOG_E(TAG, "Can only work with files in working directory %s", cwd);
LOGGER.error("Can only work with files in working directory {}", cwd);
return;
}
processed_filepath = file_path.substr(strlen(cwd));
@ -57,7 +58,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
processed_filepath = file_path;
}
TT_LOG_I(TAG, "Clicked %s", processed_filepath.c_str());
LOGGER.info("Clicked {}", processed_filepath);
lv_textarea_set_text(path_textarea, processed_filepath.c_str());
}
@ -65,7 +66,7 @@ void View::onTapFile(const std::string& path, const std::string& filename) {
void View::onDirEntryPressed(uint32_t index) {
dirent dir_entry;
if (state->getDirent(index, dir_entry)) {
TT_LOG_I(TAG, "Pressed %s %d", dir_entry.d_name, dir_entry.d_type);
LOGGER.info("Pressed {} {}", dir_entry.d_name, dir_entry.d_type);
state->setSelectedChildEntry(dir_entry.d_name);
using namespace tt::file;
switch (dir_entry.d_type) {
@ -76,7 +77,7 @@ void View::onDirEntryPressed(uint32_t index) {
update();
break;
case TT_DT_LNK:
TT_LOG_W(TAG, "opening links is not supported");
LOGGER.warn("Opening links is not supported");
break;
case TT_DT_REG:
onTapFile(state->getCurrentPath(), dir_entry.d_name);
@ -94,7 +95,7 @@ void View::onSelectButtonPressed(lv_event_t* event) {
auto* view = static_cast<View*>(lv_event_get_user_data(event));
const char* path = lv_textarea_get_text(view->path_textarea);
if (path == nullptr || strlen(path) == 0) {
TT_LOG_W(TAG, "Select pressed, but not path found in textarea");
LOGGER.warn("Select pressed, but not path found in textarea");
return;
}
@ -138,7 +139,7 @@ void View::createDirEntryWidget(lv_obj_t* list, dirent& dir_entry) {
void View::onNavigateUpPressed() {
if (state->getCurrentPath() != "/") {
TT_LOG_I(TAG, "Navigating upwards");
LOGGER.info("Navigating upwards");
std::string new_absolute_path;
if (string::getPathParent(state->getCurrentPath(), new_absolute_path)) {
state->setEntriesForPath(new_absolute_path);
@ -159,7 +160,7 @@ void View::update() {
state->withEntries([this](const std::vector<dirent>& entries) {
for (auto entry : entries) {
TT_LOG_D(TAG, "Entry: %s %d", entry.d_name, entry.d_type);
LOGGER.debug("Entry: {} {}", entry.d_name, entry.d_type);
createDirEntryWidget(dir_entry_list, entry);
}
});
@ -170,7 +171,7 @@ void View::update() {
lv_obj_remove_flag(navigate_up_button, LV_OBJ_FLAG_HIDDEN);
}
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "lvgl");
}
}

View File

@ -5,6 +5,7 @@
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Logger.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/service/gps/GpsState.h>
#include <Tactility/service/loader/Loader.h>
@ -23,7 +24,7 @@ extern const AppManifest manifest;
class GpsSettingsApp final : public App {
static constexpr auto* TAG = "GpsSettings";
const Logger logger = Logger("GpsSettings");
std::unique_ptr<Timer> timer;
std::shared_ptr<GpsSettingsApp*> appReference = std::make_shared<GpsSettingsApp*>(this);
@ -92,8 +93,8 @@ class GpsSettingsApp final : public App {
std::vector<tt::hal::gps::GpsConfiguration> configurations;
auto gps_service = service::gps::findGpsService();
if (gps_service && gps_service->getGpsConfigurations(configurations)) {
TT_LOG_I(TAG, "Found service and configs %d %d", index, configurations.size());
if (index <= configurations.size()) {
Logger("GpsSettings").info("Found service and configs {} {}", index, configurations.size());
if (index < configurations.size()) {
if (gps_service->removeGpsConfiguration(configurations[index])) {
app->updateViews();
} else {
@ -154,7 +155,7 @@ class GpsSettingsApp final : public App {
// Update toolbar
switch (state) {
case service::gps::State::OnPending:
TT_LOG_D(TAG, "OnPending");
logger.debug("OnPending");
lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_state(switchWidget, LV_STATE_CHECKED);
lv_obj_add_state(switchWidget, LV_STATE_DISABLED);
@ -163,7 +164,7 @@ class GpsSettingsApp final : public App {
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break;
case service::gps::State::On:
TT_LOG_D(TAG, "On");
logger.debug("On");
lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_state(switchWidget, LV_STATE_CHECKED);
lv_obj_remove_state(switchWidget, LV_STATE_DISABLED);
@ -172,7 +173,7 @@ class GpsSettingsApp final : public App {
lv_obj_add_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break;
case service::gps::State::OffPending:
TT_LOG_D(TAG, "OffPending");
logger.debug("OffPending");
lv_obj_remove_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_remove_state(switchWidget, LV_STATE_CHECKED);
lv_obj_add_state(switchWidget, LV_STATE_DISABLED);
@ -181,7 +182,7 @@ class GpsSettingsApp final : public App {
lv_obj_remove_flag(addGpsWrapper, LV_OBJ_FLAG_HIDDEN);
break;
case service::gps::State::Off:
TT_LOG_D(TAG, "Off");
logger.debug("Off");
lv_obj_add_flag(spinnerWidget, LV_OBJ_FLAG_HIDDEN);
lv_obj_remove_state(switchWidget, LV_STATE_CHECKED);
lv_obj_remove_state(switchWidget, LV_STATE_DISABLED);
@ -254,11 +255,11 @@ class GpsSettingsApp final : public App {
if (wants_on != is_on) {
// start/stop are potentially blocking calls, so we use a dispatcher to not block the UI
if (wants_on) {
getMainDispatcher().dispatch([this]() {
getMainDispatcher().dispatch([this] {
service->startReceiving();
});
} else {
getMainDispatcher().dispatch([this]() {
getMainDispatcher().dispatch([this] {
service->stopReceiving();
});
}

View File

@ -1,17 +1,18 @@
#include <Tactility/app/i2cscanner/I2cScannerPrivate.h>
#include <Tactility/app/i2cscanner/I2cHelpers.h>
#include <Tactility/Preferences.h>
#include <Tactility/Assets.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/hal/i2c/I2cDevice.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Timer.h>
#include <Tactility/Assets.h>
#include <Tactility/Preferences.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Tactility.h>
#include <Tactility/Timer.h>
#include <format>
@ -21,6 +22,8 @@ extern const AppManifest manifest;
class I2cScannerApp final : public App {
const Logger logger = Logger("I2cScanner");
static constexpr auto* START_SCAN_TEXT = "Scan";
static constexpr auto* STOP_SCAN_TEXT = "Stop scan";
@ -189,7 +192,7 @@ bool I2cScannerApp::getPort(i2c_port_t* outPort) {
mutex.unlock();
return true;
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
return false;
}
}
@ -200,7 +203,7 @@ bool I2cScannerApp::addAddressToList(uint8_t address) {
mutex.unlock();
return true;
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
return false;
}
}
@ -216,24 +219,24 @@ bool I2cScannerApp::shouldStopScanTimer() {
}
void I2cScannerApp::onScanTimer() {
TT_LOG_I(TAG, "Scan thread started");
logger.info("Scan thread started");
i2c_port_t safe_port;
if (!getPort(&safe_port)) {
TT_LOG_E(TAG, "Failed to get I2C port");
logger.error("Failed to get I2C port");
onScanTimerFinished();
return;
}
if (!hal::i2c::isStarted(safe_port)) {
TT_LOG_E(TAG, "I2C port not started");
logger.error("I2C port not started");
onScanTimerFinished();
return;
}
for (uint8_t address = 0; address < 128; ++address) {
if (hal::i2c::masterHasDeviceAtAddress(port, address, 10 / portTICK_PERIOD_MS)) {
TT_LOG_I(TAG, "Found device at address 0x%02X", address);
if (hal::i2c::masterHasDeviceAtAddress(safe_port, address, 10 / portTICK_PERIOD_MS)) {
logger.info("Found device at address 0x{:02X}", address);
if (!shouldStopScanTimer()) {
addAddressToList(address);
} else {
@ -246,11 +249,11 @@ void I2cScannerApp::onScanTimer() {
}
}
TT_LOG_I(TAG, "Scan thread finalizing");
logger.info("Scan thread finalizing");
onScanTimerFinished();
TT_LOG_I(TAG, "Scan timer done");
logger.info("Scan timer done");
}
bool I2cScannerApp::hasScanThread() {
@ -261,7 +264,7 @@ bool I2cScannerApp::hasScanThread() {
return has_thread;
} else {
// Unsafe way
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "hasScanTimer");
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "hasScanTimer");
return scanTimer != nullptr;
}
}
@ -284,7 +287,7 @@ void I2cScannerApp::startScanning() {
scanTimer->start();
mutex.unlock();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning");
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning");
}
}
void I2cScannerApp::stopScanning() {
@ -293,7 +296,7 @@ void I2cScannerApp::stopScanning() {
scanState = ScanStateStopped;
mutex.unlock();
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
logger.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
}
}
@ -314,7 +317,7 @@ void I2cScannerApp::selectBus(int32_t selected) {
mutex.unlock();
}
TT_LOG_I(TAG, "Selected %ld", selected);
logger.info("Selected {}", selected);
setLastBusIndex(selected);
startScanning();
@ -377,7 +380,7 @@ void I2cScannerApp::updateViews() {
mutex.unlock();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViews");
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViews");
}
}
@ -386,7 +389,7 @@ void I2cScannerApp::updateViewsSafely() {
updateViews();
lvgl::unlock();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViewsSafely");
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViewsSafely");
}
}
@ -399,7 +402,7 @@ void I2cScannerApp::onScanTimerFinished() {
updateViewsSafely();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "onScanTimerFinished");
logger.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "onScanTimerFinished");
}
}

View File

@ -2,7 +2,7 @@
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/Logger.h>
#include <Tactility/StringUtils.h>
#include <lvgl.h>
@ -11,7 +11,7 @@ namespace tt::app::imageviewer {
extern const AppManifest manifest;
constexpr auto* TAG = "ImageViewer";
static const auto LOGGER = Logger("ImageViewer");
constexpr auto* IMAGE_VIEWER_FILE_ARGUMENT = "file";
class ImageViewerApp final : public App {
@ -49,7 +49,7 @@ class ImageViewerApp final : public App {
std::string file_argument;
if (bundle->optString(IMAGE_VIEWER_FILE_ARGUMENT, file_argument)) {
std::string prefixed_path = lvgl::PATH_PREFIX + file_argument;
TT_LOG_I(TAG, "Opening %s", prefixed_path.c_str());
LOGGER.info("Opening {}", prefixed_path);
lv_img_set_src(image, prefixed_path.c_str());
auto path = string::getLastPathSegment(file_argument);
lv_label_set_text(file_label, path.c_str());

View File

@ -15,7 +15,7 @@ constexpr auto* RESULT_BUNDLE_KEY_RESULT = "result";
constexpr auto* DEFAULT_TITLE = "Input";
constexpr auto* TAG = "InputDialog";
static const auto LOGGER = Logger("InputDialog");
extern const AppManifest manifest;
class InputDialogApp;
@ -62,7 +62,7 @@ class InputDialogApp final : public App {
void onButtonClicked(lv_event_t* e) {
auto user_data = lv_event_get_user_data(e);
int index = (user_data != 0) ? 0 : 1;
TT_LOG_I(TAG, "Selected item at index %d", index);
LOGGER.info("Selected item at index {}", index);
if (index == 0) {
auto bundle = std::make_unique<Bundle>();
const char* text = lv_textarea_get_text((lv_obj_t*)user_data);

View File

@ -12,7 +12,7 @@
namespace tt::app::launcher {
constexpr auto* TAG = "Launcher";
static const auto LOGGER = Logger("Launcher");
static int getButtonSize(hal::UiScale scale) {
if (scale == hal::UiScale::Smallest) {
@ -93,7 +93,7 @@ public:
void onCreate(TT_UNUSED AppContext& app) override {
settings::BootSettings boot_properties;
if (settings::loadBootSettings(boot_properties) && !boot_properties.autoStartAppId.empty()) {
TT_LOG_I(TAG, "Starting %s", boot_properties.autoStartAppId.c_str());
LOGGER.info("Starting {}", boot_properties.autoStartAppId);
start(boot_properties.autoStartAppId);
}
}

View File

@ -12,7 +12,7 @@
namespace tt::app::notes {
constexpr auto* TAG = "Notes";
static const auto LOGGER = Logger("Notes");
constexpr auto* NOTES_FILE_ARGUMENT = "file";
class NotesApp final : public App {
@ -52,11 +52,11 @@ class NotesApp final : public App {
saveBuffer = lv_textarea_get_text(uiNoteText);
lvgl::getSyncLock()->unlock();
saveFileLaunchId = fileselection::startForExistingOrNewFile();
TT_LOG_I(TAG, "launched with id %d", loadFileLaunchId);
LOGGER.info("launched with id {}", saveFileLaunchId);
break;
case 3: // Load
loadFileLaunchId = fileselection::startForExistingFile();
TT_LOG_I(TAG, "launched with id %d", loadFileLaunchId);
LOGGER.info("launched with id {}", loadFileLaunchId);
break;
}
} else {
@ -64,7 +64,7 @@ class NotesApp final : public App {
if (obj == cont) return;
if (lv_obj_get_child(cont, 1)) {
saveFileLaunchId = fileselection::startForExistingOrNewFile();
TT_LOG_I(TAG, "launched with id %d", loadFileLaunchId);
LOGGER.info("launched with id {}", saveFileLaunchId);
} else { //Reset
resetFileContent();
}
@ -91,7 +91,7 @@ class NotesApp final : public App {
lv_textarea_set_text(uiNoteText, reinterpret_cast<const char*>(data.get()));
lv_label_set_text(uiCurrentFileName, path.c_str());
filePath = path;
TT_LOG_I(TAG, "Loaded from %s", path.c_str());
LOGGER.info("Loaded from {}", path);
}
});
}
@ -101,7 +101,7 @@ class NotesApp final : public App {
bool result = false;
file::getLock(path)->withLock([&result, this, path] {
if (file::writeString(path, saveBuffer.c_str())) {
TT_LOG_I(TAG, "Saved to %s", path.c_str());
LOGGER.info("Saved to {}", path);
filePath = path;
result = true;
}
@ -186,7 +186,7 @@ class NotesApp final : public App {
}
void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr<Bundle> resultData) override {
TT_LOG_I(TAG, "Result for launch id %d", launchId);
LOGGER.info("Result for launch id {}", launchId);
if (launchId == loadFileLaunchId) {
loadFileLaunchId = 0;
if (result == Result::Ok && resultData != nullptr) {

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