在
嵌入式系统中,成本往往是敏感的,如果你的Flash足够大,就可以省去片外Flash,我用结构体实现了该功能,并分享给广大网友,最后附有下载链接。
在FONTs.h中:
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中调用:
#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)
==============================================================================
实验效果:
![](../img/eep/emb/emb-57843zfslxfuxwhg.jpg)
百为开发平台:
![](../img/eep/emb/emb-57844izrcv40psef.jpg)
工程源码下载地址:
http://share.weiyun.com/c10c5e371d01f33a97e8c2afa0ec170d