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

📄 打铃系统.txt

📁 基于留名诺瑞的ARM的打铃系统的设计
💻 TXT
📖 第 1 页 / 共 3 页
字号:
#include "hw_ints.h"
#include "hw_types.h"
#include "gpio.h"
#include "interrupt.h"
#include "sysctl.h"
#include "uart.h"
#include "hw_adc.h"
#include "debug.h"
#include "ssi.h"
#include "hw_memmap.h"
#include "hw_types.h"
#include "hw_memmap.h"
#include "hw_timer.h"
#include "sysctl.h"
#include "timer.h"
#include "adc.h"
#include "sysctl.h"
#include"interrupt.h"
#include "hw_ints.h"
#include "ADC.H"
//#include "ADC_ISR.h"
//#include "LCD\TIMER0A_int.h"
//#include "LCD\PCF8576.H"
//#include "LCD\LCD_TH3144.H"
#include "LCD\i2cint.h"
#include "LCD\ZLG7290.H"
#define LED1   GPIO_PIN_7	  // 设置PD7为输出
#define beepcon GPIO_PIN_5	                                      
#define Glitter_COM  0x70
#define BitRate     115200			                                    // 设定波特率
#define DataWidth   8				                                    // 设定数据宽度
// I2C引脚的定义。
#define SDA  GPIO_PIN_3                                                 // 模拟I2C数据传送位
#define SCL  GPIO_PIN_2                                                 // 模拟I2C时钟控制位
#define CS   GPIO_PIN_4
unsigned char num=3,sec=0,min=0,hour=0,dom=12,month=12,ALSEC,ALMIN,ALHOUR,ALMON;
unsigned int year=2008,ALYEAR;
void judg(unsigned int jjj);
void LCDsend(unsigned char dat,unsigned char comdat);
void LCD_setxy(unsigned char x,unsigned char y);
void LCD_WriteStr(unsigned char dis_addr_x,unsigned char dis_addr_y,char* str);
void sendbyte(unsigned char a);
void img_disp1 (unsigned char  *img);
void img_disp2 (unsigned char  *img);
signed   int GetTemp(void) ;
typedef struct {
   unsigned int	  year;
   unsigned char  week;
   unsigned char  month;
   unsigned char  date;
   unsigned char  hour;
   unsigned char  minute;
   unsigned char  second;
   
}TIME_FORMAT;
TIME_FORMAT   time1;
struct   timetime  
{
   unsigned int  value;
	   }tim[200]={{820},{830},{840},{850}};
   struct  timetime   *p=tim,*pp;
void delay(unsigned int n)						// 软件延迟函数
{
    volatile int i;
    for(;n>0;n--)
    {
      for(i=0;i<1000;i++);
    }
}
void delayss(unsigned int n)						// 软件延迟函数
{
    volatile int i;
    for(;n>0;n--)
    {
      for(i=0;i<100;i++);
    }
}
void lcdInit(void)
{
    Delays(1);
    //写相应的命令
    LCDsend(0x30,1);
    LCDsend(0x0C,1);
    LCDsend(0x01,1);
    LCDsend(0x02,1);
    LCDsend(0x80,1);
}


//图片显示函数其中
void img_disp2 (uchar *img)
{
     uchar i,j; 
     LCDsend(0x34,1);
     //写上一拍图片数据
     for(j=0;j<32;j++)
     {  
       
       LCDsend(0x80+j,1);
       LCDsend(0x84,1);
       for(i=0;i<8;i++)
       {
         LCDsend(img[j*8+i],0);
       }
     }
     
     //写下面一排的图片数据
    for(j=0;j<32;j++)
     {   
       LCDsend(0x80+j,1);
       LCDsend(0x8c,1);
       for(i=0;i<8;i++)
       {
         LCDsend(img[j*8+i+256],0);   
       }
     }
     //不清除基本指令显示数据
     LCDsend(0x30,1);
     LCD_WriteStr(2,3,"              ");//清除"please wait..."
     LCDsend(0x36,1); //扩充功能指令,开绘图开关。
}
void img_disp1 (uchar *img)
{
     uchar i,j;
     for(j=0;j<32;j++)
     {
       for(i=0;i<8;i++)
       {
         LCDsend(0x34,1);
         LCDsend(0x80+j,1);
         LCDsend(0x80+i,1);
         LCDsend(0x30,1);
         LCDsend(img[j*16+i*2],0);
         LCDsend(img[j*16+i*2+1],0);
       }
     }

     LCDsend(0x01,1);
     LCDsend(0x36,1); //扩充功能指令,开绘图开关。
}

