From 2644f280e8957e4a4a661b5c9d0631489a366b5c Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Mon, 29 Nov 2021 17:05:38 -0600 Subject: Skip err accumulation if calculated error is 0.0 during calibration --- lora_pkt_fwd/src/lora_pkt_fwd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lora_pkt_fwd/src') diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index a971dc0..d59b59e 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -3622,9 +3622,11 @@ void thread_valid(void) { init_acc = 0.0; } else { if (init_cpt < XERR_INIT_AVG) { - /* initial accumulation */ - init_acc += xtal_err_cpy; - ++init_cpt; + if (xtal_err_cpy > 0.0) { + /* initial accumulation */ + init_acc += xtal_err_cpy; + ++init_cpt; + } } else if (init_cpt == XERR_INIT_AVG) { /* initial average calculation */ pthread_mutex_lock(&mx_xcorr); -- cgit v1.2.3