?? 打鈴系統(tǒng).txt
字號:
#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 // 設(shè)置PD7為輸出
#define beepcon GPIO_PIN_5
#define Glitter_COM 0x70
#define BitRate 115200 // 設(shè)定波特率
#define DataWidth 8 // 設(shè)定數(shù)據(jù)寬度
// I2C引腳的定義。
#define SDA GPIO_PIN_3 // 模擬I2C數(shù)據(jù)傳送位
#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) // 軟件延遲函數(shù)
{
volatile int i;
for(;n>0;n--)
{
for(i=0;i<1000;i++);
}
}
void delayss(unsigned int n) // 軟件延遲函數(shù)
{
volatile int i;
for(;n>0;n--)
{
for(i=0;i<100;i++);
}
}
void lcdInit(void)
{
Delays(1);
//寫相應(yīng)的命令
LCDsend(0x30,1);
LCDsend(0x0C,1);
LCDsend(0x01,1);
LCDsend(0x02,1);
LCDsend(0x80,1);
}
//圖片顯示函數(shù)其中
void img_disp2 (uchar *img)
{
uchar i,j;
LCDsend(0x34,1);
//寫上一拍圖片數(shù)據(jù)
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);
}
}
//寫下面一排的圖片數(shù)據(jù)
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);
}
}
//不清除基本指令顯示數(shù)據(jù)
LCDsend(0x30,1);
LCD_WriteStr(2,3," ");//清除"please wait..."
LCDsend(0x36,1); //擴(kuò)充功能指令,開繪圖開關(guān)。
}
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); //擴(kuò)充功能指令,開繪圖開關(guān)。
}
//送一個數(shù)據(jù)(無地址位)
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);
}
}
//送數(shù)據(jù)或命令 dat是送的數(shù)據(jù) comdat為1時送命令 否則送數(shù)據(jù)
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);
}
//送數(shù)據(jù)的行和列 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); // 引發(fā)采樣序列的處理器觸發(fā)
while(ADCSequenceDataGet(ADC_BASE, 0, ulBuffer) >=2) ; // 獲取采樣序列捕獲的數(shù)據(jù)
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,"確認(rèn)修改結(jié)果");
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)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -