• PUDN用户
    了解作者
  • C++
    开发工具
  • 112KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 4
    下载次数
  • 2011-01-01 16:48
    上传日期
基于AT89s52所编写的一些程序,上面有点阵屏、密码锁、温度计、频率计等
Lcd12864.rar
  • Lcd12864
  • directzhu.c
    7.6KB
  • lcdwrong.OBJ
    68KB
  • 1302.OBJ
    15.4KB
  • directzhu.OBJ
    17KB
  • xiuzhen.c
    7.6KB
  • lcdwrong.LST
    71.8KB
  • lcd12864.LST
    4.1KB
  • lcd12864.M51
    72.7KB
  • lcd12864.OBJ
    5.1KB
  • lcd12864
    54.4KB
  • lcd12864.plg
    185B
  • directzhu.LST
    18.3KB
  • 1302.LST
    10.1KB
  • lcd12864.c
    1.9KB
  • lcd12864.Uv2
    2KB
  • 1302.c
    4.9KB
  • lcd12864_Uv2.Bak
    2KB
  • lcd12864.hex
    17.3KB
  • 0f12864.LST
    10.1KB
  • lcd12864.Opt
    2KB
  • 0f12864.c
    4.9KB
  • lcdwrong.c
    29.7KB
  • lcd12864_Opt.Bak
    2KB
  • 0f12864.OBJ
    15.5KB
