/*############################################################# Program Name : ex1_LCD_HelloWorld Author : Grant Phillips Date Modified : 05/05/2016 Compiler : ARMmbed Tested On : STM32F429ZI-Discovery Description : Example program that displays "Hello World!" on the on-board 240 x 320 256K colors RGB (QVGA) TFT LCD, using different fonts and colors. Make sure to read LCD_DISCO_F429ZI class function explanation section on: http://controlsoft.nmmu.ac.za/ARMmbed/ STM32F429ZI-Discovery-Examples/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 counter=0; lcd.Clear(LCD_COLOR_CYAN); //clear the LCD with CYAN pixels lcd.SetBackColor(LCD_COLOR_CYAN); //use CYAN background color lcd.SetTextColor(LCD_COLOR_BLUE); //use BLUE text color lcd.SetFont(&Font12); //set to Font12 //display a message on line 0; the (unint8_t*) just converts the string to an appropriate variable format lcd.DisplayStringAtLine(0,(uint8_t*)"This program will"); lcd.SetFont(&Font16); //set to Font16 lcd.DisplayStringAtLine(1,(uint8_t*)"demonstrate the use"); lcd.SetFont(&Font20); //set to Font20 lcd.DisplayStringAtLine(2,(uint8_t*)"of LCD string"); lcd.SetFont(&Font24); //set to Font20 lcd.DisplayStringAtLine(3,(uint8_t*)"functions."); wait(2.0); while(1) { lcd.Clear(LCD_COLOR_WHITE); if(counter == 0) //set the font according to the counter value lcd.SetFont(&Font8); else if(counter == 1) lcd.SetFont(&Font12); else if(counter == 2) lcd.SetFont(&Font16); else if(counter == 3) lcd.SetFont(&Font20); else if(counter == 4) lcd.SetFont(&Font24); lcd.SetBackColor(LCD_COLOR_WHITE); lcd.SetTextColor(LCD_COLOR_RED); lcd.DisplayStringAtLine(0,(uint8_t*)"Hello World!"); lcd.SetBackColor(LCD_COLOR_YELLOW); lcd.SetTextColor(LCD_COLOR_BLUE); lcd.DisplayStringAtLine(2,(uint8_t*)" Hello World!"); lcd.SetBackColor(LCD_COLOR_LIGHTGRAY); lcd.SetTextColor(LCD_COLOR_BLACK ); //display message at absolute x,y position (120,160 is center of the screen) lcd.DisplayStringAt(120, 160, (uint8_t*)"Hello World!", LEFT_MODE); lcd.SetBackColor(LCD_COLOR_LIGHTBLUE); lcd.SetTextColor(LCD_COLOR_ORANGE ); //display message at absolute x position, but LINE() converts the linenum to the correct y pixels lcd.DisplayStringAt(0, LINE(10), (uint8_t*)"Line 10", CENTER_MODE); //alignment = center lcd.SetBackColor(LCD_COLOR_LIGHTGREEN); lcd.SetTextColor(LCD_COLOR_MAGENTA ); lcd.DisplayStringAt(0, LINE(12), (uint8_t*)"Line 12", RIGHT_MODE); //alignment = right counter++; if(counter > 4) counter = 0; wait(2.0); } }