From 3d08dca5c187bc9159c3ae382325e5f4742311dc Mon Sep 17 00:00:00 2001 From: Kate Nesana <63879779+nesanakin@users.noreply.github.com> Date: Wed, 11 Feb 2026 16:06:20 -0700 Subject: [PATCH] Fixes numeric precision issues in ground unit software. * Allow LoRa radio frequency to be set to non-integer MHz values. Fixes #25. * Retain full precision of GPS coordinates sent from Air unit. Fixes #26. --- Software/LokoGround Firmware/main_1.1.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Software/LokoGround Firmware/main_1.1.py b/Software/LokoGround Firmware/main_1.1.py index 8f876c3..8732898 100644 --- a/Software/LokoGround Firmware/main_1.1.py +++ b/Software/LokoGround Firmware/main_1.1.py @@ -389,7 +389,7 @@ def battery_level(): def lora_set(freq_hz): # Convert Hz to MHz for LoRa module - freq_mhz = freq_hz // 1000000 + freq_mhz = freq_hz / 1000000 LORA_UART.write("AT+MODE=TEST") sleep_ms(1000) @@ -486,8 +486,8 @@ def bin_unpack_lat_lon_24(packed_data): if lat_lon_scaled & 0x800000: # Check if the sign bit is set for a negative value lat_lon_scaled -= 0x1000000 # Convert to signed 24-bit integer - scaling_factor = 10000.0 - lat_lon = lat_lon_scaled / scaling_factor + lat_lon = f'{lat_lon_scaled}' + lat_lon = lat_lon[:-4] + '.' + lat_lon[-4:] return lat_lon @@ -497,8 +497,8 @@ def bin_unpack_lat_lon_32(packed_data): if lat_lon_scaled & 0x80000000: # Check if the sign bit is set for a negative value lat_lon_scaled -= 0x100000000 # Convert to signed 32-bit integer - scaling_factor = 1000000.0 - lat_lon = lat_lon_scaled / scaling_factor + lat_lon = f'{lat_lon_scaled}' + lat_lon = lat_lon[:-6] + '.' + lat_lon[-6:] return lat_lon