Mercurial > templog
comparison main.c @ 440:e6ec149d4063
- use the right variable for overshoot_factor
- make eeprom more robust
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 28 Oct 2012 21:38:30 +0800 |
parents | 7d7e7f961eae |
children |
comparison
equal
deleted
inserted
replaced
438:2607e4f322cf | 440:e6ec149d4063 |
---|---|
155 #define eeprom_write(src, eeprom_field) { eeprom_write_from(&src, eeprom_field, sizeof(src)); } | 155 #define eeprom_write(src, eeprom_field) { eeprom_write_from(&src, eeprom_field, sizeof(src)); } |
156 | 156 |
157 #define EXPECT_MAGIC 0x67c9 | 157 #define EXPECT_MAGIC 0x67c9 |
158 | 158 |
159 struct __attribute__ ((__packed__)) __eeprom_data { | 159 struct __attribute__ ((__packed__)) __eeprom_data { |
160 uint16_t magic; | |
161 uint16_t measure_wake; | 160 uint16_t measure_wake; |
162 uint16_t comms_wake; | 161 uint16_t comms_wake; |
163 uint8_t wake_secs; | 162 uint8_t wake_secs; |
164 | 163 |
165 int16_t fridge_setpoint; // decidegrees | 164 int16_t fridge_setpoint; // decidegrees |
171 | 170 |
172 #if 0 | 171 #if 0 |
173 static uint8_t wort_id[ID_LEN]; | 172 static uint8_t wort_id[ID_LEN]; |
174 static uint8_t fridge_id[ID_LEN]; | 173 static uint8_t fridge_id[ID_LEN]; |
175 #endif | 174 #endif |
175 | |
176 uint16_t magic; | |
176 }; | 177 }; |
177 | 178 |
178 static const uint8_t fridge_id[ID_LEN] = | 179 static const uint8_t fridge_id[ID_LEN] = |
179 {0x28,0xCE,0xB2,0x1A,0x03,0x00,0x00,0x99}; | 180 {0x28,0xCE,0xB2,0x1A,0x03,0x00,0x00,0x99}; |
180 static const uint8_t wort_id[ID_LEN] = | 181 static const uint8_t wort_id[ID_LEN] = |
674 { | 675 { |
675 printf_P(PSTR("Bad overshoot factor %f\n"), new_f); | 676 printf_P(PSTR("Bad overshoot factor %f\n"), new_f); |
676 return; | 677 return; |
677 } | 678 } |
678 | 679 |
679 uint8_t old = overshoot_delay; | 680 uint8_t old = overshoot_factor; |
680 | 681 |
681 overshoot_delay = new_f * 10; | 682 overshoot_factor = new_f * 10; |
682 bool written = set_initial_eeprom(); | 683 bool written = set_initial_eeprom(); |
683 if (!written) | 684 if (!written) |
684 { | 685 { |
685 if (old != overshoot_factor) | 686 if (old != overshoot_factor) |
686 { | 687 { |