/*############################################################# Program Name : ex4_LCD_BouncingBall Author : Grant Phillips Date Modified : 05/05/2016 Compiler : ARMmbed Tested On : STM32F429ZI-Discovery Description : Example program that demonstrates animation using a bouncing ball on the QVGA TFT LCD. Requirements : * STM32F429ZI-Discovery Board Circuit : * NONE ##############################################################*/ #include "mbed.h" #include "LCD_DISCO_F429ZI.h" #define BALL_RADIUS 30 LCD_DISCO_F429ZI lcd; //Create a LCD_DISCO_F429ZI object int main() { uint16_t x = 120, y = 160; int8_t xdir= -1, ydir= -1; lcd.Clear(LCD_COLOR_BLACK); /* Draw initial ball */ lcd.SetTextColor(LCD_COLOR_RED); //lcd.FillCircle(x,y,BALL_RADIUS); lcd.DrawCircle(x,y,BALL_RADIUS); wait(1.0); while(1) { /* delete the old ball by filling it with black color at the old x and y position */ lcd.SetTextColor(LCD_COLOR_BLACK); //lcd.FillCircle(x,y,BALL_RADIUS); lcd.DrawCircle(x,y,BALL_RADIUS); /* calculate the new x and y position */ if(x == (0 + BALL_RADIUS)) xdir = 1; if(x == (239 - BALL_RADIUS)) xdir = -1; if(y == (0 + BALL_RADIUS)) ydir = 1; if(y == (319 - BALL_RADIUS)) ydir = -1; x = x + xdir; y = y + ydir; /* draw a new ball at the new x and y position */ lcd.SetTextColor(LCD_COLOR_RED); //lcd.FillCircle(x,y,BALL_RADIUS); lcd.DrawCircle(x,y,BALL_RADIUS); /* delay to slow down the ball */ wait(0.01); } }