diff tempctrl.c @ 60:50fca9562310

Add support for reading/writing to a DS1307 over TWI/IIC. Note that iic_read() appears to have a bug where it stops 1 byte earlier than expected, work around it for now by adding 1 in the gettod() function. tempctrl.c now prints the TOD as read from the RTC for each line.
author darius@Inchoate
date Thu, 30 Oct 2008 11:53:32 +1030
parents c72cf25881fe
children e955aa7047ed
line wrap: on
line diff
--- a/tempctrl.c	Thu Oct 30 11:44:52 2008 +1030
+++ b/tempctrl.c	Thu Oct 30 11:53:32 2008 +1030
@@ -39,6 +39,7 @@
 #include "cons.h"
 #include "1wire.h"
 #include "tempctrl.h"
+#include "ds1307.h"
 
 typedef struct {
     int32_t	sec;
@@ -335,7 +336,11 @@
     if (nextstate != '-')
 	currstate = nextstate;
 
+#if 0
     printf_P(PSTR("Time: %10ld, "), t);
+#else
+    ds1307_printtime(PSTR(""), PSTR(": "));
+#endif
     printtemp(PSTR("Target"), settings.target_temp, PSTR(", "));
     printtemp(PSTR("Fermenter"), fermenter_temp, PSTR(", "));
     printtemp(PSTR("Fridge"), fridge_temp, PSTR(", "));
@@ -552,12 +557,12 @@
     }
 #ifndef WITHUSB
     if (!strcasecmp_P(cmd, PSTR("beep"))) {
-	if (buf[8] == '1')
+	if (buf[8] == '1' || buf[8] == 'y')
 	    settings.dobeep = 1;
-	else if (buf[8] == '0')
+	else if (buf[8] == '0' || buf[8] == 'n')
 	    settings.dobeep = 0;
 	else
-	    printf_P(PSTR("Expected a 0 or 1\r\n"));
+	    printf_P(PSTR("Expected a y/1 or n/0\r\n"));
 	return;
     }
 #endif
@@ -630,4 +635,3 @@
 	    break;
     }
 }
-