Browse Source

First Transmitting version

Fixed I2C
Fixed minor bugs
main
Sebastian 7 months ago
parent
commit
ab080c8435
  1. 2
      Cargo.toml
  2. 14
      src/application/gps.rs
  3. 16
      src/application/mod.rs
  4. 1
      src/application/setup.rs

2
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 # <-

14
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

16
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();

1
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,
}
}
Loading…
Cancel
Save