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
+13 -13
View File
@@ -1,12 +1,12 @@
#include "UnPhoneFeatures.h"
#include <tactility/device.h>
#include <Tactility/Logger.h>
#include <Tactility/LogMessages.h>
#include <Tactility/Preferences.h>
#include <Tactility/TactilityCore.h>
#include <esp_sleep.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("unPhone");
constexpr auto* TAG = "unPhone";
std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
static std::unique_ptr<tt::Thread> powerThread;
@@ -49,10 +49,10 @@ public:
}
void printInfo() {
LOGGER.info("Device stats:");
LOGGER.info(" boot: {}", getValue(bootCountKey));
LOGGER.info(" power off: {}", getValue(powerOffCountKey));
LOGGER.info(" power sleep: {}", getValue(powerSleepKey));
LOG_I(TAG, "Device stats:");
LOG_I(TAG, " boot: %d", (int)getValue(bootCountKey));
LOG_I(TAG, " power off: %d", (int)getValue(powerOffCountKey));
LOG_I(TAG, " power sleep: %d", (int)getValue(powerSleepKey));
}
};
@@ -92,11 +92,11 @@ static void updatePowerSwitch() {
if (!unPhoneFeatures->isPowerSwitchOn()) {
if (last_state != PowerState::Off) {
last_state = PowerState::Off;
LOGGER.warn("Power off");
LOG_W(TAG, "Power off");
}
if (!unPhoneFeatures->isUsbPowerConnected()) { // and usb unplugged we go into shipping mode
LOGGER.warn("Shipping mode until USB connects");
LOG_W(TAG, "Shipping mode until USB connects");
#if DEBUG_POWER_STATES
unPhoneFeatures.setExpanderPower(true);
@@ -110,7 +110,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.
LOGGER.warn("Waiting for USB disconnect to power off");
LOG_W(TAG, "Waiting for USB disconnect to power off");
#if DEBUG_POWER_STATES
powerInfoBuzz(2);
@@ -129,7 +129,7 @@ static void updatePowerSwitch() {
} else {
if (last_state != PowerState::On) {
last_state = PowerState::On;
LOGGER.warn("Power on");
LOG_W(TAG, "Power on");
#if DEBUG_POWER_STATES
powerInfoBuzz(1);
@@ -166,7 +166,7 @@ static bool unPhonePowerOn() {
unPhoneFeatures = std::make_shared<UnPhoneFeatures>(bq24295);
if (!unPhoneFeatures->init()) {
LOGGER.error("UnPhoneFeatures init failed");
LOG_E(TAG, "UnPhoneFeatures init failed");
return false;
}
@@ -186,10 +186,10 @@ static bool unPhonePowerOn() {
}
bool initBoot() {
LOGGER.info(LOG_MESSAGE_POWER_ON_START);
LOG_I(TAG, LOG_MESSAGE_POWER_ON_START);
if (!unPhonePowerOn()) {
LOGGER.error(LOG_MESSAGE_POWER_ON_FAILED);
LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
return false;
}
+18 -18
View File
@@ -1,6 +1,5 @@
#include "UnPhoneFeatures.h"
#include <Tactility/Logger.h>
#include <Tactility/app/App.h>
#include <Tactility/kernel/Kernel.h>
@@ -8,8 +7,9 @@
#include <driver/rtc_io.h>
#include <esp_io_expander.h>
#include <esp_sleep.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("unPhoneFeatures");
constexpr auto* TAG = "unPhoneFeatures";
namespace pin {
static const gpio_num_t BUTTON1 = GPIO_NUM_45; // left button
@@ -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
LOGGER.info("Pressed button {}", pinNumber);
LOG_I(TAG, "Pressed button %d", pinNumber);
if (pinNumber == pin::BUTTON1) {
tt::app::stop();
}
@@ -75,7 +75,7 @@ bool UnPhoneFeatures::initPowerSwitch() {
};
if (gpio_config(&config) != ESP_OK) {
LOGGER.error("Power pin init failed");
LOG_E(TAG, "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 {
LOGGER.error("Failed to set RTC for power switch");
LOG_E(TAG, "Failed to set RTC for power switch");
return false;
}
}
bool UnPhoneFeatures::initNavButtons() {
if (!initGpioExpander()) {
LOGGER.error("GPIO expander init failed");
LOG_E(TAG, "GPIO expander init failed");
return false;
}
@@ -125,7 +125,7 @@ bool UnPhoneFeatures::initNavButtons() {
};
if (gpio_config(&config) != ESP_OK) {
LOGGER.error("Nav button pin init failed");
LOG_E(TAG, "Nav button pin init failed");
return false;
}
@@ -135,7 +135,7 @@ bool UnPhoneFeatures::initNavButtons() {
gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON2)) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON3)) != ESP_OK
) {
LOGGER.error("Nav buttons ISR init failed");
LOG_E(TAG, "Nav buttons ISR init failed");
return false;
}
@@ -156,7 +156,7 @@ bool UnPhoneFeatures::initOutputPins() {
};
if (gpio_config(&config) != ESP_OK) {
LOGGER.error("Output pin init failed");
LOG_E(TAG, "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) {
LOGGER.error("IO expander init failed");
LOG_E(TAG, "IO expander init failed");
return false;
}
assert(ioExpander != nullptr);
@@ -201,25 +201,25 @@ bool UnPhoneFeatures::initGpioExpander() {
}
bool UnPhoneFeatures::init() {
LOGGER.info("init");
LOG_I(TAG, "init");
if (!initGpioExpander()) {
LOGGER.error("GPIO expander init failed");
LOG_E(TAG, "GPIO expander init failed");
return false;
}
if (!initNavButtons()) {
LOGGER.error("Input pin init failed");
LOG_E(TAG, "Input pin init failed");
return false;
}
if (!initOutputPins()) {
LOGGER.error("Output pin init failed");
LOG_E(TAG, "Output pin init failed");
return false;
}
if (!initPowerSwitch()) {
LOGGER.error("Power button init failed");
LOG_E(TAG, "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";
LOGGER.info("Backlight: {}", backlight_power_state);
LOG_I(TAG, "Backlight: %s", 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) {
LOGGER.warn("setShipping: on");
LOG_W(TAG, "setShipping: on");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Disabled);
batteryManagement->setBatFetOn(false);
} else {
LOGGER.warn("setShipping: off");
LOG_W(TAG, "setShipping: off");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s);
batteryManagement->setBatFetOn(true);
}
@@ -2,19 +2,19 @@
#include "Touch.h"
#include <UnPhoneFeatures.h>
#include <Tactility/Logger.h>
#include <hx8357/disp_spi.h>
#include <hx8357/hx8357.h>
#include <tactility/log.h>
static const auto LOGGER = tt::Logger("Hx8357Display");
constexpr auto* TAG = "Hx8357Display";
constexpr auto BUFFER_SIZE = (UNPHONE_LCD_HORIZONTAL_RESOLUTION * UNPHONE_LCD_DRAW_BUFFER_HEIGHT * LV_COLOR_DEPTH / 8);
extern std::shared_ptr<UnPhoneFeatures> unPhoneFeatures;
bool Hx8357Display::start() {
LOGGER.info("start");
LOG_I(TAG, "start");
disp_spi_add_device(SPI2_HOST);
@@ -27,16 +27,16 @@ bool Hx8357Display::start() {
}
bool Hx8357Display::stop() {
LOGGER.info("stop");
LOG_I(TAG, "stop");
disp_spi_remove_device();
return true;
}
bool Hx8357Display::startLvgl() {
LOGGER.info("startLvgl");
LOG_I(TAG, "startLvgl");
if (lvglDisplay != nullptr) {
LOGGER.warn("LVGL was already started");
LOG_W(TAG, "LVGL was already started");
return false;
}
@@ -59,7 +59,7 @@ bool Hx8357Display::startLvgl() {
lv_display_set_flush_cb(lvglDisplay, hx8357_flush);
if (lvglDisplay == nullptr) {
LOGGER.info("Failed");
LOG_I(TAG, "Failed");
return false;
}
@@ -74,10 +74,10 @@ bool Hx8357Display::startLvgl() {
}
bool Hx8357Display::stopLvgl() {
LOGGER.info("stopLvgl");
LOG_I(TAG, "stopLvgl");
if (lvglDisplay == nullptr) {
LOGGER.warn("LVGL was already stopped");
LOG_W(TAG, "LVGL was already stopped");
return false;
}
@@ -86,7 +86,7 @@ bool Hx8357Display::stopLvgl() {
auto touch_device = getTouchDevice();
if (touch_device != nullptr && touch_device->getLvglIndev() != nullptr) {
LOGGER.info("Stopping touch device");
LOG_I(TAG, "Stopping touch device");
touch_device->stopLvgl();
}
@@ -102,7 +102,7 @@ bool Hx8357Display::stopLvgl() {
std::shared_ptr<tt::hal::touch::TouchDevice> Hx8357Display::getTouchDevice() {
if (touchDevice == nullptr) {
touchDevice = std::reinterpret_pointer_cast<tt::hal::touch::TouchDevice>(createTouch());
LOGGER.info("Created touch device");
LOG_I(TAG, "Created touch device");
}
return touchDevice;