New logging and more (#446)

- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
This commit is contained in:
Ken Van Hoeylandt
2026-01-06 22:35:39 +01:00
committed by GitHub
parent 719f7bcece
commit f620255c41
188 changed files with 1973 additions and 1755 deletions
+22 -22
View File
@@ -1,6 +1,6 @@
#include "UnPhoneFeatures.h"
#include <Tactility/Log.h>
#include <Tactility/Logger.h>
#include <Tactility/app/App.h>
#include <Tactility/kernel/Kernel.h>
@@ -9,6 +9,8 @@
#include <esp_io_expander.h>
#include <esp_sleep.h>
static const auto LOGGER = tt::Logger("unPhoneFeatures");
namespace pin {
static const gpio_num_t BUTTON1 = GPIO_NUM_45; // left button
static const gpio_num_t BUTTON2 = GPIO_NUM_0; // middle button
@@ -27,8 +29,6 @@ namespace expanderpin {
static const esp_io_expander_pin_num_t VIBE = IO_EXPANDER_PIN_NUM_7;
} // namespace expanderpin
#define TAG "unhpone_features"
// TODO: Make part of a new type of UnPhoneFeatures data struct that holds all the thread-related data
QueueHandle_t interruptQueue;
@@ -42,7 +42,7 @@ static int32_t buttonHandlingThreadMain(const bool* interrupted) {
while (!*interrupted) {
if (xQueueReceive(interruptQueue, &pinNumber, portMAX_DELAY)) {
// The buttons might generate more than 1 click because of how they are built
TT_LOG_I(TAG, "Pressed button %d", pinNumber);
LOGGER.info("Pressed button {}", pinNumber);
if (pinNumber == pin::BUTTON1) {
tt::app::stop();
}
@@ -75,7 +75,7 @@ bool UnPhoneFeatures::initPowerSwitch() {
};
if (gpio_config(&config) != ESP_OK) {
TT_LOG_E(TAG, "Power pin init failed");
LOGGER.error("Power pin init failed");
return false;
}
@@ -83,14 +83,14 @@ bool UnPhoneFeatures::initPowerSwitch() {
rtc_gpio_pulldown_en(pin::POWER_SWITCH) == ESP_OK) {
return true;
} else {
TT_LOG_E(TAG, "Failed to set RTC for power switch");
LOGGER.error("Failed to set RTC for power switch");
return false;
}
}
bool UnPhoneFeatures::initNavButtons() {
if (!initGpioExpander()) {
TT_LOG_E(TAG, "GPIO expander init failed");
LOGGER.error("GPIO expander init failed");
return false;
}
@@ -125,17 +125,17 @@ bool UnPhoneFeatures::initNavButtons() {
};
if (gpio_config(&config) != ESP_OK) {
TT_LOG_E(TAG, "Nav button pin init failed");
LOGGER.error("Nav button pin init failed");
return false;
}
if (
gpio_install_isr_service(0) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON1, navButtonInterruptHandler, (void*)pin::BUTTON1) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, (void*)pin::BUTTON2) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, (void*)pin::BUTTON3) != ESP_OK
gpio_isr_handler_add(pin::BUTTON1, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON1)) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON2, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON2)) != ESP_OK ||
gpio_isr_handler_add(pin::BUTTON3, navButtonInterruptHandler, reinterpret_cast<void*>(pin::BUTTON3)) != ESP_OK
) {
TT_LOG_E(TAG, "Nav buttons ISR init failed");
LOGGER.error("Nav buttons ISR init failed");
return false;
}
@@ -156,7 +156,7 @@ bool UnPhoneFeatures::initOutputPins() {
};
if (gpio_config(&config) != ESP_OK) {
TT_LOG_E(TAG, "Output pin init failed");
LOGGER.error("Output pin init failed");
return false;
}
@@ -167,7 +167,7 @@ bool UnPhoneFeatures::initGpioExpander() {
// ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110 corresponds with 0x26 from the docs at
// https://gitlab.com/hamishcunningham/unphonelibrary/-/blob/main/unPhone.h?ref_type=heads#L206
if (esp_io_expander_new_i2c_tca95xx_16bit(I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9555_ADDRESS_110, &ioExpander) != ESP_OK) {
TT_LOG_E(TAG, "IO expander init failed");
LOGGER.error("IO expander init failed");
return false;
}
assert(ioExpander != nullptr);
@@ -201,25 +201,25 @@ bool UnPhoneFeatures::initGpioExpander() {
}
bool UnPhoneFeatures::init() {
TT_LOG_I(TAG, "init");
LOGGER.info("init");
if (!initGpioExpander()) {
TT_LOG_E(TAG, "GPIO expander init failed");
LOGGER.error("GPIO expander init failed");
return false;
}
if (!initNavButtons()) {
TT_LOG_E(TAG, "Input pin init failed");
LOGGER.error("Input pin init failed");
return false;
}
if (!initOutputPins()) {
TT_LOG_E(TAG, "Output pin init failed");
LOGGER.error("Output pin init failed");
return false;
}
if (!initPowerSwitch()) {
TT_LOG_E(TAG, "Power button init failed");
LOGGER.error("Power button init failed");
return false;
}
@@ -231,7 +231,7 @@ void UnPhoneFeatures::printInfo() const {
batteryManagement->printInfo();
bool backlight_power;
const char* backlight_power_state = getBacklightPower(backlight_power) && backlight_power ? "on" : "off";
TT_LOG_I(TAG, "Backlight: %s", backlight_power_state);
LOGGER.info("Backlight: {}", backlight_power_state);
}
bool UnPhoneFeatures::setRgbLed(bool red, bool green, bool blue) const {
@@ -286,11 +286,11 @@ void UnPhoneFeatures::turnPeripheralsOff() const {
bool UnPhoneFeatures::setShipping(bool on) const {
if (on) {
TT_LOG_W(TAG, "setShipping: on");
LOGGER.warn("setShipping: on");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Disabled);
batteryManagement->setBatFetOn(false);
} else {
TT_LOG_W(TAG, "setShipping: off");
LOGGER.warn("setShipping: off");
batteryManagement->setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s);
batteryManagement->setBatFetOn(true);
}