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:
committed by
GitHub
parent
719f7bcece
commit
f620255c41
@@ -1,10 +1,11 @@
|
||||
#include "Xpt2046Power.h"
|
||||
#include "Xpt2046Touch.h"
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/hal/Device.h>
|
||||
|
||||
constexpr auto TAG = "Xpt2046Power";
|
||||
static const auto LOGGER = tt::Logger("Xpt2046Power");
|
||||
|
||||
constexpr auto BATTERY_VOLTAGE_MIN = 3.2f;
|
||||
constexpr auto BATTERY_VOLTAGE_MAX = 4.2f;
|
||||
constexpr auto MAX_VOLTAGE_SAMPLES = 15;
|
||||
@@ -13,12 +14,12 @@ static std::shared_ptr<Xpt2046Touch> findXp2046TouchDevice() {
|
||||
// Make a safe copy
|
||||
auto touch = tt::hal::findFirstDevice<tt::hal::touch::TouchDevice>(tt::hal::Device::Type::Touch);
|
||||
if (touch == nullptr) {
|
||||
TT_LOG_E(TAG, "Touch device not found");
|
||||
LOGGER.error("Touch device not found");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (touch->getName() != "XPT2046") {
|
||||
TT_LOG_E(TAG, "Touch device name mismatch");
|
||||
LOGGER.error("Touch device name mismatch");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -30,7 +31,7 @@ static uint8_t estimateChargeLevelFromVoltage(uint32_t milliVolt) {
|
||||
float voltage_percentage = (volts - BATTERY_VOLTAGE_MIN) / (BATTERY_VOLTAGE_MAX - BATTERY_VOLTAGE_MIN);
|
||||
float voltage_factor = std::min(1.0f, voltage_percentage);
|
||||
auto charge_level = (uint8_t) (voltage_factor * 100.f);
|
||||
TT_LOG_V(TAG, "mV = %lu, scaled = %.2f, factor = %.2f, result = %d", milliVolt, volts, voltage_factor, charge_level);
|
||||
LOGGER.verbose("mV = {}, scaled = {}, factor = {}, result = {}", milliVolt, volts, voltage_factor, charge_level);
|
||||
return charge_level;
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ bool Xpt2046Power::readBatteryVoltageOnce(uint32_t& output) {
|
||||
if (xptTouch == nullptr) {
|
||||
xptTouch = findXp2046TouchDevice();
|
||||
if (xptTouch == nullptr) {
|
||||
TT_LOG_E(TAG, "XPT2046 touch device not found");
|
||||
LOGGER.error("XPT2046 touch device not found");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user