changeset 399:744c3c7eb09d

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 c738a52e31e4
children 1137f315209b
files main.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
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);