projects
/
gps-watch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
common: Move panic handler out of libcommon.
[gps-watch.git]
/
src
/
application
/
main.rs
diff --git
a/src/application/main.rs
b/src/application/main.rs
index 7eb180cbfa0bf42fcde3b8c9f45aceb9a822e4a0..4cad3e326ee1720361a991c263b6e7ec3db33d16 100644
(file)
--- a/
src/application/main.rs
+++ b/
src/application/main.rs
@@
-40,6
+40,8
@@
use common::uart;
use common::usb_serial;
use common::display;
use common::gps;
use common::usb_serial;
use common::display;
use common::gps;
+use common::screen;
+use common::time::Time;
extern {
fn enable_interrupts();
extern {
fn enable_interrupts();
@@
-73,6
+75,13
@@
impl Timer {
}
}
}
}
+#[inline(never)]
+#[panic_handler]
+fn panic(_info: &core::panic::PanicInfo) -> ! {
+ loop {
+ }
+}
+
#[no_mangle]
pub unsafe extern "C" fn _start() -> ! {
clock::configure();
#[no_mangle]
pub unsafe extern "C" fn _start() -> ! {
clock::configure();
@@
-117,6
+126,8
@@
pub unsafe extern "C" fn _start() -> ! {
display.init();
display.clear();
display.init();
display.clear();
+ let mut screen = screen::Screen::new();
+
// Hold GPS in reset while configuring its UART.
gpio::clear(gpio::GPIOB, 1);
systick::delay_ms(50);
// Hold GPS in reset while configuring its UART.
gpio::clear(gpio::GPIOB, 1);
systick::delay_ms(50);
@@
-134,11
+145,18
@@
pub unsafe extern "C" fn _start() -> ! {
let mut heart_icon_timer = Timer::new(1000);
let mut gps_icon_timer = Timer::new(500);
let mut heart_icon_timer = Timer::new(1000);
let mut gps_icon_timer = Timer::new(500);
+ let mut prev_tap = gps::TimeAndPos::new();
+
loop {
let mut tap = gps::TimeAndPos::new();
loop {
let mut tap = gps::TimeAndPos::new();
+ let mut show_time = false;
let old_gps_has_fix = gps_has_fix;
while gps.update(&mut tap) {
let old_gps_has_fix = gps_has_fix;
while gps.update(&mut tap) {
+ prev_tap = tap;
+
+ show_time = true;
+
gps_has_fix = true;
gps_has_fix_ticks = systick::now();
}
gps_has_fix = true;
gps_has_fix_ticks = systick::now();
}
@@
-172,6
+190,18
@@
pub unsafe extern "C" fn _start() -> ! {
});
}
});
}
+ if show_time {
+ if let Some(tm) = Time::from_unix_time(prev_tap.unix_time) {
+ let mut time_s = [b' '; 8];
+ tm.fmt_time(&mut time_s);
+
+ screen.clear();
+ screen.draw_text(&time_s);
+
+ display.draw(&screen);
+ }
+ }
+
heart_icon_timer.update(|state| {
if state == 1 {
display.hide_icon(display::Icon::Heart);
heart_icon_timer.update(|state| {
if state == 1 {
display.hide_icon(display::Icon::Heart);