
Assignment 5 for OCE360, timers, tickers, and interrupts.
Dependencies: 4DGL-uLCD-SE MMA8452Q SDFileSystem bouncing_ball mbed
Fork of OCE360_4 by
Revision 1:6b99ffa62cc8, committed 2017-10-24
- Comitter:
- slicht
- Date:
- Tue Oct 24 12:34:19 2017 +0000
- Parent:
- 0:8d3812068c6c
- Child:
- 2:552e6feb8709
- Commit message:
- Compiles and runs with physics in ball. Creates unmoving 10 radius ball in center.
Changed in this revision
bouncing_ball.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bouncing_ball.lib Tue Oct 24 12:34:19 2017 +0000 @@ -0,0 +1,1 @@ +bouncing_ball#0aa572c0f2b1
--- 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