I've been playing with car LCD instrumentation recently. I used Arduino+USART LCD before, but later found that Arduino's performance was not enough, so I turned to STM32. Since I needed to display mobile phone information on the LCD screen, I first used a common dot matrix font solution, but I felt that the effect was terrible, with jagged edges all over the screen. I searched the Internet, but couldn't find a more suitable solution.
It should be noted that the STM32 board I used is very simple: STM32+FSMC+TFT5-inch screen+SDIO. There is no expansion of SDRAM, but there is an advantage that a large-capacity TF card can be used, which is also the main factor that makes this solution feasible. After a lot of verbose, here is the picture:
the font looks very comfortable, without ugly jagged edges.
The solution is actually quite rustic:
1. Write a font extraction tool on the PC. Unlike other tools, the font extracted by this tool contains anti-aliasing information (actually grayscale information). Each pixel requires 1 byte to store. A 32*32 dot matrix font requires 1024 bytes. Assuming there are 30,000 fonts, it will take up about 30M of space. But I use a TF card, and the font information is almost negligible for the capacity of the TF card!
2. The implementation on the STM32 is even simpler. Just read the font information on the TF card, perform simple calculations with the color to be displayed, and then output it directly to the TFT.
Attached is the code for displaying dot matrix Chinese characters:
//*************** Display dot matrix Chinese characters***********
int display_hz_char(int x,int y,u16 chr){
SD_Error Status = SD_OK;
int i,x1,y1;
BYTE buff[SECTOR_SIZE*2];
u32 sec_start=hz_sec_base+(0x33ff-0x2000+1+chr-0x4e00)*hz_sector_count; //Chinese character starting sectorif
((chr>=0x2000)&&(chr<=0x33ff)){
sec_start=hz_sec_base+(chr-0x2000)*hz_sector_count;
}
if((chr>=0xff00)&&(chr<=0xffef)){ //Full-width characters
sec_start=hz_sec_base+(0x33ff-0x2000+1+0x9fbf-0x4e00+1+chr-0xff00)*hz_sector_count;
}
Status = SD_ReadMultiBlocksEx(sec_start * SECTOR_SIZE, (uint32_t*)(&buff[0]), SECTOR_SIZE, 2,true); //Read TF card sector data
if (Status != SD_OK){
in_dma_reading=false;
return x;
}
while (DMA_GetFlagStatus(DMA2_FLAG_TC4) == RESET){}; //Wait for DMA read operation to complete
i=0;
Lcd_BlockWrite(x,x+dot_font_size-1,y,y+dot_font_size-1); //TFT block write
for(y1=0;y1
*(__IO u16 *) (Bank1_LCD_D) = calc_alpha(dot_font_text_color,dot_font_bkg_color,buff);
}
else{ //background color, display with specified background color
*(__IO u16 *) (Bank1_LCD_D) = font_bg_565;
}
i++;
if(i>=SECTOR_SIZE*2){ //A 32-dot font needs to occupy 2 sectors (1024 bytes)
i=0;
}
}
}
return x+dot_font_size;
}
Finally, attach a screenshot of the PC-side font making tool:
Previous article:STM32F103X general-purpose timer 2~5 input capture edge selection
Next article:STM32 USART serial port DMA receive and send mode
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- [TI recommended course] #Live replay: 3 hours of practice + analysis: TI engineers take you step by step to fully get started with MSP430#
- ADALM2000 Experiment: Stable Current Source
- In the transistor amplifier circuit, the AC equivalent circuit says that a DC power supply with no internal resistance is considered a short circuit. Is this DC power supply a voltage source?
- Electronic Components Testing Skills Quick Guide
- pyRTOS(2):Tasks
- 【AT-START-F403A Review】2. Transplant AN0028--Locate HardFault (including simplified version project files)
- 【Silicon Labs Development Kit Review】Secure Code Testing
- Wireless chip faster than 5G is born
- I think the company is wasting money hiring me
- [DIY] Use mosquito repellent to modify wifi repeater, wifi signal booster