Assignment 5 for OCE360, timers, tickers, and interrupts.

Dependencies:   4DGL-uLCD-SE MMA8452Q SDFileSystem bouncing_ball mbed

Fork of OCE360_4 by OCE_360

Revision:
5:93f88deda5ba
Parent:
3:a7f02754bc99
Child:
6:050104c0dc75
--- a/main.cpp	Tue Nov 07 13:24:50 2017 +0000
+++ b/main.cpp	Tue Nov 07 15:24:31 2017 +0000
@@ -18,6 +18,11 @@
 
 #define DEBUG_MODE 0
 
+#define LOG_UPDATE .091         //11 Hz
+
+//Initialize Serial communication
+Serial pc(USBTX, USBRX);
+
 //Function prototype for color selection function:
 int get_LCD_color(int color_integer);
 
@@ -30,8 +35,23 @@
 physics_ball ball1;  //initialize two balls for bouncing
 physics_ball ball2;  //the default states from the library will be used initially
 
-int main()
-{
+//Ticker for logging
+Ticker logger1;
+Ticker logger2;
+
+void pos_log1(){
+    pc.printf("Ball 1 (x): %i     Ball 1 (y): %i     \n\r",ball1.posx,ball1.posy);
+    }
+    
+void pos_log2(){
+    pc.printf("Ball 2 (x): %i     Ball 2 (y): %i     \n\r",ball2.posx,ball2.posy);
+    }
+
+int main(){
+    /*
+    logger1.attach(&pos_log1, LOG_UPDATE);
+    logger2.attach(&pos_log2, LOG_UPDATE);
+    */
     // Initialize uLCD
     uLCD.baudrate(115200);
     uLCD.background_color(BLACK);