Mercurial > ~darius > hgwebdir.cgi > tempctrl
comparison 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 |
comparison
equal
deleted
inserted
replaced
59:c72cf25881fe | 60:50fca9562310 |
---|---|
37 #include <util/crc16.h> | 37 #include <util/crc16.h> |
38 | 38 |
39 #include "cons.h" | 39 #include "cons.h" |
40 #include "1wire.h" | 40 #include "1wire.h" |
41 #include "tempctrl.h" | 41 #include "tempctrl.h" |
42 #include "ds1307.h" | |
42 | 43 |
43 typedef struct { | 44 typedef struct { |
44 int32_t sec; | 45 int32_t sec; |
45 int32_t usec; | 46 int32_t usec; |
46 } time_t; | 47 } time_t; |
333 } | 334 } |
334 | 335 |
335 if (nextstate != '-') | 336 if (nextstate != '-') |
336 currstate = nextstate; | 337 currstate = nextstate; |
337 | 338 |
339 #if 0 | |
338 printf_P(PSTR("Time: %10ld, "), t); | 340 printf_P(PSTR("Time: %10ld, "), t); |
341 #else | |
342 ds1307_printtime(PSTR(""), PSTR(": ")); | |
343 #endif | |
339 printtemp(PSTR("Target"), settings.target_temp, PSTR(", ")); | 344 printtemp(PSTR("Target"), settings.target_temp, PSTR(", ")); |
340 printtemp(PSTR("Fermenter"), fermenter_temp, PSTR(", ")); | 345 printtemp(PSTR("Fermenter"), fermenter_temp, PSTR(", ")); |
341 printtemp(PSTR("Fridge"), fridge_temp, PSTR(", ")); | 346 printtemp(PSTR("Fridge"), fridge_temp, PSTR(", ")); |
342 printtemp(PSTR("Ambient"), ambient_temp, PSTR(", ")); | 347 printtemp(PSTR("Ambient"), ambient_temp, PSTR(", ")); |
343 printf_P(PSTR("State: %S, Flags: %S%S\r\n"), state2long(currstate), | 348 printf_P(PSTR("State: %S, Flags: %S%S\r\n"), state2long(currstate), |
550 } | 555 } |
551 return; | 556 return; |
552 } | 557 } |
553 #ifndef WITHUSB | 558 #ifndef WITHUSB |
554 if (!strcasecmp_P(cmd, PSTR("beep"))) { | 559 if (!strcasecmp_P(cmd, PSTR("beep"))) { |
555 if (buf[8] == '1') | 560 if (buf[8] == '1' || buf[8] == 'y') |
556 settings.dobeep = 1; | 561 settings.dobeep = 1; |
557 else if (buf[8] == '0') | 562 else if (buf[8] == '0' || buf[8] == 'n') |
558 settings.dobeep = 0; | 563 settings.dobeep = 0; |
559 else | 564 else |
560 printf_P(PSTR("Expected a 0 or 1\r\n")); | 565 printf_P(PSTR("Expected a y/1 or n/0\r\n")); |
561 return; | 566 return; |
562 } | 567 } |
563 #endif | 568 #endif |
564 if (!strcasecmp_P(cmd, PSTR("ferm")) || | 569 if (!strcasecmp_P(cmd, PSTR("ferm")) || |
565 !strcasecmp_P(cmd, PSTR("frg")) || | 570 !strcasecmp_P(cmd, PSTR("frg")) || |
628 default: | 633 default: |
629 return PSTR("unknown"); | 634 return PSTR("unknown"); |
630 break; | 635 break; |
631 } | 636 } |
632 } | 637 } |
633 |