changeset 416:99ef51dd1f61

stay on
author Matt Johnston <matt@ucc.asn.au>
date Fri, 05 Oct 2012 22:48:49 +0800
parents 83d6574c7889
children b73ea78317dc
files main.c server/ts.py
diffstat 2 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Fri Oct 05 22:24:47 2012 +0800
+++ b/main.c	Fri Oct 05 22:48:49 2012 +0800
@@ -164,6 +164,20 @@
 
 static void deep_sleep();
 
+// 0 or 1
+static uint8_t
+is_fridge_on()
+{
+    if (PORT_FRIDGE & _BV(PIN_FRIDGE))
+    {
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
 // Very first setup
 static void
 setup_chip()
@@ -348,6 +362,7 @@
     fprintf_P(crc_stdout, PSTR("fridge=%.1f\n"), fridge_setpoint/10.0);
     fprintf_P(crc_stdout, PSTR("fridge_diff=%.1f\n"), fridge_difference/10.0);
     fprintf_P(crc_stdout, PSTR("fridge_delay=%hu\n"), fridge_delay);
+    fprintf_P(crc_stdout, PSTR("fridge_status=%hhu\n"), is_fridge_on());
     fprintf_P(crc_stdout, PSTR("tick_secs=%d\n"), TICK);
     fprintf_P(crc_stdout, PSTR("tick_wake=%d\n"), SLEEP_COMPARE);
     fprintf_P(crc_stdout, PSTR("maxsens=%hhu\n"), MAX_SENSORS);
@@ -396,6 +411,7 @@
     printf_P(PSTR("tick_wake=%hhu\n"), SLEEP_COMPARE);
     _delay_ms(100);
     comms_timeout = 0;
+    stay_awake = 0;
 }
 
 static void
@@ -841,7 +857,7 @@
 
     simple_ds18b20_start_meas(NULL);
     // sleep rather than using a long delay
-    deep_sleep();
+    idle_sleep();
     //_delay_ms(DS18B20_TCONV_12BIT);
 
     if (n_measurements == max_measurements)
@@ -967,6 +983,8 @@
     need_comms = 1;
     need_measurement = 1;
 
+    stay_awake = 1;
+
     for(;;)
     {
         if (button_pressed)
--- a/server/ts.py	Fri Oct 05 22:24:47 2012 +0800
+++ b/server/ts.py	Fri Oct 05 22:48:49 2012 +0800
@@ -156,7 +156,8 @@
 
     clear_meas(sock)
 
-    next_wake = turn_off(sock)
+    next_wake = 600
+    #next_wake = turn_off(sock)
     sock.close()
     return next_wake