[fix](trx): normalize FT8 history freq and add map locator links
This commit is contained in:
@@ -1341,11 +1341,17 @@ pub async fn run_ft8_decoder(
|
||||
Ok(dur) => dur.as_millis() as i64,
|
||||
Err(_) => 0,
|
||||
};
|
||||
let base_freq_hz = state_rx.borrow().status.freq.hz as f64;
|
||||
let abs_freq_hz = base_freq_hz + res.freq_hz as f64;
|
||||
let msg = Ft8Message {
|
||||
ts_ms,
|
||||
snr_db: res.snr_db,
|
||||
dt_s: res.dt_s,
|
||||
freq_hz: res.freq_hz,
|
||||
freq_hz: if abs_freq_hz.is_finite() && abs_freq_hz > 0.0 {
|
||||
abs_freq_hz as f32
|
||||
} else {
|
||||
res.freq_hz
|
||||
},
|
||||
message: res.text,
|
||||
};
|
||||
histories.record_ft8_message(msg.clone());
|
||||
|
||||
@@ -179,7 +179,12 @@ fn now_unix_seconds() -> u32 {
|
||||
}
|
||||
|
||||
fn offset_to_abs(base_freq_hz: u64, offset_hz: f32) -> u64 {
|
||||
let freq = base_freq_hz as f64 + offset_hz as f64;
|
||||
// Accept both legacy decoder offsets (~kHz audio tones) and already-absolute RF Hz.
|
||||
let raw = offset_hz as f64;
|
||||
if raw.is_finite() && raw >= 100_000.0 {
|
||||
return raw.round() as u64;
|
||||
}
|
||||
let freq = base_freq_hz as f64 + raw;
|
||||
if freq.is_finite() && freq > 0.0 {
|
||||
freq.round() as u64
|
||||
} else {
|
||||
@@ -454,4 +459,10 @@ mod tests {
|
||||
let grid = maidenhead_from_lat_lon(52.2297, 21.0122);
|
||||
assert_eq!(grid.len(), 6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn offset_to_abs_accepts_offset_and_absolute() {
|
||||
assert_eq!(offset_to_abs(14_074_000, 1_237.0), 14_075_237);
|
||||
assert_eq!(offset_to_abs(14_074_000, 14_075_237.0), 14_075_237);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user