Mercurial > templog
changeset 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 | |
files | bma180.c main.c |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/bma180.c Wed Sep 19 23:23:06 2012 +0800 +++ b/bma180.c Wed Sep 19 23:37:15 2012 +0800 @@ -161,4 +161,6 @@ temp = bma180_read(CTRLREG0); temp &= ~SLEEP; bma180_write(CTRLREG0, temp); // Have to set ee_w to write any other registers + // delay for good measure + _delay_ms(4); }
--- a/main.c Wed Sep 19 23:23:06 2012 +0800 +++ b/main.c Wed Sep 19 23:37:15 2012 +0800 @@ -212,9 +212,9 @@ } static void -set_measurement(uint8_t sensor, uint16_t measurement, uint16_t reading) +set_current_measurement(uint8_t sensor, uint16_t reading) { - measurements[sensor*max_measurements + measurement] = reading; + measurements[sensor*max_measurements + n_measurements] = reading; } static uint16_t @@ -416,6 +416,27 @@ } static void +do_fixed_measurements(void) +{ + bma180_wake(); + + uint16_t accelx, accely, accelz; + uint8_t temp; + + bma180_get_reading(&accelx, &accely, &accelz, &temp); + uint8_t s = n_ds18b20; + set_current_measurement(s, accelx); + s++; + set_current_measurement(s, accely); + s++; + set_current_measurement(s, accelz); + s++; + set_current_measurement(s, temp); + + bma180_sleep(); +} + +static void init_fixed_sensors(void) { fixed_sensor_P[0] = PSTR("accelx"); @@ -711,7 +732,7 @@ n_measurements = 0; } - for (uint8_t s = 0; s < n_sensors; s++) + for (uint8_t s = 0; s < n_ds18b20; s++) { uint16_t reading; uint8_t ret = simple_ds18b20_read_raw(ds18b20_id[s], &reading); @@ -719,9 +740,11 @@ { reading = VALUE_BROKEN; } - set_measurement(s, n_measurements, reading); + set_current_measurement(s, reading); } + do_fixed_measurements(); + n_measurements++; }