Mercurial > templog
comparison main.c @ 113:d69eb9f3274d tilt
make the fixed measurements too
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 19 Sep 2012 23:37:15 +0800 |
parents | 5234ccc416e8 |
children |
comparison
equal
deleted
inserted
replaced
112:5234ccc416e8 | 113:d69eb9f3274d |
---|---|
210 t->rem = TCNT2; | 210 t->rem = TCNT2; |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 static void | 214 static void |
215 set_measurement(uint8_t sensor, uint16_t measurement, uint16_t reading) | 215 set_current_measurement(uint8_t sensor, uint16_t reading) |
216 { | 216 { |
217 measurements[sensor*max_measurements + measurement] = reading; | 217 measurements[sensor*max_measurements + n_measurements] = reading; |
218 } | 218 } |
219 | 219 |
220 static uint16_t | 220 static uint16_t |
221 get_measurement(uint8_t sensor, uint16_t measurement) | 221 get_measurement(uint8_t sensor, uint16_t measurement) |
222 { | 222 { |
414 long_delay(DS18B20_TCONV_12BIT); | 414 long_delay(DS18B20_TCONV_12BIT); |
415 simple_ds18b20_read_all(); | 415 simple_ds18b20_read_all(); |
416 } | 416 } |
417 | 417 |
418 static void | 418 static void |
419 do_fixed_measurements(void) | |
420 { | |
421 bma180_wake(); | |
422 | |
423 uint16_t accelx, accely, accelz; | |
424 uint8_t temp; | |
425 | |
426 bma180_get_reading(&accelx, &accely, &accelz, &temp); | |
427 uint8_t s = n_ds18b20; | |
428 set_current_measurement(s, accelx); | |
429 s++; | |
430 set_current_measurement(s, accely); | |
431 s++; | |
432 set_current_measurement(s, accelz); | |
433 s++; | |
434 set_current_measurement(s, temp); | |
435 | |
436 bma180_sleep(); | |
437 } | |
438 | |
439 static void | |
419 init_fixed_sensors(void) | 440 init_fixed_sensors(void) |
420 { | 441 { |
421 fixed_sensor_P[0] = PSTR("accelx"); | 442 fixed_sensor_P[0] = PSTR("accelx"); |
422 fixed_sensor_P[1] = PSTR("accely"); | 443 fixed_sensor_P[1] = PSTR("accely"); |
423 fixed_sensor_P[2] = PSTR("accelz"); | 444 fixed_sensor_P[2] = PSTR("accelz"); |
709 if (n_measurements == max_measurements) | 730 if (n_measurements == max_measurements) |
710 { | 731 { |
711 n_measurements = 0; | 732 n_measurements = 0; |
712 } | 733 } |
713 | 734 |
714 for (uint8_t s = 0; s < n_sensors; s++) | 735 for (uint8_t s = 0; s < n_ds18b20; s++) |
715 { | 736 { |
716 uint16_t reading; | 737 uint16_t reading; |
717 uint8_t ret = simple_ds18b20_read_raw(ds18b20_id[s], &reading); | 738 uint8_t ret = simple_ds18b20_read_raw(ds18b20_id[s], &reading); |
718 if (ret != DS18X20_OK) | 739 if (ret != DS18X20_OK) |
719 { | 740 { |
720 reading = VALUE_BROKEN; | 741 reading = VALUE_BROKEN; |
721 } | 742 } |
722 set_measurement(s, n_measurements, reading); | 743 set_current_measurement(s, reading); |
723 } | 744 } |
745 | |
746 do_fixed_measurements(); | |
724 | 747 |
725 n_measurements++; | 748 n_measurements++; |
726 } | 749 } |
727 | 750 |
728 static void | 751 static void |