|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2010-11-23 13:03:34
|
显示全部楼层
TiAH = KeyData_Sub ( TiAH );
if(TiAH > 23)
TiAH = 0;
if(TiAH < 0)
TiAH = 23;
delay1ms();
WriteC( NOFlashCur1602 , 1 );
DisplayTimeAlarm();
KeyEqu9( );
KeyEqu2( );
if(PageF != 1)
break;
}
while(3 == SubSw)
{
LcdSetXY(7,1);
WriteC( FlashCur1602 , 1 );
TiAM = KeyData_Plus( TiAM );
TiAM = KeyData_Sub ( TiAM );
if(TiAM > 59)
TiAM = 0;
if(TiAM < 0)
TiAM = 59;
delay1ms();
WriteC( NOFlashCur1602 , 1 );
DisplayTimeAlarm();
KeyEqu9( );
KeyEqu2( );
if(PageF != 1)
break;
}
if(4 == SubSw)//这两条语句的作用是解决在这里按换屏键(2键,对应变量为PageF)无效
break;
//上面的两行与下面的KeyEqu2()函数是一样的
//KeyEqu2( );
KeyEqu9( );
if(PageF != 1)
break;
}
//===============================---3--Temperature Alarm Set============================================//
LCDRst();
SubSw = 0;
//TempAlarmBellLed(); // 温度报警函数
while(PageF == 0)
{
TempAlarmBellLed(); // 温度报警函数
while(0 == SubSw)
{
TempAlarmBellLed(); // 温度报警函数
KeyEqu9( );
DisplayTempAlarm();
KeyEqu2( );
if(PageF != 0)
break;
break;
}
while(1 == SubSw)
{
TempAlarmBellLed(); // 温度报警函数
LcdSetXY(3,1);
WriteC( FlashCur1602 , 1 );
if( KeyScanValue()==5||KeyScanValue()==1)
TeALF = ~TeALF;
delay1ms();
WriteC( NOFlashCur1602 , 1 );
DisplayTempAlarm();
KeyEqu9( );
KeyEqu2( );
if(PageF != 0)
break;
}
while(2 == SubSw)
{
TempAlarmBellLed(); // 温度报警函数
LcdSetXY(5,1);
WriteC( FlashCur1602 , 1 );
TeAL = KeyData_Plus( TeAL );
TeAL = KeyData_Sub ( TeAL );
delay1ms();
WriteC( NOFlashCur1602 , 1 );
DisplayTempAlarm();
KeyEqu9( );
KeyEqu2( );
if(PageF != 0)
break;
}
while(3 == SubSw)
{
TempAlarmBellLed(); // 温度报警函数
LcdSetXY(11,1);
WriteC( FlashCur1602 , 1 );
if( KeyScanValue()==5||KeyScanValue()==1)
TeAHF = ~TeAHF;
delay1ms();
WriteC( NOFlashCur1602 , 1 );
DisplayTempAlarm();
KeyEqu9( );
KeyEqu2( );
if(PageF != 0)
break;
}
while(4 == SubSw)
{
TempAlarmBellLed(); // 温度报警函数
LcdSetXY(13,1);
WriteC( FlashCur1602 , 1 );
TeAH = KeyData_Plus( TeAH );
TeAH = KeyData_Sub ( TeAH );
delay1ms();
WriteC( NOFlashCur1602 , 1 );
DisplayTempAlarm();
KeyEqu9( );
KeyEqu2( );
if(PageF != 0)
break;
}
if(SubSw == 5)
break;
// KeyEqu2( );
if(PageF != 0)
break;
}
}
}
void SystemIni(void)
{
LCDRst();
DS1308_init(); // 硬件设计上存在失误: 没有加上拉电阻 所以如果不给写入那么会出现85这个值
DS1302Ch[0] = ReadYs ();
DS1302Ch[1] = ReadMn ();
DS1302Ch[2] = ReadDay();
DS1302Ch[3] = ReadHr ();
DS1302Ch[4] = ReadMin();
DS1302Ch[5] = ReadSec();
DS1302Ch[6] = ReadWe ();
LCDRst();
// DS1302_Write_Ini_Data(10,12,31,23,59,55,2); //因为已经将写入和读出的值均转换成BCD码 所以直接给10进制的数就可以了
// 下面让18B20转换2次 第一个get_temperature是读出默认的+85
// 第二个是DS18B20完成第一次转换,更新温度值,
// 避免温度报警的第一次判断错误(即TempAlarmBellLed函数第一次判断)
get_temperature();
get_temperature();
Uart_Init(9600);
TR1 = 1;
}
void LCD1602_Display_1302()
{
DisC(0,0,ys/10+'0');
DisC(1,0,ys%10+'0');
DisC(3,0,mn/10+'0');
DisC(4,0,mn%10+'0');
DisC(6,0,day/10+'0');
DisC(7,0,day%10+'0');
DisC(0,1,hr/10+'0');
DisC(1,1,hr%10+'0');
DisC(2,1,':');
DisC(3,1,min/10+'0');
DisC(4,1,min%10+'0');
DisC(5,1,':');
DisC(6,1,sec/10+'0');
DisC(7,1,sec%10+'0');
DisS(10,1,"Week:");
DisC(15,1,we+'0');
}
void LCD1602_Display_18B20()
{
if(1 == f) TemF = '-';
if(0 == f) TemF = '+';
DisC(10,0,TemF);
DisC(11,0,tempint/10+'0');
DisC(12,0,tempint%10+'0');
DisC(13,0,'.');
tempdf = (tempdf * 5 / 8); // 将温度的小数部分的0.00~0.15转换到0.0~0.9
DisC(14,0,tempdf+'0');
}
void DisplayTempTime(void) // PageF == 0 时显示时间和温度
{
// Clear1602
// delay1ms();
/************************下面是自定义字符 存在问题**************************************/
v_LcdWriteSelfFont_f( );
LcdSetXY( 2,0 ); // 自定义字符要在1602显示其他东西的最前面
v_LcdDisplaySelfFont_f( 0 ); //年
LcdSetXY( 5,0 );
v_LcdDisplaySelfFont_f( 1 ); // 月
LcdSetXY( 8,0 );
v_LcdDisplaySelfFont_f( 2 ); // 日
if(TAOC)
LcdSetXY( 8,1 );
v_LcdDisplaySelfFont_f( 3 ); //
LcdSetXY( 15,0 );
v_LcdDisplaySelfFont_f( 4 ); //温度标志℃
read_DS1308();
LCD1602_Display_1302();
get_temperature();
LCD1602_Display_18B20();
}
void KeyEqu2( void )
{
if( KeyScanValue()==2)
{
PageF++;
}
if(PageF == 3)
{
PageF = 0;
}
}
void KeyEqu9( void )
{
if( KeyScanValue()==9)
{
SubSw++;
}
if(SubSw == 8)
{
SubSw = 0;
}
}
void KeyEqu1_Plus( uint8 SubSw ) //对应的时间加
{
if( KeyScanValue()==1)
{
(DS1302Ch[SubSw-1])++;
}
// if( DS1302Ch == DS1302Limit)
// {
// DS1302Ch = 0;
// }
}
void KeyEqu5_Sub( uint8 SubSw ) //对应的时间减
{
if( KeyScanValue()==5)
{
(DS1302Ch[SubSw-1])--;
} |
|