]> git.earman.xyz Git - sensor-watch.git/commitdiff
documentation and such
authorJoey Castillo <joeycastillo@utexas.edu>
Sat, 19 Feb 2022 19:22:23 +0000 (14:22 -0500)
committerJoey Castillo <joeycastillo@utexas.edu>
Sat, 19 Feb 2022 19:22:23 +0000 (14:22 -0500)
movement/watch_faces/sensor/accelerometer_data_acquisition_face.c
movement/watch_faces/sensor/accelerometer_data_acquisition_face.h
watch-library/shared/driver/lis2dw.c

index ea50ad270517e0a1ffc51a33754803e61806602f..cf441031e7ac7d73ac70dfb82efd6acbd7eaca00 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "accelerometer_data_acquisition_face.h"
+#include "lis2dw.h"
 
 static const char activity_types[][3] = {
     "ID",   // Idle
@@ -61,7 +62,6 @@ void accelerometer_data_acquisition_face_setup(movement_settings_t *settings, ui
         state->beep_with_countdown = true;
         state->countdown_length = 10;
     }
-    // Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
 }
 
 void accelerometer_data_acquisition_face_activate(movement_settings_t *settings, void *context) {
index b3fdbbd7bb185d90a5ebf020d4b602a1726f9864..e29b99094a36c311f576a827eb23ae63f5694712 100644 (file)
 typedef union {
     struct {
         union {
-            int16_t record_type : 2;
-            int16_t range : 2;
-            int16_t temperature : 12;
+            int16_t record_type : 2;    // see above, helps us identify record types when reading back
+            int16_t range : 2;          // accelerometer range (see lis2dw_range_t)
+            int16_t temperature : 12;   // raw value from the temperature sensor
         } info;
-        int8_t char1 : 8;
-        int8_t char2 : 8;
-        int32_t timestamp : 32;
+        int8_t char1 : 8;               // First character of the activity type
+        int8_t char2 : 8;               // Second character of the activity type
+        int32_t timestamp : 32;         // UNIX timestamp for the measurement
     } header;
     struct {
         union {
-            int16_t mode : 2;
-            int16_t accel : 14;
+            int16_t record_type : 2;    // duplicate; this is the same field as info above
+            int16_t accel : 14;         // X acceleration value, raw
         } x;
         union {
-            int16_t lpmode : 2;
-            int16_t accel : 14;
+            int16_t lpmode : 2;         // low power mode (see lis2dw_low_power_mode_t)
+            int16_t accel : 14;         // Y acceleration value, raw
         } y;
         union {
-            int16_t filter : 2;
-            int16_t accel : 14;
+            int16_t filter : 2;         // bandwidth filtering selection (see lis2dw_bandwidth_filtering_mode_t)
+            int16_t accel : 14;         // Z acceleration value, raw
         } z;
-        int32_t counter : 16;
+        int32_t counter : 16;           // number of seconds since timestamp in header
     } data;
     uint64_t value;
 } accelerometer_data_acquisition_record_t;
index 0b788fcae5aa191f1dc865d66bdda42769e0394e..744a686babd7f3b59a454c90fe45abe51b166c12 100644 (file)
@@ -34,6 +34,16 @@ bool lis2dw_begin(void) {
     // Enable block data update (output registers not updated until MSB and LSB have been read) and address autoincrement
     watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL2, LIS2DW_CTRL2_VAL_BDU | LIS2DW_CTRL2_VAL_IF_ADD_INC);
 
+    // Parameters at startup: 
+    //  * Data rate 0 (powered down)
+    //  * Low power mode enabled
+    //  * LP mode 1 (12-bit)
+    //  * Bandwidth filtering ODR/2
+    //  * Low pass filter path
+    //  * ±2g range
+    //  * Low noise mode off
+    //  * FIFO disabled
+
     return true;
 }