Compare commits

..

9 Commits

Author SHA1 Message Date
Ken Van Hoeylandt
293c6cf5d8 Fixes 2026-01-05 23:58:30 +01:00
Ken Van Hoeylandt
f3e01ea7f8 Fixes 2026-01-05 23:31:59 +01:00
Ken Van Hoeylandt
54e8afae71 Fixes 2026-01-05 22:58:58 +01:00
Ken Van Hoeylandt
623f543a2c Fixes 2026-01-05 22:53:20 +01:00
Ken Van Hoeylandt
5abf8b40d4 Fix 2026-01-05 22:39:14 +01:00
Ken Van Hoeylandt
22ee68c891 Fixes 2026-01-05 22:25:18 +01:00
Ken Van Hoeylandt
158033af48 Revert 2026-01-05 22:15:59 +01:00
Ken Van Hoeylandt
d695231cf6 Fixes 2026-01-05 22:12:17 +01:00
Ken Van Hoeylandt
c4f0c134b2 Updates 2026-01-05 21:25:56 +01:00
109 changed files with 729 additions and 736 deletions

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

@ -11,7 +11,7 @@
#include <esp_lcd_panel_io_additions.h>
#include <esp_lcd_st7701.h>
static const auto LOGGER = Logger("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}
@ -169,12 +169,14 @@ bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc
if (esp_lcd_panel_invert_color(panelHandle, false) != ESP_OK) {
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) {
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

@ -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
Logger("HeltecV3").info("OLED power enabled");
tt::Logger("HeltecV3").info("OLED power enabled");
}
static bool initBoot() {

View File

@ -5,6 +5,7 @@
#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>

View File

@ -1,6 +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>

View File

@ -40,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;
@ -49,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) {
LOGGER.error("Pulsecounter intialization failed");
LOGGER.error("Pulsecounter initialization failed");
return false;
}
pcnt_glitch_filter_config_t filter_config = {
@ -62,16 +68,31 @@ void TpagerEncoder::initEncoder() {
if (pcnt_unit_set_glitch_filter(encPcntUnit, &filter_config) != ESP_OK) {
LOGGER.error("Pulsecounter glitch filter config failed");
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;
@ -80,36 +101,45 @@ 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)) {
LOGGER.error("Pulsecounter channel config failed");
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)) {
LOGGER.error("Pulsecounter edge action config failed");
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)) {
LOGGER.error("Pulsecounter level action config failed");
return false;
}
if ((pcnt_unit_add_watch_point(encPcntUnit, LOW_LIMIT) != ESP_OK) ||
(pcnt_unit_add_watch_point(encPcntUnit, HIGH_LIMIT) != ESP_OK)) {
LOGGER.error("Pulsecounter watch point config failed");
return false;
}
if (pcnt_unit_enable(encPcntUnit) != ESP_OK) {
LOGGER.error("Pulsecounter could not be enabled");
return false;
}
if (pcnt_unit_clear_count(encPcntUnit) != ESP_OK) {
LOGGER.error("Pulsecounter could not be cleared");
return false;
}
if (pcnt_unit_start(encPcntUnit) != ESP_OK) {
LOGGER.error("Pulsecounter could not be started");
return false;
}
return true;
}
int TpagerEncoder::getEncoderPulses() const {
@ -118,9 +148,28 @@ 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");
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);
@ -138,5 +187,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,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,7 +125,7 @@ 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;
}
@ -135,7 +135,7 @@ bool UnPhoneFeatures::initNavButtons() {
gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, (void*)pin::BUTTON2) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, (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,5 @@
#include "Bq24295.h"
#include <Tactility/Log.h>
#define TAG "bq24295"
#include <Tactility/Logger.h>
/** Reference:
* https://www.ti.com/lit/ds/symlink/bq24295.pdf
@ -49,8 +47,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 +94,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

@ -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,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

@ -13,6 +13,7 @@
#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>
@ -234,7 +235,7 @@ static void registerInstalledAppsFromSdCards() {
}
static void registerAndStartSecondaryServices() {
LOGGER.info("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);
@ -249,7 +250,7 @@ static void registerAndStartSecondaryServices() {
}
static void registerAndStartPrimaryServices() {
LOGGER.info("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);
@ -275,7 +276,7 @@ void createTempDirectory(const std::string& rootPath) {
LOGGER.error("Failed to create {}", temp_path);
}
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT_CPP, rootPath);
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, rootPath);
}
} else {
LOGGER.info("Found existing {}", temp_path);

View File

@ -1,18 +1,19 @@
#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 {
@ -46,7 +47,7 @@ class AddGpsApp final : public App {
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

@ -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) {

View File

@ -9,15 +9,16 @@
#include <Tactility/app/App.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/kernel/Platform.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Lvgl.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/screenshot/Screenshot.h>
constexpr auto* TAG = "Screenshot";
namespace tt::app::screenshot {
static const auto LOGGER = Logger("Screenshot");
extern const AppManifest manifest;
class ScreenshotApp final : public App {
@ -97,27 +98,27 @@ void ScreenshotApp::onModeSet() {
void ScreenshotApp::onStartPressed() {
auto service = service::screenshot::optScreenshotService();
if (service == nullptr) {
TT_LOG_E(TAG, "Service not found/running");
LOGGER.error("Service not found/running");
return;
}
if (service->isTaskStarted()) {
TT_LOG_I(TAG, "Stop screenshot");
LOGGER.info("Stop screenshot");
service->stop();
} else {
uint32_t selected = lv_dropdown_get_selected(modeDropdown);
const char* path = lv_textarea_get_text(pathTextArea);
if (selected == 0) {
TT_LOG_I(TAG, "Start timed screenshots");
LOGGER.info("Start timed screenshots");
const char* delay_text = lv_textarea_get_text(delayTextArea);
int delay = atoi(delay_text);
if (delay > 0) {
service->startTimed(path, delay, 1);
} else {
TT_LOG_W(TAG, "Ignored screenshot start because delay was 0");
LOGGER.warn("Ignored screenshot start because delay was 0");
}
} else {
TT_LOG_I(TAG, "Start app screenshots");
LOGGER.info("Start app screenshots");
service->startApps(path);
}
}
@ -128,7 +129,7 @@ void ScreenshotApp::onStartPressed() {
void ScreenshotApp::updateScreenshotMode() {
auto service = service::screenshot::optScreenshotService();
if (service == nullptr) {
TT_LOG_E(TAG, "Service not found/running");
LOGGER.error("Service not found/running");
return;
}
@ -151,7 +152,7 @@ void ScreenshotApp::updateScreenshotMode() {
void ScreenshotApp::createModeSettingWidgets(lv_obj_t* parent) {
auto service = service::screenshot::optScreenshotService();
if (service == nullptr) {
TT_LOG_E(TAG, "Service not found/running");
LOGGER.error("Service not found/running");
return;
}
@ -203,7 +204,7 @@ void ScreenshotApp::createFilePathWidgets(lv_obj_t* parent) {
if (kernel::getPlatform() == kernel::PlatformEsp) {
auto sdcard_devices = tt::hal::findDevices<tt::hal::sdcard::SdCardDevice>(tt::hal::Device::Type::SdCard);
if (sdcard_devices.size() > 1) {
TT_LOG_W(TAG, "Found multiple SD card devices - picking first");
LOGGER.warn("Found multiple SD card devices - picking first");
}
if (!sdcard_devices.empty() && sdcard_devices.front()->isMounted()) {
std::string lvgl_mount_path = lvgl::PATH_PREFIX + sdcard_devices.front()->getMountPath();

View File

@ -1,9 +1,9 @@
#include <Tactility/app/selectiondialog/SelectionDialog.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <Tactility/TactilityCore.h>
#include <lvgl.h>
@ -16,7 +16,7 @@ constexpr auto* RESULT_BUNDLE_KEY_INDEX = "index";
constexpr auto* PARAMETER_ITEM_CONCATENATION_TOKEN = ";;";
constexpr auto* DEFAULT_TITLE = "Select...";
constexpr auto* TAG = "SelectionDialog";
static const auto LOGGER = Logger("SelectionDialog");
extern const AppManifest manifest;
@ -53,7 +53,7 @@ class SelectionDialogApp final : public App {
void onListItemSelected(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);
setResult(Result::Ok, std::move(bundle));
@ -85,7 +85,7 @@ public:
if (parameters->optString(PARAMETER_BUNDLE_KEY_ITEMS, items_concatenated)) {
std::vector<std::string> items = string::split(items_concatenated, PARAMETER_ITEM_CONCATENATION_TOKEN);
if (items.empty() || items.front().empty()) {
TT_LOG_E(TAG, "No items provided");
LOGGER.error("No items provided");
setResult(Result::Error);
stop(manifest.appId);
} else if (items.size() == 1) {
@ -93,7 +93,7 @@ public:
result_bundle->putInt32(RESULT_BUNDLE_KEY_INDEX, 0);
setResult(Result::Ok, std::move(result_bundle));
stop(manifest.appId);
TT_LOG_W(TAG, "Auto-selecting single item");
LOGGER.warn("Auto-selecting single item");
} else {
size_t index = 0;
for (const auto& item: items) {
@ -101,7 +101,7 @@ public:
}
}
} else {
TT_LOG_E(TAG, "No items provided");
LOGGER.error("No items provided");
setResult(Result::Error);
stop(manifest.appId);
}

View File

@ -1,9 +1,10 @@
#include <Tactility/Assets.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/timezone/TimeZone.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/settings/Time.h>
#include <Tactility/settings/SystemSettings.h>
@ -12,7 +13,7 @@
namespace tt::app::timedatesettings {
constexpr auto* TAG = "TimeDate";
static const auto LOGGER = Logger("TimeDate");
extern const AppManifest manifest;
@ -137,7 +138,7 @@ public:
if (result == Result::Ok && bundle != nullptr) {
const auto name = timezone::getResultName(*bundle);
const auto code = timezone::getResultCode(*bundle);
TT_LOG_I(TAG, "Result name=%s code=%s", name.c_str(), code.c_str());
LOGGER.info("Result name={} code={}", name, code);
settings::setTimeZone(name, code);
if (!name.empty()) {

View File

@ -2,21 +2,23 @@
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/AppPaths.h>
#include <Tactility/app/timezone/TimeZone.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/Lvgl.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/Timer.h>
#include <Tactility/MountPoints.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/StringUtils.h>
#include <Tactility/Timer.h>
#include <lvgl.h>
#include <memory>
namespace tt::app::timezone {
constexpr auto* TAG = "TimeZone";
static const auto LOGGER = Logger("TimeZone");
constexpr auto* RESULT_BUNDLE_CODE_INDEX = "code";
constexpr auto* RESULT_BUNDLE_NAME_INDEX = "name";
@ -96,7 +98,7 @@ class TimeZoneApp final : public App {
}
void onListItemSelected(std::size_t index) {
TT_LOG_I(TAG, "Selected item at index %zu", index);
LOGGER.info("Selected item at index {}", index);
auto& entry = entries[index];
@ -117,7 +119,7 @@ class TimeZoneApp final : public App {
auto path = std::string(file::MOUNT_POINT_SYSTEM) + "/timezones.csv";
auto* file = fopen(path.c_str(), "rb");
if (file == nullptr) {
TT_LOG_E(TAG, "Failed to open %s", path.c_str());
LOGGER.error("Failed to open {}", path);
return;
}
char line[96];
@ -138,7 +140,7 @@ class TimeZoneApp final : public App {
}
}
} else {
TT_LOG_E(TAG, "Parse error at line %lu", count);
LOGGER.error("Parse error at line {}", count);
}
}
@ -148,10 +150,10 @@ class TimeZoneApp final : public App {
entries = std::move(new_entries);
mutex.unlock();
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
}
TT_LOG_I(TAG, "Processed %lu entries", count);
LOGGER.info("Processed {} entries", count);
}
void updateList() {
@ -160,7 +162,7 @@ class TimeZoneApp final : public App {
readTimeZones(filter);
lvgl::unlock();
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
return;
}

View File

@ -6,15 +6,16 @@
#include <Tactility/app/AppContext.h>
#include <Tactility/app/AppManifest.h>
#include <Tactility/app/alertdialog/AlertDialog.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/TactilityCore.h>
#include <lvgl.h>
namespace tt::app::wifiapsettings {
constexpr auto* TAG = "WifiApSettings";
static const auto LOGGER = Logger("WifiApSettings");
extern const AppManifest manifest;
@ -50,10 +51,10 @@ class WifiApSettings : public App {
if (service::wifi::settings::load(self->ssid.c_str(), settings)) {
settings.autoConnect = is_on;
if (!service::wifi::settings::save(settings)) {
TT_LOG_E(TAG, "Failed to save settings");
LOGGER.error("Failed to save settings");
}
} else {
TT_LOG_E(TAG, "Failed to load settings");
LOGGER.error("Failed to load settings");
}
}
@ -89,7 +90,7 @@ class WifiApSettings : public App {
updateViews();
lvgl::unlock();
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
}
@ -192,7 +193,7 @@ public:
lv_obj_remove_state(auto_connect_switch, LV_STATE_CHECKED);
}
} else {
TT_LOG_W(TAG, "No settings found");
LOGGER.warn("No settings found");
lv_obj_add_flag(forget_button, LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(auto_connect_wrapper, LV_OBJ_FLAG_HIDDEN);
}
@ -223,11 +224,11 @@ public:
std::string ssid = parameters->getString("ssid");
if (!service::wifi::settings::remove(ssid.c_str())) {
TT_LOG_E(TAG, "Failed to remove SSID");
LOGGER.error("Failed to remove SSID");
return;
}
TT_LOG_I(TAG, "Removed SSID");
LOGGER.info("Removed SSID");
if (
service::wifi::getRadioState() == service::wifi::RadioState::ConnectionActive &&
service::wifi::getConnectionTarget() == ssid

View File

@ -2,6 +2,7 @@
#include <Tactility/app/wificonnect/View.h>
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/lvgl/Spinner.h>
#include <Tactility/service/wifi/WifiApSettings.h>
@ -12,7 +13,7 @@
namespace tt::app::wificonnect {
constexpr auto* TAG = "WifiConnect";
static const auto LOGGER = Logger("WifiConnect");
void View::resetErrors() {
lv_obj_add_flag(password_error, LV_OBJ_FLAG_HIDDEN);
@ -30,7 +31,7 @@ static void onConnect(TT_UNUSED lv_event_t* event) {
const char* ssid = lv_textarea_get_text(view.ssid_textarea);
size_t ssid_len = strlen(ssid);
if (ssid_len > TT_WIFI_SSID_LIMIT) {
TT_LOG_E(TAG, "SSID too long");
LOGGER.error("SSID too long");
lv_label_set_text(view.ssid_error, "SSID too long");
lv_obj_remove_flag(view.ssid_error, LV_OBJ_FLAG_HIDDEN);
return;
@ -39,7 +40,7 @@ static void onConnect(TT_UNUSED lv_event_t* event) {
const char* password = lv_textarea_get_text(view.password_textarea);
size_t password_len = strlen(password);
if (password_len > TT_WIFI_CREDENTIALS_PASSWORD_LIMIT) {
TT_LOG_E(TAG, "Password too long");
LOGGER.error("Password too long");
lv_label_set_text(view.password_error, "Password too long");
lv_obj_remove_flag(view.password_error, LV_OBJ_FLAG_HIDDEN);
return;
@ -199,7 +200,7 @@ void View::init(AppContext& app, lv_obj_t* parent) {
}
std::string password;
if (optPasswordParameter(bundle, ssid)) {
if (optPasswordParameter(bundle, password)) {
lv_textarea_set_text(password_textarea, password.c_str());
}
}

View File

@ -1,13 +1,15 @@
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/lvgl/LvglSync.h>
namespace tt::app::wificonnect {
constexpr auto* TAG = "WifiConnect";
static const auto LOGGER = Logger("WifiConnect");
constexpr auto* WIFI_CONNECT_PARAM_SSID = "ssid"; // String
constexpr auto* WIFI_CONNECT_PARAM_PASSWORD = "password"; // String
@ -72,7 +74,7 @@ void WifiConnect::requestViewUpdate() {
view.update();
lvgl::unlock();
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
unlock();

View File

@ -1,24 +1,20 @@
#include <Tactility/network/HttpdReq.h>
#include <Tactility/app/wifimanage/View.h>
#include <Tactility/Tactility.h>
#include <Tactility/app/wifimanage/WifiManagePrivate.h>
#include <Tactility/Logger.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/lvgl/Toolbar.h>
#include <Tactility/Log.h>
#include <Tactility/service/wifi/Wifi.h>
#include <Tactility/service/wifi/WifiSettings.h>
#include <format>
#include <string>
#include <set>
#include <Tactility/service/wifi/WifiSettings.h>
namespace tt::app::wifimanage {
constexpr auto* TAG = "WifiManageView";
static const auto LOGGER = Logger("WifiManageView");
std::shared_ptr<WifiManage> _Nullable optWifiManage();
@ -70,16 +66,16 @@ static void onConnectToHiddenClicked(lv_event_t* event) {
// region Secondary updates
void View::connect(lv_event_t* event) {
TT_LOG_D(TAG, "connect()");
LOGGER.debug("connect()");
auto* widget = lv_event_get_current_target_obj(event);
auto index = reinterpret_cast<size_t>(lv_obj_get_user_data(widget));
auto* self = static_cast<View*>(lv_event_get_user_data(event));
auto ap_records = self->state->getApRecords();
if (index < ap_records.size()) {
TT_LOG_I(TAG, "Clicked %d/%d", index, ap_records.size() - 1);
LOGGER.info("Clicked {}/{}", index, ap_records.size() - 1);
auto& ssid = ap_records[index].ssid;
TT_LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
LOGGER.info("Clicked AP: {}", ssid);
std::string connection_target = service::wifi::getConnectionTarget();
if (connection_target == ssid) {
self->bindings->onDisconnect();
@ -87,12 +83,12 @@ void View::connect(lv_event_t* event) {
self->bindings->onConnectSsid(ssid);
}
} else {
TT_LOG_W(TAG, "Clicked AP: record %d/%d does not exist", index, ap_records.size() - 1);
LOGGER.warn("Clicked AP: record {}/{} does not exist", index, ap_records.size() - 1);
}
}
void View::showDetails(lv_event_t* event) {
TT_LOG_D(TAG, "showDetails()");
LOGGER.debug("showDetails()");
auto* widget = lv_event_get_current_target_obj(event);
auto index = reinterpret_cast<size_t>(lv_obj_get_user_data(widget));
auto* self = static_cast<View*>(lv_event_get_user_data(event));
@ -100,10 +96,10 @@ void View::showDetails(lv_event_t* event) {
if (index < ap_records.size()) {
auto& ssid = ap_records[index].ssid;
TT_LOG_I(TAG, "Clicked AP: %s", ssid.c_str());
LOGGER.info("Clicked AP: {}", ssid);
self->bindings->onShowApSettings(ssid);
} else {
TT_LOG_W(TAG, "Clicked AP: record %d/%d does not exist", index, ap_records.size() - 1);
LOGGER.warn("Clicked AP: record {}/{} does not exist", index, ap_records.size() - 1);
}
}

View File

@ -4,22 +4,24 @@
#include <Tactility/app/AppContext.h>
#include <Tactility/app/wifiapsettings/WifiApSettings.h>
#include <Tactility/app/wificonnect/WifiConnect.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/loader/Loader.h>
namespace tt::app::wifimanage {
constexpr auto TAG = "WifiManage";
static const auto LOGGER = Logger("WifiManage");
extern const AppManifest manifest;
static void onConnect(const std::string& ssid) {
service::wifi::settings::WifiApSettings settings;
if (service::wifi::settings::load(ssid, settings)) {
TT_LOG_I(TAG, "Connecting with known credentials");
LOGGER.info("Connecting with known credentials");
service::wifi::connect(settings, false);
} else {
TT_LOG_I(TAG, "Starting connection dialog");
LOGGER.info("Starting connection dialog");
wificonnect::start(ssid);
}
}
@ -65,7 +67,7 @@ void WifiManage::requestViewUpdate() {
view.update();
lvgl::unlock();
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
}
unlock();
@ -73,7 +75,7 @@ void WifiManage::requestViewUpdate() {
void WifiManage::onWifiEvent(service::wifi::WifiEvent event) {
auto radio_state = service::wifi::getRadioState();
TT_LOG_I(TAG, "Update with state %s", service::wifi::radioStateToString(radio_state));
LOGGER.info("Update with state {}", service::wifi::radioStateToString(radio_state));
getState().setRadioState(radio_state);
switch (event) {
using enum service::wifi::WifiEvent;
@ -118,7 +120,7 @@ void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
bool can_scan = radio_state == service::wifi::RadioState::On ||
radio_state == service::wifi::RadioState::ConnectionPending ||
radio_state == service::wifi::RadioState::ConnectionActive;
TT_LOG_I(TAG, "%s %d", service::wifi::radioStateToString(radio_state), (int)service::wifi::isScanning());
LOGGER.info("{} {}", service::wifi::radioStateToString(radio_state), service::wifi::isScanning());
if (can_scan && !service::wifi::isScanning()) {
service::wifi::scan();
}

View File

@ -3,13 +3,13 @@
#include <Tactility/hal/gps/GpsDevice.h>
#include <Tactility/hal/gps/Ublox.h>
#include <Tactility/kernel/Kernel.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <cstring>
namespace tt::hal::gps {
constexpr auto TAG = "gps";
static const auto LOGGER = Logger("Gps");
bool initMtk(uart::Uart& uart);
bool initMtkL76b(uart::Uart& uart);
@ -112,7 +112,7 @@ GpsResponse getACKCas(uart::Uart& uart, uint8_t class_id, uint8_t msg_id, uint32
// Check for an ACK-ACK for the specified class and message id
if ((msg_cls == 0x05) && (msg_msg_id == 0x01) && payload_cls == class_id && payload_msg == msg_id) {
#ifdef GPS_DEBUG
LOG_INFO("Got ACK for class %02X message %02X in %dms", class_id, msg_id, millis() - startTime);
LOGGER.info("Got ACK for class {:02X} message {:02X} in {} ms", class_id, msg_id, kernel::getMillis() - startTime);
#endif
return GpsResponse::Ok;
}
@ -120,7 +120,7 @@ GpsResponse getACKCas(uart::Uart& uart, uint8_t class_id, uint8_t msg_id, uint32
// Check for an ACK-NACK for the specified class and message id
if ((msg_cls == 0x05) && (msg_msg_id == 0x00) && payload_cls == class_id && payload_msg == msg_id) {
#ifdef GPS_DEBUG
LOG_WARN("Got NACK for class %02X message %02X in %dms", class_id, msg_id, millis() - startTime);
LOGGER.warn("Got NACK for class {:02X} message {:02X} in {} ms", class_id, msg_id, millis() - startTime);
#endif
return GpsResponse::NotAck;
}
@ -163,7 +163,7 @@ bool init(uart::Uart& uart, GpsModel type) {
return initUc6580(uart);
}
TT_LOG_I(TAG, "Init not implemented %d", static_cast<int>(type));
LOGGER.info("Init not implemented {}", static_cast<int>(type));
return false;
}
@ -213,14 +213,14 @@ bool initAtgm336h(uart::Uart& uart) {
int msglen = makeCASPacket(buffer, 0x06, 0x07, sizeof(_message_CAS_CFG_NAVX_CONF), _message_CAS_CFG_NAVX_CONF);
uart.writeBytes(buffer, msglen);
if (getACKCas(uart, 0x06, 0x07, 250) != GpsResponse::Ok) {
TT_LOG_W(TAG, "ATGM336H: Could not set Config");
LOGGER.warn("ATGM336H: Could not set Config");
}
// Set the update frequence to 1Hz
msglen = makeCASPacket(buffer, 0x06, 0x04, sizeof(_message_CAS_CFG_RATE_1HZ), _message_CAS_CFG_RATE_1HZ);
uart.writeBytes(buffer, msglen);
if (getACKCas(uart, 0x06, 0x04, 250) != GpsResponse::Ok) {
TT_LOG_W(TAG, "ATGM336H: Could not set Update Frequency");
LOGGER.warn("ATGM336H: Could not set Update Frequency");
}
// Set the NEMA output messages
@ -232,7 +232,7 @@ bool initAtgm336h(uart::Uart& uart) {
msglen = makeCASPacket(buffer, 0x06, 0x01, sizeof(cas_cfg_msg_packet), cas_cfg_msg_packet);
uart.writeBytes(buffer, msglen);
if (getACKCas(uart, 0x06, 0x01, 250) != GpsResponse::Ok) {
TT_LOG_W(TAG, "ATGM336H: Could not enable NMEA MSG: %d", fields[i]);
LOGGER.warn("ATGM336H: Could not enable NMEA MSG: {}", fields[i]);
}
}
return true;

View File

@ -1,11 +1,13 @@
#include "Tactility/hal/gps/GpsDevice.h"
#include "Tactility/hal/gps/Ublox.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/hal/uart/Uart.h>
#include <Tactility/kernel/Kernel.h>
#include <cstring>
#define TAG "gps"
static const auto LOGGER = tt::Logger("Gps");
#define GPS_UART_BUFFER_SIZE 256
using namespace tt;
@ -59,13 +61,13 @@ GpsResponse getAck(uart::Uart& uart, const char* message, uint32_t waitMillis) {
if ((bytesRead == 767) || (b == '\r')) {
if (strnstr((char*)buffer, message, bytesRead) != nullptr) {
#ifdef GPS_DEBUG
LOG_DEBUG("Found: %s", message); // Log the found message
LOGGER.debug("Found: {}", message); // Log the found message
#endif
return GpsResponse::Ok;
} else {
bytesRead = 0;
#ifdef GPS_DEBUG
LOG_DEBUG(debugmsg.c_str());
LOGGER.debug("{}", debugmsg);
#endif
}
}
@ -77,15 +79,15 @@ GpsResponse getAck(uart::Uart& uart, const char* message, uint32_t waitMillis) {
/**
* From: https://github.com/meshtastic/firmware/blob/f81d3b045dd1b7e3ca7870af3da915ff4399ea98/src/gps/GPS.cpp
*/
#define PROBE_SIMPLE(UART, CHIP, TOWRITE, RESPONSE, DRIVER, TIMEOUT, ...) \
do { \
TT_LOG_I(TAG, "Probing for %s (%s)", CHIP, TOWRITE); \
UART.flushInput(); \
UART.writeString(TOWRITE "\r\n", TIMEOUT); \
if (getAck(UART, RESPONSE, TIMEOUT) == GpsResponse::Ok) { \
TT_LOG_I(TAG, "Probe detected %s %s", CHIP, #DRIVER); \
return DRIVER; \
} \
#define PROBE_SIMPLE(UART, CHIP, TOWRITE, RESPONSE, DRIVER, TIMEOUT, ...) \
do { \
LOGGER.info("Probing for {} ({})", CHIP, TOWRITE); \
UART.flushInput(); \
UART.writeString(TOWRITE "\r\n", TIMEOUT); \
if (getAck(UART, RESPONSE, TIMEOUT) == GpsResponse::Ok) { \
LOGGER.info("Probe detected {} {}", CHIP, #DRIVER); \
return DRIVER; \
} \
} while (0)
/**
@ -132,7 +134,7 @@ GpsModel probe(uart::Uart& uart) {
if (ublox_result != GpsModel::Unknown) {
return ublox_result;
} else {
TT_LOG_W(TAG, "No GNSS Module (baudrate %lu)", uart.getBaudRate());
LOGGER.warn("No GNSS Module (baud rate {})", uart.getBaudRate());
return GpsModel::Unknown;
}
}

View File

@ -93,7 +93,7 @@ GpsResponse getAck(uart::Uart& uart, uint8_t class_id, uint8_t msg_id, uint32_t
if (sCounter == 26) {
#ifdef GPS_DEBUG
TT_LOG_I(TAG, "%s", debugmsg.c_str());
LOGGER.info("%s", debugmsg.c_str());
#endif
return GpsResponse::FrameErrors;
}
@ -108,7 +108,7 @@ GpsResponse getAck(uart::Uart& uart, uint8_t class_id, uint8_t msg_id, uint32_t
} else {
if (ack == 3 && b == 0x00) { // UBX-ACK-NAK message
#ifdef GPS_DEBUG
TT_LOG_I(TAG, "%s", debugmsg.c_str());
LOGGER.info("%s", debugmsg.c_str());
#endif
LOGGER.warn("Got NAK for class {:02X} message {:02X}", class_id, msg_id);
return GpsResponse::NotAck; // NAK received
@ -118,8 +118,8 @@ GpsResponse getAck(uart::Uart& uart, uint8_t class_id, uint8_t msg_id, uint32_t
}
}
#ifdef GPS_DEBUG
TT_LOG_I(TAG, "%s", debugmsg.c_str());
TT_LOG_W(TAG, "No response for class %02X message %02X", class_id, msg_id);
LOGGER.info("%s", debugmsg.c_str());
LOGGER.warn("No response for class %02X message %02X", class_id, msg_id);
#endif
return GpsResponse::None; // No response received within timeout
}

View File

@ -129,7 +129,7 @@ std::unique_ptr<Uart> open(uart_port_t port) {
}
std::unique_ptr<Uart> open(std::string name) {
LOGGER.info("Open {}", name.c_str());
LOGGER.info("Open {}", name);
auto result = std::views::filter(uartEntries, [&name](auto& entry) {
return entry.configuration.name == name;

View File

@ -2,7 +2,6 @@
#include <Tactility/Assets.h>
#include <Tactility/CoreDefines.h>
#include <Tactility/Log.h>
#include <lvgl.h>

View File

@ -1,17 +1,17 @@
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
#include <Tactility/Tactility.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/Logger.h>
#include <Tactility/PubSub.h>
#include <Tactility/Timer.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/lvgl/Style.h>
#include <Tactility/PubSub.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/settings/Time.h>
#include <Tactility/Tactility.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/Timer.h>
#include <lvgl.h>
@ -112,7 +112,7 @@ static void statusbar_pubsub_event(Statusbar* statusbar) {
lv_obj_invalidate(&statusbar->obj);
unlock();
} else {
LOGGER.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT_CPP, "Statusbar");
LOGGER.warn(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "Statusbar");
}
}

View File

@ -1,5 +1,6 @@
#include <Tactility/network/HttpdReq.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/StringUtils.h>
#include <Tactility/file/File.h>
@ -86,7 +87,7 @@ std::unique_ptr<char[]> receiveByteArray(httpd_req_t* request, size_t length, si
size_t read_size = length - bytesRead;
size_t bytes_received = httpd_req_recv(request, buffer + bytesRead, read_size);
if (bytes_received <= 0) {
LOGGER.warn("Received {} / {}", bytesRead + bytes_received, length);
LOGGER.warn("Received error {} after reading {}/{} bytes", bytes_received, bytesRead, length);
return nullptr;
}

View File

@ -2,6 +2,8 @@
#include <Tactility/Logger.h>
#include <Tactility/Preferences.h>
#include <memory>
#ifdef ESP_PLATFORM
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/TactilityCore.h>

View File

@ -1,7 +1,5 @@
#include "Tactility/network/Url.h"
#include <Tactility/Log.h>
namespace tt::network {
std::map<std::string, std::string> parseUrlQuery(std::string query) {

View File

@ -2,6 +2,7 @@
#include <Tactility/app/AppInstance.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/lvgl/Statusbar.h>
#include <Tactility/service/loader/Loader.h>
@ -107,7 +108,7 @@ void GuiService::redraw() {
// Unlock GUI and LVGL
lvgl::unlock();
} else {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT_CPP, "LVGL");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
}
unlock();

View File

@ -5,6 +5,7 @@
#include <Tactility/DispatcherThread.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/service/ServiceManifest.h>
#include <Tactility/service/ServiceRegistration.h>

View File

@ -4,6 +4,7 @@
#include <Tactility/CpuAffinity.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/service/screenshot/ScreenshotTask.h>
#include <Tactility/service/loader/Loader.h>

View File

@ -1,5 +1,6 @@
#include <Tactility/hal/sdcard/SdCardDevice.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Mutex.h>
#include <Tactility/service/ServiceContext.h>
#include <Tactility/service/ServiceRegistration.h>

View File

@ -8,6 +8,7 @@
#include <Tactility/EventGroup.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/RecursiveMutex.h>
#include <Tactility/Tactility.h>
#include <Tactility/Timer.h>
@ -631,7 +632,7 @@ static void dispatchDisable(std::shared_ptr<Wifi> wifi) {
auto lock = wifi->radioMutex.asScopedLock();
if (!lock.lock(50 / portTICK_PERIOD_MS)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT_CPP, "disable()");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "disable()");
return;
}
@ -730,7 +731,7 @@ static void dispatchConnect(std::shared_ptr<Wifi> wifi) {
auto lock = wifi->radioMutex.asScopedLock();
if (!lock.lock(50 / portTICK_PERIOD_MS)) {
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT_CPP, "dispatchConnect()");
LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "dispatchConnect()");
return;
}

View File

@ -3,13 +3,13 @@
#include <Tactility/app/AppPaths.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/ElfApp.h>
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <cstring>
extern "C" {
static const auto LOGGER = tt::Logger("tt_app");
constexpr auto* TAG = "tt_app";
extern "C" {
#define HANDLE_AS_APP_CONTEXT(handle) ((tt::app::AppContext*)(handle))
@ -65,7 +65,7 @@ void tt_app_get_user_data_path(AppHandle handle, char* buffer, size_t* size) {
const auto data_path = paths->getUserDataPath();
const auto expected_length = data_path.length() + 1;
if (*size < expected_length) {
TT_LOG_E(TAG, "Path buffer not large enough (%d < %d)", *size, expected_length);
LOGGER.error("Path buffer not large enough ({} < {})", *size, expected_length);
*size = 0;
buffer[0] = 0;
return;
@ -83,7 +83,7 @@ void tt_app_get_user_data_child_path(AppHandle handle, const char* childPath, ch
const auto resolved_path = paths->getUserDataPath(childPath);
const auto resolved_path_length = resolved_path.length();
if (*size < (resolved_path_length + 1)) {
TT_LOG_E(TAG, "Path buffer not large enough (%d < %d)", *size, (resolved_path_length + 1));
LOGGER.error("Path buffer not large enough ({} < {})", *size, (resolved_path_length + 1));
*size = 0;
buffer[0] = 0;
return;
@ -101,7 +101,7 @@ void tt_app_get_assets_path(AppHandle handle, char* buffer, size_t* size) {
const auto assets_path = paths->getAssetsPath();
const auto expected_length = assets_path.length() + 1;
if (*size < expected_length) {
TT_LOG_E(TAG, "Path buffer not large enough (%d < %d)", *size, expected_length);
LOGGER.error("Path buffer not large enough ({} < {})", *size, expected_length);
*size = 0;
buffer[0] = 0;
return;
@ -119,7 +119,7 @@ void tt_app_get_assets_child_path(AppHandle handle, const char* childPath, char*
const auto resolved_path = paths->getAssetsPath(childPath);
const auto resolved_path_length = resolved_path.length();
if (*size < (resolved_path_length + 1)) {
TT_LOG_E(TAG, "Path buffer not large enough (%d < %d)", *size, (resolved_path_length + 1));
LOGGER.error("Path buffer not large enough ({} < {})", *size, (resolved_path_length + 1));
*size = 0;
buffer[0] = 0;
return;

View File

@ -14,7 +14,7 @@
#pragma once
#include "CoreDefines.h"
#include "Log.h"
#include "Logger.h"
#include <cassert>
@ -28,17 +28,18 @@ namespace tt {
TT_NORETURN void _crash();
}
// TODO: Move crash logic to kernel namespace and consider refactoring to C++
/** Crash system with message. */
#define tt_crash(...) TT_ARG_CAT(_tt_crash,TT_ARGCOUNT(__VA_ARGS__))(__VA_ARGS__)
#define _tt_crash0() do { \
TT_LOG_E("crash", "at %s:%d", __FILE__, __LINE__); \
tt::Logger("Kernel").error("Crash at {}:{}", __FILE__, __LINE__); \
tt::_crash(); \
} while (0)
#define _tt_crash1(message) do { \
TT_LOG_E("crash", "%s\n\tat %s:%d", message, __FILE__, __LINE__); \
tt::_crash(); \
#define _tt_crash1(message) do { \
tt::Logger("Kernel").error("Crash: {}\n\tat {}:{}", message, __FILE__, __LINE__); \
tt::_crash(); \
} while (0)
/** Halt the system
@ -50,11 +51,11 @@ namespace tt {
#define tt_check_internal(__e, __m) \
do { \
if (!(__e)) { \
TT_LOG_E("check", "%s", #__e); \
tt::Logger("Kernel").error("Check failed: {}", #__e); \
if (__m) { \
tt_crash_internal(#__m); \
tt_crash(__m); \
} else { \
tt_crash_internal(""); \
tt_crash(""); \
} \
} \
} while (0)
@ -65,4 +66,4 @@ namespace tt {
* @param[in] optional message (const char*)
*/
#define tt_check(x, ...) if (!(x)) { TT_LOG_E("check", "Failed: %s", #x); tt::_crash(); }
#define tt_check(x, ...) if (!(x)) { tt::Logger("Kernel").error("Check failed: {}", #x); tt::_crash(); }

View File

@ -1,9 +0,0 @@
#pragma once
#ifdef ESP_PLATFORM
#include "LogEsp.h"
#else
#include "LogSimulator.h"
#endif
#include "LogMessages.h"

View File

@ -1,19 +0,0 @@
#pragma once
#ifdef ESP_PLATFORM
#include "LogCommon.h"
#include <esp_log.h>
#define TT_LOG_E(tag, format, ...) \
ESP_LOGE(tag, format, ##__VA_ARGS__)
#define TT_LOG_W(tag, format, ...) \
ESP_LOGW(tag, format, ##__VA_ARGS__)
#define TT_LOG_I(tag, format, ...) \
ESP_LOGI(tag, format, ##__VA_ARGS__)
#define TT_LOG_D(tag, format, ...) \
ESP_LOGD(tag, format, ##__VA_ARGS__)
#define TT_LOG_V(tag, format, ...) \
ESP_LOGV(tag, format, ##__VA_ARGS__)
#endif // ESP_PLATFORM

View File

@ -9,21 +9,11 @@
// Alloc
#define LOG_MESSAGE_ALLOC_FAILED "Out of memory"
#define LOG_MESSAGE_ALLOC_FAILED_FMT "Out of memory (failed to allocated %zu bytes)"
#define LOG_MESSAGE_ALLOC_FAILED_FMT "Out of memory (failed to allocated {} bytes)"
// Mutex
#define LOG_MESSAGE_MUTEX_LOCK_FAILED "Mutex acquisition timeout"
#define LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT "Mutex acquisition timeout (%s)"
#define LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT_CPP "Mutex acquisition timeout ({})"
// SPI
#define LOG_MESSAGE_SPI_INIT_START_FMT "SPI %d init"
#define LOG_MESSAGE_SPI_INIT_FAILED_FMT "SPI %d init failed"
// I2C
#define LOG_MESSAGE_I2C_INIT_START "I2C init"
#define LOG_MESSAGE_I2C_INIT_CONFIG_FAILED "I2C config failed"
#define LOG_MESSAGE_I2C_INIT_DRIVER_INSTALL_FAILED "I2C driver install failed"
#define LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT "Mutex acquisition timeout ({})"
// Power on
#define LOG_MESSAGE_POWER_ON_START "Power on"

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