projects
/
gps-watch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0edc261
)
application: Use the Button struct to handle the play button.
author
Tilman Sauerbeck
<tilman@code-monkey.de>
Sun, 22 Mar 2020 14:27:34 +0000
(15:27 +0100)
committer
Tilman Sauerbeck
<tilman@code-monkey.de>
Sun, 22 Mar 2020 16:35:57 +0000
(17:35 +0100)
src/application/main.rs
patch
|
blob
|
history
diff --git
a/src/application/main.rs
b/src/application/main.rs
index ac87977963aa8c4411c10ecef9ffc6adabd88ca8..5ec2f96b7c98dc7d87d9f5d01adfee0b8b91e247 100644
(file)
--- a/
src/application/main.rs
+++ b/
src/application/main.rs
@@
-28,6
+28,7
@@
extern crate common;
mod uart0;
extern crate common;
mod uart0;
+mod button;
use common::buffer::Buffer;
use common::ringbuf::Ringbuf;
use common::buffer::Buffer;
use common::ringbuf::Ringbuf;
@@
-124,10
+125,6
@@
fn configure_push_buttons() {
port::set_pull(port::PORTE, 31, port::Pull::Up);
}
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;
fn uart0_try_read() -> Option<u8> {
extern {
static mut uart0_rx_buf: Ringbuf;
@@
-215,8
+212,7
@@
pub unsafe extern "C" fn _start() -> ! {
let mut logger = Logger::new(&mut mx25l);
logger.init();
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();
let mut is_recording = false;
let mut gps = gps::Gps::new();
@@
-316,12
+312,7
@@
pub unsafe extern "C" fn _start() -> ! {
shell.update(&mut logger);
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 {
is_recording = !is_recording;
if is_recording {
@@
-331,11
+322,8
@@
pub unsafe extern "C" fn _start() -> ! {
}
total_distance_cm = 0;
}
total_distance_cm = 0;
- }
}
}
- pta12_was_pressed = pta12_is_pressed;
-
if reset_requested() {
nvic::system_reset();
}
if reset_requested() {
nvic::system_reset();
}