/*############################################################# Program Name : ex2_LCD_Counter Author : Grant Phillips Date Modified : 05/05/2016 Compiler : ARMmbed Tested On : STM32F429ZI-Discovery Description : Example program that demonstrates the use of the sprintf() function for displaying text on the QVGA TFT LCD. Requirements : * STM32F429ZI-Discovery Board Circuit : * NONE ##############################################################*/ #include "mbed.h" #include "LCD_DISCO_F429ZI.h" LCD_DISCO_F429ZI lcd; //Create a LCD_DISCO_F429ZI object int main() { int count=0; //count variable char buf[20]; //declare a string variable of 20 chars lcd.Clear(LCD_COLOR_YELLOW); //clear the LCD with YELLOW pixels lcd.SetFont(&Font24); lcd.SetTextColor(LCD_COLOR_BLUE); //set forecolor for text lcd.SetBackColor(LCD_COLOR_YELLOW); //set backcolor for text lcd.DisplayStringAtLine(5, (uint8_t*)"Count Value:"); while(1) { lcd.SetTextColor(LCD_COLOR_YELLOW); lcd.SetBackColor(LCD_COLOR_BLUE); sprintf(buf, "%3d (%2X HEX)", count, count); //print a integer value as decimal and hexadecimal to the buf string lcd.DisplayStringAtLine(6, (uint8_t*)buf); //write the buf string to the LCD wait(0.1); //wait 100ms count++; //increment counter if(count >= 100) //reset counter after 100 counts count = 0; } }