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
@@ -1,8 +1,7 @@
#include "ChargeFromAdcVoltage.h"
#include <Tactility/Log.h>
#include <algorithm>
#include <Tactility/Logger.h>
constexpr auto TAG = "ChargeFromAdcV";
static const auto LOGGER = tt::Logger("ChargeFromAdcV");
constexpr auto MAX_VOLTAGE_SAMPLES = 15;
ChargeFromAdcVoltage::ChargeFromAdcVoltage(
@@ -11,12 +10,12 @@ ChargeFromAdcVoltage::ChargeFromAdcVoltage(
float voltageMax
) : configuration(configuration), chargeFromVoltage(voltageMin, voltageMax) {
if (adc_oneshot_new_unit(&configuration.adcConfig, &adcHandle) != ESP_OK) {
TT_LOG_E(TAG, "ADC config failed");
LOGGER.error("ADC config failed");
return;
}
if (adc_oneshot_config_channel(adcHandle, configuration.adcChannel, &configuration.adcChannelConfig) != ESP_OK) {
TT_LOG_E(TAG, "ADC channel config failed");
LOGGER.error("ADC channel config failed");
adc_oneshot_del_unit(adcHandle);
return;
@@ -33,10 +32,12 @@ 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;
TT_LOG_V(TAG, "Raw = %d, voltage = %lu", raw, output);
if (LOGGER.isLoggingVerbose()) {
LOGGER.verbose("Raw = {}, voltage = {}", raw, output);
}
return true;
} else {
TT_LOG_E(TAG, "Read failed");
LOGGER.error("Read failed");
return false;
}
}
@@ -1,9 +1,9 @@
#include "ChargeFromVoltage.h"
#include <Tactility/Logger.h>
#include <algorithm>
#include <Tactility/Log.h>
constexpr auto* TAG = "ChargeFromVoltage";
const static auto LOGGER = tt::Logger("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);
TT_LOG_D(TAG, "mV = %lu, scaled = %.2f, factor = %.2f, result = %d", milliVolt, volts, voltage_factor, charge_level);
LOGGER.debug("mV = {}, scaled = {}, factor = {:.2f}, result = {}", milliVolt, volts, voltage_factor, charge_level);
return charge_level;
}