Mercurial > templog
comparison main.c @ 36:a670a67ba489
- decrease measurement interval, measure at start
- fix integer sizes or format strings
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 16 Jun 2012 09:07:38 +0800 |
parents | 024f5571df8c |
children | 9b5b202129c3 |
comparison
equal
deleted
inserted
replaced
34:79124d7d3f79 | 36:a670a67ba489 |
---|---|
28 // - number of sensors (and range?) | 28 // - number of sensors (and range?) |
29 | 29 |
30 // 1 second. we have 1024 prescaler, 32768 crystal. | 30 // 1 second. we have 1024 prescaler, 32768 crystal. |
31 #define SLEEP_COMPARE 32 | 31 #define SLEEP_COMPARE 32 |
32 // limited to uint16_t | 32 // limited to uint16_t |
33 #define MEASURE_WAKE 300 | 33 #define MEASURE_WAKE 20 |
34 | 34 |
35 #define VALUE_NOSENSOR -9000 | 35 #define VALUE_NOSENSOR -9000 |
36 #define VALUE_BROKEN -8000 | 36 #define VALUE_BROKEN -8000 |
37 | 37 |
38 // limited to uint16_t | 38 // limited to uint16_t |
232 uint8_t n_sensors; | 232 uint8_t n_sensors; |
233 eeprom_read(n_sensors, n_sensors); | 233 eeprom_read(n_sensors, n_sensors); |
234 | 234 |
235 fprintf_P(crc_stdout, PSTR("START\n")); | 235 fprintf_P(crc_stdout, PSTR("START\n")); |
236 fprintf_P(crc_stdout, PSTR("now=%lu\n" | 236 fprintf_P(crc_stdout, PSTR("now=%lu\n" |
237 "time_step=%lu\n" | 237 "time_step=%hu\n" |
238 "first_time=%lu\n" | 238 "first_time=%lu\n" |
239 "last_time=%lu\n"), | 239 "last_time=%lu\n"), |
240 clock_epoch, | 240 clock_epoch, |
241 MEASURE_WAKE, | 241 (uint16_t)MEASURE_WAKE, |
242 first_measurement_clock, | 242 first_measurement_clock, |
243 last_measurement_clock); | 243 last_measurement_clock); |
244 fprintf_P(crc_stdout, PSTR("sensors=%u\n"), n_sensors); | 244 fprintf_P(crc_stdout, PSTR("sensors=%u\n"), n_sensors); |
245 for (uint8_t s = 0; s < n_sensors; s++) | 245 for (uint8_t s = 0; s < n_sensors; s++) |
246 { | 246 { |
248 fprintf_P(crc_stdout, PSTR("sensor_id%u="), s); | 248 fprintf_P(crc_stdout, PSTR("sensor_id%u="), s); |
249 eeprom_read_to(id, sensor_id[s], ID_LEN); | 249 eeprom_read_to(id, sensor_id[s], ID_LEN); |
250 printhex(id, ID_LEN, crc_stdout); | 250 printhex(id, ID_LEN, crc_stdout); |
251 fputc('\n', crc_stdout); | 251 fputc('\n', crc_stdout); |
252 } | 252 } |
253 fprintf_P(crc_stdout, PSTR("measurements=%u\n"), n_measurements); | 253 fprintf_P(crc_stdout, PSTR("measurements=%hu\n"), n_measurements); |
254 for (uint16_t n = 0; n < n_measurements; n++) | 254 for (uint16_t n = 0; n < n_measurements; n++) |
255 { | 255 { |
256 fprintf_P(crc_stdout, PSTR("meas%u="), n); | 256 fprintf_P(crc_stdout, PSTR("meas%u="), n); |
257 for (uint8_t s = 0; s < n_sensors; s++) | 257 for (uint8_t s = 0; s < n_sensors; s++) |
258 { | 258 { |
259 fprintf_P(crc_stdout, PSTR(" %u"), measurements[n][s]); | 259 fprintf_P(crc_stdout, PSTR(" %hu"), measurements[n][s]); |
260 } | 260 } |
261 fputc('\n', crc_stdout); | 261 fputc('\n', crc_stdout); |
262 } | 262 } |
263 fprintf_P(crc_stdout, PSTR("END\n")); | 263 fprintf_P(crc_stdout, PSTR("END\n")); |
264 fprintf_P(stdout, PSTR("CRC=%hu\n"), crc_out); | 264 fprintf_P(stdout, PSTR("CRC=%hu\n"), crc_out); |
517 | 517 |
518 clock_epoch ++; | 518 clock_epoch ++; |
519 | 519 |
520 if (comms_timeout != 0) | 520 if (comms_timeout != 0) |
521 { | 521 { |
522 comms_timeout--; | 522 // XXX testing |
523 //comms_timeout--; | |
523 } | 524 } |
524 | 525 |
525 if (measure_count >= MEASURE_WAKE) | 526 if (measure_count >= MEASURE_WAKE) |
526 { | 527 { |
527 measure_count = 0; | 528 measure_count = 0; |
748 setup_tick_counter(); | 749 setup_tick_counter(); |
749 | 750 |
750 sei(); | 751 sei(); |
751 | 752 |
752 need_comms = 1; | 753 need_comms = 1; |
754 need_measurement = 1; | |
753 | 755 |
754 #if 0 | 756 #if 0 |
755 for (;;) | 757 for (;;) |
756 { | 758 { |
757 do_comms(); | 759 do_comms(); |