![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
OCE360 HW#4 Solution Example
Dependencies: 4DGL-uLCD-SE MMA8452Q bouncing_ball mbed
Fork of OCE360_4 by
Diff: main.cpp
- Revision:
- 3:a7f02754bc99
- Parent:
- 2:552e6feb8709
--- a/main.cpp Tue Nov 07 12:07:36 2017 +0000 +++ b/main.cpp Tue Nov 07 12:09:39 2017 +0000 @@ -1,6 +1,7 @@ // A solution to OCE360 Homework #4. // Objective: Use object oriented programming to create a system that displays // multiple balls bouncing around the LCD screen. +// Stephen Licht, 11/7/2017 #include "mbed.h" #include "MMA8452Q.h" //acceleromater library @@ -51,9 +52,8 @@ to update themselves at regular intervals, and te drawing the locations reported by the ball objects on the LCD screen: */ while (1) { //execute 'forever' - // Draw a red circle using the x and y positions stored by the object 'ball1': + // Draw circles in the x and y positions stored by the ball objects: uLCD.filled_circle(ball1.posx, ball1.posy, ball1.radius, get_LCD_color(ball1.color)); - // Draw a blue circle using the x and y positions stored by the object 'ball2': uLCD.filled_circle(ball2.posx, ball2.posy, ball2.radius, get_LCD_color(ball2.color)); // Wait before erasing old circles: @@ -69,6 +69,7 @@ ball2.update(UPDATE_TIME_S,accel); if (DEBUG_MODE) { + //If compiled with DEBUG_MODE flag raised, print values to screen. uLCD.locate(0,4); uLCD.printf("X: %d.1\nY: %.1d",ball1.posx,ball1.posy); @@ -81,6 +82,7 @@ } } +//Interpret LCD colors. int get_LCD_color(int color_integer) { switch (color_integer) {