diff main.c @ 93:f18fd4257296

don't reset the wake time when btoff happens
author Matt Johnston <matt@ucc.asn.au>
date Mon, 16 Jul 2012 21:50:24 +0800
parents a1c1c2d475b0
children bf707a3775d2
line wrap: on
line diff
--- a/main.c	Mon Jul 16 21:28:49 2012 +0800
+++ b/main.c	Mon Jul 16 21:50:24 2012 +0800
@@ -355,12 +355,14 @@
 static void
 cmd_btoff()
 {
+    uint8_t rem;
+    uint16_t count_copy;
     ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
     {
-        comms_count = 0;
+        count_copy = comms_count;
+        rem = TCNT2;
     }
-    uint8_t rem = TCNT2;
-    printf_P(PSTR("next_wake=%hu,"), comms_wake);
+    printf_P(PSTR("next_wake=%hu,"), comms_wake-count_copy);
     printf_P(PSTR("rem=%hhu,"), rem);
     printf_P(PSTR("tick_secs=%hhu,"), TICK);
     printf_P(PSTR("tick_wake=%hhu\n"), SLEEP_COMPARE);