main: repurpose led activity, obtain fresh time

This commit is contained in:
Astro 2019-03-14 22:07:26 +01:00
parent 384b537555
commit e6125581fd
1 changed files with 5 additions and 3 deletions

View File

@ -105,20 +105,22 @@ fn main() -> ! {
let mut last_output = 0_u32; let mut last_output = 0_u32;
loop { loop {
led_red.on(); led_green.on();
let now = timer::now().0; let now = timer::now().0;
let instant = Instant::from_millis(now as i64); let instant = Instant::from_millis(now as i64);
server.poll(instant); server.poll(instant);
led_green.off();
if now - last_output >= OUTPUT_INTERVAL {
led_blue.on(); led_blue.on();
let now = timer::now().0;
if now - last_output >= OUTPUT_INTERVAL {
let adc_value = adc_input::read(); let adc_value = adc_input::read();
adc_value.map(|adc_value| { adc_value.map(|adc_value| {
write!(server, "t={},pa3={}\r\n", now, adc_value).unwrap(); write!(server, "t={},pa3={}\r\n", now, adc_value).unwrap();
}); });
last_output = now; last_output = now;
led_blue.off();
} }
led_blue.off();
// Update watchdog // Update watchdog
wd.feed(); wd.feed();