5110-51.c
来自「诺基亚5110 LCD资料」· C语言 代码 · 共 408 行 · 第 1/2 页
C
408 行
};
unsigned char code jiaohao[]={
/*-- 文字: + - --48*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x00,
/*-- 文字: + --49*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: - --50*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x00
};
unsigned char code hanzi[]=
{
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 南 0
; 宽×高(像素): 16×16
------------------------------------------------------------------------------*/
0x04,0x04,0xE4,0xE4,0x24,0x64,0xF4,0xBF,0x2F,0xA4,0xE4,0x64,0x24,0xE6,0xE6,0x04,
0x00,0x00,0x7F,0x7F,0x05,0x05,0x05,0x7F,0x7F,0x05,0x05,0x25,0x65,0x7F,0x3F,0x00,
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 京 1
; 宽×高(像素): 16×16
------------------------------------------------------------------------------*/
0x00,0x04,0x04,0xE4,0xE4,0x24,0x25,0x27,0x26,0x24,0x24,0xE4,0xE6,0x06,0x04,0x00,
0x00,0x20,0x30,0x19,0x1D,0x4D,0xC1,0xFF,0x7F,0x01,0x05,0x0D,0x3D,0x38,0x10,0x00,
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 发 2
; 宽×高(像素): 16×16
------------------------------------------------------------------------------*/
0x00,0x10,0x3E,0x3E,0x10,0xF0,0xFF,0x9F,0x90,0x92,0x96,0x9C,0x1C,0x10,0x10,0x10,
0x40,0x60,0x30,0x98,0x8F,0xC7,0x47,0x6E,0x38,0x38,0x2F,0x67,0xC0,0xC0,0x40,0x00,
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 烧 3
; 宽×高(像素): 16×16
------------------------------------------------------------------------------*/
0x00,0xE0,0xE0,0xFF,0xFF,0x9C,0xCC,0x44,0x6F,0x3F,0x74,0x74,0xDC,0xEC,0xE4,0x80,
0x41,0x71,0x3C,0x0F,0x87,0xCD,0x79,0x3F,0x0F,0x01,0x3F,0x7F,0x41,0x41,0x71,0x70,
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 电 4
; 宽×高(像素): 16×16
------------------------------------------------------------------------------*/
0x00,0x00,0xF8,0xF8,0x48,0x48,0x48,0xFF,0xFF,0x48,0x48,0x48,0xF8,0xF8,0x00,0x00,
0x00,0x00,0x0F,0x0F,0x04,0x04,0x04,0x3F,0x7F,0x44,0x44,0x44,0x4F,0x4F,0x70,0x70,
/*------------------------------------------------------------------------------
; 源文件 / 文字 : 子 5
; 宽×高(像素): 16×16
------------------------------------------------------------------------------*/
0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xE2,0xF2,0x1A,0x0E,0x06,0x02,0x80,0x80,0x00,
0x01,0x01,0x01,0x01,0x01,0x41,0xC1,0xFF,0x7F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
};
void delay_1ms(void)//1ms延时函数
{
unsigned int i;
for (i=0;i<50;i++) ;
;
}
/*--------------------------------------------
LCD_write_byte: 使用SPI接口写数据到LCD
输入参数:dt:写入的数据;
command :写数据/命令选择;
编写日期:20080918
----------------------------------------------*/
void LCD_write_byte(unsigned char dt, unsigned char command)
{
unsigned char i;
sce=0;
dc=command;
for(i=0;i<8;i++)
{
if(dt&0x80)
sdin=1;
else
sdin=0;
dt=dt<<1;
sclk=0;
sclk=1;
}
dc=1;
sce=1;
sdin=1;
}
/*---------------------------------------
LCD_init: 3310LCD初始化
编写日期:20080918
----------------------------------------- */
void LCD_init(void)
{
res=0;
delay_1ms();
res=1;
LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令
LCD_write_byte(0xC0,0);//设定液晶偏置电压
LCD_write_byte(0x06,0);
LCD_write_byte(0x13,0);
LCD_write_byte(0x20,0);//使用基本指令
LCD_write_byte(0x0C,0);//设定显示模式,正常显示
}
/*-------------------------------------------
LCD_set_XY: 设置LCD坐标函数
输入参数:X:0-83 Y:0-5
编写日期:20080918
---------------------------------------------*/
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40 | Y, 0);// column
LCD_write_byte(0x80 | X, 0);// row
}
/*------------------------------------------
LCD_clear: LCD清屏函数
编写日期:20080918
--------------------------------------------*/
void LCD_clear(void)
{
unsigned char t;
unsigned char k;
LCD_set_XY(0,0);
for(t=0;t<6;t++)
{
for(k=0;k<84;k++)
{
LCD_write_byte(0x00,1);
}
}
}
/*---------------------------------------------
LCD_write_shu: 显示8(宽)*16(高)点阵列数字字母符号等半角类
输入参数:c:显示的字符;
编写日期:20080918
-----------------------------------------------*/
void LCD_write_shu(unsigned char row, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
{
unsigned char i;
LCD_set_XY(row*8, page);// 列,页
for(i=0; i<8;i++)
{
LCD_write_byte(shuzi[c*16+i],1);
}
LCD_set_XY(row*8, page+1);// 列,页
for(i=8; i<16;i++)
{
LCD_write_byte(shuzi[c*16+i],1);
}
}
/*---------------------------------------------
LCD_write_hanzi: 显示16(宽)*16(高)点阵列汉字等半角类
输入参数:c:显示的字符;
编写日期:20080918
-----------------------------------------------*/
void LCD_write_hanzi(unsigned char row, unsigned char page,unsigned char c) //row:列 page:页 dd:字符
{
unsigned char i;
LCD_set_XY(row*8, page);// 列,页
for(i=0; i<16;i++)
{
LCD_write_byte(hanzi[c*32+i],1);
}
LCD_set_XY(row*8, page+1);// 列,页
for(i=16; i<32;i++)
{
LCD_write_byte(hanzi[c*32+i],1);
}
}
main()
{
unsigned char k;
res=0;
for(k=0;k<10;k++);
res=1;
LCD_init(); //初始化LCD模块
LCD_clear(); //清屏幕
LCD_write_hanzi(2,0,0); //南
LCD_write_hanzi(6,0,1); //京
LCD_write_hanzi(1,2,2); //发
LCD_write_hanzi(3,2,3); //烧
LCD_write_hanzi(5,2,4); //电
LCD_write_hanzi(7,2,5); //子
LCD_write_shu(0,4,14); //e
LCD_write_shu(1,4,13); //d
LCD_write_shu(2,4,18); //i
LCD_write_shu(3,4,34); //y
LCD_write_shu(4,4,15); //f
LCD_write_shu(5,4,10); //a
LCD_write_shu(6,4,28); //s
LCD_write_shu(7,4,17); //h
LCD_write_shu(8,4,10); //a
LCD_write_shu(9,4,24); //o
while(1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?