Restored tuning via encoder
This commit is contained in:
parent
2dc4af2145
commit
16d6e842a2
21
src/main.rs
21
src/main.rs
|
@ -73,8 +73,6 @@ mod app {
|
|||
|
||||
#[local]
|
||||
struct Local {
|
||||
pll: si5153::Si5153<I2c<I2C1>>,
|
||||
i2c: I2c<I2C1>,
|
||||
board_led: gpioc::PC13<Output<PushPull>>,
|
||||
rx_en: gpioa::PA7<Output<PushPull>>,
|
||||
//mic_in: gpio::Pin<'A', 4, Analog>,
|
||||
|
@ -102,6 +100,9 @@ mod app {
|
|||
|
||||
#[shared]
|
||||
struct Shared {
|
||||
pll: si5153::Si5153<I2c<I2C1>>,
|
||||
i2c: I2c<I2C1>,
|
||||
|
||||
audio_buffer: Option<&'static mut [u16; 128]>,
|
||||
}
|
||||
|
||||
|
@ -271,11 +272,11 @@ mod app {
|
|||
|
||||
(
|
||||
Shared {
|
||||
i2c,
|
||||
pll,
|
||||
audio_buffer: Some(audio_buff2),
|
||||
},
|
||||
Local {
|
||||
i2c,
|
||||
pll,
|
||||
board_led,
|
||||
rx_en,
|
||||
//mic_in,
|
||||
|
@ -296,9 +297,15 @@ mod app {
|
|||
)
|
||||
}
|
||||
|
||||
#[task(priority = 0, local = [ui])]
|
||||
async fn update_display(cx: update_display::Context, mut row: [Complex<f32>; 128]) {
|
||||
cx.local.ui.update_display(row);
|
||||
#[task(priority = 0, local = [ui], shared=[pll, i2c])]
|
||||
async fn update_display(cx: update_display::Context, row: [Complex<f32>; 128]) {
|
||||
let pll = cx.shared.pll;
|
||||
let i2c = cx.shared.i2c;
|
||||
let ui = cx.local.ui;
|
||||
|
||||
(pll, i2c).lock(|pll, i2c| {
|
||||
ui.update_display(row, pll, i2c);
|
||||
});
|
||||
}
|
||||
|
||||
#[task(binds = DMA2_STREAM0, local = [adc_transfer, iq_buffer, board_led, i_offset, q_offset, usb_filter, audio_max_duty], shared = [audio_buffer])]
|
||||
|
|
25
src/ui.rs
25
src/ui.rs
|
@ -36,6 +36,8 @@ use num_traits::{float::Float, Pow};
|
|||
|
||||
use core::fmt::Write;
|
||||
|
||||
use crate::si5153;
|
||||
|
||||
type EncoderA = gpio::Pin<'A', 0, Input>;
|
||||
type EncoderB = gpio::Pin<'A', 1, Input>;
|
||||
|
||||
|
@ -119,7 +121,12 @@ impl UI {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update_display(&mut self, mut row: [Complex<f32>; 128]) {
|
||||
pub fn update_display(
|
||||
&mut self,
|
||||
mut row: [Complex<f32>; 128],
|
||||
pll: &mut si5153::Si5153<I2c<I2C1>>,
|
||||
i2c: &mut I2c<I2C1>,
|
||||
) {
|
||||
let buffers_per_row = 4;
|
||||
|
||||
let row = cfft_128(&mut row);
|
||||
|
@ -171,17 +178,11 @@ impl UI {
|
|||
|
||||
if diff >= 1 || diff <= -1 {
|
||||
self.carrier_freq = (self.carrier_freq as i32 + diff * 100) as u32;
|
||||
/*
|
||||
self.pll
|
||||
.set_pll_freq(self.i2c, si5153::PLL::A, self.carrier_freq * 100);
|
||||
self.pll
|
||||
.set_ms_freq(self.i2c, si5153::Multisynth::MS0, *cx.local.carrier_freq);
|
||||
cx.local.pll.set_ms_freq(
|
||||
cx.local.i2c,
|
||||
si5153::Multisynth::MS1,
|
||||
*cx.local.carrier_freq,
|
||||
);
|
||||
*/
|
||||
|
||||
pll.set_pll_freq(i2c, si5153::PLL::A, self.carrier_freq * 100);
|
||||
pll.set_ms_freq(i2c, si5153::Multisynth::MS0, self.carrier_freq);
|
||||
pll.set_ms_freq(i2c, si5153::Multisynth::MS1, self.carrier_freq);
|
||||
|
||||
Rectangle::new(Point::new(0, 0), Size::new(160, 28))
|
||||
.into_styled(PrimitiveStyle::with_fill(Rgb565::BLACK))
|
||||
.draw(&mut self.disp)
|
||||
|
|
Loading…
Reference in New Issue