From 3b45c14dede85d37e856390859ee829c31cad50d Mon Sep 17 00:00:00 2001 From: Roby Date: Sun, 18 Oct 2026 13:47:28 +0200 Subject: [PATCH] frequency precision display --- app.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 1a5700b..2c7ff18 100644 --- a/app.py +++ b/app.py @@ -471,8 +471,15 @@ def on_message(client, userdata, msg): loc = data.get("Location", "Sconosciuta") def format_freq(f): + # Hz -> MHz senza arrotondare: almeno 5 decimali (10 Hz), 6 se serve (1 Hz). + # Aritmetica intera: nessun errore di virgola mobile. if str(f).isdigit() and int(f) > 0: - return f"{int(f)/1000000:.3f} MHz" + hz = int(f) + mhz, frac = divmod(hz, 1000000) + dec = f"{frac:06d}" + if dec.endswith("0"): + dec = dec[:-1] + return f"{mhz}.{dec} MHz" return str(f) node_info[cid] = {