Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

starnote spectrum #178

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sfy-buoy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ git = "https://github.com/gauteh/notecard-rs"
half = { version = "2.4", features = [ "use-intrinsics", "bytemuck", "serde" ] }

[features]
default = [ "build-bin" ]
default = [ "build-bin", "ext-gps", "spectrum" ]
continuous = []
continuous-post = [ "continuous", "dep:ufmt" ]
20Hz = ["fir"]
raw = [ "storage" ]
fir = []
storage = []
ext-gps = [ "dep:serde-json-core"]
spectrum = []
surf = []
ice = []
target-test = [ "storage" ]
Expand Down
1 change: 1 addition & 0 deletions sfy-buoy/sfy-artemis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ surf = [ "sfy/surf" ]
ice = [ "sfy/ice" ]
deploy = []
defmt-serial = [ "dep:ufmt", "dep:defmt-serial" ]
spectrum = [ "sfy/spectrum" ]

3 changes: 3 additions & 0 deletions sfy-buoy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub mod waves;
#[cfg(feature = "ext-gps")]
pub mod gps;

#[cfg(feature = "spectrum")]
pub mod welch;

use axl::AxlPacket;
#[cfg(feature = "storage")]
use storage::Storage;
Expand Down
38 changes: 38 additions & 0 deletions sfy-buoy/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,44 @@ impl<I2C: Read + Write> Notecarrier<I2C> {
.wait(delay)?;
}

#[cfg(feature = "spectrum")]
{
defmt::debug!("setting up spectrum templates..");

#[derive(serde::Serialize, Default)]
struct SpectrumMetaTemplate {
timestamp: u32,

_ltime: u32,
_lon: f32,
_lat: f32,

length: u32,
}

let meta_template = SpectrumMetaTemplate {
timestamp: 18,

_ltime: 14,
_lon: 14.1,
_lat: 14.1,

length: 14,
};

defmt::debug!("setting up template for spectrum");
self.note()
.template(
delay,
Some("spec.qo"),
Some(meta_template),
Some(crate::welch::WELCH_OUTN as u32),
notecard::template::Compact, // sync over starnote/lora as well
Some(10), // starnote/lora port
)?
.wait(delay)?;
}

Ok(())
}

Expand Down
19 changes: 19 additions & 0 deletions sfy-buoy/src/welch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use heapless::Vec;

pub const NFFT: usize = 4096;
pub const NSEG: usize = 4096;
pub const NOVERLAP: usize = NSEG / 2;

// Cut-off frequencies for spectrum.
pub const f0: f32 = 0.01; // Hz
pub const f1: f32 = 5.0; // Hz

pub const WELCH_PACKET_SZ: usize = 124;

/// Maximum length of base64 string
pub const WELCH_OUTN: usize = { 6 * WELCH_PACKET_SZ * 2 } * 4 / 3 + 4;

pub struct Welch {
buf: Vec<f64, NSEG>,
spec: Vec<f64, NFFT>,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More stats, like breakers?

}
Loading