内容介绍
/*************************************************** *标题:液晶系统 定义0-F按键,其中与switch中的值差1,case 0表示无键按下 C(13)键表示确认,D(14)键表示下翻,E(15)键表示上翻 F(16)表示退出 制作人:涂俊华 2010年8月24日 于湖南工学院 内含8个功能程序(一些还没编好) ***************************************************/ #include<reg52.h> #include<intrins.h> #include<LCD12864.h> #define uchar unsigned char #define uint unsigned int #define OP_READ 0xa1 // 器件地址以及读取操作 #define OP_WRITE 0xa0 // 器件地址以及写入操作 #define MAX_ADDR 0x7f // AT24C02最大地址 sbit xinhaoin = P3^4; sbit SCL = P3^7; sbit SDA = P3^6; sbit DQ = P3^3; uchar code tab0[]={0xBA,0xFE,0xC4,0xCF,0xB9,0xA4,0xD1,0xA7,0xD4,0xBA};//10显示湖南工学院 uchar code tabzhu_1[]={0x31,0x2E,0xCD,0xF2,0xC4,0xEA,0xC0,0xFA, 0x32,0x2E,0xB5,0xE3,0xD5,0xF3,0xC6,0xC1};//16显示1.万年历2.点阵屏 uchar code tabzhu_2[]={0x33,0x2E,0xC6,0xB5,0xC2,0xCA,0xBC,0xC6, 0x34,0x2E,0xC3,0xDC,0xC2,0xEB,0xCB,0xF8};//显示3.频率计4.密码锁 uchar code tabzhu_3[]={0x35,0x2E,0xD0,0xC5,0xBA,0xC5,0xD4,0xB4, 0x36,0x2E,0xB5,0xE7,0xD1,0xB9,0xB1,0xED};//显示5.信号源6.电压表 uchar code tabzhu_4[]={0x37,0x2E,0xCE,0xC2,0xB6,0xC8,0xBC,0xC6, 0x38,0x2E,0xBC,0xC6,0xCB,0xE3,0xC6,0xF7};//显示7.温度计8.计算器 uchar code table_dianzhen[]= { 0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00,//0 0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00,//1 0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00, 0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00, 0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00, 0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00, 0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00, 0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00, 0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, 0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00, }; uchar table_dian[8];//用于点阵时,暂时存放临时值, uchar code tab_wei[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; uchar code yejingtable[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, 0x38,0x39,0x20,0x2e,0x0f};//0--9 灭 小数点 星号 uchar keyscan(); uchar function; uchar i; //用于循环变量 uchar Num_Index; //用于点阵时显示某个数 bit jinru,dothing,change; //是否有键按下的标志位,确定键标志位,进入功能界面标志 bit f1,f2,f3,f4,f5,f6,f7,f8;//用于8个功能的标志位 bit f21,f22,f23; bit f31,f32,f33,f34; //用于频率计的四个标志位 uchar n3,nout; //用于频率计时,计50毫秒的中断次数,当频率较高时,会使计数溢出 //nout为溢出次数 uchar mimatemp[8]; //mima[8]为临时密码数组 uchar code mimasuper[8]={1,1,2,2,3,3,4,4}; //为系统的超级密码 bit f42; //修改密码标志位, uchar time; //在使用温度计时,设置全局变量,专门用于严格延时 void clearall(); void lcd_clear(); void lcd_set(); void delayms(uint count); void delay(uint m); void write_cmd(uchar command); void write_data(uchar data0); void clearall(); void display0(); void displayzhu(); void wannianli(); void dianchu(); //用于显示点阵初界面 void dianzhen(); void dianzhen1(); void dianzhen2(); void dianzhen3(); void dianzhen11(uchar Num_Index); void dianzhen22(uchar Num_Index); void dianzhen33(); //*************** void pinlvjichu(); void pinlvji(); //信号从P3.4输入 void pinlvji1(); void pinlvji2(); void pinlvji3(); void pinlvji4(); void pinlv_display(long f); //专门用于显示频率计时的周期与频率,f为周期或频率 //******************** void mimachu(); // 用于显示密码锁的初始界面 void mimasuo(); void changemima(); //修改密码程序 void inmima(); //输入密码程序 void start(); void stop(); uchar shin(); bit shout(uchar write_data); uchar read_random(uchar random_addr); void write_byte( uchar addr, uchar write_data); //********************************** void xinhaoyaun(); void dianyabiao(); //**************************************** void wenduji(); bit Init_DS18B20(void); uchar ReadOneChar(void); void WriteOneChar(uchar dat); void ReadyReadTemp(void); //************************************* void jisuanqi(); /*********************主程序*********************/ void main() { lcd_clear(); lcd_set(); while(1) { display0(); if(keyscan()=='c') { jinru=1;lcd_clear();function=1;displayzhu();} while(jinru) { switch(keyscan()) { case 1: change=1; function=1;break;//1键 case 2: change=1; function=2;break;//2键 case 3: change=1; function=3;break; case 4: change=1; function=4;break; case 5: change=1; function=5;break; case 6: change=1; function=6;break; case 7: change=1; function=7;break; case 8: change=1; function=8;break; case 'c': change=1;dothing=1; break;/*确认*/ case 'd': change=1;function--; if(function==0) {function=1;} break; /*下翻*/ case 'e': change=1; function++; if(function==9) {function=8;} break; /*上翻*/ case 'f': change=1; function=0; jinru=0;break; /*退出*/ default : change=0; break; } if(change) { change=0; lcd_clear(); switch(function) { case 0: display0(); break; case 1: write_cmd(0x92); //万年历 for(i=0;i<8;i++) write_data(tabzhu_1[i]); if(dothing==1) {dothing=0;wannianli();} break; case 2: write_cmd(0x92); //点阵屏 for(i=8;i<16;i++) write_data(tabzhu_1[i]); if(dothing==1) {dothing=0;f2=1;dianzhen(); } break; case 3: write_cmd(0x92); //频率计 for(i=0;i<8;i++) write_data(tabzhu_2[i]); if(dothing==1) {dothing=0;f3=1;pinlvji();} break; case 4: write_cmd(0x92); //密码锁 for(i=8;i<16;i++) write_data(tabzhu_2[i]); if(dothing==1) {dothing=0;f4=1;mimasuo();} break; case 5: write_cmd(0x92); for(i=0;i<8;i++) write_data(tabzhu_3[i]); if(dothing==1) {dothing=0; xinhaoyaun();} break; case 6: write_cmd(0x92); for(i=8;i<16;i++) write_data(tabzhu_3[i]); if(dothing==1) {dothing=0;dianyabiao();} break; case 7: write_cmd(0x92); //温度计 for(i=0;i<8;i++) write_data(tabzhu_4[i]); if(dothing==1) {dothing=0;f7=1;wenduji();} break; case 8: write_cmd(0x92); for(i=8;i<16;i++) write_data(tabzhu_4[i]); if(dothing==1) {dothing=0;jisuanqi();} break; default: break; } } } } } /******************LCD功能设置******************/ void lcd_set() { write_cmd(0x34); write_cmd(0x30); write_cmd(0x01); write_cmd(0x06); write_cmd(0x0c); } /*******************清屏程序*********************/ void lcd_clear() { write_cmd(0x01); write_cmd(0x34); write_cmd(0x30); } /*****************写指令程序********************/ void write_cmd(uchar command) { delay(100); rs=0; rw=0; P0=command; en=1; _nop_(); _nop_(); en=0; } /*****************写数据程序********************/ void write_data(uchar data0) { delay(100); rs=1; rw=0; P0=data0; en=1; _nop_(); _nop_(); en=0; } /*****************显示程序*********************/ void display0() //显示湖南工学院开始界面 { write_cmd(0x91); for(i=0;i<10;i++) write_data(tab0[i]); } //*************************************** void displayzhu() //显示功能主界面 { write_cmd(0x80); for(i=0;i<16;i++) { write_data(tabzhu_1[i]); } write_cmd(0x90); for(i=0;i<16;i++) { write_data(tabzhu_2[i]); } write_cmd(0x88); //第三行的首地址为0x88 for(i=0;i<16;i++) { write_data(tabzhu_3[i]); } write_cmd(0x98); for(i=0;i<16;i++) { write_data(tabzhu_4[i]); } } /******************延时程序*********************/ void delay(uint m) { while(--m); } //****************************************************** uchar keyscan() { uchar temp,num='z'; P1=0xfe; temp=P1; temp=temp&0xf0; while(temp!=0xf0) { delayms(15); temp=P1; temp=temp&0xf0; while(temp!=0xf0
评论
    相关推荐