diff --git a/src/iir.rs b/src/iir.rs index ff2d011..0c34306 100644 --- a/src/iir.rs +++ b/src/iir.rs @@ -105,14 +105,4 @@ impl IIR { xy[xy.len() / 2] = y0; y0 } - - pub fn update_from_adc_sample( - &mut self, - sample: u16, - state: &mut IIRState, - ) -> u16 { - let x0 = f32::from(sample as i16); - let y0 = self.update(state, x0); - y0 as i16 as u16 ^ 0x8000 - } } diff --git a/src/main.rs b/src/main.rs index b5fff64..1805370 100644 --- a/src/main.rs +++ b/src/main.rs @@ -742,11 +742,19 @@ const APP: () = { c.resources.adcs.transfer_complete_handler(); for (adc0, adc1) in adc0_samples.iter().zip(adc1_samples.iter()) { - let result_adc0 = c.resources.iir_ch[0] - .update_from_adc_sample(*adc0, &mut c.resources.iir_state[0]); + let result_adc0 = { + let x0 = f32::from(*adc0 as i16); + let y0 = c.resources.iir_ch[0] + .update(&mut c.resources.iir_state[0], x0); + y0 as i16 as u16 ^ 0x8000 + }; - let result_adc1 = c.resources.iir_ch[1] - .update_from_adc_sample(*adc1, &mut c.resources.iir_state[1]); + let result_adc1 = { + let x1 = f32::from(*adc1 as i16); + let y1 = c.resources.iir_ch[1] + .update(&mut c.resources.iir_state[1], x1); + y1 as i16 as u16 ^ 0x8000 + }; c.resources .dacs