//送一个数据(无地址位)
void SendByte(unsigned char a)
{
	unsigned char i;
	for(i=8;i>0;i--)
    {		
		if(a&(0x01<<(i-1)))
			GPIOPinWrite(GPIO_PORTD_BASE, SDA , SDA);
		else
			GPIOPinWrite(GPIO_PORTD_BASE, SDA , ~SDA);
		delayss(1);
		GPIOPinWrite(GPIO_PORTD_BASE, SCL , SCL);
		delayss(1);
		GPIOPinWrite(GPIO_PORTD_BASE, SCL , ~SCL);
		delayss(1);
    }	
}


void LCD_WriteStr(unsigned char dis_addr_x,unsigned char dis_addr_y,char* str)
{ 
    unsigned char LCD_temp; 
    LCD_setxy(dis_addr_x,dis_addr_y);
    LCD_temp=*str;
    while(LCD_temp != 0x00) 
    { 
        LCDsend(LCD_temp,0);
        LCD_temp=*(++str);
    }  
}

//送数据或命令   dat是送的数据   comdat为1时送命令  否则送数据
void LCDsend(unsigned char dat,unsigned char comdat)
{
	unsigned char temp,com;
	
	
	GPIOPinWrite(GPIO_PORTD_BASE, CS, CS);
	delayss(1);
	if(comdat==1) com=0XF8;
	else com=0XFA;
	
	SendByte(com);
	
	temp=dat&0XF0;
	SendByte(temp);
	
	temp=((dat&0X0F)<<4)&0XF0;
	SendByte(temp);
	
	delayss(5);
	GPIOPinWrite(GPIO_PORTD_BASE, CS, ~CS);
}
//送数据的行和列  y为行(1-4)   x为列 (1-8)
void LCD_setxy(unsigned char x,unsigned char y)
{
	switch(y)
	{
		case 1:
			LCDsend(0X7F+x,1);break;
		case 2:
			LCDsend(0X8F+x,1);break;
		case 3:
			LCDsend(0X87+x,1);break;
		case 4:
			LCDsend(0X97+x,1);break;
		default:break;
	}
}


