From c4e3be1d05a4c87e10a64da4ccaa73838e17a8db Mon Sep 17 00:00:00 2001 From: topquark12 Date: Sat, 16 Jan 2021 11:04:24 +0800 Subject: [PATCH] fix pid.rs test, exclude dfu from test --- src/dfu.rs | 1 + src/pid.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dfu.rs b/src/dfu.rs index 95a4085..773fb96 100644 --- a/src/dfu.rs +++ b/src/dfu.rs @@ -14,6 +14,7 @@ pub unsafe fn set_dfu_trigger() { /// Called by reset handler in lib.rs immediately after reset. /// This function should not be called outside of reset handler as /// bootloader expects MCU to be in reset state when called. +#[cfg(target_arch = "arm")] #[pre_init] unsafe fn __pre_init() { if _dfu_msg == DFU_TRIG_MSG { diff --git a/src/pid.rs b/src/pid.rs index b2a3f61..3251d6a 100644 --- a/src/pid.rs +++ b/src/pid.rs @@ -172,11 +172,12 @@ mod test { let mut values = [DEFAULT; DELAY]; let mut t = 0; let mut total_t = 0; + let mut output: f64 = 0.0; let target = (TARGET - ERROR)..=(TARGET + ERROR); while !values.iter().all(|value| target.contains(value)) && total_t < CYCLE_LIMIT { let next_t = (t + 1) % DELAY; // Feed the oldest temperature - let output = pid.update(values[next_t], Time::new::(1.0), values[next_t]); + output = pid.update(values[next_t], Time::new::(1.0), ElectricCurrent::new::(output)); // Overwrite oldest with previous temperature - output values[next_t] = values[t] + output - (values[t] - DEFAULT) * LOSS; t = next_t;