Compare commits

...

2 Commits

Author SHA1 Message Date
Ken Van Hoeylandt
31b8fb8a5b Updates and fixes 2026-01-04 23:58:08 +01:00
Ken Van Hoeylandt
2284fb8a69 Fixes 2026-01-04 23:32:08 +01:00
10 changed files with 54 additions and 43 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
#include "TpagerEncoder.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <driver/gpio.h>
constexpr auto* TAG = "TpagerEncoder";
static const auto LOGGER = tt::Logger("TpagerEncoder");
constexpr auto ENCODER_A = GPIO_NUM_40;
constexpr auto ENCODER_B = GPIO_NUM_41;
constexpr auto ENCODER_ENTER = GPIO_NUM_7;
@ -52,7 +53,7 @@ void TpagerEncoder::initEncoder() {
};
if (pcnt_new_unit(&unit_config, &encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter intialization failed");
LOGGER.error("Pulsecounter intialization failed");
}
pcnt_glitch_filter_config_t filter_config = {
@ -60,7 +61,7 @@ void TpagerEncoder::initEncoder() {
};
if (pcnt_unit_set_glitch_filter(encPcntUnit, &filter_config) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter glitch filter config failed");
LOGGER.error("Pulsecounter glitch filter config failed");
}
pcnt_chan_config_t chan_1_config = {
@ -78,36 +79,36 @@ void TpagerEncoder::initEncoder() {
if ((pcnt_new_channel(encPcntUnit, &chan_1_config, &pcnt_chan_1) != ESP_OK) ||
(pcnt_new_channel(encPcntUnit, &chan_2_config, &pcnt_chan_2) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter channel config failed");
LOGGER.error("Pulsecounter channel config failed");
}
// Second argument is rising edge, third argument is falling edge
if ((pcnt_channel_set_edge_action(pcnt_chan_1, PCNT_CHANNEL_EDGE_ACTION_DECREASE, PCNT_CHANNEL_EDGE_ACTION_INCREASE) != ESP_OK) ||
(pcnt_channel_set_edge_action(pcnt_chan_2, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_DECREASE) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter edge action config failed");
LOGGER.error("Pulsecounter edge action config failed");
}
// Second argument is low level, third argument is high level
if ((pcnt_channel_set_level_action(pcnt_chan_1, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK) ||
(pcnt_channel_set_level_action(pcnt_chan_2, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_INVERSE) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter level action config failed");
LOGGER.error("Pulsecounter level action config failed");
}
if ((pcnt_unit_add_watch_point(encPcntUnit, LOW_LIMIT) != ESP_OK) ||
(pcnt_unit_add_watch_point(encPcntUnit, HIGH_LIMIT) != ESP_OK)) {
TT_LOG_E(TAG, "Pulsecounter watch point config failed");
LOGGER.error("Pulsecounter watch point config failed");
}
if (pcnt_unit_enable(encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter could not be enabled");
LOGGER.error("Pulsecounter could not be enabled");
}
if (pcnt_unit_clear_count(encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter could not be cleared");
LOGGER.error("Pulsecounter could not be cleared");
}
if (pcnt_unit_start(encPcntUnit) != ESP_OK) {
TT_LOG_E(TAG, "Pulsecounter could not be started");
LOGGER.error("Pulsecounter could not be started");
}
}

View File

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

View File

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

View File

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

View File

@ -13,12 +13,14 @@ namespace tt {
static uint64_t getLogTimestamp() {
static uint64_t base = 0U;
static std::once_flag init_flag;
std::call_once(init_flag, []() {
timeval time {};
gettimeofday(&time, nullptr);
base = ((uint64_t)time.tv_sec * 1000U) + (time.tv_usec / 1000U);
});
timeval time {};
gettimeofday(&time, nullptr);
uint64_t now = ((uint64_t)time.tv_sec * 1000U) + (time.tv_usec / 1000U);
std::call_once(init_flag, [now]() {
base = now;
});
return now - base;
}