From 80055076b8b6af141543f466b45c9e29c0bf3b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Sun, 31 Jan 2021 17:41:20 +0100 Subject: [PATCH] lockin: scale output --- src/bin/lockin.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/bin/lockin.rs b/src/bin/lockin.rs index 48c717a..f9e2f58 100644 --- a/src/bin/lockin.rs +++ b/src/bin/lockin.rs @@ -151,16 +151,14 @@ const APP: () = { phase = iir_ch[1][j].update(&mut iir_state[1][j], phase); } - // TODO: IIR filter DC gain needs to be 1/(1 << 16) - // Note(unsafe): range clipping to i16 is ensured by IIR filters above. // Convert to DAC data. for i in 0..dac_samples[0].len() { unsafe { dac_samples[0][i] = - power.to_int_unchecked::() as u16 ^ 0x8000; + (power.to_int_unchecked::() >> 16) as u16 ^ 0x8000; dac_samples[1][i] = - phase.to_int_unchecked::() as u16 ^ 0x8000; + (phase.to_int_unchecked::() >> 16) as u16 ^ 0x8000; } } }