Replaced Logger usage with LOG_x (#548)

This commit is contained in:
Ken Van Hoeylandt
2026-07-04 23:49:19 +02:00
committed by GitHub
parent ecad2248d9
commit 9d5993930d
162 changed files with 1776 additions and 1842 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
#include "Bq24295.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("BQ24295");
constexpr auto* TAG = "BQ24295";
/** Reference:
* https://www.ti.com/lit/ds/symlink/bq24295.pdf
@@ -50,7 +50,7 @@ bool Bq24295::setWatchDogTimer(WatchDogTimer in) const {
uint8_t bits_to_set = 0b00110000 & static_cast<uint8_t>(in);
uint8_t value_cleared = value & 0b11001111;
uint8_t to_set = bits_to_set | value_cleared;
LOGGER.info("WatchDogTimer: {:02x} -> {:02x}", value, to_set);
LOG_I(TAG, "WatchDogTimer: %02X -> %02X", value, to_set);
return writeRegister8(registers::CHARGE_TERMINATION, to_set);
}
@@ -96,9 +96,9 @@ bool Bq24295::getVersion(uint8_t& value) const {
void Bq24295::printInfo() const {
uint8_t version, status, charge_termination;
if (getStatus(status) && getVersion(version) && readChargeTermination(charge_termination)) {
LOGGER.info("Version {}, status {:02x}, charge termination {:02x}", version, status, charge_termination);
LOG_I(TAG, "Version %d, status %02X, charge termination %02X", version, status, charge_termination);
} else {
LOGGER.error("Failed to retrieve version and/or status");
LOG_E(TAG, "Failed to retrieve version and/or status");
}
}
+4 -4
View File
@@ -1,15 +1,15 @@
#include "Bq25896.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("BQ25896");
constexpr auto* TAG = "BQ25896";
void Bq25896::powerOff() {
LOGGER.info("Power off");
LOG_I(TAG, "Power off");
bitOn(0x09, BIT(5));
}
void Bq25896::powerOn() {
LOGGER.info("Power on");
LOG_I(TAG, "Power on");
bitOff(0x09, BIT(5));
}
+12 -12
View File
@@ -1,9 +1,9 @@
#include "Bq27220.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include "esp_sleep.h"
static const auto LOGGER = tt::Logger("BQ27220");
constexpr auto* TAG = "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)) {
LOGGER.error("Failed to set design capacity!");
LOG_E(TAG, "Failed to set design capacity!");
return false;
}
vTaskDelay(10 / portTICK_PERIOD_MS);
// Set full charge capacity
if (!writeConfig16(registers::ROM_FULL_CHARGE_CAPACITY, fullChargeCapacity)) {
LOGGER.error("Failed to set full charge capacity!");
LOG_E(TAG, "Failed to set full charge capacity!");
return false;
}
vTaskDelay(10 / portTICK_PERIOD_MS);
@@ -260,7 +260,7 @@ bool Bq27220::sendSubCommand(uint16_t subCmd, bool waitConfirm)
}
vTaskDelay(100 / portTICK_PERIOD_MS);
}
LOGGER.error("Subcommand 0x{:04X} failed!", subCmd);
LOG_E(TAG, "Subcommand 0x%04X failed!", subCmd);
return false;
}
@@ -298,28 +298,28 @@ bool Bq27220::configPreamble(bool &isSealed) {
// Check access settings
if(!getOperationStatus(status)) {
LOGGER.error("Cannot read initial operation status!");
LOG_E(TAG, "Cannot read initial operation status!");
return false;
}
if (status.reg.SEC == OperationStatusSecSealed) {
isSealed = true;
if (!unsealDevice()) {
LOGGER.error("Unsealing device failure!");
LOG_E(TAG, "Unsealing device failure!");
return false;
}
}
if (status.reg.SEC != OperationStatusSecFull) {
if (!unsealFullAccess()) {
LOGGER.error("Unsealing full access failure!");
LOG_E(TAG, "Unsealing full access failure!");
return false;
}
}
// Send ENTER_CFG_UPDATE command (0x0090)
if (!sendSubCommand(registers::SUBCMD_ENTER_CFG_UPDATE)) {
LOGGER.error("Config Update Subcommand failure!");
LOG_E(TAG, "Config Update Subcommand failure!");
}
// Confirm CFUPDATE mode by polling the OperationStatus() register until Bit 2 is set.
@@ -333,7 +333,7 @@ bool Bq27220::configPreamble(bool &isSealed) {
vTaskDelay(100 / portTICK_PERIOD_MS);
}
if (!isConfigUpdate) {
LOGGER.error("Update Mode timeout, maybe the access key for full permissions is invalid!");
LOG_E(TAG, "Update Mode timeout, maybe the access key for full permissions is invalid!");
return false;
}
@@ -357,13 +357,13 @@ bool Bq27220::configEpilouge(const bool isSealed) {
vTaskDelay(100 / portTICK_PERIOD_MS);
}
if (timeout == 0) {
LOGGER.error("Timed out waiting to exit update mode.");
LOG_E(TAG, "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) {
LOGGER.debug("Restore Safe Mode!");
LOG_D(TAG, "Restore Safe Mode!");
exitSealMode();
}
return true;
+10 -10
View File
@@ -1,11 +1,11 @@
#include "ButtonControl.h"
#include <Tactility/app/App.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ButtonControl");
constexpr auto* TAG = "ButtonControl";
ButtonControl::ButtonControl(const std::vector<PinConfiguration>& pinConfigurations)
: buttonQueue(20, sizeof(ButtonEvent)),
@@ -34,7 +34,7 @@ ButtonControl::ButtonControl(const std::vector<PinConfiguration>& pinConfigurati
};
esp_err_t err = gpio_config(&io_conf);
if (err != ESP_OK) {
LOGGER.error("Failed to configure GPIO {}: {}", static_cast<int>(pin), esp_err_to_name(err));
LOG_E(TAG, "Failed to configure GPIO %d: %s", static_cast<int>(pin), esp_err_to_name(err));
continue;
}
@@ -103,10 +103,10 @@ void ButtonControl::updatePin(std::vector<PinConfiguration>::const_reference con
if (state.pressState) {
auto time_passed = now - state.pressStartTime;
if (time_passed < 500) {
LOGGER.info("Short press ({}ms)", time_passed);
LOG_I(TAG, "Short press (%dms)", (int)time_passed);
state.triggerShortPress = true;
} else {
LOGGER.info("Long press ({}ms)", time_passed);
LOG_I(TAG, "Long press (%dms)", (int)time_passed);
state.triggerLongPress = true;
}
state.pressState = false;
@@ -131,7 +131,7 @@ void ButtonControl::driverThreadMain() {
if (event.pin == GPIO_NUM_NC) {
break; // shutdown sentinel
}
LOGGER.info("Pin {} {}", static_cast<int>(event.pin), event.pressed ? "down" : "up");
LOG_I(TAG, "Pin %d %s", static_cast<int>(event.pin), event.pressed ? "down" : "up");
if (mutex.lock(portMAX_DELAY)) {
// Update ALL PinConfiguration entries that share this physical pin.
for (size_t i = 0; i < pinConfigurations.size(); i++) {
@@ -145,11 +145,11 @@ void ButtonControl::driverThreadMain() {
}
bool ButtonControl::startThread() {
LOGGER.info("Start");
LOG_I(TAG, "Start");
esp_err_t err = gpio_install_isr_service(ESP_INTR_FLAG_IRAM);
if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
LOGGER.error("Failed to install GPIO ISR service: {}", esp_err_to_name(err));
LOG_E(TAG, "Failed to install GPIO ISR service: %s", esp_err_to_name(err));
return false;
}
@@ -159,7 +159,7 @@ bool ButtonControl::startThread() {
for (auto& arg : isrArgs) {
err = gpio_isr_handler_add(arg.pin, gpioIsrHandler, &arg);
if (err != ESP_OK) {
LOGGER.error("Failed to add ISR for GPIO {}: {}", static_cast<int>(arg.pin), esp_err_to_name(err));
LOG_E(TAG, "Failed to add ISR for GPIO %d: %s", static_cast<int>(arg.pin), esp_err_to_name(err));
for (int i = 0; i < handlersAdded; i++) {
gpio_isr_handler_remove(isrArgs[i].pin);
}
@@ -178,7 +178,7 @@ bool ButtonControl::startThread() {
}
void ButtonControl::stopThread() {
LOGGER.info("Stop");
LOG_I(TAG, "Stop");
for (const auto& arg : isrArgs) {
gpio_isr_handler_remove(arg.pin);
+5 -5
View File
@@ -1,9 +1,9 @@
#include "Drv2605.h"
#include <tactility/check.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("DRV2605");
constexpr auto* TAG = "DRV2605";
Drv2605::Drv2605(::Device* controller, bool autoPlayStartupBuzz) : I2cDevice(controller, ADDRESS), autoPlayStartupBuzz(autoPlayStartupBuzz) {
check(init(), "Initialize DRV2605");
@@ -17,14 +17,14 @@ Drv2605::Drv2605(::Device* controller, bool autoPlayStartupBuzz) : I2cDevice(con
bool Drv2605::init() {
uint8_t status;
if (!readRegister8(static_cast<uint8_t>(Register::Status), status)) {
LOGGER.error("Failed to read status");
LOG_E(TAG, "Failed to read status");
return false;
}
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) {
LOGGER.error("Unknown chip id {:02x}", static_cast<uint8_t>(chip_id));
LOG_E(TAG, "Unknown chip id %02X", static_cast<uint8_t>(chip_id));
return false;
}
@@ -39,7 +39,7 @@ bool Drv2605::init() {
uint8_t feedback;
if (!readRegister(Register::Feedback, feedback)) {
LOGGER.error("Failed to read feedback");
LOG_E(TAG, "Failed to read feedback");
return false;
}
@@ -1,13 +1,13 @@
#include "EspLcdDisplay.h"
#include "EspLcdDisplayDriver.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <tactility/check.h>
#include <Tactility/hal/touch/TouchDevice.h>
#include <cassert>
#include <esp_lvgl_port_disp.h>
static const auto LOGGER = tt::Logger("EspLcdDisplay");
constexpr auto* TAG = "EspLcdDisplay";
EspLcdDisplay::~EspLcdDisplay() {
check(
@@ -18,12 +18,12 @@ EspLcdDisplay::~EspLcdDisplay() {
bool EspLcdDisplay::start() {
if (!createIoHandle(ioHandle)) {
LOGGER.error("Failed to create IO handle");
LOG_E(TAG, "Failed to create IO handle");
return false;
}
if (!createPanelHandle(ioHandle, panelHandle)) {
LOGGER.error("Failed to create panel handle");
LOG_E(TAG, "Failed to create panel handle");
esp_lcd_panel_io_del(ioHandle);
return false;
}
@@ -46,7 +46,7 @@ bool EspLcdDisplay::stop() {
}
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use.");
LOG_W(TAG, "DisplayDriver is still in use.");
}
return true;
@@ -56,7 +56,7 @@ bool EspLcdDisplay::startLvgl() {
assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use.");
LOG_W(TAG, "DisplayDriver is still in use.");
}
auto lvgl_port_config = getLvglPortDisplayConfig(ioHandle, panelHandle);
+14 -14
View File
@@ -1,13 +1,13 @@
#include "EspLcdDisplayV2.h"
#include "EspLcdDisplayDriver.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <tactility/check.h>
#include <Tactility/hal/touch/TouchDevice.h>
#include <cassert>
#include <esp_lvgl_port_disp.h>
static const auto LOGGER = tt::Logger("EspLcdDispV2");
constexpr auto* TAG = "EspLcdDispV2";
inline unsigned int getBufferSize(const std::shared_ptr<EspLcdConfiguration>& configuration) {
if (configuration->bufferSize != DEFAULT_BUFFER_SIZE) {
@@ -26,17 +26,17 @@ EspLcdDisplayV2::~EspLcdDisplayV2() {
bool EspLcdDisplayV2::applyConfiguration() const {
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel");
LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel");
LOG_E(TAG, "Failed to init panel");
return false;
}
if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
@@ -45,28 +45,28 @@ bool EspLcdDisplayV2::applyConfiguration() const {
int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY;
bool should_set_gap = gap_x != 0 || gap_y != 0;
if (should_set_gap && esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) {
LOGGER.error("Failed to set panel gap");
LOG_E(TAG, "Failed to set panel gap");
return false;
}
if (configuration->swapXY && esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY ");
LOG_E(TAG, "Failed to swap XY ");
return false;
}
bool should_set_mirror = configuration->mirrorX || configuration->mirrorY;
if (should_set_mirror && esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror");
LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on");
LOG_E(TAG, "Failed to turn display on");
return false;
}
@@ -75,14 +75,14 @@ bool EspLcdDisplayV2::applyConfiguration() const {
bool EspLcdDisplayV2::start() {
if (!createIoHandle(ioHandle)) {
LOGGER.error("Failed to create IO handle");
LOG_E(TAG, "Failed to create IO handle");
return false;
}
esp_lcd_panel_dev_config_t panel_config = createPanelConfig(configuration, configuration->resetPin);
if (!createPanelHandle(ioHandle, panel_config, panelHandle)) {
LOGGER.error("Failed to create panel handle");
LOG_E(TAG, "Failed to create panel handle");
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
return false;
@@ -114,7 +114,7 @@ bool EspLcdDisplayV2::stop() {
}
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use.");
LOG_W(TAG, "DisplayDriver is still in use.");
}
return true;
@@ -124,7 +124,7 @@ bool EspLcdDisplayV2::startLvgl() {
assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use.");
LOG_W(TAG, "DisplayDriver is still in use.");
}
auto lvgl_port_config = getLvglPortDisplayConfig(configuration, ioHandle, panelHandle);
@@ -1,12 +1,12 @@
#include "EspLcdSpiDisplay.h"
#include <esp_lcd_panel_commands.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("EspLcdSpiDisplay");
constexpr auto* TAG = "EspLcdSpiDisplay";
bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
LOGGER.info("createIoHandle");
LOG_I(TAG, "createIoHandle");
const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = spiConfiguration->csPin,
@@ -33,7 +33,7 @@ bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
};
if (esp_lcd_new_panel_io_spi(spiConfiguration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
@@ -65,6 +65,6 @@ void EspLcdSpiDisplay::setGammaCurve(uint8_t index) {
auto io_handle = getIoHandle();
assert(io_handle != nullptr);
if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) {
LOGGER.error("Failed to set gamma");
LOG_E(TAG, "Failed to set gamma");
}
}
+7 -7
View File
@@ -2,21 +2,21 @@
#include <EspLcdTouchDriver.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_lvgl_port_touch.h>
static const auto LOGGER = tt::Logger("EspLcdTouch");
constexpr auto* TAG = "EspLcdTouch";
bool EspLcdTouch::start() {
if (!createIoHandle(ioHandle) != ESP_OK) {
LOGGER.error("Touch IO failed");
LOG_E(TAG, "Touch IO failed");
return false;
}
config = createEspLcdTouchConfig();
if (!createTouchHandle(ioHandle, config, touchHandle)) {
LOGGER.error("Driver init failed");
LOG_E(TAG, "Driver init failed");
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
return false;
@@ -49,7 +49,7 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
}
if (touchDriver != nullptr && touchDriver.use_count() > 1) {
LOGGER.warn("TouchDriver is still in use.");
LOG_W(TAG, "TouchDriver is still in use.");
}
const lvgl_port_touch_cfg_t touch_cfg = {
@@ -57,10 +57,10 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) {
.handle = touchHandle,
};
LOGGER.info("Adding touch to LVGL");
LOG_I(TAG, "Adding touch to LVGL");
lvglDevice = lvgl_port_add_touch(&touch_cfg);
if (lvglDevice == nullptr) {
LOGGER.error("Adding touch failed");
LOG_E(TAG, "Adding touch failed");
return false;
}
@@ -1,12 +1,12 @@
#include "EspLcdTouchDriver.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("EspLcdTouchDriver");
constexpr auto* TAG = "EspLcdTouchDriver";
bool EspLcdTouchDriver::getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* _Nullable strength, uint8_t* pointCount, uint8_t maxPointCount) {
if (esp_lcd_touch_read_data(handle) != ESP_OK) {
LOGGER.error("Read data failed");
LOG_E(TAG, "Read data failed");
return false;
}
return esp_lcd_touch_get_coordinates(handle, x, y, strength, pointCount, maxPointCount);
@@ -1,7 +1,7 @@
#include "ChargeFromAdcVoltage.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("ChargeFromAdcV");
constexpr auto* TAG = "ChargeFromAdcV";
constexpr auto MAX_VOLTAGE_SAMPLES = 15;
ChargeFromAdcVoltage::ChargeFromAdcVoltage(
@@ -10,12 +10,12 @@ ChargeFromAdcVoltage::ChargeFromAdcVoltage(
float voltageMax
) : configuration(configuration), chargeFromVoltage(voltageMin, voltageMax) {
if (adc_oneshot_new_unit(&configuration.adcConfig, &adcHandle) != ESP_OK) {
LOGGER.error("ADC config failed");
LOG_E(TAG, "ADC config failed");
return;
}
if (adc_oneshot_config_channel(adcHandle, configuration.adcChannel, &configuration.adcChannelConfig) != ESP_OK) {
LOGGER.error("ADC channel config failed");
LOG_E(TAG, "ADC channel config failed");
adc_oneshot_del_unit(adcHandle);
adcHandle = nullptr;
@@ -36,12 +36,10 @@ 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;
if (LOGGER.isLoggingVerbose()) {
LOGGER.verbose("Raw = {}, voltage = {}", raw, output);
}
LOG_V(TAG, "Raw = %d, voltage = %u", raw, (unsigned)output);
return true;
} else {
LOGGER.error("Read failed");
LOG_E(TAG, "Read failed");
return false;
}
}
@@ -1,9 +1,9 @@
#include "ChargeFromVoltage.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <algorithm>
const static auto LOGGER = tt::Logger("ChargeFromVoltage");
constexpr auto* TAG = "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);
LOGGER.debug("mV = {}, scaled = {}, factor = {:.2f}, result = {}", milliVolt, volts, voltage_factor, charge_level);
LOG_D(TAG, "mV = %u, scaled = %f, factor = %.2f, result = %d", (unsigned)milliVolt, volts, voltage_factor, charge_level);
return charge_level;
}
+11 -11
View File
@@ -1,15 +1,15 @@
#include "Gc9a01Display.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_lcd_gc9a01.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("GC9A01");
constexpr auto* TAG = "GC9A01";
bool Gc9a01Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
LOGGER.info("Starting");
LOG_I(TAG, "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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel");
LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel");
LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY ");
LOG_E(TAG, "Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror");
LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on");
LOG_E(TAG, "Failed to turn display on");
return false;
}
+4 -4
View File
@@ -1,6 +1,6 @@
#include "Gt911Touch.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_lcd_io_i2c.h>
#include <esp_lcd_touch_gt911.h>
@@ -11,7 +11,7 @@
#include <tactility/drivers/esp32_i2c_master.h>
#include <tactility/drivers/i2c_controller.h>
static const auto LOGGER = tt::Logger("GT911");
constexpr auto* TAG = "GT911";
bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
@@ -23,7 +23,7 @@ bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
} else if (i2c_controller_has_device_at_address(i2c, ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP, pdMS_TO_TICKS(10)) == ERROR_NONE) {
io_config.dev_addr = ESP_LCD_TOUCH_IO_I2C_GT911_ADDRESS_BACKUP;
} else {
LOGGER.error("No device found on I2C bus");
LOG_E(TAG, "No device found on I2C bus");
return false;
}
@@ -38,7 +38,7 @@ bool Gt911Touch::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
return esp_lcd_new_panel_io_i2c_v2(bus, &io_config, &outHandle) == ESP_OK;
}
LOGGER.error("Unsupported I2C driver");
LOG_E(TAG, "Unsupported I2C driver");
return false;
}
+9 -9
View File
@@ -1,12 +1,12 @@
#include "Ili9488Display.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_lcd_ili9488.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ILI9488");
constexpr auto* TAG = "ILI9488";
bool Ili9488Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel");
LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel");
LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY ");
LOG_E(TAG, "Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror");
LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on");
LOG_E(TAG, "Failed to turn display on");
return false;
}
+6 -6
View File
@@ -1,8 +1,8 @@
#include "PwmBacklight.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("PwmBacklight");
constexpr auto* TAG = "PwmBacklight";
namespace driver::pwmbacklight {
@@ -16,7 +16,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
backlightTimer = timer;
backlightChannel = channel;
LOGGER.info("Init");
LOG_I(TAG, "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) {
LOGGER.error("Timer config failed");
LOG_E(TAG, "Timer config failed");
return false;
}
@@ -46,7 +46,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
};
if (ledc_channel_config(&ledc_channel) != ESP_OK) {
LOGGER.error("Channel config failed");
LOG_E(TAG, "Channel config failed");
return false;
}
@@ -57,7 +57,7 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel
bool setBacklightDuty(uint8_t duty) {
if (!isBacklightInitialized) {
LOGGER.error("Not initialized");
LOG_E(TAG, "Not initialized");
return false;
}
return ledc_set_duty(LEDC_LOW_SPEED_MODE, backlightChannel, duty) == ESP_OK &&
+12 -12
View File
@@ -2,14 +2,14 @@
#include <tactility/check.h>
#include <Tactility/hal/touch/TouchDevice.h>
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_err.h>
#include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h>
#include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("RgbDisplay");
constexpr auto* TAG = "RgbDisplay";
RgbDisplay::~RgbDisplay() {
check(
@@ -19,35 +19,35 @@ RgbDisplay::~RgbDisplay() {
}
bool RgbDisplay::start() {
LOGGER.info("Starting");
LOG_I(TAG, "Starting");
if (esp_lcd_new_rgb_panel(&configuration->panelConfig, &panelHandle) != ESP_OK) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel");
LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel");
LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY");
LOG_E(TAG, "Failed to swap XY");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror");
LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
@@ -65,7 +65,7 @@ bool RgbDisplay::stop() {
}
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use.");
LOG_W(TAG, "DisplayDriver is still in use.");
}
auto touch_device = getTouchDevice();
@@ -81,7 +81,7 @@ bool RgbDisplay::startLvgl() {
assert(lvglDisplay == nullptr);
if (displayDriver != nullptr && displayDriver.use_count() > 1) {
LOGGER.warn("DisplayDriver is still in use.");
LOG_W(TAG, "DisplayDriver is still in use.");
}
auto display_config = getLvglPortDisplayConfig();
@@ -94,7 +94,7 @@ bool RgbDisplay::startLvgl() {
};
lvglDisplay = lvgl_port_add_disp_rgb(&display_config, &rgb_config);
LOGGER.info("Finished");
LOG_I(TAG, "Finished");
auto touch_device = getTouchDevice();
if (touch_device != nullptr) {
+7 -7
View File
@@ -1,6 +1,6 @@
#include "Ssd1306Display.h"
#include <Tactility/Logger.h>
#include <tactility/log.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>
static const auto LOGGER = tt::Logger("Ssd1306Display");
constexpr auto* TAG = "Ssd1306Display";
// SSD1306 commands
#define SSD1306_CMD_SET_CLOCK 0xD5
@@ -38,7 +38,7 @@ static bool ssd1306_i2c_send_cmd(i2c_port_t port, uint8_t addr, uint8_t cmd) {
uint8_t data[2] = {0x00, cmd}; // 0x00 = command mode
esp_err_t ret = i2c_master_write_to_device(port, addr, data, sizeof(data), pdMS_TO_TICKS(1000));
if (ret != ESP_OK) {
LOGGER.error("Failed to send command 0x{:02X}: {}", cmd, ret);
LOG_E(TAG, "Failed to send command 0x%02X: %d", cmd, (int)ret);
return false;
}
return true;
@@ -61,7 +61,7 @@ bool Ssd1306Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
};
if (esp_lcd_new_panel_io_i2c(static_cast<esp_lcd_i2c_bus_handle_t>(configuration->port), &io_config, &ioHandle) != ESP_OK) {
LOGGER.error("Failed to create IO handle");
LOG_E(TAG, "Failed to create IO handle");
return false;
}
@@ -106,7 +106,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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
@@ -116,7 +116,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
auto port = configuration->port;
auto addr = configuration->deviceAddress;
LOGGER.info("Sending Heltec V3 custom init sequence");
LOG_I(TAG, "Sending Heltec V3 custom init sequence");
// Display off while configuring
ssd1306_i2c_send_cmd(port, addr, SSD1306_CMD_DISPLAY_OFF);
@@ -182,7 +182,7 @@ bool Ssd1306Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_l
vTaskDelay(pdMS_TO_TICKS(100)); // Let display stabilize
LOGGER.info("Heltec V3 display initialized successfully");
LOG_I(TAG, "Heltec V3 display initialized successfully");
return true;
}
+13 -13
View File
@@ -1,16 +1,16 @@
#include "St7735Display.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_lcd_panel_commands.h>
#include <esp_lcd_panel_dev.h>
#include <esp_lcd_st7735.h>
#include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ST7735");
constexpr auto* TAG = "ST7735";
bool St7735Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
LOGGER.info("Starting");
LOG_I(TAG, "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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel");
LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel");
LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
@@ -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) {
LOGGER.error("Failed to set panel gap");
LOG_E(TAG, "Failed to set panel gap");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY ");
LOG_E(TAG, "Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror");
LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on");
LOG_E(TAG, "Failed to turn display on");
return false;
}
@@ -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) {
LOGGER.error("Failed to set gamma");
LOG_E(TAG, "Failed to set gamma");
}
}
@@ -1,5 +1,5 @@
#include "St7789i8080Display.h"
#include <Tactility/Logger.h>
#include <tactility/log.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>
static const auto LOGGER = tt::Logger("St7789i8080Display");
constexpr auto* TAG = "St7789i8080Display";
static St7789i8080Display* g_display_instance = nullptr;
// ST7789 initialization commands
@@ -51,13 +51,13 @@ St7789i8080Display::St7789i8080Display(const Configuration& config)
// Validate configuration
if (!configuration.isValid()) {
LOGGER.error("Invalid configuration: resolution must be set");
LOG_E(TAG, "Invalid configuration: resolution must be set");
return;
}
}
bool St7789i8080Display::createI80Bus() {
LOGGER.info("Creating I80 bus");
LOG_I(TAG, "Creating I80 bus");
// Create I80 bus configuration
esp_lcd_i80_bus_config_t bus_cfg = {
@@ -78,15 +78,15 @@ bool St7789i8080Display::createI80Bus() {
esp_err_t ret = esp_lcd_new_i80_bus(&bus_cfg, &i80BusHandle);
if (ret != ESP_OK) {
LOGGER.error("Failed to create I80 bus: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to create I80 bus: %s", esp_err_to_name(ret));
return false;
}
return true;
}
bool St7789i8080Display::createPanelIO() {
LOGGER.info("Creating panel IO");
LOG_I(TAG, "Creating panel IO");
// Create panel IO with proper callback
esp_lcd_panel_io_i80_config_t io_cfg = {
@@ -114,15 +114,15 @@ bool St7789i8080Display::createPanelIO() {
esp_err_t ret = esp_lcd_new_panel_io_i80(i80BusHandle, &io_cfg, &ioHandle);
if (ret != ESP_OK) {
LOGGER.error("Failed to create panel IO: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to create panel IO: %s", esp_err_to_name(ret));
return false;
}
return true;
}
bool St7789i8080Display::createPanel() {
LOGGER.info("Configuring panel");
LOG_I(TAG, "Configuring panel");
// Create ST7789 panel
esp_lcd_panel_dev_config_t panel_config = {
@@ -138,57 +138,57 @@ bool St7789i8080Display::createPanel() {
esp_err_t ret = esp_lcd_new_panel_st7789(ioHandle, &panel_config, &panelHandle);
if (ret != ESP_OK) {
LOGGER.error("Failed to create ST7789 panel: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to create ST7789 panel: %s", esp_err_to_name(ret));
return false;
}
// Reset panel
ret = esp_lcd_panel_reset(panelHandle);
if (ret != ESP_OK) {
LOGGER.error("Failed to reset panel: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to reset panel: %s", esp_err_to_name(ret));
return false;
}
// Initialize panel
ret = esp_lcd_panel_init(panelHandle);
if (ret != ESP_OK) {
LOGGER.error("Failed to init panel: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to init panel: %s", esp_err_to_name(ret));
return false;
}
// Set gap
ret = esp_lcd_panel_set_gap(panelHandle, configuration.gapX, configuration.gapY);
if (ret != ESP_OK) {
LOGGER.error("Failed to set panel gap: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to set panel gap: %s", esp_err_to_name(ret));
return false;
}
// Set inversion
ret = esp_lcd_panel_invert_color(panelHandle, configuration.invertColor);
if (ret != ESP_OK) {
LOGGER.error("Failed to set panel inversion: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to set panel inversion: %s", esp_err_to_name(ret));
return false;
}
// Set mirror
ret = esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY);
if (ret != ESP_OK) {
LOGGER.error("Failed to set panel mirror: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to set panel mirror: %s", esp_err_to_name(ret));
return false;
}
// Turn on display
ret = esp_lcd_panel_disp_on_off(panelHandle, true);
if (ret != ESP_OK) {
LOGGER.error("Failed to turn display on: {}", esp_err_to_name(ret));
LOG_E(TAG, "Failed to turn display on: %s", esp_err_to_name(ret));
return false;
}
return true;
}
void St7789i8080Display::sendInitCommands() {
LOGGER.info("Sending ST7789 init commands");
LOG_I(TAG, "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() {
LOGGER.info("Initializing I8080 ST7789 Display hardware...");
LOG_I(TAG, "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) {
LOGGER.error("Failed to allocate display buffer");
LOG_E(TAG, "Failed to allocate display buffer");
return false;
}
@@ -239,7 +239,7 @@ bool St7789i8080Display::start() {
return false;
}
LOGGER.info("Display hardware initialized");
LOG_I(TAG, "Display hardware initialized");
return true;
}
@@ -278,17 +278,17 @@ bool St7789i8080Display::stop() {
}
bool St7789i8080Display::startLvgl() {
LOGGER.info("Initializing LVGL for ST7789 display");
LOG_I(TAG, "Initializing LVGL for ST7789 display");
// Don't reinitialize hardware if it's already done
if (!ioHandle) {
LOGGER.info("Hardware not initialized, calling start()");
LOG_I(TAG, "Hardware not initialized, calling start()");
if (!start()) {
LOGGER.error("Hardware initialization failed");
LOG_E(TAG, "Hardware initialization failed");
return false;
}
} else {
LOGGER.info("Hardware already initialized, skipping");
LOG_I(TAG, "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) {
LOGGER.error("Failed to create LVGL display");
LOG_E(TAG, "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;
LOGGER.info("LVGL display created successfully");
LOG_I(TAG, "LVGL display created successfully");
return true;
}
@@ -1,5 +1,5 @@
#include "St7796i8080Display.h"
#include <Tactility/Logger.h>
#include <tactility/log.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>
static const auto LOGGER = tt::Logger("St7796i8080Display");
constexpr auto* TAG = "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()) {
LOGGER.error("Invalid configuration: resolution must be set");
LOG_E(TAG, "Invalid configuration: resolution must be set");
return;
}
}
bool St7796i8080Display::createI80Bus() {
LOGGER.info("Creating I80 bus");
LOG_I(TAG, "Creating I80 bus");
// Create I80 bus configuration
esp_lcd_i80_bus_config_t bus_cfg = {
@@ -42,15 +42,15 @@ bool St7796i8080Display::createI80Bus() {
};
if (esp_lcd_new_i80_bus(&bus_cfg, &i80BusHandle) != ESP_OK) {
LOGGER.error("Failed to create I80 bus");
LOG_E(TAG, "Failed to create I80 bus");
return false;
}
return true;
}
bool St7796i8080Display::createPanelIO() {
LOGGER.info("Creating panel IO");
LOG_I(TAG, "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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
@@ -85,7 +85,7 @@ bool St7796i8080Display::createPanelIO() {
}
bool St7796i8080Display::createPanel() {
LOGGER.info("Configuring panel");
LOG_I(TAG, "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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
// Reset panel
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel");
LOG_E(TAG, "Failed to reset panel");
return false;
}
// Initialize panel
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel");
LOG_E(TAG, "Failed to init panel");
return false;
}
// Set swap XY
if (esp_lcd_panel_swap_xy(panelHandle, configuration.swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY ");
LOG_E(TAG, "Failed to swap XY ");
return false;
}
// Set mirror
if (esp_lcd_panel_mirror(panelHandle, configuration.mirrorX, configuration.mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror");
LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
// Set inversion
if (esp_lcd_panel_invert_color(panelHandle, configuration.invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
// Turn on display
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on");
LOG_E(TAG, "Failed to turn display on");
return false;
}
@@ -144,7 +144,7 @@ bool St7796i8080Display::createPanel() {
}
bool St7796i8080Display::start() {
LOGGER.info("Initializing I8080 ST7796 Display hardware...");
LOG_I(TAG, "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) {
LOGGER.error("Failed to allocate display buffer");
LOG_E(TAG, "Failed to allocate display buffer");
return false;
}
@@ -175,7 +175,7 @@ bool St7796i8080Display::start() {
return false;
}
LOGGER.info("Display hardware initialized");
LOG_I(TAG, "Display hardware initialized");
return true;
}
@@ -214,17 +214,17 @@ bool St7796i8080Display::stop() {
}
bool St7796i8080Display::startLvgl() {
LOGGER.info("Initializing LVGL for ST7796 display");
LOG_I(TAG, "Initializing LVGL for ST7796 display");
// Don't reinitialize hardware if it's already done
if (!ioHandle) {
LOGGER.info("Hardware not initialized, calling start()");
LOG_I(TAG, "Hardware not initialized, calling start()");
if (!start()) {
LOGGER.error("Hardware initialization failed");
LOG_E(TAG, "Hardware initialization failed");
return false;
}
} else {
LOGGER.info("Hardware already initialized, skipping");
LOG_I(TAG, "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) {
LOGGER.error("Failed to create LVGL display");
LOG_E(TAG, "Failed to create LVGL display");
return false;
}
g_display_instance = this;
LOGGER.info("LVGL display created successfully");
LOG_I(TAG, "LVGL display created successfully");
return true;
}
+11 -11
View File
@@ -1,12 +1,12 @@
#include "St7796Display.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <esp_lcd_panel_dev.h>
#include <esp_lcd_st7796.h>
#include <esp_lvgl_port.h>
static const auto LOGGER = tt::Logger("ST7796");
constexpr auto* TAG = "ST7796";
bool St7796Display::createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) {
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) {
LOGGER.error("Failed to create panel");
LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
LOGGER.error("Failed to reset panel");
LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
LOGGER.error("Failed to init panel");
LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
LOGGER.error("Failed to set panel to invert");
LOG_E(TAG, "Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) {
LOGGER.error("Failed to swap XY ");
LOG_E(TAG, "Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
LOGGER.error("Failed to set panel to mirror");
LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_set_gap(panelHandle, configuration->gapX, configuration->gapY) != ESP_OK) {
LOGGER.error("Failed to set panel gap");
LOG_E(TAG, "Failed to set panel gap");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
LOGGER.error("Failed to turn display on");
LOG_E(TAG, "Failed to turn display on");
return false;
}
@@ -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) {
LOGGER.error("Failed to set gamma");
LOG_E(TAG, "Failed to set gamma");
}*/
}
@@ -1,6 +1,6 @@
#include "Xpt2046SoftSpi.h"
#include <Tactility/Logger.h>
#include <tactility/log.h>
#include <Tactility/settings/TouchCalibrationSettings.h>
#include <algorithm>
@@ -11,7 +11,7 @@
#include <freertos/task.h>
#include <rom/ets_sys.h>
static const auto LOGGER = tt::Logger("Xpt2046SoftSpi");
constexpr auto* TAG = "Xpt2046SoftSpi";
constexpr auto CMD_READ_Y = 0x90;
constexpr auto CMD_READ_X = 0xD0;
@@ -27,7 +27,7 @@ Xpt2046SoftSpi::Xpt2046SoftSpi(std::unique_ptr<Configuration> inConfiguration)
}
bool Xpt2046SoftSpi::start() {
LOGGER.info("Starting Xpt2046SoftSpi touch driver");
LOG_I(TAG, "Starting Xpt2046SoftSpi touch driver");
// Configure GPIO pins
gpio_config_t io_conf = {};
@@ -42,7 +42,7 @@ bool Xpt2046SoftSpi::start() {
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
if (gpio_config(&io_conf) != ESP_OK) {
LOGGER.error("Failed to configure output pins");
LOG_E(TAG, "Failed to configure output pins");
return false;
}
@@ -52,7 +52,7 @@ bool Xpt2046SoftSpi::start() {
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
if (gpio_config(&io_conf) != ESP_OK) {
LOGGER.error("Failed to configure input pin");
LOG_E(TAG, "Failed to configure input pin");
return false;
}
@@ -61,8 +61,9 @@ bool Xpt2046SoftSpi::start() {
gpio_set_level(configuration->clkPin, 0); // CLK low
gpio_set_level(configuration->mosiPin, 0); // MOSI low
LOGGER.info(
"GPIO configured: MOSI={}, MISO={}, CLK={}, CS={}",
LOG_I(
TAG,
"GPIO configured: MOSI=%d, MISO=%d, CLK=%d, CS=%d",
static_cast<int>(configuration->mosiPin),
static_cast<int>(configuration->misoPin),
static_cast<int>(configuration->clkPin),
@@ -73,7 +74,7 @@ bool Xpt2046SoftSpi::start() {
}
bool Xpt2046SoftSpi::stop() {
LOGGER.info("Stopping Xpt2046SoftSpi touch driver");
LOG_I(TAG, "Stopping Xpt2046SoftSpi touch driver");
// Stop LVLG if needed
if (lvglDevice != nullptr) {
@@ -86,13 +87,13 @@ bool Xpt2046SoftSpi::stop() {
bool Xpt2046SoftSpi::startLvgl(lv_display_t* display) {
(void)display;
if (lvglDevice != nullptr) {
LOGGER.error("LVGL was already started");
LOG_E(TAG, "LVGL was already started");
return false;
}
lvglDevice = lv_indev_create();
if (lvglDevice == nullptr) {
LOGGER.error("Failed to create LVGL input device");
LOG_E(TAG, "Failed to create LVGL input device");
return false;
}
@@ -100,7 +101,7 @@ bool Xpt2046SoftSpi::startLvgl(lv_display_t* display) {
lv_indev_set_read_cb(lvglDevice, touchReadCallback);
lv_indev_set_user_data(lvglDevice, this);
LOGGER.info("Xpt2046SoftSpi touch driver started successfully");
LOG_I(TAG, "Xpt2046SoftSpi touch driver started successfully");
return true;
}