Commit 1fee8f07 authored by Ethan Frei's avatar Ethan Frei
Browse files

fixing the timer to not reset the syst counter every time the button is pressed

parent e010ba32
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -97,11 +97,12 @@ impl<'a> Timer<'a> {
    fn add_seconds(&mut self, seconds: u16) {
        let new_countdown = self.state.countdown.unwrap_or(0) + seconds;
        if new_countdown == 0 { return } // short circuit if this is the case
        self.state.countdown = Some(new_countdown);

        // Start countdown
        if self.state.countdown.is_none() {
            // If not currently counting down - start system timer
            self.ashi.start_syst();
        }
        self.state.countdown = Some(new_countdown);
    }
}

#[cfg(test)]
+3 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ extern crate lib;
mod blue_pill_ashi;

// use core::fmt::Write;
// use cortex_m_semihosting::hio::{self, HStdout};
// use cortex_m_semihosting::hio::{self};//, HStdout};
use cortex_m::peripheral::syst::SystClkSource;
use rtfm::{app, Threshold};
use hal::prelude::*;
@@ -106,6 +106,8 @@ fn init(mut p: init::Peripherals, _r: init::Resources) -> init::LateResources {

    // --------------------------------------------------------

    // writeln!(hio::hstdout().unwrap(), "hsitrim: {:?}", rcc.cr.read().hsitrim().bits()).unwrap();

    init::LateResources {
        LED_PIN: led,
        // STDOUT: hio::hstdout().unwrap(),