signed   int GetTemp(void)   //output temperture*100
{
 	unsigned long ulBuffer[2];
    signed   int i;
		
	ADCProcessorTrigger(ADC_BASE, 0); 		// 引发采样序列的处理器触发

	while(ADCSequenceDataGet(ADC_BASE, 0, ulBuffer) >=2)	; // 获取采样序列捕获的数据

	for(i=1; i<2; i++)
	{ ulBuffer[0] +=ulBuffer[i]; }

	ulBuffer[0] =(unsigned int) (ulBuffer[0]*300)/(0x400*2) ;   
  
	i=(unsigned int)( (270-ulBuffer[0])*75-5500 );	   // 得到终端 SENSO电压
    
	return(i);
}

 void keyvalue(unsigned char key0)
 {
   unsigned char e=0,min0=0,min1=0,hour0=0,hour1=0,month0=0,month1=0,year0=0,year1=0,year2=0,year3=0,ghour=0,gmin=0,ww=0,ee=0;
   unsigned int kkk1,counter0=0,counter1=0;
  switch(key0)
{  
      case  6:
    
      	
      	     for(e=0;e<8;e++)
      	       { ZLG7290_Download(0,0,e,0);}
      	       LCD_WriteStr(1,1,"6键按下");
               LCD_WriteStr(2,2,"修改打铃时间");
      	 while(ZLG7290_GetKey()!=8)
      	 {   
      	        ZLG7290_SendCmd(Glitter_COM, 0xff);
                if(ZLG7290_GetKey()==6) 
                { delay(100);
                hour=hour+1;
                if(hour>24)
                hour=0;
                hour0=hour%10;
                hour1=hour/10;
                ZLG7290_Download(0,0,6,hour0);
                ZLG7290_Download(0,0,7,hour1);
                }
               if(ZLG7290_GetKey()==5)
               {
               delay(100);
               min=min+1;
               if(min>59)
               min=0;
               min0=min%10;
               min1=min/10;
               ZLG7290_Download(0,0,4,min0);
               ZLG7290_Download(0,0,5,min1);
               }
               if(ZLG7290_GetKey()==4)
               {
            
                delay(100);
                ghour=ghour+1;
                if(ghour>24)
                ghour=0;
                hour0=ghour%10;
                hour1=ghour/10;
                ZLG7290_Download(0,0,2,hour0);
                ZLG7290_Download(0,0,3,hour1);
            
                }
            
                if(ZLG7290_GetKey()==3)
                {
                delay(100);
                gmin=gmin+1;
                if(gmin>59)
                gmin=0;
                min0=gmin%10;
                min1=gmin/10;
                ZLG7290_Download(0,0,0,min0);
                ZLG7290_Download(0,0,1,min1);
                }
      }
              counter0=hour*100+min;
              counter1=ghour*100+gmin;
              pp=p;
              p=tim;
              for(p;p<&tim[200];p++)
              {   if(0==p->value)   break;
              if(p->value==counter0)
 	              {
 	                p->value=counter1;
 	                
 	                  p=pp;
 	                  ALSEC =0;
  	                  ALMIN = (p->value)%100;
  	                  ALHOUR = (p->value)/100; 
 	                break;
 	                }
               } 
                 ZLG7290_Download(0,0,2,0x1f);
                   ZLG7290_Download(0,0,5,0x1f);
       
              ZLG7290_SendCmd(Glitter_COM, 0x00);
               LCD_WriteStr(1,1,"修改完毕");
               LCD_WriteStr(2,2,"确认修改结果");
               delay(1000);
                       LCD_WriteStr(1,1,"大家好!");
                    LCD_WriteStr(2,2,"时钟运行中!");
                   
               break;        
      
         case  5:
       
           for(e=0;e<8;e++)
      	       { ZLG7290_Download(0,0,e,0);}
      	       LCD_WriteStr(1,1,"5键按下");
               LCD_WriteStr(2,2,"删除时间!!");
      	 while(ZLG7290_GetKey()!=8)
      	 {     
      	       ZLG7290_SendCmd(Glitter_COM, 0xff);
      	        if(ZLG7290_GetKey()==6) 
                { delay(100);
                hour=hour+1;
                if(hour>24)
                hour=0;
                hour0=hour%10;
                hour1=hour/10;
                ZLG7290_Download(0,0,6,hour0);
                ZLG7290_Download(0,0,7,hour1);
                }
               if(ZLG7290_GetKey()==5)
               {
               delay(100);
               min=min+1;
               if(min>59)
               min=0;
               min0=min%10;
               min1=min/10;
               ZLG7290_Download(0,0,4,min0);
               ZLG7290_Download(0,0,5,min1);
               }
               if(ZLG7290_GetKey()==4)
               {
            
                delay(100);
                ghour=ghour+1;
                if(ghour>24)
                ghour=0;
                hour0=ghour%10;
                hour1=ghour/10;
                ZLG7290_Download(0,0,2,hour0);
                ZLG7290_Download(0,0,3,hour1);
            
                }
            
                if(ZLG7290_GetKey()==3)

⌨️ 快捷键说明

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