在嵌入式系統(tǒng)中,成本往往是敏感的,如果你的Flash足夠大,就可以省去片外Flash,我用結(jié)構(gòu)體實(shí)現(xiàn)了該功能,并分享給廣大網(wǎng)友,最后附有下載鏈接。在fonts.h中:
本文引用地址:http://www.ex-cimer.com/article/201611/318125.htm typedef struct _tFont
{
const uint16_t *table;
uint16_t Width;
uint16_t Height;
} sFONT;
extern sFONT Font8x8;
extern sFONT Font8x12_bold;
extern sFONT Font8x12;
extern sFONT Font12x12;
extern sFONT Font16x24;
#define GL_Font8x8 Font8x8
#define GL_Font8x12_bold Font8x12_bold
#define GL_Font8x12 Font8x12
#define GL_Font12x12 Font12x12
#define GL_Font16x24 Font16x24
在fonts.c中
const uint16_t ASCII16x24_Table []={………………};//字模
sFONT Font16x24 = {
ASCII16x24_Table,
16,
24,
};
sFONT Font12x12 = {
ASCII12x12_Table,
12,
12,
};
sFONT Font8x12 = {
ASCII8x12_Table,
8,
12,
};
sFONT Font8x12_bold ={
ASCII8x12_bold_Table,
8,
12,
};
sFONT Font8x8 = {
ASCII8x8_Table,
8,
8,
};
在main.c中調(diào)用:
#include "user_config.h"
uint8_t test1[]="你見,或者不見我,我就在那里,不悲不喜;";
uint8_t test2[]="你念,或者不念我,我就在那里,不來不去;";
uint8_t test3[]="你愛,或者不愛我,愛就在那里,不增不減;";
uint8_t test4[]="你跟,或者不跟我,我的手就在你手里,";
uint8_t test5[]="不舍 不棄.";
uint8_t test6[]="默然 相愛";
uint8_t test7[]="寂靜 喜歡";
int main(void)
{
u8 i,j,k;
NVIC_Config();
SysTick_Init();
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
USART_Config( COM1,115200);
STM3210E_LCD_Init();
LCD_Clear(LCD_COLOR_MAGENTA);
LCD_SetColors(LCD_COLOR_RED,LCD_COLOR_CYAN);
LCD_DisplayStringLine(LCD_LINE_0, (uint8_t *)MESSAGE1);
LCD_DisplayStringLine(LCD_LINE_1, (uint8_t *)MESSAGE2);
LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *)MESSAGE3);
LCD_DisplayStringLine(LCD_LINE_3, (uint8_t *)MESSAGE4);
printf("nr %s", MESSAGE1);
printf(" %s", MESSAGE2);
printf(" %snr", MESSAGE3);
LCD_Clear(LCD_COLOR_BLUE);
GL_Clear(GL_Grey);
GL_SetTextColor(GL_Blue);
GL_SetBackColor(GL_Yellow);
GL_SetFont(GL_FONT_GB2312);
LCD_ClearLine(LINE(0)); // disp yellow line
LCD_ClearLine(LINE(9));
GL_DisplayAdjStringLine(0,220,(uint8_t*)"Loading...",GL_FALSE);
GL_DisplayAdjStringLine(LINE(2),310,test1,GL_TRUE); //如果橫屏,Y軸遞減
GL_DisplayAdjStringLine(LINE(3),310,test2,GL_TRUE);
GL_DisplayAdjStringLine(LINE(4),310,test3,GL_TRUE);
GL_DisplayAdjStringLine(LINE(5),310,test4,GL_TRUE);
GL_DisplayAdjStringLine(LINE(6),310,test5,GL_TRUE);
GL_DisplayAdjStringLine(LINE(7),310,test6,GL_TRUE);
GL_DisplayAdjStringLine(LINE(8),310,test7,GL_TRUE);
GL_DisplayAdjStringLine(LINE(9),130,"蔡志威",GL_TRUE);
GL_SetFont(GL_FONT_SMALL);
//SetFont(GL_Font8x12_bold);
GL_DisplayAdjStringLine(220,80," 2013-10-08",GL_TRUE);
while (1)
{
}
}
map文件:
==============================================================================
Code (inc. data) RO Data RW Data ZI Data Debug
9944 738 293276 360 1080 0 Grand Totals
9944 738 293276 224 1080 0 ELF Image Totals (compressed)
9944 738 293276 224 0 0 ROM Totals
==============================================================================
Total RO Size (Code + RO Data) 303220 ( 296.11kB)
Total RW Size (RW Data + ZI Data) 1440 ( 1.41kB)
Total ROM Size (Code + RO Data + RW Data) 303444 ( 296.33kB)
==============================================================================
實(shí)驗(yàn)效果:
百為開發(fā)平臺:
工程源碼下載地址:
http://share.weiyun.com/c10c5e371d01f33a97e8c2afa0ec170d
評論