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
@@ -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;
}