Tuan Le / Mbed 2 deprecated AccelerometerProject

Dependencies:   MMA8452 N5110 PowerControl beep mbed

Revision:
9:522f9311ff4b
Parent:
8:aebb468546c5
diff -r aebb468546c5 -r 522f9311ff4b Accel-cize.cpp
--- a/Accel-cize.cpp	Sat May 09 22:59:15 2015 +0000
+++ b/Accel-cize.cpp	Sun May 10 17:21:39 2015 +0000
@@ -1,44 +1,49 @@
+/**
+@file Accel-cize.cpp
+@brief This is a main file where the code runs.
+@brief Revision 1.0
+@author Huynh Minh Tuan Le
+@date April 2015
+*/
+
 #include "MMA8452Test.h"
 #include "GameFSM.h"
+#include "PowerControl/PowerControl.h"
 
-AnalogIn adjust(p20);
-Timer t;
-FSM program;
-Menu wel;
+AnalogIn adjust(p20); ///<A analogue-in variable for potentiometer.
+Timer t; ///<A timer object t for timing the moment to put mbed into sleep mode.
+FSM program; ///<A "program" variable declared with FSM class.
+Menu wel; ///<A "wel" variable declared with Menu class.
+Test init; ///<A "init" variable declared with Test class from MMA8452Test.h header file.
+
 int main()
 {
-    Test init;
-    init.initial();
-
-    ButtonU.rise(&BuUPress);
+    init.initial(); //A Function to initialise the Nokia 5110 screen and reading data from MMA8452.
+    
+    ButtonU.rise(&BuUPress); 
     ButtonD.rise(&BuDPress);
     ButtonA.rise(&BuAPress);
     ButtonB.rise(&BuBPress);
 
-    wel.welcome();
-    debounce.start();
+    wel.welcome(); //Run the welcome function from Menu class.
 
     while(1) {
-        lcd.setBrightness(adjust);
+        lcd.setBrightness(adjust); //Attach the screen LED brightness value to potentiometer. 
 
-        program.proact();
+        program.proact(); //Running proact function from FSM class.
 
         //////// Timer for the mbed go to sleep mode when waiting for 2 mins ////////
 
-        if ((BuAFlag==0) && (BuBFlag==0) && (BuDFlag==0) && (BuUFlag==0)) {
+        if ((BuAFlag==0) && (BuBFlag==0) && (BuDFlag==0) && (BuUFlag==0)) { //If all buttons are not pressed, start the timer t.
             t.start();
-            float time = t.read();
-            char buffer[14];
-            sprintf(buffer,"Time: %0.1f",time);
-            lcd.printString(buffer,0,5);
         }
-        if ((BuAFlag)||(BuBFlag)||(BuUFlag)||(BuDFlag)) {
+        if ((BuAFlag)||(BuBFlag)||(BuUFlag)||(BuDFlag)) { //If one of the buttons is pressed, reset timer t.
             t.reset();
         }
-        if (t.read()>10) {
-            lcd.setBrightness(0);
-            t.reset();
-            Sleep();
+        if (t.read()>10) { //If timer t greater than 10s,
+            lcd.setBrightness(0); //Set LCD brightness to zero.
+            t.stop(); //Stop timer t.
+            Sleep(); //Put mbed into sleep mode.
         }
     }
 }