extern crate common;
mod uart0;
+mod button;
use common::buffer::Buffer;
use common::ringbuf::Ringbuf;
port::set_pull(port::PORTE, 31, port::Pull::Up);
}
-fn poll_pta12() -> bool {
- (gpio::get(gpio::GPIOA) & (1 << 12)) == 0
-}
-
fn uart0_try_read() -> Option<u8> {
extern {
static mut uart0_rx_buf: Ringbuf;
let mut logger = Logger::new(&mut mx25l);
logger.init();
- let mut pta1_start_press_ticks = 0;
- let mut pta12_was_pressed = poll_pta12();
+ let mut pta12 = button::Button::new(gpio::GPIOA, 1 << 12);
let mut is_recording = false;
let mut gps = gps::Gps::new();
shell.update(&mut logger);
- let pta12_is_pressed = poll_pta12();
-
- if !pta12_was_pressed && pta12_is_pressed {
- pta1_start_press_ticks = systick::now();
- } else if pta12_was_pressed && !pta12_is_pressed {
- if systick::has_timeout_ms(pta1_start_press_ticks, 1500) {
+ if pta12.has_been_held_for_ms(1500) {
is_recording = !is_recording;
if is_recording {
}
total_distance_cm = 0;
- }
}
- pta12_was_pressed = pta12_is_pressed;
-
if reset_requested() {
nvic::system_reset();
}