Nokia5110 液晶 C51 源代码 源程序
ESP8266点亮nokia5110,打造自己的小电视
ESP8266点亮nokia5110,打造⾃⼰的⼩电视
材料清单:
esp8266
nokia5110
⾯包板
跳线
ARDUINO IDE下载
Arduino IDE离线安装esp8266 SDK (8266_package_2.6.3)
双击运⾏即可解压,解压完成后,再打开Arduino IDE,即可在菜单栏>⼯具>开发板中找到你使⽤的esp8266开发板**ESP8266-NodeMCU开发板驱动 (CP210X) **
可以上传个blink测试⼀下板⼦
点亮 nokia5110
安装这两个库
测试代码
点击查看代码
显⽰图案
因为使⽤的nokia屏幕,致敬⼀下经典握⼿开机logo
点击查看代码
ESP8266⾃动配⽹ – WiFiManager库(强烈推荐,⾮常好⽤)
点击查看代码
ESP8266获取时间
点击查看代码
ESP8266获取并解析⼼知天⽓数据
点击查看代码
ESP8266获取并解析哔哩哔哩API数据(获取粉丝数量)
点击查看代码
将以上代码综合⼀下
点击查看代码。
单片机之路—诺基亚5110LCD显示屏驱动
单片机之路—诺基亚5110LCD显示屏驱动电子产品在很多场合都需要提供和用户交互的人机界面,具备人机交互界面的电子产品可以给用户更好的使用,让电子产品更加直观。
今天给大家讲一个性价比很高的LCD显示器——诺基亚5110LCD。
可能很多人奇怪,为什么这个LCD显示屏被叫做诺基亚5110,那是因为这个显示屏诺基亚经典机型5110手机上使用的现实屏。
就是下图这部手机,曾经的经典。
记得第一部手机就是诺基亚的,那会还在读初中,宿舍的同学总是抢着来打贪吃蛇,打到满屏。
电子产品的更新换代实在太快了,现在已经很难找到这个手机的踪影了。
诺基亚5110手机5110LCD是一个84X48的点阵LCD,可以显示4行汉字。
和单片机的接口不是很复杂,是一个没有MISO只有MOSI的SPI协议。
用于通信的数据线是4根,其中有一根是用于设定传入的数据是命令还是数据的选择端口。
下图是在马云家买的一个诺基亚5110LCD模块,总共有8个引脚。
用于通信的引脚为4个,1个复位引脚,2个电源引脚,1个是背光灯控制引脚。
因为诺基亚LCD本身是不会发光的,为了能够在晚上也能够看到液晶显示屏显示的内容,需要增加背光灯。
诺基亚5110实物图和引脚描述我们把LCD需要单片机控制的5个引脚连接到单片机的P1口,背光灯通过一个电阻接到VCC5V,让背光灯保持常亮的状态,也可以接到单片机的引脚上去,通过单片机控制背光灯的亮灭。
5110LCD与单片机接口图我们来看一下怎么写程序驱动诺基亚5110,实现在5110上显示出字符。
由于接通电源后,LCD内部的RAM数据状态是不确定的,所以我们需要给LCD复位一下。
5110LCD复位时序//产生一个复位脉冲Lcd_res=0;delay_us();Lcd_res=1;我们需要往LCD写数据,SPI的写时序如下,这里实现的是通过单片机IO口模拟SPI时序,如果单片机有硬件的SPI接口是可以用来驱动的5110LCD的。
诺基亚5110学习(含字库,免财富)
0x3C, 0x4A, 0x49, 0x49, 0x30, 0x01, 0x71, 0x09, 0x05, 0x03, 0x36, 0x49, 0x49, 0x49, 0x36, 0x06, 0x49, 0x49, 0x29, 0x1E, 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, 0x56, 0x36, 0x00, 0x00, 0x08, 0x14, 0x22, 0x41, 0x00, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x51, 0x09, 0x06, 0x32, 0x49, 0x59, 0x51, 0x3E, 0x7C, 0x12, 0x11, 0x12, 0x7C, 0x7F, 0x49, 0x49, 0x49, 0x36, 0x3E, 0x41, 0x41, 0x41, 0x22, 0x7F, 0x41, 0x41, 0x22, 0x1C, 0x7F, 0x49, 0x49, 0x49, 0x41, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x3E, 0x41, 0x49, 0x49, 0x7A, 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x41, 0x7F, 0x41, 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01, 0x7F, 0x08, 0x14, 0x22, 0x41, 0x7F, 0x40, 0x40, 0x40, 0x40, 0x7F, 0x02, 0x0C, 0x02, 0x7F, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x7F, 0x09, 0x09, 0x09, 0x06, 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x7F, 0x09, 0x19, 0x29, 0x46, 0x46, 0x49, 0x49, 0x49, 0x31, 0x01, 0x01, 0x7F, 0x01, 0x01, 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x63, 0x14, 0x08, 0x14, 0x63, 0x07, 0x08, 0x70, 0x08, 0x07, 0x61, 0x51, 0x49, 0x45, 0x43, 0x00, 0x7F, 0x41, 0x41, 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55, 0x00, 0x41, 0x41, 0x7F, 0x00, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x01, 0x02, 0x04, 0x00, 0x20, 0x54, 0x54, 0x54, 0x78,
毕业设计基于Nokia5110的液晶屏模块设计
电气信息学院基于Nokia5110的液晶屏模块设计摘要:本设计是以单片机STC89C52RC为核心器件的基于Nokia5110液晶屏的电子指南针。
整个系统主要由单片机最小系统,电源输入模块,LCD液晶显示模块,磁阻传感器模块和串口电路部分构成。
通过用C语言编程使单片机处理磁阻传感器接收到的X轴和Y轴上的磁场分量,转换为距南方的角度后,通过Nokia5110动态显示。
Nokia5110是一块84×48 的LCD点阵型液晶显示屏,如果字模是12×16 大小的字符,则能显示3 行,每行显示7个汉字。
每个字符都分为上下两部分进行扫描,在每行扫描时以一列8位为单位进行扫描。
通过原理图设计、软件仿真、制作硬质板电路,硬件调试,证明了本设计的可行性。
关键词:Nokia5110,STC89C52RC,磁阻传感器HMC5883L,电子指南针Abstract: This design is a digital compass based on Nokia5110, with the MCU STC89C52RC as its core. The system mainly consists of a MCU minimum system, a power input module, a LCD module, a magnetic sensor module and a serial port module. Through C language programming, the MCU processes the data on the X and Y axes, which is collected by the magnetic sensor. Then it is transformed into an angle indicating its relative direction to the south pole in degrees. Finally, it is shown on the Nokia5110 dynamically. The Nokia5110 is an LCD with 84×48 dots, if a character is displayed with 12×16 dots, then it can display 3 lines, with each line comprising 7 characters. The characters are scanned in two halves, the upper half and the lower half. For each half, 8 bits( a byte)are scanned as a unit at a time. Through schematic design, software simulation, making the printed circuit board and hardware debugging, the feasibility of this design has been proved.Keywords:Nokia5110, STC89C52RC, magnetic sensor, digital compass目录1 前言 .............................................................................................. 错误!未定义书签。
Nokia5110程序
#include <hidef.h> /* common defines and macros */#include "derivative.h" /* derivative-specific definitions */#define uchar unsigned char#define uint unsigned int#define lcd12864_date PORTB //数据口#define lcd12864_rs PTT_PTT5// PTT_PTT5; //寄存器选择输入#define lcd12864_rw PTT_PTT3 //液晶读/写控制#define lcd12864_e PTT_PTT2 //液晶使能控制#define DQ PORTA_PA0 // 定义DQ引脚为P3.3 #define DQ_HIGH() DDRA=0 //设置数据口为输入#define DQ_LOW() DDRA=1;DQ=0; //设置数据口为输出//uint temp; //温度值variable of temperature uchar A1,A2,A3;void delay2(uint i);void Init_Ds18b20(void);uchar Read_One_Byte();void Write_One_Byte(uchar dat);uint Get_Tmp();void DisplayTemp(uint temp) ;void delay(unsigned int t){uint i,j;for(i=t;i>0;i--)for(j=1000;j>0;j--);}void lcd12864_write_cmd(unsigned char command) //写指令{lcd12864_rs=0;lcd12864_rw=0;lcd12864_e=0;lcd12864_date=command;delay(5);lcd12864_e=1;lcd12864_e=0;delay(5);}void lcd12864_write_data(unsigned char data) // 写数据写入一个字符{lcd12864_rs=1;lcd12864_rw=0;lcd12864_e=0;lcd12864_date=data;delay(5);lcd12864_e=1;lcd12864_e=0;delay(5);}void lcd12864_pos(unsigned char x,unsigned char y) //确定位置{unsigned char pos;if (x==1){x=0x80;}else if (x==2){x=0x90;}else if (x==3){x=0x88;}else{x=0x98;}pos=x+y-1;lcd12864_write_cmd(pos); //显示地址}void io_init(){lcd12864_write_cmd(0x30); //基本指令操作lcd12864_write_cmd(0x0C); //显示开,关光标lcd12864_write_cmd(0x01); //清除LCD的显示内容位置计数器调整为0x00 }void lcd12864_wrtie_string( char *str) //写字符串{while(*str!='\0') //未结束{lcd12864_write_data(*str++);}}void init_LCD(){delay(20);lcd12864_write_cmd(0x30);delay(20);lcd12864_write_cmd(0x30);delay(20);lcd12864_write_cmd(0x0c);//开显示,不显示光标,且不闪烁delay(20);lcd12864_write_cmd(0x01); //清屏delay(20);lcd12864_write_cmd(0x06); //每次写入数据后地址指针加1delay(20);}/**/void Display1(){lcd12864_pos(1,2);lcd12864_wrtie_string("温度调节系统");lcd12864_pos(2,1);lcd12864_wrtie_string("菜单1:当前温度");lcd12864_pos(3,1);lcd12864_wrtie_string("菜单2:目标温度");lcd12864_pos(4,1);lcd12864_wrtie_string("菜单3:温度曲线");}void Display2(){lcd12864_pos(1,2);lcd12864_wrtie_string("温度调节系统");lcd12864_pos(2,1);lcd12864_wrtie_string("当前温度:**度");lcd12864_pos(3,1);lcd12864_wrtie_string("目标温度:**度");lcd12864_pos(4,2);lcd12864_wrtie_string(" Welcome ! ");}void main(void){delay(5);DDRB=0xff;DDRT=0xff;// io_init();init_LCD();lcd12864_pos(2,2);lcd12864_wrtie_string(" Welcome To ! ");lcd12864_pos(3,2);lcd12864_wrtie_string("温度调节系统");delay(2000);lcd12864_write_cmd(0x01); //清屏delay(20);while(1){DisplayTemp(Get_Tmp());lcd12864_pos(2,3);lcd12864_write_data(0x30+A1);lcd12864_pos(2,4);lcd12864_write_data(0x30+A2);lcd12864_pos(2,5);lcd12864_write_data(0x2e);lcd12864_pos(2,6);lcd12864_write_data(0x30+A3);/*Display1() ; */}}/*************精确延时函数*****************/ void delay2(unsigned int i){i=10*i;while(--i);}/****************************************** 此延时函数针对的是12Mhz的晶振delay(0):延时518us 误差:518-2*256=6delay(1):延时7us (原帖写"5us"是错的)delay(10):延时25us 误差:25-20=5delay(20):延时45us 误差:45-40=5delay(100):延时205us 误差:205-200=5delay(200):延时405us 误差:405-400=5*******************************************//*****************DS18B20******************/void Init_Ds18b20(void) //DS18B20初始化send reset and initialization command{char presence=1;while(presence){//DQ = 1; //DQ复位,不要也可行。
C51密码锁源程序
//================================================================== //工程名称://工程功能://作者://审核://版本: 0001.02.03//日期:2007.04.12//================================================================== #include "reg51.h"#include "intrins.h"#define uchar unsigned char#define uint unsigned int//==================液晶12864 端口定义sbit E=P1^0;sbit RW=P1^1;sbit RS=P1^2;//====================================//==================IIC 24c04 端口定义sbit SDA=P1^0;sbit SCL=P1^0;//====================================uchar code table1[]={"B :密码锁系统"};uchar code table2[]={"作者:潘素琴"};uchar code table3[]={"日期:2007.05.16"};/*****************************//*延时子程序*//****************************/void delayms (uchar k){uchar j;while((k--)!=0){for(j=0;j<115;j++){;}}}//=============================================================//函数名称:void check_busy(void)//函数功能:检测LCM是不是处于忙状态,并等待忙结束//作者://日期:2007.03.31//============================================================= void check_busy(void){uchar i;RS=0;RW=1;E=1;P0=0xff;while(P0&0x01);i=6;while(i--);E=0;}//=====================================================//======================================================//函数名称:void sendorder(uchar order)//函数功能:给LCM发送指令//作者://日期:2007.03.31//======================================================void sendorder(uchar order){uchar i,temp1=0,temp2=0;check_busy();RS=0;RW=0;for(i=0;i<8;i++){temp1=order&0x01;temp2|=temp1;order>>=1;temp2<<=1;}P0=temp2;i=7;while(i--);E=1;E=0;}//=====================================================//===================================================== //函数名称:void sendbyte(uchar byte)//函数功能:给LCM发送数据//作者://日期:2007.03.31//=====================================================void sendbyte(uchar byte){uchar i,temp1=0,temp2=0;check_busy();for(i=0;i<8;i++){temp1=byte&0x01;temp2|=temp1;byte>>=1;temp2<<=1;}RS=1;RW=0;P0=temp2;i=7;while(i--);E=1;E=0;}//=======================================================/*----------------------------------------------------------------------调用方式:void start_bit(void)函数说明:开始位------------------------------------------------------------------------*/void start_bit(void){SCL=1;_nop_();SDA=1;_nop_();SDA=0;_nop_();_nop_();}/*------------------------------------------------------------------- 调用方式:void stop_bit(void)函数说明:停止位--------------------------------------------------------------------*/ void stop_bit(void){SDA=0;_nop_();SCL=1;_nop_();SDA=1;_nop_();}/*----------------------------------------------------------------- 调用方式:void mast_ack(void)-函数说明:主答函数-----------------------------------------------------------------*/ void mast_ack(void){SCL=0;_nop_();SDA=0;_nop_();SCL=1;_nop_();SCL=0;_nop_();SDA=1;_nop_();}/*-----------------------------------------------调用方式:void ack(void)函数说明:应答函数-----------------------------------------------*/void ack(void){SDA=1;SCL=0;_nop_();SCL=1;while(SDA){;}SCL=0;_nop_();}/*-----------------------------------------------调用方式:void no_ack(void)函数说明:无需应答位,在读程序中用到-----------------------------------------------*/void no_ack(void){SDA=1;_nop_();SCL=1;_nop_();SCL=0;_nop_();}/*-----------------------------------------------调用方式:write_8bit(unsigned char ch)函数说明:写一个字节(8位)数据-----------------------------------------------*/write_8bit(unsigned char ch){unsigned char i=8;SCL=0;_nop_();while(i--){SDA=(bit)(ch&0x80);_nop_();ch<<=1;SCL=1;_nop_();SCL=0;_nop_();}}/*----------------------------------------------调用方式:unsigned char read24c16(unsigned int address) 函数说明:读24c16指定地址数据(字节读)-----------------------------------------------*/unsigned char read24c16(uchar addh){unsigned char data rdata;unsigned char i=8;start_bit();write_8bit(0xa0);ack();write_8bit(addh);ack(); //伪写start_bit();write_8bit(0xa1);ack();while(i--){rdata<<=1;SCL=0;_nop_();SCL=1;_nop_();if(SDA) rdata|=0x01;}no_ack();stop_bit();return(rdata);}/*-----------------------------------------------调用方式:void write24c16(unsigned int address,unsigned char ddata)函数说明:写数据到24c16的指定地址(字节写)-----------------------------------------------*/void write24c16(unsigned int addr_h,unsigned char ddata){start_bit();write_8bit(0xa0);ack();write_8bit(addr_h);ack();write_8bit(ddata);ack();stop_bit();delayms(4);}//===================================================================== ==//===================================================================== ==//函数名:void LCD_init()//函数功能://参数://作者://日期://===================================================================== ==void LCD_init(){uchar i;sendorder(0x30); ///功能设置8位控制界面基本指令sendorder(0x0c); ///显示打开光标关反白显示关sendorder(0x01); ///清除屏幕显示将DDRAM的地址计数器清零sendorder(0x80); ///设置DDRAM地址为0000000for(i=0;i<14;i++){sendbyte(table1[i]);}sendorder(0x88);for(i=0;i<12;i++){sendbyte(table2[i]);}sendorder(0x98);for(i=0;i<16;i++){sendbyte(table3[i]);}}//===================================================================== ==//===================================================================== ==//函数名://函数功能://参数://作者://日期://===================================================================== ==void main(){LCD_init();while(1);}//===================================================================== ==。
诺基亚5110显示屏51单片机驱动程序2
诺基亚5110显示屏51单片机驱动程序#include <stc.h>#include "intrins.h" //_nop_();延时函数用#include <dmb.h> //字符代码表#define uchar unsigned char#define uint unsigned intsbit sce = P3^4; //片选sbit res = P0^0; //复位,0复位sbit dc = P3^5; //1写数据,0写指令sbit sdin = P3^7; //数据sbit sclk = P3^6; //时钟uint data temp_data[2]={0x00,0x00}; //读出温度暂放//================18b20数据口定义===============sbit DQ=P0^0; //温度输入口uint h;uint temp;unsigned char presence,flash=0;/*****************延时函数*************************/void delay(uint t){for (;t>0;t--);}//================延时函数=====================void delay_1ms(void)//1ms延时函数{unsigned int i;for (i=0;i<500;i++);}/*---------------lcd显示函数开始----------------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;elsesdin=0;dt=dt<<1;sclk=0;sclk=1;}dc=1;sce=1;sdin=1;}/*---------------------------------------LCD_init: 5110LCD初始化编写日期:20080918----------------------------------------- */void LCD_init(void){res=0;delay_1ms();res=1;LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令LCD_write_byte(0xd0,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);// columnLCD_write_byte(0x80 | X, 0);// row}/*------------------------------------------LCD_clear: LCD清屏函数编写日期:20080918--------------------------------------------*/void LCD_c lear(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);}}//=================lcd显示函数结束================//=================18b20相关函数开始==============/****************DS18B20复位函数************************/ow_reset(void){char presence=1;while(presence){while(presence){DQ=1;_nop_();_nop_(); //从高拉倒低DQ=0;delay(50); //550 usDQ=1;delay(6); //66 uspresence=DQ; //presence=0 复位成功,继续下一步}delay(45); //延时500 uspresence=~DQ;}DQ=1; //拉高电平}/////****************DS18B20写命令函数************************/ void write_byte(uchar val) //向1-WIRE 总线上写1个字节{uchar i;for(i=8;i>0;i--){DQ=1;_nop_();_nop_(); //从高拉倒低DQ=0;_nop_();_nop_();_nop_();_nop_(); //5 usDQ=val&0x01; //最低位移出delay(6); //66 usval=val/2; //右移1位}DQ=1;delay(1);}/****************DS18B20读1字节函数************************/ uchar read_byte(void) //从总线上取1个字节{uchar i;uchar value=0;for(i=8;i>0;i--){DQ=1;_nop_();_nop_();value>>=1;DQ=0;_nop_();_nop_();_nop_();_nop_(); //4 usDQ=1;_nop_();_nop_();_nop_();_nop_(); //4 usif(DQ)value|=0x80;delay(6); //66 us}DQ=1;return(value);}///****************读出温度函数************************/read_temp(){ow_reset(); //总线复位if(presence==1){flash=1;} //DS18B20不正常,蜂鸣器报警delay(200);write_byte(0xcc); //发命令write_byte(0x44); //发转换命令ow_reset();delay(1);write_byte(0xcc); //发命令write_byte(0xbe);temp_data[0]=read_byte(); //读温度值的第字节temp_data[1]=read_byte(); //读温度值的高字节temp=temp_data[1];temp<<=8;temp=temp|temp_data[0]; // 两字节合成一个整型变量。
c51单片机程序-nokia5110液晶显示
高电平表示数据输入 ,低电平表示命令输入 #define LCD_CLK P15 上升沿写入 #define LCD_DIN P23 #define LCD_BL P17 高电平点亮,低电平关闭 code unsigned char { ascii_dot[] = // ASCII 表
0x00,0x00,0x00,0x00,0x00, // - 0x00,0x00,0x5F,0x00,0x00, // -!0x00,0x07,0x00,0x07,0x00, // -"0x14,0x7F,0x14,0x7F,0x14, // -#0x24,0x2E,0x7B,0x2A,0x12, // -$0x23,0x13,0x08,0x64,0x62, // -%0x36,0x49,0x56,0x20,0x50, // -&0x00,0x04,0x03,0x01,0x00, // -'0x00,0x1C,0x22,0x41,0x00, // -(0x00,0x41,0x22,0x1C,0x00, // -)0x22,0x14,0x7F,0x14,0x22, // -*0x08,0x08,0x7F,0x08,0x08, // -+0x40,0x30,0x10,0x00,0x00, // -,0x08,0x08,0x08,0x08,0x08, // --0x00,0x60,0x60,0x00,0x00, // -.0x20,0x10,0x08,0x04,0x02, // -/0x3E,0x51,0x49,0x45,0x3E, // -00x00,0x42,0x7F,0x40,0x00, // -10x62,0x51,0x49,0x49,0x46, // -20x21,0x41,0x49,0x4D,0x33, // -30x18,0x14,0x12,0x7F,0x10, // -40x27,0x45,0x45,0x45,0x39, // -50x3C,0x4A,0x49,0x49,0x31, // -60x01,0x71,0x09,0x05,0x03, // -70x36,0x49,0x49,0x49,0x36, // -80x46,0x49,0x49,0x29,0x1E, // -90x00,0x36,0x36,0x00,0x00, // -:-
诺基亚5110液晶显示器应用课程设计
单片机原理及应用课程设计电气工程学院一、课程设计任务书1.课程设计项目诺基亚5110液晶显示器应用。
2.设计内容1)设计诺基亚5110液晶显示器应用的总体设计方案;2)以MCS-51系列单片机为核心器件和诺基亚5110液晶显示器组成液晶显示硬件系统;3)系统程序编制与调试;4)电路系统的综合调试;5)撰写课程设计论文;6)完成课程设计论文答辩。
3.设计要求1)以STC89C51单片机为控制核心,对诺基亚5110液晶显示器进行控制。
编程使得在LCD显示器上显示字符,如多行滚动显示:“吉林工程技术师范学院”“电气工程学院”。
等字符,还可以显示别的文字;2)单片机课程设计题目的硬件电路、程序由学生自行设计完成。
3)液晶显示器上要显示出设计人的班级,组长的学号等信息。
4.设计进度(2011年6月13日至2011年6月24日)时间设计内容第1-2天查阅资料,方案比较、设计与论证,理论分析与计算第3-5天硬件电路调试第6-8天系统调试第9-10天书写报告、答辩5.设计地点新实验楼323微机实验室二.参考资料[1]李广弟,朱月秀,王秀山编著.单片机基础. 北京:北京航空航天大学出版社,2001[2] 何立民编著.MCS-51系列单片机应用系统设计系统配置与接口技术.北京:北京航空航天大学出版社,1999[3] 蔡美琴等编著.MCS-51 单片机系统及应用.北京:高等教育出版社.1992二、评语及成绩成绩:指导教师:单片机原理及应用课程设计班级:自动化0845 姓名:刘旭阳学号: 11 号指导教师:方健撰写日期: 2011年6月23日Nokia LCD多功能显示摘要液晶显示器件[1](LCD)是一种高新技术的基础元器件。
它利用液晶的各种电光效应,把液晶对电场、磁场、光线和温度等外界条件的变化在一定条件下转换为可视信号而制成的显示器。
液晶显示器具有低电压、低功耗的特点,与CMOS集成电路相匹配.电池作为电源,适合于便携式显示。
C51万能学习型遥控器源程序
#define SEND5P22
#define SEND6P21
#define SEND7P20
#define SEND8P11
#define SEND9P12
#define SEND10P13
#define SEND11P14
#define SEND12P15
#define SEND13P16
temp=SBUF;
if((temp>=0xe0)&&(temp<=0xef))
{
device=temp%16;
r_device=1;
}
else
order=temp;
RI=0;
}
}
void open_scon()
{
SCON=0x40;
REN=1;
void write8(unsigned char d);
unsigned char read(unsigned int addr);
unsigned char read0(unsigned char addr);
void write0(unsigned char addr,unsigned char x);
void send_sharp();
void send_rec();
void rec(unsigned char key);
intcode y=10700;
unsigned char code mask[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
void delay(unsigned int x);
NOKIA_5110液晶51单片机驱动程序
#include <reg51.h>/* 雨亭电子代码测试环境:JME-2核心板+1T指令周期的STC单片机(51内核STC12LE5A60S2)+33M 晶振单片机工作电压3.3V程序默认IO连接方式:sce-P0^0; res-P0^1; dc-P0^2; sdin-P1^5; sclk-P1^7;*/sbit sce = P2^0; //片选sbit res = P2^1; //复位,0复位sbit dc = P2^2; //1写数据,0写指令sbit sdin = P2^3; //数据sbit sclk = P2^4; //时钟//6*16字符unsigned char code shuzi[]={/*-- 文字: > --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0x00,0x02,0x04,0x88,0x50,0x20,0x00,0x02,0x01,0x00,0x00,0x00,/*-- 文字: W --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0x1C,0xE0,0x3C,0xE0,0x1C,0x00,0x00,0x03,0x00,0x03,0x00,0x00,/*-- 文字: Y --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0x04,0x1C,0xE0,0x1C,0x04,0x00,0x00,0x02,0x03,0x02,0x00,0x00,/*-- 文字: G --*//*-- 宋体9; 此字体下对应的点阵为:宽x高=6x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=6x16 --*/0xF0,0x08,0x04,0x44,0xCC,0x40,0x00,0x01,0x02,0x02,0x01,0x00};unsigned char code hanzi[]={/*-- 文字: 单--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x00,0x7C,0x55,0x56,0xFC,0x56,0x55,0x54,0x7C,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x07,0x01,0x01,0x01,0x01,0x01,0x00,/*-- 文字: 片--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x00,0xFF,0x48,0x48,0x48,0x4F,0xC8,0x08,0x08,0x08,0x00,0x04,0x02,0x01,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,/*-- 文字: 机--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x84,0x64,0xFF,0x24,0x44,0xFE,0x02,0x02,0xFF,0x02,0x00,0x00,0x01,0x00,0x07,0x04,0x02,0x01,0x00,0x00,0x07,0x04,0x07,0x00,/*-- 文字: 开--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x20,0x22,0x22,0xFE,0x22,0x22,0x22,0xFE,0x22,0x23,0x22,0x00,0x04,0x04,0x02,0x01,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,/*-- 文字: 发--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x08,0x0E,0x88,0x78,0x2F,0xE8,0x28,0xA9,0x6A,0x08,0x08,0x00,0x04,0x02,0x05,0x04,0x02,0x02,0x01,0x02,0x02,0x04,0x04,0x00,/*-- 文字: 工--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x03,0x02,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04,0x04,0x00,/*-- 文字: 作--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x10,0x08,0xFC,0x13,0x08,0x04,0xFF,0x24,0x24,0x24,0x04,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x01,0x01,0x01,0x01,0x00,/*-- 文字: 室--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x04,0x06,0x4A,0x6A,0x5A,0xCB,0x4A,0x5A,0x6A,0x4A,0x06,0x00,0x04,0x04,0x05,0x05,0x05,0x07,0x05,0x05,0x05,0x04,0x04,0x00,/*-- 文字: 雨--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x02,0xFA,0x9A,0x2A,0x0A,0xFE,0x9A,0x2A,0x0A,0xFB,0x02,0x00,0x00,0x07,0x00,0x01,0x00,0x07,0x00,0x05,0x04,0x07,0x00,0x00,/*-- 文字: 亭--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x60,0x22,0xA2,0xBA,0xAA,0xAB,0xAA,0xAA,0xBA,0x22,0x60,0x00,0x00,0x00,0x00,0x04, 0x04,0x07,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: 电--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0xFC,0x94,0x94,0x94,0xFF,0x94,0x94,0x94,0xFE,0x04,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x04,0x04,0x04,0x04,0x06,0x00,/*-- 文字: 子--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x20,0x21,0x21,0x21,0x21,0xF9,0x29,0x25,0x23,0x31,0x20,0x00,0x00,0x00,0x00,0x04,0x04,0x07,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: 第--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x04,0xEA,0xAB,0xAE,0xAA,0xFC,0xAA,0xAB,0xAE,0xBA,0x82,0x00,0x04,0x04,0x02,0x01, 0x00,0x07,0x00,0x02,0x02,0x02,0x01,0x00,/*-- 文字: 一--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*-- 文字: 行--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x48,0x24,0xF3,0x08,0x09,0x09,0x09,0x09,0xF9,0x09,0x08,0x00,0x00,0x00,0x07,0x00,0x00,0x04,0x04,0x04,0x07,0x00,0x00,0x00,/*-- 文字: 二--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,/*-- 文字: 三--*//*-- 宋体9; 此字体下对应的点阵为:宽x高=12x12 --*//*-- 高度不是8的倍数,现调整为:宽度x高度=12x16 --*/0x00,0x02,0x22,0x22,0x22,0x22,0x22,0x22,0x23,0x02,0x00,0x00,0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00};void delayms(unsigned int ii)//1ms延时函数{unsigned int i,x;for (x=0;x<ii;x++){for (i=0;i<100;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;elsesdin=0;dt=dt<<1;sclk=0;sclk=1;}dc=1;sce=1;sdin=1;}/*---------------------------------------LCD_init: 3310LCD初始化编写日期:20080918----------------------------------------- */void LCD_init(void){res=0;delayms(10);res=1;LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令LCD_write_byte(0xC6,0);//设定液晶偏置电压LCD_write_byte(0x06,0);//温度校正LCD_write_byte(0x13,0);;//1:48LCD_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);// columnLCD_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: 显示6(宽)*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*6, page);// 列,页for(i=0; i<6;i++){LCD_write_byte(shuzi[c*12+i],1);}LCD_set_XY(row*6, page+1);// 列,页for(i=6; i<12;i++){LCD_write_byte(shuzi[c*12+i],1);}}/*---------------------------------------------LCD_write_hanzi: 显示12(宽)*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*6, page);// 列,页for(i=0; i<12;i++){LCD_write_byte(hanzi[c*24+i],1);}LCD_set_XY(row*6, page+1);// 列,页for(i=12; i<24;i++){LCD_write_byte(hanzi[c*24+i],1);}}main(){unsigned char k;sce=0;res=0;for(k=0;k<250;k++);res=1;LCD_init(); //初始化LCD模块LCD_clear(); //清屏幕LCD_write_hanzi(0,0,0); //单LCD_write_hanzi(2,0,1); //片LCD_write_hanzi(4,0,2); //机LCD_write_hanzi(6,0,3); //开LCD_write_hanzi(8,0,4); //发LCD_write_hanzi(10,0,5); //工LCD_write_hanzi(12,0,6); //作LCD_write_hanzi(0,2,7); //室LCD_write_hanzi(2,4,8); //雨LCD_write_hanzi(4,4,9); //亭LCD_write_hanzi(6,4,10); //电LCD_write_hanzi(8,4,11); //子LCD_write_shu(10,4,0); //>LCD_write_shu(11,4,1); //WLCD_write_shu(12,4,2); //YLCD_write_shu(13,4,3); //Gwhile(1){delayms(5000);}。
诺基亚5110LCD驱动程序
/******************************************************************** NOKIA5110(3310)液晶屏驱动程序** 晶振频率:11.0592M** 线路->单片机实验开发板A******************************************************************/#include/*-- -------定义Nokia5110 引角---- -----*/sbit sclk = P3^3;sbit sdin = P3^4;sbit dc = P3^5;sbit sce = P3^7;sbit res = P3^6;void initNokia5110(void); /* NOkia 5110 初始化*/void clearNokia5110(void); /* 清除屏幕整屏清空*/void Display_char(unsigned char x,unsigned char y,char *s); /* 写字符x 设置显示字符的X位置; y 设置显示字符的Y 位置*s 显示字符的首地址*/void Display_num(unsigned char x,unsigned char y,char s); /* 写数字x 设置显示字符的X位置; y 设置显示字符的Y 位置s 显示数字*/void write_byte(unsigned char data1); /* 发送1字节到NOkia 5110 */void setxy(unsigned char x,unsigned char y); /* 设置显示坐标x 行坐标(0-83) unsigned char y 列坐标(0-5) */void delay(unsigned int time);void main(void){initNokia5110(); /* NOkia 5110 初始化*/clearNokia5110(); /* 清除屏幕整屏清空*/Display_char(1,2,""); /* 写字符x 设置显示字符的X位置; y 设置显示字符的Y位置*s 显示字符的首地址*/Display_char(10,4,"NOKIA5510"); /* 写字符x 设置显示字符的X位置; y 设置显示字符的Y位置*s 显示字符的首地址*///Display_num(0,0,9); // 写数字while(1);}/****************************5110 0-9字模**************************//*函数原型:无/*函数功能:0-9字模/*输入参数:无/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ unsigned char code asc2tab[][6] ={{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },// sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 },// !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 },// "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 },// #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 },// ${ 0x00, 0x62, 0x64, 0x08, 0x13, 0x23 },// %{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 },// &{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 },// '{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 },// ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 },// ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 },// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 },// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 },// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 },// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 },// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 },// /{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E },// 0{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 },// 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 },// 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 },// 3 { 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 },// 4 { 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 },// 5 { 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 },// 6 { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 },// 7 { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 },// 8 { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E },// 9 { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 },// : { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 },// ; { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 },// < { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 },// = { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 },// > { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 },// ? { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E },// @ { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C },// A { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 },// B { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 },// C { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C },// D { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 },// E { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 },// F { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A },// G { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F },// H{ 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 },// I { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 },// J { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 },// K { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 },// L { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F },// M { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F },// N { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E },// O { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 },// P { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E },// Q { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 },// R { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 },// S { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 },// T { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F },// U { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F },// V { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F },// W { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 },// X { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 },// Y { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 },// Z { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 },// [ { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 },// 55 { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 },// ] { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 },// ^{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 },// _ { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 },// ' { 0x00, 0x20, 0x54, 0x54, 0x54, 0x78 },// a { 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 },// b { 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 },// c { 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F },// d { 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 },// e { 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 },// f { 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C },// g { 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 },// h { 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 },// i { 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 },// j { 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 },// k { 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 },// l { 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 },// m { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 },// n { 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 },// o { 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 },// p { 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC },// q { 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 },// r { 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 },// s { 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 },// t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C },// u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C },// v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C },// w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 },// x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C },// y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 },// z{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 }};/****************************Nokia5110初始化函数**************************//*函数原型:initNokia5110(void)/*函数功能:Nokia5110初始化/*输入参数:无/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/void initNokia5110(void){delay(10); //系统复位res = 0;delay(2);res = 1;dc = 0;write_byte(0x21); //;芯片是活动的(PD=0) 使用扩展指令集write_byte(0xd5);write_byte(0x20); //;芯片是活动的(PD=0) 使用水平寻址(V=0) 使用基本指令集(H=0) write_byte(0x0c); //;设置显示配置(D=1 E=0)}/****************************Nokia5110清屏函数*********************//*函数原型:void clearNokia5110(void)/*函数功能:Nokia5110清屏/*输入参数:无/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/void clearNokia5110(void){unsigned int i,j;for(i=0;i<6;i++){setxy(j,i);dc = 1;while (j<84){write_byte(0x00);j++;}j = 0;}}/*--------------------------------------;模块名称:Display_char(unsigned char x,unsigned char y,char *s);;功能:写字符;占用资源:;参数说明:x 设置显示字符的X位置; y 设置显示字符的Y位置*s 显示字符的首地址;创建日期:2001.01.19;版本:VER 2.0 ★STALI☆;-------------------------------------*/void Display_char(unsigned char x,unsigned char y,char *s){unsigned char line;setxy(x,y);while(*s){for(line=0;line<6;line++){dc = 1;write_byte(asc2tab[*s - 32][line]);}}sce = 1;}/****************************Nokia5110写数字函数*********************/ /*函数原型:void Display_num(unsigned char x,unsigned char y,char s)/*函数功能:Nokia5110写数字/*输入参数:x 设置显示字符的X位置; y 设置显示字符的Y位置s 显示数字/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ void Display_num(unsigned char x,unsigned char y,char s){unsigned char line;setxy(x,y);dc = 1;for(line=0;line<6;line++){write_byte(asc2tab[s+16][line]);}sce = 1;}/*************************Nokia5110发送1字节函数*********************/ /*函数原型:void Display_num(unsigned char x,unsigned char y,char s)/*函数功能:发送1字节到NOkia 5110/*输入参数:x 设置显示字符的X位置; y 设置显示字符的Y位置s 显示数字/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ void write_byte(unsigned char data1){unsigned char i;res = 1;sce = 0;for(i=0;i<8;i++){sdin = (bit) (data1&0x80);;sclk = 1;data1 <<=1;}}/*************************Nokia5110设置显示坐标函数*********************/ /*函数原型:void setxy(unsigned char x,unsigned char y)/*函数功能:设置显示坐标/*输入参数:unsigned char x 行坐标(0-83) unsigned char y 列坐标(0-5)/*输出参数:无/*调用模块:/*建立时间:2006/10/1/*作者:站长/**********************************************************************/ void setxy(unsigned char x,unsigned char y){dc = 0;write_byte(y|0x40); //设置y轴。
C51程序
MAIN.C#include<reg51.h> //通用寄存器头文件#include"clock.h" //对象模块头文件此处包含软件中所有模块的头文件#include"lcd.h"#include"key.h"#include"ad.h"#include"pid.h"#define CYCLE 35121//系统常数定义此处填写系统基本的常数数据例如定时中断时间常数float filter_out,T,t1; /* 此处定义为主模块各函数共用的全局变量unsigned int f; /*unsigned:无符号变量;static:静态变量主函数:void main(){unsigned char /*n,y,r,h,m,s,c,*/b; 此处定义主函数内部使用的全部局部变量//int i=0;clock_init(11,9,28,15,33,40);//定时中断初始化TMOD=TMOD&0xf0; //设定计数器T0为工作方式1,16位计数器方式TMOD=TMOD|0x01;TL0=CYCLE%256; //分别写入时间常数的高8位和低8位TH0=CYCLE/256;EA=1; //打开中断控制逻辑开关ET0=1;TR0=1; //打开计数器逻辑开关//其他模块的初始化clr_screen();convert_da(0);//put_float(2340.789,3,2);// //输出浮点数2340.789,整数后3位,小数前2位main_loop: //监控程序主循环/*n=current_time('n'); /* 此处填写监控程序的散转控制部分y=current_time('y');r=current_time('r');h=current_time('h');m=current_time('m');s=current_time('s');locate(3,7); //显示位置定位style_5x7(2); //输出字库中第2个字符(本程序中为数字2)style_5x7(0);put_int((int)n,2); //输出整型数n(定义的“年”,下为:月日时分秒)style_5x7(12); //输出字库中第12个字符(本程序中为“冒号:”)put_int((int)y,2);style_5x7(12);put_int((int)r,2);style_5x7(12);put_int((int)h,2);style_5x7(15);put_int((int)m,2);style_5x7(15);put_int((int)s,2);*/ //至此,显示完整日期,年月日时分秒locate(2,8);put_float(T,2,1); //输出浮点数T(液晶屏上显示的温度)b=inkey(); //读取键入值,赋给b/*if (b!=0xff){ //如果有键按下locate(5,7+5*i);c=getkey(); //读取键入值,赋给c(注意与inkey的区别)style_5x7(c);i++; //控制字符连续排列输出}*/locate(6,8);if(b!=255){b=getkey();if(b<10){f=(f*10+b)%100; //算出的值赋给f}}t1=(float)f; //f取浮点数赋给t1put_int(t1,2); //输出2位整型数字goto main_loop; //执行主循环}void timer_int()interrupt 1 //定时中断服务程序{unsigned int x; //定义一个辅助变量xunsigned char y; //int:整型(数字)char:字符型static unsigned char count/*,temp_row=0,temp_col=0*/;x=CYCLE+TL0; //重写时间常数TL0=x%256;TH0=x/256;clock_run(); //实时多任务程序此处填写实时多任务类型的多个程序模块key_scan();//convert_da(50);filter_out=Yn(filter_out); //从Yn函数取得DA值T=-0.00009174716*filter_out*filter_out+0.33669798421*filter_out+19.7078734907;//进行标度变换,以便输出温度(一个DA值对应一个温度,上式为确定二次函数)count++;if (count>=31)/*{ //判断大于1秒钟(时间常数30,若是2秒,则61)count=0;locate(temp_row,temp_col);put_float(T,2,1);temp_row++;if (temp_row==8){temp_col=temp_col+25;temp_row=0;}if (temp_col==125){temp_row=0;temp_col=0;}*///下划线部分为了在屏幕上每列输出8个,输出5列的实时温度值,可不做了解{y=pid(t1-T); //将t1-T的值用作PID运算,将PID运算结果赋给ycount=0;convert_da(y); //将y值用作convert_da函数的计算}}CLOCK.H#define SECOND_CONST 30 //定义时间常数30extern void clock_init(unsigned char n,unsigned char y,unsigned char r,unsigned char h,unsigned char m,unsigned char s);extern void clock_run();extern unsigned char current_time(char c);功能: 以上三个函数组成一个标准计时钟对象.其中clock_run为时钟的走时部分,必须放在定时中断中执行.函数clock_init完成时钟初始化,变元h,m,s分别为设定的时、分、秒时间。
NOKIA5110参考程序
//说明:以下函数在STM32F405RGT6上验证过,应用于其他条件下根据自身需要做移植//nokia5110.h//********************* nokia5110.h *********************////串行线协议,并非I2c总线协议,可达4MHz//84*48 14*6个6*8字符左上角为(0,0) 纵向六个字节,可水平会垂直寻址//高位在下面,先写入高位工作电压2.7V~3.3V 六根线控制背光线可省//********************* nokia5110.h *********************//#include "stm32f4xx.h"//*****************调试函数启用****************////#define Nokia5110_debug 1#ifdef Nokia5110_debugvoid Nokia5110_dbg(void);#endif//*********************IO引脚定义*********************//Nokia5110: PC0-RST CS-PC1 DC-PC2 Din-PC3 PA0-CLK PA1-BL//注:!!要对IO进行设置,设置在其他文件中,为包含在本WORD文档中//液晶背光控制#define lcd_lbg_1 G PIOA->BSRRL=GPIO_Pin_1 //背光高电平亮#define lcd_lbg_0 G PIOA->BSRRH=GPIO_Pin_1 //背光低电平灭#define lcd_rst_1 GPIOC->BSRRL=GPIO_Pin_0 //复位,0复位#define lcd_ce_1 GPIOC->BSRRL=GPIO_Pin_1 //片选端口#define lcd_dc_1 GPIOC->BSRRL=GPIO_Pin_2 //数据1/指令0#define lcd_da_1 GPIOC->BSRRL=GPIO_Pin_3 //数据#define lcd_clk_1 GPIOA->BSRRL=GPIO_Pin_0 //时钟(4Mhz)#define lcd_rst_0 GPIOC->BSRRH=GPIO_Pin_0 //复位,0复位#define lcd_ce_0 GPIOC->BSRRH=GPIO_Pin_1 //片选端口#define lcd_dc_0 GPIOC->BSRRH=GPIO_Pin_2 //数据1/指令0#define lcd_da_0 GPIOC->BSRRH=GPIO_Pin_3 //数据#define lcd_clk_0 GPIOA->BSRRH=GPIO_Pin_0 //时钟(4Mhz)//*********************IO引脚定义*********************//*********************nokia5110命令定义*********************#define kongbai 0x08 //显示空白#define zhengchang 0x0c //显示正常#define quanxian 0x09 //全部显示#define fanzhuan 0x0d //显示反转#define pd_h_kz 0x80;//显示空白//*********************nokia5110命令定义*********************//***********************字库定义声明************************//6 x 8ascii码,0x10--0x1f可以自定义externconst u8 font6x8[128][6];//8*16 数字字母字小写asc码-0x57externconst u8 font8x16[36][16];//0_哈//1_尔//2_滨//3_工//4_程//5_大//6_学//7_图//8_书//9_馆externconst u8 hanzi[10][32];//数据水平字节垂直,40*40qq图片externconst u8 Image_QQ[200];//*********************字库定义声明************************//***********************函数声明**************************//写入的数据voidlcdwrdat(u8 dat);//连续写入的数据,*s为字符数组或字符串ascii码voidlcdwrcom(u8 com);void lcdclear(void);//清屏//lcd反清屏函数voidlcdall(void);//5110lcd初始化函数上电100ms内完成voidlcd_init(void);//**0<=x<=83,0<=y<=47,设置坐标voidlcd_set_xy(u8 x,u8 y);//**0<=x<=13,0<=y<=5,写一个字符dat为asc码voidlcddispone(u8 x,u8 y,u8 dat);//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组,num为数据长度voidlcddispmore(u8 x,u8 y,u8 num,u8 *s);//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组voidlcddispstr(u8 x,u8 y,u8 *s);//**0<=x<=9,0<=y<=5,写8x16数字或小写字母voidlcd_write_shu(u8 x, u8 y,u8 dat);//**0<=x<=9,0<=y<=5,写16x16汉字index为汉字编号如0_哈voidlcd_write_hanzi(u8 x, u8 y,u8 index);//**0<=x<=83,0<=y<=5,显示图片,width为宽度,hight为高度自动除8 如40*40 voidlcddispimage(u8 x,u8 y,u8 *s,u8 width,u8 hight);//显示10位数占用11位voiddisp_long(u8 x,u8 y,longdat);//有符号数显示,占6位void disp_s16(u8 x,u8 y,s16 dat);//8位无符号数显示,占3位void disp_u8(u8 x,u8 y,u8 dat);//8位数HEX码显示,占2位voiddisp_hex(u8 x,u8 y,u8 dat);//16位数HEX码显示,占4位void disp_hex2(u8 x,u8 y,u16 dat);//32位数HEX码显示,占8位void disp_hex4(u8 x,u8 y,u32 dat);//***********************函数声明**************************/*函数调用示例lcd_lbg_1; //开背光lcd_init(); //初始化lcd模块lcdclear(); //清屏幕for(i=0;i<2;i++)for(j=0;j<5;j++)lcd_write_hanzi(j,i,j*5+i);lcddispmore(0,4,6,"shgued");lcddispmore(0,5,6,"shgued");lcddispone(6,4,0x30);lcddispone(7,4,'1');lcddispone(6,5,0x32);lcddispone(7,5,'3');lcd_write_shu(6,5,'4');lcd_write_shu(9,5,'9');delay(2000);lcdclear(); //清屏幕lcddispimage(10,1,(u8*)Image_QQ,40,40);//??u8**///Nokia5110.c//********************* Nokia5110.c *********************////串行线协议,并非I2c总线协议,可达4MHz(实际上上可以比这快,自己验证下,改变下面系统频率)//84*48 14*6个6*8字符左上角为(0,0) 纵向六个字节,可水平会垂直寻址//高位在下面,先写入高位工作电压2.7V~3.3V 六根线控制背光线可省//********************* Nokia5110.c *********************//#include "stm32f4xx.h"#include "Nokia5110.h"#define lcd_adress_check 1 //地址范围检验功能启用//Nokia5110延时,系统频率定义!!根据需要设置//#define cpuclk_84Mhz//#define cpuclk_72Mhz//#define cpuclk_144Mhz//#define cpuclk_168Mhz//#define cpuclk_48Mhz//#define cpuclk_24Mhz#define cpuclk_16Mhz//72Mhz 1 6*(n+1)个nop//#define delay_4Mhz for(lcd_cnt=0;lcd_cnt<3;lcd_cnt++)//0.125us//72Mhz 9clk 4Mhz *2#ifdef cpuclk_84Mhz#define delay_4Mhz __asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_72Mhz#define delay_4Mhz __asm("nop;nop;nop;nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_144Mhz#define delay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;nop;nop;n op;nop")#elifdefined cpuclk_168Mhz#define delay_4Mhz__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;n op;nop;nop;nop;nop;nop");__asm("nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_48Mhz#define delay_4Mhz __asm("nop;nop;nop;nop;nop;nop")#elifdefined cpuclk_24Mhz#define delay_4Mhz __asm("nop;nop;nop")#elifdefined cpuclk_16Mhz#define delay_4Mhz __asm("nop;nop")#else#define delay_4Mhz __asm("nop")#endif//6 x 8ascii码,0x10--0x1f可以自定义//右上5*7 字节倒序高位在下const u8 font6x8[128][6] ={{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, //0x00// 0 ??{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, //0x01// 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, //0x02// 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, //0x03// 3{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, //0x04// 4{ 0x00, 0x27, 0x45, 0x45, 0x45, 0x39 }, //0x05// 5{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, //0x06// 6{ 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, //0x07// 7{ 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, //0x08// 8{ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, //0x0a// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, //0x0b// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, //0x0c// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, //0x0d// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, //0x0e// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, //0x0f// /{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x10// sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, //0x11// !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, //0x12// "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, //0x13// #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, //0x14// ${ 0x00, 0x23, 0x13, 0x08, 0x64, 0x62 }, //0x15// % ?{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, //0x16// &{ 0x00, 0x00, 0x05, 0x03, 0x00, 0x00 }, //0x17// '{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, //0x18// ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, //0x19// ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, //0x1a// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, //0x1b// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, //0x1c// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, //0x1d// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, //0x1e// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, //0x1f// / ??{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, //0x20// sp{ 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00 }, //0x21// !{ 0x00, 0x00, 0x07, 0x00, 0x07, 0x00 }, //0x22// "{ 0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14 }, //0x23// #{ 0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12 }, //0x24// ${ 0x00, 0x23, 0x13, 0x08, 0x64, 0x62 }, //0x25// %{ 0x00, 0x36, 0x49, 0x55, 0x22, 0x50 }, //0x26// & { 0x00, 0x04, 0x08, 0x10, 0x20, 0x40 }, //0x27// \ 换行{ 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00 }, //0x28// ({ 0x00, 0x00, 0x41, 0x22, 0x1c, 0x00 }, //0x29// ){ 0x00, 0x14, 0x08, 0x3E, 0x08, 0x14 }, //0x2a// *{ 0x00, 0x08, 0x08, 0x3E, 0x08, 0x08 }, //0x2b// +{ 0x00, 0x00, 0x00, 0xA0, 0x60, 0x00 }, //0x2c// ,{ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08 }, //0x2d// -{ 0x00, 0x00, 0x60, 0x60, 0x00, 0x00 }, //0x2e// .{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x02 }, //0x2f// /{ 0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E }, //0x30// 0{ 0x00, 0x00, 0x42, 0x7F, 0x40, 0x00 }, //0x31// 1{ 0x00, 0x42, 0x61, 0x51, 0x49, 0x46 }, //0x32// 2{ 0x00, 0x21, 0x41, 0x45, 0x4B, 0x31 }, //0x33// 3{ 0x00, 0x18, 0x14, 0x12, 0x7F, 0x10 }, //0x34// 4{ 0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30 }, //0x36// 6 { 0x00, 0x01, 0x71, 0x09, 0x05, 0x03 }, //0x37// 7 { 0x00, 0x36, 0x49, 0x49, 0x49, 0x36 }, //0x38// 8 { 0x00, 0x06, 0x49, 0x49, 0x29, 0x1E }, //0x39// 9 { 0x00, 0x00, 0x36, 0x36, 0x00, 0x00 }, //0x3a// : { 0x00, 0x00, 0x56, 0x36, 0x00, 0x00 }, //0x3b// ; { 0x00, 0x08, 0x14, 0x22, 0x41, 0x00 }, //0x3c// < { 0x00, 0x14, 0x14, 0x14, 0x14, 0x14 }, //0x3d// = { 0x00, 0x00, 0x41, 0x22, 0x14, 0x08 }, //0x3e// > { 0x00, 0x02, 0x01, 0x51, 0x09, 0x06 }, //0x3f// ? { 0x00, 0x32, 0x49, 0x59, 0x51, 0x3E }, //0x40// @ { 0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C }, //0x41// A { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x36 }, //0x42// B { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x22 }, //0x43// C { 0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C }, //0x44// D { 0x00, 0x7F, 0x49, 0x49, 0x49, 0x41 }, //0x45// E { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01 }, //0x46// F { 0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A }, //0x47// G { 0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F }, //0x48// H { 0x00, 0x00, 0x41, 0x7F, 0x41, 0x00 }, //0x49// I { 0x00, 0x20, 0x40, 0x41, 0x3F, 0x01 }, //0x4a// J { 0x00, 0x7F, 0x08, 0x14, 0x22, 0x41 }, //0x4b// K { 0x00, 0x7F, 0x40, 0x40, 0x40, 0x40 }, //0x4c// L { 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F }, //0x4d// M { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F }, //0x4e// N { 0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E }, //0x4f// O { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x06 }, //0x50// P { 0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E }, //0x51// Q { 0x00, 0x7F, 0x09, 0x19, 0x29, 0x46 }, //0x52// R { 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 }, //0x53// S { 0x00, 0x01, 0x01, 0x7F, 0x01, 0x01 }, //0x54// T { 0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F }, //0x55// U { 0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F }, //0x56// V { 0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F }, //0x57// W { 0x00, 0x63, 0x14, 0x08, 0x14, 0x63 }, //0x58// X { 0x00, 0x07, 0x08, 0x70, 0x08, 0x07 }, //0x59// Y { 0x00, 0x61, 0x51, 0x49, 0x45, 0x43 }, //0x5a// Z { 0x00, 0x00, 0x7F, 0x41, 0x41, 0x00 }, //0x5b// [ { 0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55 }, //0x5c// \\? { 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00 }, //0x5d// ] { 0x00, 0x04, 0x02, 0x01, 0x02, 0x04 }, //0x5e// ^ { 0x00, 0x40, 0x40, 0x40, 0x40, 0x40 }, //0x5f// _ { 0x00, 0x00, 0x01, 0x02, 0x04, 0x00 }, //0x60// '{ 0x00, 0x7F, 0x48, 0x44, 0x44, 0x38 }, //0x62// b{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x20 }, //0x63// c{ 0x00, 0x38, 0x44, 0x44, 0x48, 0x7F }, //0x64// d{ 0x00, 0x38, 0x54, 0x54, 0x54, 0x18 }, //0x65// e{ 0x00, 0x08, 0x7E, 0x09, 0x01, 0x02 }, //0x66// f{ 0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C }, //0x67// g{ 0x00, 0x7F, 0x08, 0x04, 0x04, 0x78 }, //0x68// h{ 0x00, 0x00, 0x44, 0x7D, 0x40, 0x00 }, //0x69// i{ 0x00, 0x40, 0x80, 0x84, 0x7D, 0x00 }, //0x6a// j{ 0x00, 0x7F, 0x10, 0x28, 0x44, 0x00 }, //0x6b// k{ 0x00, 0x00, 0x41, 0x7F, 0x40, 0x00 }, //0x6c// l{ 0x00, 0x7C, 0x04, 0x18, 0x04, 0x78 }, //0x6d// m{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x78 }, //0x6e// n{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38 }, //0x6f// o{ 0x00, 0xFC, 0x24, 0x24, 0x24, 0x18 }, //0x70// p{ 0x00, 0x18, 0x24, 0x24, 0x18, 0xFC }, //0x71// q{ 0x00, 0x7C, 0x08, 0x04, 0x04, 0x08 }, //0x72// r{ 0x00, 0x48, 0x54, 0x54, 0x54, 0x20 }, //0x73// s{ 0x00, 0x04, 0x3F, 0x44, 0x40, 0x20 }, //0x74// t{ 0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C }, //0x75// u{ 0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C }, //0x76// v{ 0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C }, //0x77// w{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44 }, //0x78// x{ 0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C }, //0x79// y{ 0x00, 0x44, 0x64, 0x54, 0x4C, 0x44 }, //0x7a// z{ 0x00, 0x18, 0x7E, 0x81, 0x00, 0x00 }, //0x7b// {{ 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00 }, //0x7c// |{ 0x00, 0x00, 0x81, 0x7E, 0x18, 0x00 }, //0x7d// }{ 0x00, 0x04, 0x08, 0x04, 0x02, 0x04 }, //0x7e// ~{ 0x14, 0x14, 0x14, 0x14, 0x14, 0x14 } //0x7f// horiz lines};//8*16 数字字母字母小写asc码-0x57const u8 font8x16[36][16]={/*-- 文字: 0 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00},/*-- 文字: 1 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00}, /*-- 文字: 2 --*/{0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00},/*-- 文字: 3 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: 4 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00},/*-- 文字: 5 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: 6 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: 7 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00},/*-- 文字: 8 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00},/*-- 文字: 9 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00},/*-- 文字: a --10*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20},/*-- 文字: b --11*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: c --12*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00}, /*-- 文字: d --13*/{0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20},/*-- 文字: e --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00},/*-- 文字: f --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},/*-- 文字: g --16*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00},/*-- 文字: h --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20},/*-- 文字: i --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},/*-- 文字: j --19*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00},/*-- 文字: k --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00},/*-- 文字: l --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},/*-- 文字: m --22*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F},/*-- 文字: n --23*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20}, /*-- 文字: o --24*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00},/*-- 文字: p --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00},/*-- 文字: q --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80},/*-- 文字: r --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00},/*-- 文字: s --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00},/*-- 文字: t --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00},/*-- 文字: u --30*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20},/*-- 文字: v --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00},/*-- 文字: w --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00},/*-- 文字: x --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00},/*-- 文字: y --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00}, /*-- 文字: z --35*/{0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00} };//******************************************//0_哈//1_尔//2_滨//3_工//4_程//5_大//6_学//7_图//8_书//9_馆//******************************************const u8 hanzi[10][32]={/*-- 文字: 哈--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0xFC,0x04,0x04,0xFC,0x20,0x50,0x48,0x44,0x43,0x44,0x48,0x50,0x20,0x20,0x00, 0x00,0x0F,0x04,0x04,0x0F,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00},/*-- 文字: 尔--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x80,0x40,0x20,0x18,0x0F,0x08,0x08,0xE8,0x08,0x08,0x08,0x08,0x28,0x18,0x00,0x00, 0x20,0x10,0x08,0x06,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x02,0x04,0x08,0x30,0x00},/*-- 文字: 滨--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x10,0x60,0x02,0x0C,0xD0,0x0C,0xE4,0x24,0x25,0x26,0x24,0x14,0x04,0x14,0x0C,0x00, 0x04,0x04,0x7C,0x03,0x08,0x88,0x4F,0x29,0x09,0x09,0x09,0x2F,0x49,0x89,0x08,0x00},/*-- 文字: 工--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0x04,0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,0x04,0x00,0x00, 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00},/*-- 文字: 程--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x24,0x24,0xA4,0xFE,0x23,0x22,0x00,0x3E,0x22,0x22,0x22,0x22,0x22,0x3E,0x00,0x00, 0x08,0x06,0x01,0xFF,0x01,0x06,0x40,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x41,0x00},/*-- 文字: 大--*///5/*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00},/*-- 文字: 学--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00,0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00},/*-- 文字: 图--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0xFE,0x02,0x42,0x22,0x32,0x5E,0x92,0x52,0x32,0x12,0x02,0x02,0xFE,0x00,0x00,0x00,0xFF,0x42,0x42,0x42,0x51,0x55,0x64,0x69,0x41,0x42,0x42,0x42,0xFF,0x00,0x00},/*-- 文字: 书--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x00,0x00,0x08,0x08,0x08,0x08,0xFF,0x08,0x08,0x08,0xF9,0x02,0x04,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x21,0x41,0x21,0x1F,0x00,0x00},/*-- 文字: 馆--*//*-- Trebuchet MS12; 此字体下对应的点阵为:宽x高=16x16 --*/{0x40,0x30,0x8F,0x28,0x18,0x10,0x0C,0xE4,0x24,0x25,0x26,0x24,0xE4,0x14,0x0C,0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xF8,0x00,0x00}};//数据水平字节垂直,40*40qq图片const u8 Image_QQ[200] = {0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XC0,0XE0,0XF0,0XF8,0XE8,0XF4,0XF4,0X7E,0X7E,0X7E,0XFF,0XFF,0XFE,0XFE,0X7E,0X7E,0XFC,0XFC,0XF8,0XF0,0XF0,0XC0,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X10,0X70,0XF0,0XF8,0XF0,0XE0,0XC0,0X80,0XFC,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0X7F,0X61,0X61,0X60,0X60,0X7F,0X7F,0X73,0X67,0X43,0X40,0XE0,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0XC0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X03,0X07,0X0F,0X1F,0XFF,0XFF,0X7F,0X7F,0XFF,0XFF,0XEC,0XFE,0XDC,0XDC,0XD8,0XB8,0XB8,0XB8,0XB8,0XF8,0XF8,0XF8,0XFC,0XFE,0XFE,0XFD,0XFF,0XFF,0XFF,0X7F,0XFF,0XFF,0XFF,0XF0,0XE0,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X3F,0X7F,0XC0,0X00,0X00,0X00,0X01,0X01,0X01,0X01,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X03,0X3F,0X7F,0X7F,0X7F,0X7F,0X3F,0X00,0X80,0XE0,0XFF,0X3F,0X1F,0X3F,0X7F,0X7E,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X38,0X44,0X41,0X83,0X86,0X8C,0X88,0X90,0XB0,0XA0,0XE0,0X60,0X60,0X20,0X20,0X20,0X60,0X60,0XE0,0XB0,0XB0,0X98,0X98,0X8C,0X86,0X87,0X41,0X48,0X30,0X00,0X00,0X00,0X00};/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*///*//写入的数据voidlcdwrdat(u8 dat){u8i;lcd_clk_1;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出for(i=0;i<8;i++)//先位7{if(dat&0x80)lcd_da_1;//正边沿取样elselcd_da_0;dat=dat<<1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}lcd_ce_1;delay_4Mhz;}//连续写入的数据,*s为字符数组或字符串ascii码voidlcdwrdat_cont(u8 *s,u8 num){u8i,j,dat;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_clk_1;for(j=0;j<num;j++){dat=*s;for(i=0;i<8;i++)//先位7{if(dat&0x80)lcd_da_1;//正边沿取样elselcd_da_0;dat=dat<<1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}s++;}lcd_ce_1;delay_4Mhz;}//写入指令voidlcdwrcom(u8 com){u8i;lcd_clk_1;lcd_ce_0;lcd_dc_0;for(i=0;i<8;i++){if(com&0x80)lcd_da_1;elselcd_da_0;com=com<<1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}lcd_ce_1;delay_4Mhz;}//5110lcd初始化函数上电100ms内完成voidlcd_init(void){unsignedinti;lcd_ce_0;//<30ms内lcd_rst_0;//delay(1);//>100nsfor(i=0;i<100000;i++);//没明显效果lcd_rst_1;lcdwrcom(0x21);//lcd功能设置:芯片活动,水平寻址,使用扩展指令lcdwrcom(4+0x10);//1:48//对于有些NOKIA5110,VOP值设置不对显示不出东西,有一个函数用来调试选出合适的值lcdwrcom(54+0x80);//设置VOP值,没有明显效果,0<vop<90//Vlcd=3.06+(VOP)*0.06,本例VOP为0B0101 0000为十进制的80,Vlcd=7.86Vlcdwrcom(0x20);//lcd功能设置:芯片活动,水平寻址,使用基本指令lcdwrcom(0x0C);//设定显示配置:普通模式}//**0<=x<=83,0<=y<=47,设置坐标voidlcd_set_xy(u8 x, u8 y){lcdwrcom(0x40 | y);lcdwrcom(0x80 | x);}//lcd清屏函数voidlcdclear(void){u8t,k,i;lcd_set_xy(0,0);lcd_clk_1;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_da_0;for(t=0;t<6;t++){for(k=0;k<84;k++){//lcdwrdat(0x00);for(i=0;i<8;i++)//先位7{lcd_clk_1;delay_4Mhz;lcd_clk_0;delay_4Mhz;}}}lcd_ce_1;delay_4Mhz;}//lcd反清屏函数voidlcdall(void){u8t,k,i;lcd_set_xy(0,0);lcd_clk_1;lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_da_1;for(t=0;t<6;t++){for(k=0;k<84;k++){//lcdwrdat(0x00);for(i=0;i<8;i++)//先位7{lcd_clk_1;delay_4Mhz;lcd_clk_0;delay_4Mhz;}}}lcd_ce_1;delay_4Mhz;}//**0<=x<=13,0<=y<=5,写一个字符dat为asc码voidlcddispone(u8 x,u8 y,u8 dat){u8i;#ifdeflcd_adress_checkif(x>13) x=13;if(y>5) y=5;#endiflcdwrcom(0x40 | y);// columnlcdwrcom(0x80 | x*6);// rowfor (i=0; i<6; i++)lcdwrdat(font6x8[dat][i]);}//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组,num为数据长度voidlcddispmore(u8 x,u8 y,u8 num,u8 *s){u8i,j;#ifdeflcd_adress_checkif(x>13) x=13;if(y>5) y=5;#endiflcdwrcom(0x40 | y);// columnlcdwrcom(0x80 | x*6);// rowfor(j=0;j<num;j++){for (i=0; i<6; i++)lcdwrdat(font6x8[*s][i]);s++;if(*s=='\0')break;}}//**0<=x<=13,0<=y<=5,写字符串*s字符串或字符数组voidlcddispstr(u8 x,u8 y,u8 *s){#ifdeflcd_adress_checkif(x>13) x=13;if(y>5) y=5;#endiflcdwrcom(0x40 | y);// columnlcdwrcom(0x80 | x*6);// rowwhile(*s!='\0'){lcdwrdat_cont((u8*)font6x8[*s],6);s++;}}//**0<=x<=9,0<=y<=5,写8x16数字或小写字母voidlcd_write_shu(u8 x, u8 y,u8 dat){u8i;#ifdeflcd_adress_checkif(x>9) x=9;if(y>2) y=2;#endifx=x<<3;y=y<<1;lcd_set_xy(x, y);// 列,页for(i=0; i<8;i++){lcdwrdat(font8x16[dat][i]);}lcd_set_xy(x, y+1);// 列,页for(i=8; i<16;i++){lcdwrdat(font8x16[dat][i]);}}//**0<=x<=9,0<=y<=5,写16x16汉字index为汉字编号如0_哈void lcd_write_hanzi(u8 x, u8 y,u8 index) //row:列page:页dd:字符{u8i;#ifdeflcd_adress_checkif(x>4) x=4;if(y>2) y=2;#endifx=x<<4;y=y<<1;lcd_set_xy(x, y);// 列,页for(i=0; i<16;i++){lcdwrdat(hanzi[index][i]);}lcd_set_xy(x, y+1);// 列,页for(i=16; i<32;i++){lcdwrdat(hanzi[index][i]);}}//**0<=x<=83,0<=y<=5,显示图片,width为宽度,hight为高度自动除8 如40*40 voidlcddispimage(u8 x,u8 y,u8 *s,u8 width,u8 hight){u8i,j,k,wid,hig,dat;hight=hight/8;if((x+width)>84)wid=84-x;elsewid=width;if((y+hight)>6)hig=6-y;elsehig=hight;for(j=0;j<hig;j++){lcdwrcom(0x40 | y+j);lcdwrcom(0x80 | x);lcd_ce_0; //负边沿使能芯片lcd_dc_1;//第八个sclk正边沿被读出lcd_clk_1;for(i=0;i<wid;i++)//先位7{dat=*s;for(k=0;k<8;k++){if(dat&0x80)lcd_da_1;//正边沿取样elselcd_da_0;dat<<=1;lcd_clk_0;delay_4Mhz;lcd_clk_1;delay_4Mhz;}s++;}s=s-wid+width;}lcd_ce_1;delay_4Mhz;}//*//显示10位数占用11位voiddisp_long(u8 x,u8 y,longdat){u8disp[12];if(dat>=0) disp[0]=' ';else{disp[0]='-';dat=-dat;}disp[1]=dat/1000000000+48;disp[2]=dat/100000000%10+48;disp[3]=dat/10000000%10+48;disp[4]=dat/1000000%10+48;disp[5]=dat/100000%10+48;disp[6]=dat/10000%10+48;disp[7]=dat/1000%10+48;disp[8]=dat/100%10+48;disp[9]=dat/10%10+48;disp[10]=dat%10+48;disp[11]='\0';if(disp[1]=='0'){disp[1]=disp[0];disp[0]=' ';if(disp[2]=='0'){disp[2]=disp[1];disp[1]=' ';if(disp[3]=='0'){disp[3]=disp[2];disp[2]=' ';if(disp[4]=='0'){disp[4]=disp[3];disp[3]=' ';if(disp[5]=='0'){disp[5]=disp[4];disp[4]=' ';if(disp[6]=='0'){disp[6]=disp[5];disp[5]=' ';if(disp[7]=='0'){disp[7]=disp[6];disp[6]=' ';if(disp[8]=='0'){disp[8]=disp[7];disp[7]=' ';if(disp[8]=='0'){disp[9]=disp[8];disp[8]=' ';}}}}}}}}}lcddispmore(x,y,11,disp);}//16位有符号数显示,占6位void disp_s16(u8 x,u8 y,s16 dat){u8disp[6];if(dat<0){disp[0]='-';dat=-dat;}else{disp[0]=' ';}disp[1]=dat/10000+0x30;disp[2]=dat/1000%10+0x30;disp[3]=dat/100%10+0x30;disp[4]=dat/10%10+0x30;disp[5]=dat%10+0x30;if(disp[1]==0x30){disp[1]=disp[0];disp[0]=' ';if(disp[2]==0x30){disp[2]=disp[1];disp[1]=' ';if(disp[3]==0x30){disp[3]=disp[2];disp[2]=' ';if(disp[4]==0x30){disp[4]=disp[3];disp[3]=' ';。
51单片机C语言程序设计源代码
新概念51单片机C语言教程----入门、提高、开发、拓展全攻略郭天祥编著电子工业出版社例2.2.1编写程序,点亮第一个发光二极管(part2_1.c P27)#include <reg52.h> //52系列单片机头文件sbit led1=P1^0; //声明单片机P1口的第一位void main() //主函数{led1=0; /*点亮第一个发光二极管*/}例2.2.2编写程序,点亮P1口的若干二极管(part2_2.c P39)#include <reg52.h> //52系列单片机头文件void main() //主函数{P1=0xaa;//while(1);}例2.5.1利用for语句延时特性,编写第一个发光二极管以间隔1S亮灭闪动的程序(part2_3.c P42)#include <reg52.h> //52系列单片机头文件#define uint unsigned int //宏定义sbit led1=P1^0; //声明单片机P1口的第一位uint i,j;void main() //主函数{while(1) //大循环{led1=0; /*点亮第一个发光二极管*/for(i=1000;i>0;i--) //延时for(j=110;j>0;j--);led1=1; /*关闭第一个发光二极管*/for(i=1000;i>0;i--) //延时for(j=110;j>0;j--);}}- 2 -例2.6.1编写程序使第一个发光二极管以间隔500ms亮灭闪动。
(part2_4.c P48)#include <reg52.h> //52系列单片机头文件#define uint unsigned int //宏定义sbit led1=P1^0; //声明单片机P1口的第一位void delay1s(); //声明子函数void main() //主函数{while(1) //大循环{led1=0; /*点亮第一个发光二极管*/delay1s(); //调用延时子函数led1=1; /*关闭第一个发光二极管*/delay1s(); //调用延时子函数}}void delay1s() //子函数体{uint i,j;for(i=500;i>0;i--)for(j=110;j>0;j--);}例2.7.1编写程序使第一个二极管以亮200ms、灭800ms的方式闪动。
(整理)诺基亚LCD5110液晶接线图和程序
该模块具有以下特点:●84x48 的点阵LCD,可以显示4 行汉字,●采用串行接口与主处理器进行通信,接口信号线数量大幅度减少,包括电源和地在内的信号线仅有9 条。
支持多种串行通信协议(如AVR 单片机的SPI、MCS51 的串口模式0等),传输速率高达4Mbps,可全速写入显示数据,无等待时间。
●可通过导电胶连接模块与印制版,而不用连接电缆,用模块上的金属钩可将模块固定到印制板上,因而非常便于安装和更换。
●LCD 控制器/驱动器芯片已绑定到LCD 晶片上,模块的体积很小。
●采用低电压供电,正常显示时的工作电流在200μA 以下,且具有掉电模式。
LPH7366 的这些特点非常适合于电池供电的便携式通信设备和测试设备中C8051F学习笔记:Nokia 5110驱动Nokia5110是一款经典机型,可能由于经典的缘故,旧机器很多,所以很多电子工程师就把旧机器的屏幕拆下来,自己驱动Nokia5110,用于开发的设备显示,取代LCD1602。
使用Nokia5110液晶的四大理由1)性价比高,LCD1602可以显示32个字符,而Nokia5110可以显示15个汉字,30个字符。
Nokia5110裸屏仅8.8元,LCD1602一般15元左右,LCD12864一般50~70元。
2)接口简单,仅四根I/O线即可驱动,LCD1602需11根I/O线,LCD12864需12根。
3)速度快,是LCD12864的20倍,是LCD1602的40倍。
4)Nokia5110工作电压3.3V,正常显示时工作电流200uA以下,具有掉电模式,适合电池供电的便携式移动设备。
可以在市场上买到Nokia5110的裸屏和带PCB的Nokia5110屏幕,因为Nokia5110是不带背光的,所以通常商家会在PCB上按了几个背光LED,上电就能亮,建议大家还是买那种连上PCB的51 10。
Nokia5110原理图:商家把该引出的管脚都引出了,下面就可以连接C8051F的相应管脚,写程序驱动5110了。
完整的NOKIA-5110液晶51单片机驱动程序
Nokia 5110驱动*说明:本驱动适用于51单片机(5V或3.3V),液晶的VCC接5V 或3.3V修改偏置电压可改变5110点阵显示的亮度5110接5V时偏置电压改为(0xa7,0),接3.3V时改为(0xc0,0)*作者:JK*创建日期:2013/1/26*修改日期:#include <reg52.h>#include "font.h"#define uint unsigned int#define uchar unsigned charIO口定义区sbit LCD_RST = P0^0;sbit LCD_CE = P0^1;sbit LCD_DC = P0^2;sbit LCD_DIN = P0^3;sbit LCD_CLK = P0^4;函数声明区void LCD_Init(void);void LCD_WriteByte(unsigned char dat, unsigned char command);void LCD_Set_XY(unsigned char X, unsigned char Y);void LCD_Clear(void);void LCD_WriteChar(unsigned char x,unsigned char y,unsigned char c); void LCD_WriteString(unsigned char X,unsigned char Y,char *s);void LCD_WriteNum(unsigned char X,unsigned char Y,unsigned int num);void LCD_Write_12X16Font(unsigned char x,unsigned char y,unsigned char c[2]);void LCD_DrawPicture(unsigned char X,unsigned char Y,unsigned char const *map,unsigned char Pix_x,unsigned char Pix_y);*函数名:LCD_Init*功能:初始化LCD*参数:无*返回值:无*备注:void LCD_Init(void){unsigned char i;LCD_RST=0; //复位for(i=0;i<150;i++);LCD_RST=1;LCD_WriteByte(0x21, 0); // 使用扩展命令设置LCD模式LCD_WriteByte(0xc0, 0); // 设置偏置电压,修改可改变5110点阵显示的亮度/*5110接5V时偏置电压改为(0xa7,0),接3.3V时改为(0xc0,0)*/LCD_WriteByte(0x20, 0); // 使用基本命令。
51单片机制作诺基亚5110时间可调的时钟
该表时间可以调整,当按下调整按键的时候,时钟的时位开始闪烁,可以移动调整闪烁位,然后可以加时间,当再按下调整键的时候就不再闪烁了#include "reg52.h"#include "shu.h" 数据的编码不过没写在上面#include "zi.h" 汉字的字模表#include "xzimu.h" 小写字母的字模表sbit sce=P2^0; 芯片使能sbit res=P2^1; 复位端sbit dc=P2^2; 数据命令端口sbit sdin=P2^3; 串行数据输入端口sbit sclk=P2^4; 串行时钟输入端sbit k4=P1^3; 调整时间,时间加,选择位左移右移。
具体是哪个键后面会提到sbit k3=P1^2;sbit k2=P1^1;sbit k1=P1^0;unsigned char shi=12,fen=0,miao=0,count=0,dingwei=0; 时分秒定位等全局变量bit wei; 位定义全局变量这个主要是控制哪位开始闪烁void delay_1ms(void) 延时子程序{unsigned int i; 定义无符号数for(i=0;i<50;i++);}void LCD_write_byte(unsigned char dt,unsigned char command) 液晶写数据命令函数{unsigned char i;sce=0; 使芯片使能,低电平有效dc=command; dc即为数据命令选择控制端口for(i=0;i<8;i++){if(dt&0x80) 判断最高位,如果为1,则数据输出为1sdin=1;elsesdin=0;dt=dt<<1; 左移一位,即次高位,通过循环八次即把一个字节的数据传输出去sclk=0; 时钟的一个上升沿才能把数据传输出去,芯片接收数据的时候只认上升沿,一个上升沿传输一个数据sclk=1;}dc=1;sce=1; 使芯片接下来不受控制sdin=1; 相当于数据输入端的初始化}void LCD_init(void) LCD初始化{res=0; 使芯片复位delay_1ms(); 延时一小段时间res=1; 复位不再有效LCD_write_byte(0x21,0); 功能设置,选择扩展指令集LCD_write_byte(0xd0,0); 设置V OPLCD_write_byte(0x20,0); 功能设置,选择标准指令集LCD_write_byte(0x0C,0); 显示控制}void LCD_set_xy(unsigned char y,unsigned char x) 设定地址行列此显示分为6页(即行),84列{LCD_write_byte(0x40|y,0); 设定y地址LCD_write_byte(0x80|x,0); 设定x地址}void LCD_write_shu(unsigned char x,unsigned char y,unsigned char z) 写数字如果数据比较会占用两页的话就得设置两次地址,分为上下两页写{unsigned char i;LCD_set_xy(x,y*8); 设定显示的位置第N页for(i=1;i<=8;i++){LCD_write_byte(shu[z*16+i],1); 写shu这个数组中的数据}LCD_set_xy(x+1,y*8); 设定显示的位置第N+1页for(i=9;i<=16;i++){LCD_write_byte(shu[z*16+i],1); 写shu这个数组中的紧接下来的数据}}void LCD_write_zi(unsigned char x,unsigned char y,unsigned char z) 写字和上个函数一样{unsigned char i;LCD_set_xy(x,y*8);for(i=1;i<=16;i++){LCD_write_byte(zi[z*32+i],1);}LCD_set_xy(x+1,y*8);for(i=17;i<=32;i++){LCD_write_byte(zi[z*32+i],1);}}void LCD_write_xzimu(unsigned char x,unsigned char y,unsigned char z) 写小字母函数一样{unsigned char i;LCD_set_xy(x,y*8);for(i=1;i<=8;i++){LCD_write_byte(xzimu[z*16+i],1);}LCD_set_xy(x+1,y*8);for(i=9;i<=16;i++){LCD_write_byte(xzimu[z*16+i],1);}}void LCD_clear(void) LCD清屏{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); 全屏写数据零即为清屏}}}timer0()interrupt 1 using 1{ 定时器0TH0=0x4b;TL0=0xff; count++; 定时值可以自己查}void LCD_san(unsigned char x,unsigned char y,unsigned char z) LCD闪烁函数{if(count==8) 定时器定时周期到了八次之后就写空白{LCD_write_xzimu(x,y,4);}if(count==18) 等定时器定时周期到了十八次的时候就写此刻的时间,这样就能实现闪烁的功能了{LCD_write_shu(x,y,z);}}void LCD_tiaoshi(void) 时间调试函数{if(k4==0) 如果k4按键按下{delay_1ms(); 延时去抖动if(k4!=0) 如果按键松开了,则再处理程序,这样可以防止一次按键,程序被执行多次{wei=~wei; wei即为闪烁控制标志位,如果wei==0;则不闪dingwei=1;if(wei==0){LCD_write_shu(2,1,shi/10);LCD_write_shu(2,2,shi%10);LCD_write_shu(2,4,fen/10);LCD_write_shu(2,5,fen%10);}}}if(wei==1){switch(dingwei) dingwei即选择哪一位闪烁,相当于一个闪烁标志位{case 1: LCD_san(2,1,shi/10);break;case 2: LCD_san(2,2,shi%10);break;case 3: LCD_san(2,4,fen/10);break;case 4: LCD_san(2,5,fen%10);break;default: break;}if(k3==0&dingwei!=1) 闪烁位左移{delay_1ms();if(k3!=0){dingwei--;switch(dingwei){case 1: LCD_write_shu(2,2,shi%10);break;case 2: LCD_write_shu(2,4,fen/10);break;case 3: LCD_write_shu(2,5,fen%10);break;default: break;}}}if(k1==0) 时间加{delay_1ms();if(k1!=0){switch(dingwei){case 1: {if(shi/10<=1){shi=shi+10;}else shi=shi-20;};break;case 2: {if(shi%10<9){shi++;}else shi=shi-9;};break;case 3: {if(fen/10<5){fen+=10;}else fen-=50;};break;case 4: {if(fen%10<9){fen++;}else fen-=9;};break;default: break;}}}if(k2==0&dingwei!=4) 闪烁位右移{delay_1ms();if(k2!=0){dingwei++ ;switch(dingwei){case 2: LCD_write_shu(2,1,shi/10);break;case 3: LCD_write_shu(2,2,shi%10);break;case 4: LCD_write_shu(2,4,fen/10);break;default: break;}}}}if(shi>=24){shi-=4;}}void main(){unsigned char k;res=0; 液晶复位for(k=0;k<250;k++);res=1;LCD_init(); 液晶初始化LCD_clear(); 液晶清屏LCD_write_zi(0,1,0); //chong “重”这个汉字这些就是一开机液晶屏显示的初始时间LCD_write_zi(0,3,1); //qing “庆”LCD_write_zi(0,5,2); //shi “时”LCD_write_zi(0,7,3); //jian “间”LCD_write_shu(2,3,10); //mao hao 冒号LCD_write_shu(2,6,10); // mao haoLCD_write_shu(2,1,1); //shi gao 写时的高位LCD_write_shu(2,2,2); //shi di 时的地位LCD_write_shu(2,4,0); //fen gao 分的高位LCD_write_shu(2,5,0); //shi diLCD_write_shu(2,7,0); //miao gaoLCD_write_shu(2,8,0); //miao diLCD_write_xzimu(4,0,0); //cLCD_write_xzimu(4,1,1); //oLCD_write_xzimu(4,2,2); //mLCD_write_xzimu(4,3,3); //eLCD_write_xzimu(4,4,7); //LCD_write_xzimu(4,5,8); //bLCD_write_xzimu(4,6,9); //aLCD_write_xzimu(4,7,10); //bLCD_write_xzimu(4,8,11); //yEA=1;TMOD=0x01; //工作方式定时0TH0=0x4b;TL0=0xff; //定时50msET0=1; //定时器0中断允许TR0=1;while(1){if(count==10) 半秒到了就开始闪烁时间之间的冒号{LCD_write_xzimu(2,3,4);LCD_write_xzimu(2,6,4);}if(count==20) 到了一秒则开始处理时间{LCD_write_shu(2,3,10);LCD_write_shu(2,6,10);count=0;if(miao!=60) 若秒没到60则秒加一{miao++;LCD_write_shu(2,7,miao/10);LCD_write_shu(2,8,miao%10);}if(miao==60){fen++;miao=0;LCD_write_shu(2,7,0);LCD_write_shu(2,8,0);LCD_write_shu(2,4,fen/10);LCD_write_shu(2,5,fen%10);if(fen==60){shi++;LCD_write_shu(2,1,shi/10);LCD_write_shu(2,2,shi%10);fen=0;LCD_write_shu(2,4,0);LCD_write_shu(2,5,0);if(shi==24){shi=0;LCD_write_shu(2,1,0);LCD_write_shu(2,2,0);}}}} LCD_tiaoshi();}}。
51单片机C语言程序设计源代码
新概念51单片机C语言教程----入门、提高、开发、拓展全攻略郭天祥编著电子工业出版社例2.2.1编写程序,点亮第一个发光二极管(part2_1.c P27)#include <reg52.h> //52系列单片机头文件sbit led1=P1^0; //声明单片机P1口的第一位void main() //主函数{led1=0; /*点亮第一个发光二极管*/}例2.2.2编写程序,点亮P1口的若干二极管(part2_2.c P39)#include <reg52.h> //52系列单片机头文件void main() //主函数{P1=0xaa;//while(1);}例2.5.1利用for语句延时特性,编写第一个发光二极管以间隔1S亮灭闪动的程序(part2_3.c P42)#include <reg52.h> //52系列单片机头文件#define uint unsigned int //宏定义sbit led1=P1^0; //声明单片机P1口的第一位uint i,j;void main() //主函数{while(1) //大循环{led1=0; /*点亮第一个发光二极管*/for(i=1000;i>0;i--) //延时for(j=110;j>0;j--);led1=1; /*关闭第一个发光二极管*/for(i=1000;i>0;i--) //延时for(j=110;j>0;j--);}}- 2 - 例2.6.1编写程序使第一个发光二极管以间隔500ms亮灭闪动。
(part2_4.c P48)#include <reg52.h> //52系列单片机头文件#define uint unsigned int //宏定义sbit led1=P1^0; //声明单片机P1口的第一位void delay1s(); //声明子函数void main() //主函数{while(1) //大循环{led1=0; /*点亮第一个发光二极管*/delay1s(); //调用延时子函数led1=1; /*关闭第一个发光二极管*/delay1s(); //调用延时子函数}}void delay1s() //子函数体{uint i,j;for(i=500;i>0;i--)for(j=110;j>0;j--);}例2.7.1编写程序使第一个二极管以亮200ms、灭800ms的方式闪动。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
NOKIA5110--- 51C语言代码,头文件与对应C代码已分离开,直接可用(自己写,绝对可用。
) ///////////////////////////////////////////////////////////////NOKIA5110头文件:5110.H#ifndef _5110_H_#define _5110_H_#include <reg52.h>#define uchar unsigned char#define uint unsigned intsbit sclk = P2^0;sbit sdin = P2^1;sbit dc = P2^2;sbit sce = P2^3;sbit rst = P2^4;void write_byte(uchar byte, uchar command);void shezhi_lcd();void delay(unsigned int aa);void SET_XY(unsigned char x, unsigned char y);void LCD_CLEAR();void LCD_CLEAR_X(uchar x); //清由x开始的右半屏幕void LCD_CLEAR_Y(uchar y); //清由y开始的下半屏幕void write_hanzi(uchar x, uchar y, uchar code *dat);void write_shuzi(uchar x, uchar y, uchar c);#endif////////////////////////////////////////////////5110.C#include <reg52.h>#include <5110.H>#include <TAB.H>void write_byte(uchar byte, uchar command){unsigned char i;sce = 0;dc = command;for(i = 0; i < 8; i++){if(byte & 0x80)sdin = 1;elsesdin = 0;byte = byte << 1;sclk = 0;sclk = 1;}sce = 1;sdin = 1;dc = 1;}void shezhi_lcd(){rst = 0;delay(1000);rst = 1;write_byte(0x20, 0);write_byte(0xd0, 0);write_byte(0x0c, 0);write_byte(0x04, 0);}void delay(unsigned int aa){while(aa--);}void SET_XY(unsigned char x, unsigned char y) {write_byte(0x80 | x, 0);write_byte(0x40 | y, 0);}void LCD_CLEAR(){unsigned char i, j;SET_XY(0, 0);for(j = 0; j < 6; j++){for(i = 0; i < 84; i++){write_byte(0x00, 1);}}}void LCD_CLEAR_X(uchar x){unsigned char i, j;for(j = 0; j < 6; j++){SET_XY(x, j);for(i = x; i < 84; i++){write_byte(0x00, 1);}}}void LCD_CLEAR_Y(uchar y){unsigned char i, j;for(j = 0; j < 2; j++){SET_XY(0, y + j);for(i = 0; i < 84; i++){write_byte(0x00, 1);}}}void write_hanzi(uchar x, uchar y, uchar code *dat){uchar i ,j, k;y <<= 1;while(*dat){for(k = 0; k < ZISHU; k++){if((GB_16[k].JIANMA[0] == dat[0]) && (GB_16[k].JIANMA[1] == dat[1])) break;}for(j = 0; j < 2; j++){SET_XY(x, (y + j));for(i = 16*j; i < 16*(j+1); i++){write_byte(GB_16[k].MO[i], 1);}}x= x + 16;dat += 2;}}void write_shuzi(uchar x, uchar y, uchar c){unsigned char i, j;for(j = 0; j < 2; j++){SET_XY(x, y + j);for(i = j * 8; i < 8 * (j + 1); i++){write_byte(shuzi[c * 16 + i], 1);}}}//////////////////////////////////////码表存放处TAB.HTAB.Htypedef struct ZIMO_16 // 汉字字模数据结构{signed char JIANMA[2]; // 汉字内码索引char MO[32]; // 点阵码数据};struct ZIMO_16 code GB_16[] = // 数据表汉字:”确认登录失败功能选择成重置修改“{ // "角度测量旋转调当前试进微粗电机复位" "确", 0x04,0x84,0xE4,0x5C,0x44,0xC4,0x20,0x10,0xE8,0x27,0x24,0xE4,0x34,0x2C,0xE0,0x00, 0x02,0x01,0x7F,0x10,0x10,0x3F,0x80,0x60,0x1F,0x09,0x09,0x3F,0x49,0x89,0x7F,0x00, "认", 0x40,0x40,0x42,0xCC,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x3F,0x90,0x48,0x20,0x18,0x07,0x00,0x07,0x18,0x20,0x40,0x80,0x00, "登", 0x00,0x00,0x8A,0x52,0x22,0x5A,0x46,0x40,0x47,0x58,0x24,0x52,0x88,0x04,0x00,0x00, 0x01,0x41,0x40,0x4F,0x59,0x69,0x49,0x49,0x49,0x69,0x59,0x4F,0x40,0x41,0x01,0x00, "录", 0x80,0x80,0x82,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0xFE,0x80,0x80,0x80,0x00, 0x40,0x40,0x22,0x24,0x10,0x48,0x80,0x7F,0x04,0x08,0x18,0x24,0x22,0x40,0x40,0x00, "失", 0x00,0x40,0x30,0x1E,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 0x81,0x81,0x41,0x21,0x11,0x0D,0x03,0x01,0x03,0x0D,0x11,0x21,0x41,0x81,0x81,0x00,"败", 0x00,0xFE,0x02,0xFA,0x02,0xFE,0x40,0x20,0xD8,0x17,0x10,0x10,0xF0,0x10,0x10,0x00, 0x80,0x47,0x30,0x0F,0x10,0x67,0x80,0x40,0x21,0x16,0x08,0x16,0x21,0x40,0x80,0x00, "功", 0x08,0x08,0x08,0xF8,0x08,0x08,0x08,0x10,0x10,0xFF,0x10,0x10,0x10,0xF0,0x00,0x00, 0x10,0x30,0x10,0x1F,0x08,0x88,0x48,0x30,0x0E,0x01,0x40,0x80,0x40,0x3F,0x00,0x00, "能", 0x08,0xCC,0x4A,0x49,0x48,0x4A,0xCC,0x18,0x00,0x7F,0x88,0x88,0x84,0x82,0xE0,0x00, 0x00,0xFF,0x12,0x12,0x52,0x92,0x7F,0x00,0x00,0x7E,0x88,0x88,0x84,0x82,0xE0,0x00, "选", 0x40,0x40,0x42,0xCC,0x00,0x50,0x4E,0xC8,0x48,0x7F,0xC8,0x48,0x48,0x40,0x00,0x00, 0x00,0x40,0x20,0x1F,0x20,0x50,0x4C,0x43,0x40,0x40,0x4F,0x50,0x50,0x5C,0x40,0x00, "择", 0x10,0x10,0xFF,0x10,0x00,0x82,0x86,0x4A,0x52,0xA2,0x52,0x4A,0x86,0x80,0x80,0x00, 0x42,0x82,0x7F,0x01,0x00,0x10,0x12,0x12,0x12,0xFF,0x12,0x12,0x12,0x10,0x00,0x00, "成", 0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0x08,0x08,0xFF,0x08,0x09,0x0A,0xC8,0x08,0x00, 0x80,0x60,0x1F,0x00,0x10,0x20,0x1F,0x80,0x40,0x21,0x16,0x18,0x26,0x41,0xF8,0x00, "重", 0x10,0x10,0x14,0xD4,0x54,0x54,0x54,0xFC,0x52,0x52,0x52,0xD3,0x12,0x10,0x10,0x00, 0x40,0x40,0x50,0x57,0x55,0x55,0x55,0x7F,0x55,0x55,0x55,0x57,0x50,0x40,0x40,0x00, "置", 0x00,0x17,0x15,0xD5,0x55,0x57,0x55,0x7D,0x55,0x57,0x55,0xD5,0x15,0x17,0x00,0x00, 0x40,0x40,0x40,0x7F,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x7F,0x40,0x40,0x40,0x00, "新", 0x40,0x44,0x54,0x65,0xC6,0x64,0x54,0x44,0x00,0xFC,0x44,0x44,0xC4,0x42,0x40,0x00, 0x20,0x12,0x4A,0x82,0x7F,0x02,0x0A,0x92,0x60,0x1F,0x00,0x00,0xFF,0x00,0x00,0x00, "尖", 0x00,0x00,0x80,0xC0,0xE0,0xE0,0xF0,0xF8,0xFC,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0, 0x00,0x01,0x03,0x07,0x0F,0x0F,0x1F,0x3F,0x7F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F, "角", 0x20,0x10,0xE8,0x24,0x27,0x24,0x24,0xE4,0x24,0x34,0x2C,0x20,0xE0,0x00,0x00,0x00, 0x80,0x60,0x1F,0x09,0x09,0x09,0x09,0x7F,0x09,0x09,0x49,0x89,0x7F,0x00,0x00,0x00, "度", 0x00,0x00,0xFC,0x24,0x24,0x24,0xFC,0x25,0x26,0x24,0xFC,0x24,0x24,0x24,0x04,0x00, 0x40,0x30,0x8F,0x80,0x84,0x4C,0x55,0x25,0x25,0x25,0x55,0x4C,0x80,0x80,0x80,0x00, "测", 0x10,0x60,0x02,0x8C,0x00,0xFE,0x02,0xF2,0x02,0xFE,0x00,0xF8,0x00,0xFF,0x00,0x00, 0x04,0x04,0x7E,0x01,0x80,0x47,0x30,0x0F,0x10,0x27,0x00,0x47,0x80,0x7F,0x00,0x00, "量", 0x20,0x20,0x20,0xBE,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xBE,0x20,0x20,0x20,0x00 ,0x00,0x80,0x80,0xAF,0xAA,0xAA,0xAA,0xFF,0xAA,0xAA,0xAA,0xAF,0x80,0x80,0x00,0x00, "扭", 0x10,0x10,0xF1,0x96,0x90,0x90,0x10,0x28,0x27,0x24,0xE4,0x24,0x24,0xE4,0x04,0x00, 0x80,0x60,0x1F,0x40,0x80,0x7F,0x80,0x60,0x1F,0x20,0x7F,0x44,0x44,0x44,0x40,0x00, "调", 0x40,0x42,0xCC,0x00,0x00,0xFE,0x82,0x92,0x92,0xFE,0x92,0x92,0x82,0xFE,0x00,0x00, 0x00,0x00,0x3F,0x10,0x88,0x7F,0x00,0x1E,0x12,0x12,0x12,0x5E,0x80,0x7F,0x00,0x00, "当", 0x00,0x40,0x42,0x44,0x58,0x40,0x40,0x7F,0x40,0x40,0x50,0x48,0xC6,0x00,0x00,0x00, 0x00,0x40,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0xFF,0x00,0x00,0x00, "前", 0x08,0x08,0xE8,0x29,0x2E,0x28,0xE8,0x08,0x08,0xC8,0x0C,0x0B,0xE8,0x08,0x08,0x00, 0x00,0x00,0xFF,0x09,0x49,0x89,0x7F,0x00,0x00,0x0F,0x40,0x80,0x7F,0x00,0x00,0x00, "车", 0xC8,0xB8,0x8F,0xE8,0x88,0x88,0x40,0x48,0x48,0xE8,0x5F,0x48,0x48,0x48,0x40,0x00,0x08,0x18,0x08,0xFF,0x04,0x04,0x00,0x02,0x0B,0x12,0x22,0xD2,0x0A,0x06,0x00,0x00, "试", 0x40,0x40,0x42,0xCC,0x00,0x90,0x90,0x90,0x90,0x90,0xFF,0x10,0x11,0x16,0x10,0x00,0x00,0x00,0x00,0x3F,0x10,0x28,0x60,0x3F,0x10,0x10,0x01,0x0E,0x30,0x40,0xF0,0x00, "进", 0x40,0x40,0x42,0xCC,0x00,0x80,0x88,0x88,0xFF,0x88,0x88,0xFF,0x88,0x88,0x80,0x00, 0x00,0x40,0x20,0x1F,0x20,0x40,0x50,0x4C,0x43,0x40,0x40,0x5F,0x40,0x40,0x40,0x00, "微", 0x10,0x88,0xC4,0x33,0x80,0x9E,0x90,0x9F,0x90,0x9E,0x20,0xD8,0x17,0xF0,0x10,0x00, 0x01,0x00,0xFF,0x80,0x40,0x3E,0x02,0x02,0x3E,0x10,0x88,0x67,0x18,0x67,0x80,0x00, "粗", 0x44,0x58,0xC0,0xFF,0x50,0x4C,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE,0x00,0x00,0x00, 0x08,0x06,0x01,0xFF,0x01,0x46,0x40,0x7F,0x42,0x42,0x42,0x42,0x7F,0x40,0x40,0x00, "电", 0x00,0x00,0xF8,0x88,0x88,0x88,0x88,0xFF,0x88,0x88,0x88,0x88,0xF8,0x00,0x00,0x00, 0x00,0x00,0x1F,0x08,0x08,0x08,0x08,0x7F,0x88,0x88,0x88,0x88,0x9F,0x80,0xF0,0x00, "机", 0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00, 0x04,0x03,0x00,0xFF,0x00,0x83,0x60,0x1F,0x00,0x00,0x00,0x3F,0x40,0x40,0x78,0x00, "复", 0x20,0x10,0x08,0xF7,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0xF4,0x04,0x04,0x00,0x00, 0x80,0x90,0x90,0x49,0x4D,0x57,0x25,0x25,0x25,0x55,0x4D,0x45,0x80,0x80,0x80,0x00, "位", 0x00,0x80,0x60,0xF8,0x07,0x10,0x90,0x10,0x11,0x16,0x10,0x10,0xD0,0x10,0x00,0x00, 0x01,0x00,0x00,0xFF,0x40,0x40,0x41,0x5E,0x40,0x40,0x70,0x4E,0x41,0x40,0x40,0x00, };uchar code shuzi[] ={0x00,0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F, //"0"0x00,0x00,0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00, //"1" 0x00,0x10,0x08,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x30,0x28,0x24,0x22,0x21,0x20, //"2" 0x00,0x10,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x10,0x20,0x21,0x21,0x22,0x1C,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0xF8,0x00,0x00,0x07,0x04,0x04,0x04,0x04,0x3F,0x04,0x00,0xF8,0x88,0x88,0x88,0x08,0x08,0x00,0x10,0x20,0x20,0x20,0x20,0x11,0x0E,0x00,0x00,0xC0,0x20,0x90,0x88,0x88,0x88,0x00,0x00,0x0F,0x11,0x20,0x20,0x20,0x10,0x0F,0x00,0x08,0x08,0x08,0x08,0x88,0x68,0x18,0x00,0x00,0x00,0x30,0x0E,0x01,0x00,0x00,0x00,0x70,0x88,0x08,0x08,0x08,0x88,0x70,0x00,0x1E,0x21,0x21,0x21,0x21,0x21,0x1E,0x00,0xF0,0x08,0x08,0x08,0x08,0x08,0xF0,0x00,0x01,0x22,0x22,0x22,0x22,0x11,0x0F, //"9"0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00, //". 10"0x00,0x80,0x80,0x80,0xFC,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00, // "+ 11"0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x00, // "- 12"0x00,0xC0,0xF8,0xFE,0xF8,0xC0,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,//"上箭头13"};#define ZISHU sizeof(GB_16) / 34。