diff --git a/Cargo.toml b/Cargo.toml index 2f5b35b..86df9fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ codegen-units = 1 debug = 2 debug-assertions = false # <- incremental = false -lto = 'fat' +#lto = 'fat' opt-level = 3 # <- overflow-checks = false # <- diff --git a/src/application/gps.rs b/src/application/gps.rs index d06939b..f21a551 100644 --- a/src/application/gps.rs +++ b/src/application/gps.rs @@ -18,12 +18,14 @@ impl App { if let Some(result) = self.gps_parser.parse_from_byte(byte) { match result { Ok(ParseResult::GGA(Some(gga))) => { - time::set(&gga.time); - self.locator = loc::locator_from_coordinates( - gga.latitude.as_f64(), - gga.longitude.as_f64(), - ); - defmt::info!("Got GGA. New locator: {}", self.locator.as_str()); + if !self.transmitting { + time::set(&gga.time); + self.locator = loc::locator_from_coordinates( + gga.latitude.as_f64(), + gga.longitude.as_f64(), + ); + defmt::info!("Got GGA. New locator: {}", self.locator.as_str()); + } } Ok(_) => {} // Some other sentences.. Err(_) => {} // Got parse error diff --git a/src/application/mod.rs b/src/application/mod.rs index a0699e1..8fda9a0 100644 --- a/src/application/mod.rs +++ b/src/application/mod.rs @@ -41,6 +41,7 @@ pub struct App { >, gps_parser: Parser, locator: arrayvec::ArrayString<6>, + transmitting: bool, } // For PLL with 800MHz @@ -87,7 +88,6 @@ impl App { defmt::info!("PLL setup complete."); - let mut transmitting = false; let mut symbol_start = time::get(); let mut symbol_idx: usize = 0; let mut message: [u8; 162] = [0; 162]; @@ -95,7 +95,7 @@ impl App { loop { self.poll_gps(); - if !transmitting { + if !self.transmitting { let ts = time::get(); if self.locator.len() > 0 && ts.minutes % 2 == 0 @@ -103,6 +103,7 @@ impl App { && ts.seconds < 2.0 { defmt::info!("Starting tranmission"); + self.transmitting = true; message = wspr::encode_message(&callsign, &self.locator, 27); symbol_start = ts; symbol_idx = 0; @@ -115,22 +116,27 @@ impl App { } } else { let ts = time::get(); - if (ts.seconds - symbol_start.seconds) >= 0.683 { + let delta_sec = (ts.seconds - symbol_start.seconds) + + (ts.minutes - symbol_start.minutes) as f32 * 60.0; + if delta_sec >= 0.683 { symbol_start = ts; symbol_idx += 1; + if symbol_idx < 162 { si_pll.write_synth_params( &mut self.i2c, si5153::Multisynth::MS0, &WSPR_SYMBOLS[message[symbol_idx] as usize], ); + defmt::info!("Tranmitting Symbol {}", symbol_idx); } else { si_pll.disable_ms_output(&mut self.i2c, si5153::Multisynth::MS0); - transmitting = false; + self.transmitting = false; + defmt::info!("Transmission ended"); } } } - wfi(); + //wfi(); } //exit(); diff --git a/src/application/setup.rs b/src/application/setup.rs index d8a1974..87b0f70 100644 --- a/src/application/setup.rs +++ b/src/application/setup.rs @@ -86,5 +86,6 @@ pub fn setup(cp: cortex_m::peripheral::Peripherals, dp: stm32::Peripherals) -> A i2c, gps_parser, locator: arrayvec::ArrayString::new(), + transmitting: false, } }