throttle GPS sync messages

This commit is contained in:
Bob 2025-12-06 13:33:18 -08:00
parent 120c864f73
commit c4673e2249
1 changed files with 12 additions and 5 deletions

View File

@ -9,7 +9,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <inttypes.h> // Required for PRIu64 #include <inttypes.h>
// --- SAFE WIRING FOR ESP32-C5 --- // --- SAFE WIRING FOR ESP32-C5 ---
#define GPS_UART_NUM UART_NUM_1 #define GPS_UART_NUM UART_NUM_1
@ -100,6 +100,7 @@ void gps_force_next_update(void) {
static void gps_task(void* arg) { static void gps_task(void* arg) {
char line[128]; char line[128];
int pos = 0; int pos = 0;
static int log_counter = 0; // NEW: Counter to throttle logs
while (1) { while (1) {
uint8_t data; uint8_t data;
@ -132,6 +133,7 @@ static void gps_task(void* arg) {
if (force_sync_update) { if (force_sync_update) {
ESP_LOGW(TAG, "GPS sync SNAP: Offset forced to %lld us", monotonic_offset_us); ESP_LOGW(TAG, "GPS sync SNAP: Offset forced to %lld us", monotonic_offset_us);
force_sync_update = false; force_sync_update = false;
log_counter = 0; // Ensure we see the log immediately after a snap
} }
} else { } else {
// Low-pass filter: 90% old + 10% new // Low-pass filter: 90% old + 10% new
@ -140,10 +142,15 @@ static void gps_task(void* arg) {
gps_has_fix = true; gps_has_fix = true;
ESP_LOGI(TAG, "GPS sync: %04d-%02d-%02d %02d:%02d:%02d, offset=%lld us", // LOGGING THROTTLE: Only print every 60th update (approx 60 seconds)
gps_tm.tm_year + 1900, gps_tm.tm_mon + 1, gps_tm.tm_mday, if (log_counter == 0) {
gps_tm.tm_hour, gps_tm.tm_min, gps_tm.tm_sec, ESP_LOGI(TAG, "GPS sync: %04d-%02d-%02d %02d:%02d:%02d, offset=%lld us",
monotonic_offset_us); gps_tm.tm_year + 1900, gps_tm.tm_mon + 1, gps_tm.tm_mday,
gps_tm.tm_hour, gps_tm.tm_min, gps_tm.tm_sec,
monotonic_offset_us);
log_counter = 60;
}
log_counter--;
} }
xSemaphoreGive(sync_mutex); xSemaphoreGive(sync_mutex);
} else { } else {