SPI DMA演示
一、源码
#include <stdio.h>
#include <stdlib.h>
#include "pico/stdlib.h"
#include "pico/binary_info.h"
#include "hardware/spi.h"
#include "hardware/dma.h"
#include "font.h"
#define X_MAX_PIXEL 128
#define Y_MAX_PIXEL 132
#define TEST_SIZE X_MAX_PIXEL*2*16
#define LCD_SPI_PORT spi0
#define LCD_MISO 16
#define LCD_CS 17
#define LCD_SCK 18
#define LCD_MOSI 19
#define LCD_RESET 21
#define LCD_DC 20
#define LCD_PORTRAIT 0
#define LCD_LANDSCAPE 1
#define LCD_INV_PORTRAIT 2
#define LCD_INV_LANDSCAPE 3
#define MADCTL_MX 0x40
#define MADCTL_MY 0x80
#define MADCTL_MV 0x20
#define MADCTL_ML 0x10
#define MADCTL_BGR 0x08
#define MADCTL_MH 0x04
#define BGR 0x08
#define COLOR_Black 0x0000
#define COLOR_Navy 0x000F
#define COLOR_DarkGreen 0x03E0
#define COLOR_DarkCyan 0x03EF
#define COLOR_Maroon 0x7800
#define COLOR_Purple 0x780F
#define COLOR_Olive 0x7BE0
#define COLOR_LightGrey 0xC618
#define COLOR_DarkGrey 0x7BEF
#define COLOR_Blue 0x001F
#define COLOR_Green 0x07E0
#define COLOR_Cyan 0x07FF
#define COLOR_Red 0xF800
#define COLOR_Magenta 0xF81F
#define COLOR_Yellow 0xFFE0
#define COLOR_White 0xFFFF
#define COLOR_Orange 0xFD20
#define COLOR_GreenYellow 0xAFE5
#define COLOR_Pink 0xF81F
#define COLOR_INV_Black 0x0000
#define COLOR_INV_Navy 0x7800
#define COLOR_INV_DarkGreen 0x03E0
#define COLOR_INV_DarkCyan 0x7BE0
#define COLOR_INV_Maroon 0x000F
#define COLOR_INV_Purple 0x780F
#define COLOR_INV_Olive 0x03EF
#define COLOR_INV_LightGrey 0xC618
#define COLOR_INV_DarkGrey 0x7BEF
#define COLOR_INV_Blue 0xF800
#define COLOR_INV_Green 0x07E0
#define COLOR_INV_Cyan 0xFFE0
#define COLOR_INV_Red 0x001F
#define COLOR_INV_Magenta 0xF81F
#define COLOR_INV_Yellow 0x07FF
#define COLOR_INV_White 0xFFFF
#define COLOR_INV_Orange 0x053F
#define COLOR_INV_GreenYellow 0x2FF5
char buf[TEST_SIZE];
typedef struct {
uint8_t cmd;
uint8_t dat[16];
uint datLen;
uint32_t sleep;
} st7735_ini_str_t;
st7735_ini_str_t lcd_ini_str[] = {
{0x11, {0x00}, 0, 120}, /* software reset */
{0xB1, {0x02, 0x35, 0x36}, 3, 0},
{0xB2, {0x02,0x35,0x36}, 3 ,0}, //Frame rate 80Hz
{0xB3, {0x02,0x35,0x36,0x02,0x35,0x36}, 6 ,0},
{0xB4, {0x03}, 1, 0 },
{0xC0, {0xA2,0x02,0x84}, 3 ,0},
{0xC1, {0xC5}, 1 ,0},
{0xC2, {0x0D,0x00}, 2,0},
{0xC3, {0x8D,0x2A}, 2,0},
{0xC4, {0x8D,0xEE}, 2,0},
{0xC5, {0x0A}, 1,0},
{0xC7, {0x00},1,0},
{0x36, {0xc8}, 1,0},
{0xE0, {0x12,0x1C,0x10,0x18,0x33,0x2C,0x25,0x28,0x28,0x27,0x2F,0x3c,0x00,0x03,0x03,0x10}, 16,0},
{0xE1, {0x12,0x1C,0x10,0x18,0x2D,0x28,0x23,0x28,0x28,0x26,0x2F,0x3B,0x00,0x03,0x03,0x10}, 16,0},
{0x3A, {0x05}, 1, 0}, //65k mode
{0x29, {0x00}, 0, 0}, //Display on
{0x00, {0x00}, 0, 0} /* EOL */
};
int dmaChannel;
dma_channel_config c;
void st7735_HardReset()
{
gpio_put(LCD_RESET, 1);
sleep_ms(10);
gpio_put(LCD_RESET, 0);
sleep_ms(100);
gpio_put(LCD_RESET, 1);
sleep_ms(100);
}
void st7735_SetCS(bool val)
{
asm volatile("nop\n");
asm volatile("nop\n");
gpio_put(LCD_CS, val);
asm volatile("nop\n");
asm volatile("nop\n");
}
void st7735_SetDC(bool val)
{
asm volatile("nop\n");
asm volatile("nop\n");
gpio_put(LCD_DC, val);
asm volatile("nop\n");
asm volatile("nop\n");
}
void st7735_SendData(uint8_t cmd, uint8_t *data, uint length)
{
st7735_SetCS(0);
st7735_SetDC(0);
spi_write_blocking(LCD_SPI_PORT, &cmd, 1);
st7735_SetDC(1);
spi_write_blocking(LCD_SPI_PORT, data, length);
st7735_SetCS(1);
}
void st7735_SendInitStr()
{
st7735_SetCS(0);
uint i = 0;
while(lcd_ini_str[i].cmd != 0x00)
{
uint8_t cmd = lcd_ini_str[i].cmd;
uint datLen = lcd_ini_str[i].datLen;
uint8_t *dat;
dat = &(lcd_ini_str[i].dat[0]);
uint32_t slp = lcd_ini_str[i].sleep;
st7735_SetDC(0);
spi_write_blocking(LCD_SPI_PORT, &cmd, 1);
if(datLen > 0)
{
st7735_SetDC(1);
spi_write_blocking(LCD_SPI_PORT, dat, datLen);
}
if(slp > 0)
{
sleep_ms(slp);
}
i++;
}
st7735_SetCS(1);
}
void st7735_SetWindow(uint x, uint y, uint w, uint h)
{
/* CASET */
uint8_t cmd = 0x2A;
x=x+2;
y=y+2;
uint8_t buf4[4];
buf4[0] = (x >> 8) & 0xFF;
buf4[1] = x & 0xFF;
buf4[2] = ((x + w -1) >> 8) & 0xFF;
buf4[3] = (x + w -1) & 0xFF;
st7735_SendData(cmd, buf4, 4);
/* RASET */
cmd = 0x2B;
buf4[0] = (y >> 8) & 0xFF;
buf4[1] = y & 0xFF;
buf4[2] = ((y + h - 1) >> 8) & 0xFF;
buf4[3] = (y + h - 1) & 0xFF;
st7735_SendData(cmd, buf4, 4);
}
void lcd_Send_Color_DMA(void * buf, uint16_t length)
{
dma_channel_configure(
dmaChannel, // Channel to be configured
&c, // The configuration we just created
&spi_get_hw(LCD_SPI_PORT)->dr, // The initial write address
buf, // The initial read address
length, // Number of transfers; in this case each is 1 byte.
true // Start immediately.
);
}
void Lcd_Clear(unsigned int Color) //
uint8_t cmd = 0x2C;
int i;
for(i=0;i<X_MAX_PIXEL*2;i++)
{
buf[2*i]=Color>>8;
buf[2*i+1]=Color;
}
st7735_SetWindow(0, 0, X_MAX_PIXEL, Y_MAX_PIXEL);
st7735_SetCS(0);
st7735_SetDC(0);
spi_write_blocking(LCD_SPI_PORT, &cmd, 1); /* RAMWR **/
st7735_SetDC(1);
for(i=0;i<Y_MAX_PIXEL;i++)
{
lcd_Send_Color_DMA((void *) buf, X_MAX_PIXEL*2); //DMA方式
//spi_write_blocking(LCD_SPI_PORT, (void *)buf, TEST_SIZE); //SPI方式
while(1)
{
bool a = dma_channel_is_busy(dmaChannel);
if(a == false) break;
}
}
st7735_SetCS(1);
}
//控制屏幕方向
void st7735_setRotate(uint rot)
{
uint8_t cmd = 0x36;
uint8_t r;
switch (rot)
{
case LCD_PORTRAIT:
r = MADCTL_MX;
break;
case LCD_LANDSCAPE:
r = MADCTL_MV;
break;
case LCD_INV_PORTRAIT:
r = MADCTL_MY;
break;
case LCD_INV_LANDSCAPE:
r = (MADCTL_MX | MADCTL_MY | MADCTL_MV);
break;
default:
r = MADCTL_MX;
}
r |= 0x08;
st7735_SendData(cmd, &r, 1);
}
void st7735_Init(void)
{
// Get a free channel, panic() if there are none
dmaChannel = dma_claim_unused_channel(true);
c = dma_channel_get_default_config(dmaChannel);
channel_config_set_transfer_data_size(&c, DMA_SIZE_8);
channel_config_set_dreq(&c, DREQ_SPI0_TX);
channel_config_set_read_increment(&c, true);
channel_config_set_write_increment(&c, false);
// SPI initialisation. This example will use SPI at 1MHz.
spi_init(LCD_SPI_PORT, 1 * 1000 * 1000);
spi_set_baudrate(LCD_SPI_PORT, 46000000);
gpio_set_function(LCD_MISO, GPIO_FUNC_SPI);
gpio_set_function(LCD_CS, GPIO_FUNC_SIO);
gpio_set_function(LCD_SCK, GPIO_FUNC_SPI);
gpio_set_function(LCD_MOSI, GPIO_FUNC_SPI);
// Chip select is active-low, so we'll initialise it to a driven-high state
gpio_init(LCD_CS);
gpio_set_dir(LCD_CS, GPIO_OUT);
gpio_put(LCD_CS, 1);
gpio_init(LCD_DC);
gpio_set_dir(LCD_DC, GPIO_OUT);
gpio_put(LCD_DC, 1);
gpio_init(LCD_RESET);
gpio_set_dir(LCD_RESET, GPIO_OUT);
gpio_put(LCD_RESET, 1);
// initialize LCD
st7735_HardReset();
st7735_SendInitStr();
//st7735_setRotate(1);
st7735_SetWindow(0, 0, X_MAX_PIXEL, Y_MAX_PIXEL);
}
void drawPoint_DMA(unsigned int x,unsigned int y,unsigned short Data)
{
buf[2*x+y*X_MAX_PIXEL*2]=Data>>8;
buf[2*x+y*X_MAX_PIXEL*2+1]=Data;
}
void DMA_buff_set(unsigned short Data)
{
int j;
for(j=0 ;j<TEST_SIZE;j+=2){
buf[j] = Data>>8;
buf[j+1] = Data;
}
}
void drawFont_GBK16_DMA(unsigned int x, unsigned int y, unsigned int fc, unsigned int bc,unsigned char *s)
{
unsigned char i,j;
unsigned short k,x0,y0;
x0=x;
y0=y;
y=0;
DMA_buff_set(bc); //
while(*s)
{
if((*s) < 128) //ASCII
{
k=*s;
if (k>32) k-=32; else k=0;
for(i=0;i<16;i++)
for(j=0;j<8;j++)
{
if(ASCII_Font_Data[k].dat[i]&(0x01<<j)) drawPoint_DMA(x+j,y+i,fc);
else
{
if (fc!=bc) drawPoint_DMA(x+j,y+i,bc);
}
}
x+=8;
s++;
}
else //汉字
{
for (k=0;k<sizeof(Font_Data)/sizeof(Font_Data[0]);k++)
{
if ((Font_Data[k].txt[0]==*(s))&&(Font_Data[k].txt[1]==*(s+1)))
{
for(i=0;i<16;i++)
{
for(j=0;j<8;j++)
{
if(Font_Data[k].dat[i*2]&(0x01<<j)) drawPoint_DMA(x+j,y+i,fc);
else {
if (fc!=bc) drawPoint_DMA(x+j,y+i,bc);
}
}
for(j=0;j<8;j++)
{
if(Font_Data[k].dat[i*2+1]&(0x01<<j)) drawPoint_DMA(x+j+8,y+i,fc);
else
{
if (fc!=bc) drawPoint_DMA(x+j+8,y+i,bc);
}
}
}
}
}
s+=2;x+=16;
}
}
uint8_t cmd=0x2c;
st7735_SetWindow(0,y0,X_MAX_PIXEL,y0+16);
st7735_SetCS(0);
st7735_SetDC(0);
spi_write_blocking(LCD_SPI_PORT, &cmd, 1);
st7735_SetDC(1);
lcd_Send_Color_DMA((void *) buf, TEST_SIZE);
while(1)
{
bool a = dma_channel_is_busy(dmaChannel);
if(a == false) break;
}
st7735_SetCS(1);
}
int main() {
// Enable UART so we can print status output
stdio_init_all();
st7735_Init();
Lcd_Clear(0xF800);
while(1)
{
sleep_ms(1000);
Lcd_Clear(COLOR_Red);
drawFont_GBK16_DMA(0,0,COLOR_White,COLOR_Red,(char*)"我有一壶酒,");
drawFont_GBK16_DMA(0,16,COLOR_White,COLOR_Red,(char*)"足以慰风尘");
drawFont_GBK16_DMA(0,32,COLOR_White,COLOR_Red,(char*)"尽倾江海里,");
drawFont_GBK16_DMA(0,48,COLOR_White,COLOR_Red,(char*)"赠饮天下人");
drawFont_GBK16_DMA(0,64,COLOR_White,COLOR_Red,(char*)"封时引朋伴,");
drawFont_GBK16_DMA(0,80,COLOR_White,COLOR_Red,(char*)"启时孑孑身");
drawFont_GBK16_DMA(0,96,COLOR_White,COLOR_Red,(char*)"醉里经年少,");
drawFont_GBK16_DMA(0,112,COLOR_White,COLOR_Red,(char*)"乍醒华发生");
sleep_ms(1000);
Lcd_Clear(COLOR_Blue);
drawFont_GBK16_DMA(0,0,COLOR_White,COLOR_Blue,(char*)"我有一壶酒,");
drawFont_GBK16_DMA(0,16,COLOR_White,COLOR_Blue,(char*)"足以慰风尘");
drawFont_GBK16_DMA(0,32,COLOR_White,COLOR_Blue,(char*)"尽倾江海里,");
drawFont_GBK16_DMA(0,48,COLOR_White,COLOR_Blue,(char*)"赠饮天下人");
drawFont_GBK16_DMA(0,64,COLOR_White,COLOR_Blue,(char*)"封时引朋伴,");
drawFont_GBK16_DMA(0,80,COLOR_White,COLOR_Blue,(char*)"启时孑孑身");
drawFont_GBK16_DMA(0,96,COLOR_White,COLOR_Blue,(char*)"醉里经年少,");
drawFont_GBK16_DMA(0,112,COLOR_White,COLOR_Blue,(char*)"乍醒华发生");
}
}
font.h
struct FONT_DATA16
{
char txt[1];
unsigned char dat[16];
};
static struct FONT_DATA16 ASCII_Font_Data[] =
{
" ",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0 */
"!",0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x08,0x08,0x00,0x00, /* 1 */
"\"",0x00,0x48,0x24,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 2 */
"#",0x00,0x00,0x00,0x48,0x48,0x48,0x7e,0x24,0x24,0x24,0x7e,0x24,0x24,0x24,0x00,0x00, /* 3 */
"$",0x00,0x00,0x10,0x3c,0x52,0x52,0x12,0x1c,0x30,0x50,0x50,0x52,0x52,0x3c,0x10,0x10, /* 4 */
"%",0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x0d,0x2a,0x58,0x54,0x54,0x52,0x22,0x00,0x00, /* 5 */
"&",0x00,0x00,0x00,0x0c,0x12,0x12,0x12,0x0a,0x76,0x25,0x29,0x19,0x91,0x6e,0x00,0x00, /* 6 */
"'",0x00,0x06,0x04,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 7 */
"(",0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00, /* 8 */
")",0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00, /* 9 */
"*",0x00,0x00,0x00,0x00,0x08,0x08,0x6b,0x1c,0x1c,0x6b,0x08,0x08,0x00,0x00,0x00,0x00, /* 10 */
"+",0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0xfe,0x10,0x10,0x10,0x00,0x00,0x00,0x00, /* 11 */
",",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x04,0x04,0x02, /* 12 */
"-",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 13 */
".",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00, /* 14 */
"/",0x00,0x00,0x40,0x20,0x20,0x20,0x10,0x10,0x08,0x08,0x08,0x04,0x04,0x02,0x02,0x00, /* 15 */
"0",0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00, /* 16 */
"1",0x00,0x00,0x00,0x10,0x1c,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x7c,0x00,0x00, /* 17 */
"2",0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x40,0x20,0x10,0x08,0x04,0x42,0x7e,0x00,0x00, /* 18 */
"3",0x00,0x00,0x00,0x3c,0x42,0x42,0x40,0x20,0x18,0x20,0x40,0x42,0x42,0x3c,0x00,0x00, /* 19 */
"4",0x00,0x00,0x00,0x20,0x30,0x30,0x28,0x24,0x24,0x22,0xfe,0x20,0x20,0xf8,0x00,0x00, /* 20 */
"5",0x00,0x00,0x00,0x7e,0x02,0x02,0x02,0x1e,0x22,0x40,0x40,0x42,0x22,0x1c,0x00,0x00, /* 21 */
"6",0x00,0x00,0x00,0x18,0x24,0x02,0x02,0x3a,0x46,0x42,0x42,0x42,0x44,0x38,0x00,0x00, /* 22 */
"7",0x00,0x00,0x00,0x7e,0x42,0x20,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x00,0x00, /* 23 */
"8",0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3c,0x00,0x00, /* 24 */
"9",0x00,0x00,0x00,0x1c,0x22,0x42,0x42,0x42,0x62,0x5c,0x40,0x40,0x24,0x18,0x00,0x00, /* 25 */
":",0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00, /* 26 */
";",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08, /* 27 */
"<",0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00, /* 28 */
"=",0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00, /* 29 */
">",0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00, /* 30 */
"?",0x00,0x00,0x00,0x3c,0x42,0x42,0x46,0x20,0x10,0x10,0x10,0x00,0x18,0x18,0x00,0x00, /* 31 */
"@",0x00,0x00,0x00,0x1c,0x22,0x5a,0x55,0x55,0x55,0x55,0x55,0x3a,0x42,0x3c,0x00,0x00, /* 32 */
"A",0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3c,0x22,0x42,0x42,0xe7,0x00,0x00, /* 33 */
"B",0x00,0x00,0x00,0x1f,0x22,0x22,0x22,0x1e,0x22,0x42,0x42,0x42,0x22,0x1f,0x00,0x00, /* 34 */
"C",0x00,0x00,0x00,0x7c,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1c,0x00,0x00, /* 35 */
"D",0x00,0x00,0x00,0x1f,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1f,0x00,0x00, /* 36 */
"E",0x00,0x00,0x00,0x3f,0x42,0x12,0x12,0x1e,0x12,0x12,0x02,0x42,0x42,0x3f,0x00,0x00, /* 37 */
"F",0x00,0x00,0x00,0x3f,0x42,0x12,0x12,0x1e,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00, /* 38 */
"G",0x00,0x00,0x00,0x3c,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1c,0x00,0x00, /* 39 */
"H",0x00,0x00,0x00,0xe7,0x42,0x42,0x42,0x42,0x7e,0x42,0x42,0x42,0x42,0xe7,0x00,0x00, /* 40 */
"I",0x00,0x00,0x00,0x3e,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3e,0x00,0x00, /* 41 */
"J",0x00,0x00,0x00,0x7c,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0f, /* 42 */
"K",0x00,0x00,0x00,0x77,0x22,0x12,0x0a,0x0e,0x0a,0x12,0x12,0x22,0x22,0x77,0x00,0x00, /* 43 */
"L",0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7f,0x00,0x00, /* 44 */
"M",0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x36,0x2a,0x2a,0x2a,0x2a,0x6b,0x00,0x00, /* 45 */
"N",0x00,0x00,0x00,0xe3,0x46,0x46,0x4a,0x4a,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00, /* 46 */
"O",0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1c,0x00,0x00, /* 47 */
"P",0x00,0x00,0x00,0x3f,0x42,0x42,0x42,0x42,0x3e,0x02,0x02,0x02,0x02,0x07,0x00,0x00, /* 48 */
"Q",0x00,0x00,0x00,0x1c,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x4d,0x32,0x1c,0x60,0x00, /* 49 */
"R",0x00,0x00,0x00,0x3f,0x42,0x42,0x42,0x3e,0x12,0x12,0x22,0x22,0x42,0xc7,0x00,0x00, /* 50 */
"S",0x00,0x00,0x00,0x7c,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3e,0x00,0x00, /* 51 */
"T",0x00,0x00,0x00,0x7f,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00, /* 52 */
"U",0x00,0x00,0x00,0xe7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 53 */
"V",0x00,0x00,0x00,0xe7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00, /* 54 */
"W",0x00,0x00,0x00,0x6b,0x2a,0x2a,0x2a,0x2a,0x2a,0x36,0x14,0x14,0x14,0x14,0x00,0x00, /* 55 */
"X",0x00,0x00,0x00,0xe7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xe7,0x00,0x00, /* 56 */
"Y",0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00, /* 57 */
"Z",0x00,0x00,0x00,0x7e,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3f,0x00,0x00, /* 58 */
"[",0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00, /* 59 */
"\\",0x00,0x00,0x02,0x04,0x04,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40, /* 60 */
"]",0x00,0x1e,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1e,0x00, /* 61 */
"^",0x00,0x18,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 62 */
"_",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff, /* 63 */
"`",0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 64 */
"a",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1c,0x22,0x30,0x2c,0x22,0x32,0x6c,0x00,0x00, /* 65 */
"b",0x00,0x00,0x00,0x00,0x03,0x02,0x02,0x1a,0x26,0x42,0x42,0x42,0x26,0x1a,0x00,0x00, /* 66 */
"c",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x02,0x02,0x02,0x44,0x38,0x00,0x00, /* 67 */
"d",0x00,0x00,0x00,0x00,0x60,0x40,0x40,0x7c,0x42,0x42,0x42,0x42,0x62,0xdc,0x00,0x00, /* 68 */
"e",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x7e,0x02,0x42,0x3c,0x00,0x00, /* 69 */
"f",0x00,0x00,0x00,0x00,0x30,0x48,0x08,0x3e,0x08,0x08,0x08,0x08,0x08,0x3e,0x00,0x00, /* 70 */
"g",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x22,0x22,0x1c,0x02,0x3c,0x42,0x42,0x3c, /* 71 */
"h",0x00,0x00,0x00,0x00,0x03,0x02,0x02,0x3a,0x46,0x42,0x42,0x42,0x42,0xe7,0x00,0x00, /* 72 */
"i",0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0e,0x08,0x08,0x08,0x08,0x08,0x3e,0x00,0x00, /* 73 */
"j",0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x1e, /* 74 */
"k",0x00,0x00,0x00,0x00,0x03,0x02,0x02,0x72,0x12,0x0a,0x0e,0x12,0x22,0x77,0x00,0x00, /* 75 */
"l",0x00,0x00,0x00,0x08,0x0e,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3e,0x00,0x00, /* 76 */
"m",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x92,0x92,0x92,0x92,0x92,0xb7,0x00,0x00, /* 77 */
"n",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3b,0x46,0x42,0x42,0x42,0x42,0xe7,0x00,0x00, /* 78 */
"o",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00, /* 79 */
"p",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x26,0x42,0x42,0x42,0x26,0x1a,0x02,0x07, /* 80 */
"q",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x64,0x42,0x42,0x42,0x64,0x58,0x40,0xe0, /* 81 */
"r",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x4c,0x04,0x04,0x04,0x04,0x1f,0x00,0x00, /* 82 */
"s",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x42,0x02,0x3c,0x40,0x42,0x3e,0x00,0x00, /* 83 */
"t",0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x3e,0x08,0x08,0x08,0x08,0x48,0x30,0x00,0x00, /* 84 */
"u",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x42,0x42,0x42,0x42,0x62,0xdc,0x00,0x00, /* 85 */
"v",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x00,0x00, /* 86 */
"w",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdb,0x91,0x52,0x5a,0x2a,0x24,0x24,0x00,0x00, /* 87 */
"x",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x24,0x18,0x18,0x18,0x24,0x76,0x00,0x00, /* 88 */
"y",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe7,0x42,0x24,0x24,0x18,0x18,0x08,0x08,0x06, /* 89 */
"z",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x22,0x10,0x08,0x08,0x44,0x7e,0x00,0x00, /* 90 */
"{",0x00,0xc0,0x20,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x20,0xc0,0x00, /* 91 */
"|",0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, /* 92 */
"}",0x00,0x03,0x04,0x04,0x04,0x04,0x04,0x04,0x08,0x04,0x04,0x04,0x04,0x04,0x03,0x00, /* 93 */
"~",0x04,0x5a,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 94 */
"",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 95 */
};
struct FONT_DATA32
{
char txt[2];
unsigned char dat[32];
};
static struct FONT_DATA32 Font_Data[] =
{
"我",0x20,0x02,0x70,0x0a,0x1e,0x12,0x10,0x12,0x10,0x02,0xff,0x7f,0x10,0x02,0x10,0x22,
0x50,0x22,0x30,0x12,0x18,0x0c,0x16,0x44,0x10,0x4a,0x10,0x51,0xd4,0x60,0x08,0x40, /* 0 */
"有",0x40,0x00,0x40,0x00,0xff,0x7f,0x20,0x00,0x20,0x00,0xf0,0x0f,0x10,0x08,0x18,0x08,
0xf4,0x0f,0x12,0x08,0x11,0x08,0xf0,0x0f,0x10,0x08,0x10,0x08,0x10,0x0a,0x10,0x04, /* 1 */
"一",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x7f,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 2 */
"壶",0x80,0x00,0x80,0x00,0xfe,0x3f,0x80,0x00,0x80,0x00,0xf8,0x0f,0x00,0x00,0xfe,0x7f,
0x02,0x40,0x21,0x22,0x20,0x02,0x24,0x12,0x28,0x12,0x28,0x0a,0x20,0x02,0xfe,0x3f, /* 3 */
"酒",0x00,0x00,0xf2,0x7f,0x04,0x05,0x04,0x05,0xe0,0x3f,0x21,0x25,0x22,0x25,0x2a,0x25,
0xa8,0x38,0x64,0x20,0x27,0x20,0xe4,0x3f,0x24,0x20,0x24,0x20,0xe4,0x3f,0x20,0x20, /* 4 */
",",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x0c,0x00,0x08,0x00,0x04,0x00,0x00,0x00, /* 5 */
"足",0x00,0x00,0xf8,0x0f,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xf8,0x0f,0x80,0x00,
0x80,0x00,0x88,0x00,0x88,0x1f,0x88,0x00,0x94,0x00,0xa4,0x00,0xc2,0x7f,0x01,0x00, /* 6 */
"以",0x00,0x08,0x20,0x08,0x44,0x08,0x84,0x08,0x84,0x08,0x04,0x08,0x04,0x08,0x04,0x04,
0x04,0x04,0x04,0x04,0x24,0x02,0x14,0x0a,0x0c,0x11,0x84,0x20,0x40,0x40,0x20,0x40, /* 7 */
"慰",0xfc,0x10,0x84,0x10,0xfc,0x7e,0x04,0x10,0xf4,0x12,0x04,0x14,0xfa,0x15,0x22,0x10,
0xa9,0x14,0x34,0x09,0x80,0x00,0x10,0x21,0x12,0x49,0x12,0x48,0xe1,0x0f,0x00,0x00, /* 8 */
"风",0x00,0x00,0xfc,0x0f,0x04,0x08,0x04,0x08,0x14,0x0a,0x24,0x0a,0x44,0x09,0x44,0x09,
0x84,0x08,0x84,0x08,0x44,0x09,0x44,0x49,0x24,0x52,0x12,0x52,0x02,0x60,0x01,0x40, /* 9 */
"尘",0x80,0x00,0x80,0x00,0x90,0x04,0x90,0x08,0x88,0x10,0x84,0x20,0x82,0x20,0x00,0x00,
0x80,0x00,0x80,0x00,0xfc,0x1f,0x80,0x00,0x80,0x00,0x80,0x00,0xff,0x7f,0x00,0x00, /* 10 */
" ",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 11 */
"尽",0x00,0x00,0xf8,0x1f,0x08,0x10,0x08,0x10,0x08,0x10,0xf8,0x1f,0x08,0x12,0x08,0x02,
0x08,0x04,0xc4,0x08,0x04,0x11,0x02,0x60,0x31,0x00,0xc0,0x00,0x00,0x01,0x00,0x02, /* 12 */
"倾",0x08,0x00,0x08,0x7f,0x28,0x08,0x24,0x04,0x24,0x3e,0x26,0x22,0xe6,0x2a,0x25,0x2a,
0x24,0x2a,0x24,0x2a,0xa4,0x2a,0x64,0x2a,0x24,0x04,0x04,0x14,0x04,0x22,0x04,0x41, /* 13 */
"江",0x00,0x00,0x04,0x00,0xe8,0x3f,0x08,0x02,0x01,0x02,0x02,0x02,0x12,0x02,0x10,0x02,
0x08,0x02,0x08,0x02,0x07,0x02,0x04,0x02,0x04,0x02,0xf4,0x7f,0x04,0x00,0x00,0x00, /* 14 */
"海",0x80,0x00,0x84,0x00,0x88,0x3f,0x48,0x00,0xa1,0x1f,0x82,0x10,0x92,0x12,0x90,0x14,
0xe8,0x7f,0x88,0x10,0x47,0x12,0x44,0x14,0xc4,0x3f,0x04,0x10,0x04,0x0a,0x00,0x04, /* 15 */
"里",0x00,0x00,0xfc,0x1f,0x84,0x10,0x84,0x10,0xfc,0x1f,0x84,0x10,0x84,0x10,0xfc,0x1f,
0x80,0x00,0x80,0x00,0xfc,0x1f,0x80,0x00,0x80,0x00,0x80,0x00,0xff,0x7f,0x00,0x00, /* 16 */
"赠",0x00,0x11,0x3e,0x12,0x22,0x0a,0xaa,0x3f,0xaa,0x24,0xaa,0x35,0xaa,0x2e,0xaa,0x24,
0xaa,0x3f,0x2a,0x00,0x2a,0x1f,0x08,0x11,0x14,0x1f,0x24,0x11,0x22,0x1f,0x01,0x11, /* 17 */
"饮",0x04,0x02,0x04,0x02,0x04,0x02,0x7c,0x3e,0x22,0x21,0x12,0x11,0x81,0x04,0x08,0x04,
0x08,0x04,0x08,0x0a,0x08,0x0a,0x48,0x0a,0x28,0x11,0x18,0x11,0x88,0x20,0x40,0x40, /* 18 */
"天",0x00,0x00,0xfc,0x1f,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xff,0x7f,0x80,0x00,
0x40,0x01,0x40,0x01,0x20,0x02,0x20,0x02,0x10,0x04,0x08,0x08,0x04,0x10,0x03,0x60, /* 19 */
"下",0x00,0x00,0xff,0x7f,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x02,0x40,0x04,
0x40,0x08,0x40,0x10,0x40,0x10,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00, /* 20 */
"人",0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x40,0x01,0x40,0x01,
0x20,0x02,0x20,0x02,0x10,0x04,0x10,0x04,0x08,0x08,0x04,0x10,0x02,0x20,0x01,0x40, /* 21 */
"封",0x10,0x10,0x10,0x10,0x10,0x10,0xfe,0x10,0x10,0x7e,0x10,0x10,0xff,0x10,0x00,0x12,
0x10,0x14,0x10,0x14,0xfe,0x10,0x10,0x10,0x10,0x10,0xf0,0x10,0x0f,0x14,0x02,0x08, /* 22 */
"时",0x00,0x10,0x00,0x10,0x3e,0x10,0x22,0x10,0xa2,0x7f,0x22,0x10,0x22,0x10,0x3e,0x10,
0x22,0x11,0x22,0x12,0x22,0x12,0x22,0x10,0x3e,0x10,0x22,0x10,0x00,0x14,0x00,0x08, /* 23 */
"引",0x00,0x10,0xfe,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0xfc,0x10,0x04,0x10,0x04,0x10,
0x02,0x10,0xfe,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x50,0x10,0x20,0x10, /* 24 */
"朋",0x00,0x00,0x7c,0x3e,0x44,0x22,0x44,0x22,0x44,0x22,0x7c,0x3e,0x44,0x22,0x44,0x22,
0x44,0x22,0x7c,0x3e,0x44,0x22,0x44,0x22,0x44,0x22,0x42,0x21,0x52,0x29,0xa1,0x10, /* 25 */
"伴",0x10,0x02,0x50,0x22,0x90,0x12,0x88,0x0a,0x08,0x02,0xec,0x3f,0x0c,0x02,0x0a,0x02,
0x09,0x02,0xf8,0x7f,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0x02,0x08,0x02, /* 26 */
"启",0x80,0x00,0x00,0x01,0xf8,0x3f,0x08,0x20,0x08,0x20,0x08,0x20,0xf8,0x3f,0x08,0x00,
0x08,0x00,0x08,0x00,0xe8,0x3f,0x24,0x20,0x24,0x20,0x22,0x20,0xe1,0x3f,0x20,0x20, /* 27 */
"孑",0x00,0x00,0xfe,0x1f,0x00,0x08,0x00,0x04,0x00,0x02,0x80,0x21,0x80,0x18,0x80,0x06,
0xc0,0x01,0xb8,0x00,0x87,0x00,0x82,0x00,0x80,0x00,0x80,0x00,0xa0,0x00,0x40,0x00, /* 28 */
"身",0x40,0x00,0x20,0x00,0xf8,0x0f,0x08,0x08,0xf8,0x0f,0x08,0x08,0xf8,0x4f,0x08,0x28,
0x08,0x18,0xfe,0x0f,0x00,0x0a,0x00,0x09,0xc0,0x08,0x38,0x08,0x07,0x0a,0x00,0x04, /* 29 */
"醉",0x00,0x02,0x7f,0x04,0x94,0x7f,0x14,0x00,0x7f,0x11,0x55,0x11,0xd5,0x2a,0x55,0x44,
0x75,0x00,0x43,0x04,0xc1,0x7f,0x7f,0x04,0x41,0x04,0x41,0x04,0x7f,0x04,0x41,0x04, /* 30 */
"经",0x08,0x00,0x88,0x3f,0x04,0x10,0x24,0x08,0x22,0x0c,0x1f,0x12,0x08,0x21,0xc4,0x40,
0x02,0x00,0xbf,0x3f,0x02,0x04,0x00,0x04,0x38,0x04,0x07,0x04,0xc2,0x7f,0x00,0x00, /* 31 */
"年",0x08,0x00,0x08,0x00,0xf8,0x3f,0x04,0x01,0x04,0x01,0x02,0x01,0xf8,0x1f,0x08,0x01,
0x08,0x01,0x08,0x01,0xff,0x7f,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, /* 32 */
"少",0x80,0x00,0x80,0x00,0x80,0x00,0x90,0x04,0x90,0x08,0x88,0x10,0x88,0x20,0x84,0x28,
0x82,0x08,0x80,0x04,0x00,0x02,0x00,0x01,0x80,0x00,0x40,0x00,0x30,0x00,0x0e,0x00, /* 33 */
"乍",0x10,0x00,0x10,0x00,0xf0,0x7f,0x48,0x00,0x48,0x00,0x44,0x00,0xc2,0x1f,0x41,0x00,
0x40,0x00,0x40,0x00,0xc0,0x3f,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00, /* 34 */
"醒",0x00,0x00,0x7f,0x3e,0x14,0x22,0x14,0x3e,0x7f,0x22,0x55,0x3e,0x55,0x08,0x55,0x0a,
0x75,0x3e,0x43,0x09,0x41,0x08,0x7f,0x3e,0x41,0x08,0x41,0x08,0x7f,0x7f,0x41,0x00, /* 35 */
"华",0x10,0x01,0x10,0x11,0x08,0x09,0x0c,0x07,0x8a,0x01,0x69,0x21,0x08,0x21,0x08,0x3e,
0x88,0x00,0x80,0x00,0xff,0x7f,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00, /* 36 */
"发",0x80,0x00,0x88,0x08,0x88,0x10,0x44,0x00,0xfc,0x3f,0x40,0x00,0x20,0x00,0xe0,0x1f,
0x50,0x10,0x90,0x10,0x88,0x08,0x08,0x05,0x04,0x02,0x02,0x05,0xc0,0x18,0x38,0x60, /* 37 */
"生",0x80,0x00,0x88,0x00,0x88,0x00,0x88,0x00,0xfc,0x3f,0x84,0x00,0x82,0x00,0x81,0x00,
0x80,0x00,0xfc,0x1f,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xff,0x7f,0x00,0x00, /* 38 */
};
二、说明
1、由于要处理中文字模,文件需要保存为GB2312格式。