diff 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
line wrap: on
line diff
--- 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++;
 }