pub fn shortcut(&mut self, shortcut: TimerShortcut, compare_num: usize) {
        // todo: DRY
        self.regs.shorts.modify(|_, w| match compare_num {
            0 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare0_clear().disabled();
                    w.compare0_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare0_clear().enabled();
                    w.compare0_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare0_clear().enabled();
                    w.compare0_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare0_clear().disabled();
                    w.compare0_stop().disabled()
                }
            },
            1 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare1_clear().disabled();
                    w.compare1_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare1_clear().enabled();
                    w.compare1_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare1_clear().enabled();
                    w.compare1_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare1_clear().disabled();
                    w.compare1_stop().disabled()
                }
            },
            2 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare2_clear().disabled();
                    w.compare2_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare2_clear().enabled();
                    w.compare2_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare2_clear().enabled();
                    w.compare2_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare2_clear().disabled();
                    w.compare2_stop().disabled()
                }
            },
            3 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare3_clear().disabled();
                    w.compare3_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare3_clear().enabled();
                    w.compare3_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare3_clear().enabled();
                    w.compare3_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare3_clear().disabled();
                    w.compare3_stop().disabled()
                }
            },
            _ => panic!("compare number must be 0 - 5"),
        });
        // todo: compare4 and 5 for the other timers??
    }
/// Set up a shortcut associated with an event. This can allow a timer event to
/// automatically stop or clear the timer.
Set up a shortcut associated with an event. This can allow a timer event to
automatically stop or clear the timer.
Set up a shortcut associated with an event . This can allow a timer event to automatically stop or clear the timer .
pub fn shortcut(&mut self, shortcut: TimerShortcut, compare_num: usize) {
        // todo: DRY
        self.regs.shorts.modify(|_, w| match compare_num {
            0 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare0_clear().disabled();
                    w.compare0_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare0_clear().enabled();
                    w.compare0_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare0_clear().enabled();
                    w.compare0_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare0_clear().disabled();
                    w.compare0_stop().disabled()
                }
            },
            1 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare1_clear().disabled();
                    w.compare1_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare1_clear().enabled();
                    w.compare1_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare1_clear().enabled();
                    w.compare1_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare1_clear().disabled();
                    w.compare1_stop().disabled()
                }
            },
            2 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare2_clear().disabled();
                    w.compare2_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare2_clear().enabled();
                    w.compare2_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare2_clear().enabled();
                    w.compare2_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare2_clear().disabled();
                    w.compare2_stop().disabled()
                }
            },
            3 => match shortcut {
                TimerShortcut::Stop => {
                    w.compare3_clear().disabled();
                    w.compare3_stop().enabled()
                }
                TimerShortcut::Clear => {
                    w.compare3_clear().enabled();
                    w.compare3_stop().disabled()
                }
                TimerShortcut::StopClear => {
                    w.compare3_clear().enabled();
                    w.compare3_stop().enabled()
                }
                TimerShortcut::Disabled => {
                    w.compare3_clear().disabled();
                    w.compare3_stop().disabled()
                }
            },
            _ => panic!("compare number must be 0 - 5"),
        });
        // todo: compare4 and 5 for the other timers??
    }
pub fn shortcut ( & mut self , shortcut : TimerShortcut , compare_num : usize ) { // todo: DRY self . regs . shorts . modify ( | _ , w | match compare_num { 0 => match shortcut { TimerShortcut :: Stop => { w . compare0_clear ( ) . disabled ( ) ; w . compare0_stop ( ) . enabled ( ) } TimerShortcut :: Clear => { w . compare0_clear ( ) . enabled ( ) ; w . compare0_stop ( ) . disabled ( ) } TimerShortcut :: StopClear => { w . compare0_clear ( ) . enabled ( ) ; w . compare0_stop ( ) . enabled ( ) } TimerShortcut :: Disabled => { w . compare0_clear ( ) . disabled ( ) ; w . compare0_stop ( ) . disabled ( ) } } , 1 => match shortcut { TimerShortcut :: Stop => { w . compare1_clear ( ) . disabled ( ) ; w . compare1_stop ( ) . enabled ( ) } TimerShortcut :: Clear => { w . compare1_clear ( ) . enabled ( ) ; w . compare1_stop ( ) . disabled ( ) } TimerShortcut :: StopClear => { w . compare1_clear ( ) . enabled ( ) ; w . compare1_stop ( ) . enabled ( ) } TimerShortcut :: Disabled => { w . compare1_clear ( ) . disabled ( ) ; w . compare1_stop ( ) . disabled ( ) } } , 2 => match shortcut { TimerShortcut :: Stop => { w . compare2_clear ( ) . disabled ( ) ; w . compare2_stop ( ) . enabled ( ) } TimerShortcut :: Clear => { w . compare2_clear ( ) . enabled ( ) ; w . compare2_stop ( ) . disabled ( ) } TimerShortcut :: StopClear => { w . compare2_clear ( ) . enabled ( ) ; w . compare2_stop ( ) . enabled ( ) } TimerShortcut :: Disabled => { w . compare2_clear ( ) . disabled ( ) ; w . compare2_stop ( ) . disabled ( ) } } , 3 => match shortcut { TimerShortcut :: Stop => { w . compare3_clear ( ) . disabled ( ) ; w . compare3_stop ( ) . enabled ( ) } TimerShortcut :: Clear => { w . compare3_clear ( ) . enabled ( ) ; w . compare3_stop ( ) . disabled ( ) } TimerShortcut :: StopClear => { w . compare3_clear ( ) . enabled ( ) ; w . compare3_stop ( ) . enabled ( ) } TimerShortcut :: Disabled => { w . compare3_clear ( ) . disabled ( ) ; w . compare3_stop ( ) . disabled ( ) } } , _ => panic ! ( " " ) , } ) ; // todo: compare4 and 5 for the other timers?? }
Set up a shortcut associated with an event.
Set up a shortcut associated with an event .
&mut self
shortcut
TimerShortcut
compare_num
usize
&mut self
shortcut
TimerShortcut
compare_num
usize