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:
1:6b99ffa62cc8
Parent:
0:8d3812068c6c
Child:
2:552e6feb8709
--- a/main.cpp	Thu Oct 19 12:53:21 2017 +0000
+++ b/main.cpp	Tue Oct 24 12:34:19 2017 +0000
@@ -1,12 +1,45 @@
+// Demo for the uLCD-144-G2 and MMA8452Q 3-axis accelerometer
+
 #include "mbed.h"
+#include "MMA8452Q.h"
+#include "uLCD_4DGL.h"
+#include "bouncing_ball.h"
+
+#define INIT_RADIUS 10
+#define INIT_COLOR 1
 
-DigitalOut myled(LED1);
+//#include "bouncing_ball.h"
+
+// Graphic LCD - TX, RX, and RES pins
+uLCD_4DGL uLCD(p9,p10,p11);
+
+// Accelerometer - SDA, SCL, and I2C address
+MMA8452Q accel(p28, p27, 0x1D);
+
+physics_ball ball1(INIT_COLOR,INIT_RADIUS);
 
 int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+
+    // Initialize uLCD
+    uLCD.baudrate(115200);
+    uLCD.background_color(BLACK);
+    uLCD.cls();
+
+    // Initialize accelerometer
+    accel.init();
+
+    //Initiailize ball
+    
+    // Make a ball "fall" in direction of accelerometer
+    while (1) {
+
+        // Draw a red circle
+        uLCD.filled_circle((int)ball1.posx, (int)ball1.posy, ball1.radius, RED);
+
+        // Wait before erasing old circle
+        wait(0.02);         // In seconds
+
+        // Erase old circle
+        uLCD.filled_circle((int)ball1.posx, (int)ball1.posy, ball1.radius, BLACK);
     }
-}
+}
\ No newline at end of file