⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7290test.c

📁 12864液晶显示屏结合周立功7290按键显示的具体例子
💻 C
字号:
#include "REG52.h"
#include <intrins.h>
#include <absacc.h>
#include "VIIC_C51.h"
#include "ZLG7290.h"
#include "lcd.h"
#define uchar unsigned char;
#define uint  unsigned int

sbit KEY_INT=P3^2;
sbit P1_0=P1^0;
sbit P1_1=P1^1;
sbit P1_2=P1^2;
sbit P1_3=P1^3;
sbit P1_4=P1^4;
sbit P1_5=P1^5;
sbit P1_6=P1^6;
sbit P1_7=P1^7;
//lcd引脚
sbit RS = P2^0;
sbit RW = P2^1;
sbit E = P2^2;
sbit PSB = P2^3;          //串并口选择
sbit RES = P2^4;
//

unsigned char disp_buf[8]={0,0,0,0,0,0,0,0};
unsigned char buf[8]={0,0,0,0};
unsigned char code number_n[10] ={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
unsigned char code dizhi_n[4]={0x80,0x90,0x88,0x98}; //DDRAM地址

unsigned char t,flash,shan;
unsigned char display(unsigned char  *sd)
{ 
  	 disp_buf[0] = (disp_buf[0]&0xe0)|(sd[0]);			// 装载" dp-932"
    disp_buf[1] = (disp_buf[1]&0xe0)|(sd[1]);		
    disp_buf[2] = (disp_buf[2]&0xe0)|(sd[2]);
    disp_buf[3] = (disp_buf[3]&0xe0)|(sd[3]);
    disp_buf[4] = (disp_buf[4]&0xe0)|(sd[4]);
    disp_buf[5] = (disp_buf[5]&0xe0)|(sd[5]);
    disp_buf[6] = (disp_buf[6]&0xe0)|(sd[6]);	
    disp_buf[7] = (disp_buf[7]&0xe0)|(sd[7]);
    ZLG7290_SendBuf(disp_buf,8);
	return 0;
}



void fla()
{
   unsigned char bufx[8]={0,0,0,0,0,0,0,0};
   if(shan==0x00)
	shan=0xff;
	else shan=0x00;
    bufx[0] = (disp_buf[0]&shan)|(buf[0]);			// 装载" dp-932"
    bufx[1] = (disp_buf[1]&shan)|(buf[1]);		
    bufx[2] = (disp_buf[2]&shan)|(buf[2]);
    bufx[3] = (disp_buf[3]&shan)|(buf[3]);
    bufx[4] = (disp_buf[4]&shan)|(buf[4]);
    bufx[5] = (disp_buf[5]&shan)|(buf[5]);
    bufx[6] = (disp_buf[6]&shan)|(buf[6]);	
    bufx[7] = (disp_buf[7]&shan)|(buf[7]);
    shuzi(1,5,bufx[1],bufx[0]);
    shuzi(1,3,bufx[3],bufx[2]);
    shuzi(1,1,bufx[5],bufx[4]);
}


timer0() interrupt 1 //T0中断服务程序
{         
   t++;     //时间加1
	//秒
	if(t%10==0) fla();
	if(t==20)
	{ t=0;buf[0]++;}  	   
	if(buf[0]==10)
	{ buf[0]=0;buf[1]++;	
	}
	//分
   if(buf[1]==6)
	{  buf[1]=0;buf[2]++;}
	if(buf[2]==10)
	{  buf[2]=0;buf[3]++;}
	//小时
   if(buf[3]==6)
	{  buf[3]=0;buf[4]++;}
	if(buf[4]==10)
	{  buf[4]=0;buf[5]++;}



   TH0=-50000/256;//重载计数初值
   TL0=-50000%256;
}



void  main()
{	
   extern void motor(bit x1,bit x2,bit x3,bit x4,uint motor_A,uint motor_B);  /*电机驱动控制程序模块*/
  // unsigned char buf[8]={8,8,8,8,8,8,8,8};//显示缓冲区

   extern unsigned char adc0832(unsigned char chx0);

   unsigned char key,i;
   RES=0;
   _nop_();
   RES=1;    //复位
   PSB=1;
   RW=0;
   lcdreset();       //初始化LCD屏
   zifu(0,2,"北京时间");
	TMOD=0x01;
	EA=1;
	ET0=1;
	TH0=-50000/256;//重载计数初值
   TL0=-50000%256;
	TR0=1;

   shuzi(1,5,buf[1],buf[0]);
   shuzi(1,3,buf[3],buf[2]);
	shuzi(1,1,buf[5],buf[4]);

  
   for(;;)
	 {

		if(KEY_INT==0)    //读键值
		{
			key=ZLG7290_GetKey();
			switch(key)
			{
            case 11: lcdwc(0x14);break;
				case 12: disp_buf[flash]=0;flash++;disp_buf[flash]=0xff; break;
				case 13: disp_buf[flash]=0;flash--;disp_buf[flash]=0xff; break;
				case 14: lcdwc(0x0c);break;
				case 15: lcdwc(0x0e);break;
				case 16: for(i=0;i<=7;i++)
		               disp_buf[flash]=0;flash=0;break;
				default: buf[flash]=key; break;

			}
		}
	 }
}
			




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -