|
@@ -635,7 +635,14 @@ impl Clock {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- update_digit(&mut self.dot);
|
|
|
+ // The dot is somewhat sensitive to changes to PWM signal, so for the sake
|
|
|
+ // of consistency, keep the signal on time at the end of the PWM period.
|
|
|
+ // Otherwise the distribution algorithm will sometimes place the on time at
|
|
|
+ // the end of the PWM period in one cycle and at the start of the period for
|
|
|
+ // the next, which results in visual flickers.
|
|
|
+ // update_digit(&mut self.dot);
|
|
|
+ self.dot.pwm_start = DIGIT_MAX_BRIGHTNESS - self.dot.value;
|
|
|
+ self.dot.pwm_end = DIGIT_MAX_BRIGHTNESS;
|
|
|
|
|
|
#[cfg(test)]
|
|
|
println!(
|
|
@@ -761,6 +768,48 @@ mod test {
|
|
|
println!("Refresh halted");
|
|
|
break;
|
|
|
}
|
|
|
+ clock.tubes.iter_mut().for_each(|tube| {
|
|
|
+ tube.digits.iter_mut().for_each(|digit| {
|
|
|
+ digit.updated = false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ clock.dot.updated = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #[test]
|
|
|
+ fn cycle_test() {
|
|
|
+ let mut clock: Clock = Clock::default();
|
|
|
+
|
|
|
+ clock.tubes[0].cycle = Some(CycleSettings {
|
|
|
+ last_digit: clock.tubes[0].last_digit,
|
|
|
+ next_digit: 0,
|
|
|
+ iteration: CYCLE_ITERATIONS,
|
|
|
+ last_fade_duration: DIGIT_FADE_DURATION_MS,
|
|
|
+ });
|
|
|
+
|
|
|
+ clock.rtc_tick(10, 23, 12);
|
|
|
+
|
|
|
+ for cycle in 0..1000 {
|
|
|
+ println!("\nCycle tick: {}", cycle);
|
|
|
+ if clock.cycle_tick() {
|
|
|
+ println!("Cycle halted");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ for tick in 0..1005 {
|
|
|
+ println!("\nRefresh tick: {}", tick);
|
|
|
+ if !clock.fps_tick() {
|
|
|
+ println!("Refresh halted");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ clock.tubes.iter_mut().for_each(|tube| {
|
|
|
+ tube.digits.iter_mut().for_each(|digit| {
|
|
|
+ digit.updated = false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ clock.dot.updated = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|