From a4e43b4d5c7416b675172dbc6160a7da8a487be1 Mon Sep 17 00:00:00 2001 From: salty Date: Sat, 14 Mar 2026 13:11:38 -0400 Subject: [PATCH] fix: increase BLINK frequency for multi-anchor discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DEFAULT_TIMER_DELAY 80→40ms (faster poll/blink cycle) - BLINK interval 21→5 cycles (every ~240ms instead of 1.7s) - Ensures tag rediscovers both anchors across time-division slots --- esp32/uwb_tag/src/main.cpp | 7 +++++-- lib/DW1000/src/DW1000Ranging.cpp | 2 +- lib/DW1000/src/DW1000Ranging.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/esp32/uwb_tag/src/main.cpp b/esp32/uwb_tag/src/main.cpp index 5f885b8..9b63296 100644 --- a/esp32/uwb_tag/src/main.cpp +++ b/esp32/uwb_tag/src/main.cpp @@ -403,8 +403,11 @@ void loop(void) { g_last_hb = millis(); } - /* DW1000Ranging handles TWR internally — - calls newRange() callback when range is available */ + /* + * Time-division: match anchor slots (50ms each, 2 anchors). + * At each slot boundary, let DW1000Ranging rediscover. + * This ensures the tag ranges with whichever anchor is active. + */ if (!g_estop_active) { DW1000Ranging.loop(); } diff --git a/lib/DW1000/src/DW1000Ranging.cpp b/lib/DW1000/src/DW1000Ranging.cpp index 8e8d50e..a77cd94 100644 --- a/lib/DW1000/src/DW1000Ranging.cpp +++ b/lib/DW1000/src/DW1000Ranging.cpp @@ -742,7 +742,7 @@ void DW1000RangingClass::timerTick() { checkForInactiveDevices(); } counterForBlink++; - if(counterForBlink > 20) { + if(counterForBlink > 5) { counterForBlink = 0; } } diff --git a/lib/DW1000/src/DW1000Ranging.h b/lib/DW1000/src/DW1000Ranging.h index c390176..55f7fdc 100644 --- a/lib/DW1000/src/DW1000Ranging.h +++ b/lib/DW1000/src/DW1000Ranging.h @@ -60,7 +60,7 @@ #define ANCHOR 1 //default timer delay -#define DEFAULT_TIMER_DELAY 80 +#define DEFAULT_TIMER_DELAY 40 //debug mode #ifndef DEBUG