Build upon MMA7660_HelloWorld to pull out x, y, z axes from device and print to LCD on mbed Application Board

Dependencies:   C12832_lcd MMA7660 mbed

Fork of MMA7660_HelloWorld by Erik -

Here reside bits and pieces of coding that is mostly derivative of the work of others. Mostly extensions and other modifications.

The proprioception board project.

Board design images follow.

/media/uploads/chapfohn/260px-sphere-and-ring_balance_board_underside.jpg /media/uploads/chapfohn/obroc2.gif

/media/uploads/chapfohn/coolboard-balance-board-ultimate-package-medium-bot02-03-w450.png

Files at this revision

API Documentation at this revision

Comitter:
chapfohn
Date:
Wed Jun 05 01:27:07 2013 +0000
Parent:
4:10426f54d388
Child:
6:62095a0c2429
Commit message:
Take x, y data into array, summation and average.
; Prints data to LCD.
; Tests stability in x, y plane, prints STABLE/UNSTABLE flag to LCD.
; Interest statement included.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jun 04 04:16:34 2013 +0000
+++ b/main.cpp	Wed Jun 05 01:27:07 2013 +0000
@@ -1,4 +1,11 @@
 //Iteration for 3 axis, ...
+//This code is being developed  for use with
+//Sphere and Ring type Physiotherapy Balance Boards
+//example images at -
+//http://www.balance360.com/servlet/the-Balance-360-Boards/Categories
+//The author has no commercial, or other, relationship with [Balance 360] or other manufacturers
+//The author is simply having fun
+//C B P Chapman
 
 #include "mbed.h"
 #include "MMA7660.h"
@@ -40,19 +47,42 @@
         if (MMA.testConnection())
             connectionLed = 1;
 
+        if (pulseXa > (-0.2) && pulseXa < (0.2) && pulseYa > (-0.2) && pulseYa < (0.2)) {//average result within stability range; x, y
+            lcd.cls();//clear LCD for next reading round
+            lcd.locate(3,3);//first LCD column label
+            lcd.printf("x-axis | ");//label column
+            lcd.locate(3,12);//xdata location
+            lcd.printf("%.2f\n",pulseXa);//print x to LCD
+            lcd.locate(40,3);//second LCD column label
+            lcd.printf("y-axis | ");//label column
+            lcd.locate(40,12);//ydata location
+            lcd.printf("%.2f\n",pulseYa);//print y to LCD
+            lcd.locate(77,3);//initial LCD location
+            lcd.printf("z-axis");//label column
+            lcd.locate(77,12);//zdata location
+            lcd.printf("%.2f\n",MMA.z());//print z to LCD
+            lcd.locate(3,21);//flag location
+            lcd.printf("STABLE");//flag
+            //wait (2);
+        }
 
-        lcd.cls();//clear LCD for next reading round
-        lcd.locate(3,3);//first LCD column label
-        lcd.printf("x-axis | ");//label column
-        lcd.locate(3,14);//xdata location
-        lcd.printf("%.2f\n",pulseXa);//print x to LCD
-        lcd.locate(40,3);//second LCD column label
-        lcd.printf("y-axis | ");//label column
-        lcd.locate(40,14);//ydata location
-        lcd.printf("%.2f\n",pulseYa);//print y to LCD
-        lcd.locate(77,3);//initial LCD location
-        lcd.printf("z-axis");//label column
-        lcd.locate(77,14);//zdata location
-        lcd.printf("%.2f\n",MMA.z());//print z to LCD
+        else {////average result not within stability range; x, y
+            lcd.cls();//clear LCD for next reading round
+            lcd.locate(3,3);//first LCD column label
+            lcd.printf("x-axis | ");//label column
+            lcd.locate(3,12);//xdata location
+            lcd.printf("%.2f\n",pulseXa);//print x to LCD
+            lcd.locate(40,3);//second LCD column label
+            lcd.printf("y-axis | ");//label column
+            lcd.locate(40,12);//ydata location
+            lcd.printf("%.2f\n",pulseYa);//print y to LCD
+            lcd.locate(77,3);//initial LCD location
+            lcd.printf("z-axis");//label column
+            lcd.locate(77,12);//zdata location
+            lcd.printf("%.2f\n",MMA.z());//print z to LCD
+            lcd.locate(3,21);//flag location
+            lcd.printf("UNSTABLE");//flag
+            //wait (2);
+        }
     }
 }
\ No newline at end of file