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
+14 -12
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;
}