Skip to content

Commit

Permalink
Fix iq calculation :(
Browse files Browse the repository at this point in the history
  • Loading branch information
billylindeman committed Apr 16, 2021
1 parent b9d895b commit bb1176d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/sdr/dsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct IQ {
impl IQ {
pub fn magnitude(&self) -> u8 {
let i: f32 = (self.i as i16 - 127 as i16).into();
let q: f32 = (self.i as i16 - 127 as i16).into();
let q: f32 = (self.q as i16 - 127 as i16).into();
let mag: u8 = (i * i + q * q).sqrt().round() as u8;
return mag;
}
Expand Down Expand Up @@ -53,9 +53,11 @@ impl<T: AsyncRead> AsyncRead for IQMagnitudeReader<T> {
return Poll::Pending;
}
Poll::Ready(Ok(())) => {
trace!("IQMagnitudeReader got iq-samples, calculating magnitudes");

let filled = inner_bytebuf.filled();
trace!(
"IQMagnitudeReader got {} iq-samples, calculating magnitudes",
filled.len()
);
let ptr = filled.as_ptr() as *const IQ;
let iq = unsafe { std::slice::from_raw_parts::<IQ>(ptr, filled.len() / 2) };

Expand Down

0 comments on commit bb1176d

Please sign in to comment.