/*############################################################# Program Name : ex4_F469NI_LCDBouncingBall Author : Grant Phillips Date Modified : 22/09/2016 Compiler : ARMmbed Tested On : DISCO-F469NI Description : Example program that demonstrates animation using a bouncing ball on the DSI TFT LCD. Requirements : * DISCO-F469NI Board Circuit : * NONE ##############################################################*/ #include "mbed.h" #include "LCD_DISCO_F469NI.h" #define BALL_RADIUS 30 LCD_DISCO_F469NI lcd; //Create a LCD_DISCO_F469NI 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 == (799 - BALL_RADIUS)) xdir = -1; if(y == (0 + BALL_RADIUS)) ydir = 1; if(y == (479 - 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); } }