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,12 +1,10 @@
|
||||
#include <Tactility/hal/gps/Satellites.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
constexpr auto TAG = "Satellites";
|
||||
static const auto LOGGER = Logger("Satellites");
|
||||
|
||||
constexpr bool hasTimeElapsed(TickType_t now, TickType_t timeInThePast, TickType_t expireTimeInTicks) {
|
||||
return (TickType_t)(now - timeInThePast) >= expireTimeInTicks;
|
||||
@@ -35,7 +33,9 @@ SatelliteStorage::SatelliteRecord* SatelliteStorage::findUnusedRecord() {
|
||||
if (!result.empty()) {
|
||||
auto* record = &result.front();
|
||||
record->inUse = true;
|
||||
TT_LOG_D(TAG, "Found unused record");
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Found unused record");
|
||||
}
|
||||
return record;
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -53,7 +53,9 @@ SatelliteStorage::SatelliteRecord* SatelliteStorage::findRecordToRecycle() {
|
||||
for (int i = 0; i < records.size(); ++i) {
|
||||
// First try to find a record that is "old enough"
|
||||
if (hasTimeElapsed(now, records[i].lastUpdated, expire_duration)) {
|
||||
TT_LOG_D(TAG, "! [%d] %lu < %lu", i, records[i].lastUpdated, expire_duration);
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("! [{}] {} < {}", i, records[i].lastUpdated, expire_duration);
|
||||
}
|
||||
candidate_index = i;
|
||||
break;
|
||||
}
|
||||
@@ -62,13 +64,17 @@ SatelliteStorage::SatelliteRecord* SatelliteStorage::findRecordToRecycle() {
|
||||
if (records[i].inUse && records[i].lastUpdated < candidate_age) {
|
||||
candidate_index = i;
|
||||
candidate_age = records[i].lastUpdated;
|
||||
TT_LOG_D(TAG, "? [%d] %lu < %lu", i, records[i].lastUpdated, candidate_age);
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("? [{}] {} < {}", i, records[i].lastUpdated, candidate_age);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert(candidate_index != -1);
|
||||
|
||||
TT_LOG_D(TAG, "Recycled record %d", candidate_index);
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Recycled record {}", candidate_index);
|
||||
}
|
||||
|
||||
return &records[candidate_index];
|
||||
}
|
||||
@@ -95,7 +101,9 @@ void SatelliteStorage::notify(const minmea_sat_info& data) {
|
||||
record->inUse = true;
|
||||
record->lastUpdated = kernel::getTicks();
|
||||
record->data = data;
|
||||
TT_LOG_D(TAG, "Updated satellite %d: elevation %d, azimuth %d, snr %d", record->data.nr, record->data.elevation, record->data.elevation, record->data.snr);
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Updated satellite {}: elevation {}, azimuth {}, snr {}", record->data.nr, record->data.elevation, record->data.elevation, record->data.snr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user