Accelerometer demo for PoliMI

Dependencies:   X_NUCLEO_IKS01A1 mbed

Files at this revision

API Documentation at this revision

Comitter:
daz
Date:
Wed Mar 16 16:45:20 2016 +0000
Commit message:
Shows in real time X-Axis values from X-NUCLEO-IKS01A1 Expansion Board over UART

Changed in this revision

X_NUCLEO_IKS01A1.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 636fa5751b1f X_NUCLEO_IKS01A1.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IKS01A1.lib	Wed Mar 16 16:45:20 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/X_NUCLEO_IKS01A1/#a91987e8cf51
diff -r 000000000000 -r 636fa5751b1f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 16 16:45:20 2016 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "x_nucleo_iks01a1.h"
+
+#define NCOLUMNS 80
+
+static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15);
+static MotionSensor *accelerometer = mems_expansion_board->GetAccelerometer();
+
+int main(int argc, char** argv)
+{
+    char bar[NCOLUMNS];
+    int32_t axes[3];
+           
+    while(1){
+        /* SENSE accelerometer X axis */
+        accelerometer->Get_X_Axes(axes);
+        
+        /* COMPUTE User Interface  */
+        memset(bar, 0, NCOLUMNS);
+        for(int i=0; i<NCOLUMNS; i++)
+            if(abs(axes[0])*NCOLUMNS/1000 > i)
+                bar[i] = '#';
+        
+        /* COMMUNICATE it to PC */
+        printf("[%04i]%s\r\n", axes[0], bar);
+        
+        /* Wait 50ms */
+        wait(0.05);
+    }
+}
+
diff -r 000000000000 -r 636fa5751b1f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 16 16:45:20 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa
\ No newline at end of file