Special note: This function uses printf to print the LCD ID, so if you do not initialize the serial port in the main function, the program will die in printf! ! If you do not want to use printf, please comment it out.
This is the end of the LCD driver related functions. Next, let's look at the main function code as follows:
int main(void)
{
x=0;
u8 lcd_id[12]; //Store LCD ID string
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //Set system interrupt priority group 2
delay_init(168); //Initialize delay function
uart_init(115200); //Initialize the serial port baud rate to 115200
LED_Init(); //Initialize LED
LCD_Init(); //Initialize LCD FSMC interface
POINT_COLOR=RED;
sprintf((char*)lcd_id,"LCD ID:X",lcddev.id);//Print LCD ID to lcd_id array.
while(1)
{
switch(x)
{
case 0:LCD_Clear(WHITE);break;
case 1:LCD_Clear(BLACK);break;
case 2:LCD_Clear(BLUE);break;
case 3:LCD_Clear(RED);break;
case 4:LCD_Clear(MAGENTA);break;
case 5:LCD_Clear(GREEN);break;
case 6:LCD_Clear(CYAN);break;
case 7:LCD_Clear(YELLOW);break;
case 8:LCD_Clear(BRRED);break;
case 9:LCD_Clear(GRAY);break;
case 10:LCD_Clear(LGRAY);break;
case 11:LCD_Clear(BROWN);break;
}
POINT_COLOR=RED;
LCD_ShowString(30,40,210,24,24,"Explorer STM32F4");
LCD_ShowString(30,70,200,16,16,"TFTLCD TEST");
LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(30,110,200,16,16,lcd_id); //Show LCD ID
LCD_ShowString(30,130,200,12,12,"2014/5/4");
x++;
if(x==12)x=0;
LED0=!LED0;delay_ms(1000);
}
}
This part of the code will display some fixed characters, with font sizes of 24*12, 16*8 and 12*6, and the model of the LCD driver IC, and then switch the background color continuously, switching once every 1s. LED0 will also flash continuously, indicating that the program is running. We use a sprintf function, which is used in the same way as printf, except that sprintf outputs the printed content to the specified memory range. For detailed usage of sprintf, please search Baidu.
Also pay special attention: the uart_init function cannot be removed, because printf is called in the LCD_Init function, so once you remove this initialization, the system will freeze! In fact, as long as your code uses printf, you must initialize the serial port, otherwise it will freeze, that is, stop at the fputc function in usart.c and cannot get out.
Previous article:STM32f4 key input experimental code (01)
Next article:STM32f4---TFTLCD display experimental code (05)
Recommended ReadingLatest update time:2024-11-16 14:33
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Electronic computing software
- MCO (PA8) does not output waveform during DEBUG. What is the reason?
- Patch reverse check
- EEWORLD University ---- Control system of 100 quantum bits
- The difference between USART, USI, USCI and eUSCI serial communication modules in MSP430 microcontroller (updated on March 4, 2019)
- Polarity of EPWMA pulse
- RF Sampling DAC Spurious Troubleshooting and Optimization
- CH549EVT development board test - solution to the problem of data segment exceeding the limit
- Direct code generation under simulink
- Recommended stepper motor driver chips