📄 clock.c
字号:
GotoXY(12,0);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(12,0);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case MONTH_ADJ_L: //月份底位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=9))
{
DateString[MONTH_L]=Key_temp+'0';GotoXY(10,0);LCD_send_data(DateString[MONTH_L]);
}
GotoXY(10,0);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(10,0);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case MONTH_ADJ_H: //月份高位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=1))
{
DateString[MONTH_H]=Key_temp+'0';GotoXY(9,0);LCD_send_data(DateString[MONTH_H]);
}
GotoXY(9,0);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(9,0);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case YEAR_ADJ_L: //年份底位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=9))
{
DateString[YEAR_L]=Key_temp+'0';GotoXY(7,0);LCD_send_data(DateString[YEAR_L]);
}
GotoXY(7,0);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(7,0);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case YEAR_ADJ_H: //年份高位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=9))
{
DateString[YEAR_H]=Key_temp+'0';GotoXY(6,0);LCD_send_data(DateString[YEAR_H]);
}
GotoXY(6,0);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(6,0);
Delay1ms(20);
BurstWrite1302_Flag=1;
Call_Display_Adjust_ALARM_Time_Bit=1;
}
break;
case ALARM_ADJ_SECOND_L: //打玲时间秒底位调整
//display
{
if(Call_Display_Adjust_ALARM_Time_Bit==1)
{
Call_Display_Adjust_ALARM_Time_Bit=0;
Display_Adjust_ALARM_Time();
}
if((Key_temp>=0)&&(Key_temp<=9))
{
Alarm_Ram[SECOND_L]=Key_temp+'0';GotoXY(11,1);LCD_send_data(Alarm_Ram[SECOND_L]);
}
GotoXY(11,1);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(11,1);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case ALARM_ADJ_SECOND_H: //打玲时间秒高位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=5))
{
Alarm_Ram[SECOND_H]=Key_temp+'0';GotoXY(10,1);LCD_send_data(Alarm_Ram[SECOND_H]);
}
GotoXY(10,1);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(10,1);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case ALARM_ADJ_MIN_L: //打玲时间分钟底位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=9))
{
Alarm_Ram[MIN_L]=Key_temp+'0';GotoXY(8,1);LCD_send_data(Alarm_Ram[MIN_L]);
}
GotoXY(8,1);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(8,1);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case ALARM_ADJ_MIN_H: //打玲时间分钟高位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=5))
{
Alarm_Ram[MIN_H]=Key_temp+'0';GotoXY(7,1);LCD_send_data(Alarm_Ram[MIN_H]);
}
GotoXY(7,1);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(7,1);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case ALARM_ADJ_HOUR_L: //打玲时间小时底位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=9))
{
Alarm_Ram[HOUR_L]=Key_temp+'0';GotoXY(5,1);LCD_send_data(Alarm_Ram[HOUR_L]);
}
GotoXY(5,1);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(5,1);
Delay1ms(20);
BurstWrite1302_Flag=1;
}
break;
case ALARM_ADJ_HOUR_H: //打玲时间小时高位调整
//display
{
if((Key_temp>=0)&&(Key_temp<=2))
{
Alarm_Ram[HOUR_H]=Key_temp+'0';GotoXY(4,1);LCD_send_data(Alarm_Ram[HOUR_H]);
}
GotoXY(4,1);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
GotoXY(4,1);
Delay1ms(20);
BurstWrite1302_Flag=1;
Bell_State_switch_flag=1;
}
break;
case Bell_Enable_ON_OFF: //打玲使能状态
{ if(Bell_State_switch_flag==1)
{
Bell_State_switch_flag=0;
LCD_send_command(LCD_CLEAR_SCREEN);
LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_OFF);//不显示光标
GotoXY(1,0);
Print("Eanble the Bell ");
}
if(Key_temp==ZERO)
{
Bell_Enable=~Bell_Enable;
}
if(Bell_Enable==1)
{
GotoXY(8,1);
Print("ON ");
}
else
{
GotoXY(8,1);
Print("OFF");
}
BurstWrite1302_Flag=1;
Delay1ms(20);
}
default :break;
}//end switch
//}//end if
}//end Clock
void Display_Adjust_ALARM_Time(void) //显示调整打玲时间
{
unsigned char code * p_string_code;
p_string_code=string_input_the_alarm_time;
LCD_disp_string_code(0,0,p_string_code);
p_string_code=string_clear_line2;
LCD_disp_string_code(0,1,p_string_code);
GotoXY(4,1);
Print(Alarm_Ram);
}
void BurstWrite1302_New(void) //多字节时钟数据写入DS1302
{
ClockRtc[0]=(((TimeString[6]-'0')<<4)&0x70)|(TimeString[7]-'0'&0x0f);
ClockRtc[1]=(((TimeString[3]-'0')<<4)&0x70)|(TimeString[4]-'0'&0x0f);
ClockRtc[2]=(((TimeString[0]-'0')<<4)&0x70)|(TimeString[1]-'0'&0x0f);
ClockRtc[3]=(((DateString[6]-'0')<<4)&0x70)|(DateString[7]-'0'&0x0f);
ClockRtc[4]=(((DateString[3]-'0')<<4)&0x70)|(DateString[4]-'0'&0x0f);
ClockRtc[6]=(((DateString[0]-'0')<<4)&0x70)|(DateString[1]-'0'&0x0f);
BurstWrite1302(ClockRtc);//写入新的时间数据
DS1302_SetProtect(1);//关闭写入
}
/**************************************************************************
定时器0 50MS 中断 实现功能
1 读取DS1302 时钟数据
2 控制蜂呜器响频率
**************************************************************************/
void Time0(void) interrupt 1
{
static unsigned char count_DS1302_R_time;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count_DS1302_R_time++;
if(count_DS1302_R_time>=5)
{
count_DS1302_R_time=0;
DateToStr();
GotoXY(6,0);
Print(DateString);
GotoXY(6,1);
Print(TimeString);
}
if(LCD_LIGHT_FLAG==1)
{
if(count_50ms++==100)
{
LCD_LIGHT_FLAG=0;
count_50ms=0;
LCD_LIGHT=1;
}
}
if(Bell_Enable==1)//(Bell_Enable==1)
{
if((TimeString[HOUR_H]==Alarm_Ram[0])&&(TimeString[HOUR_L]==Alarm_Ram[1]))
{
if((TimeString[MIN_H]==Alarm_Ram[3])&&(TimeString[MIN_L]==Alarm_Ram[4]))
{
if((TimeString[SECOND_H]==Alarm_Ram[6])&&(TimeString[SECOND_L]==Alarm_Ram[7]))
{
Bell_Flag=1;
}
}
}
}
if(Bell_Flag==1)
{
if((TimeString[MIN_H]>=Alarm_Ram[3])&&((TimeString[MIN_L]>=(Alarm_Ram[4]+1))))
{
Bell_Flag=0;
}
else
{ //Bell=0;
Bell_f++;
if(Bell_f==1||Bell_f==2)
Bell=0;
if(Bell_f==3)
Bell=1;
if(Bell_f==4||Bell_f==5)
Bell=0;
if(Bell_f==6||Bell_f==7||Bell_f==8||Bell_f==9)
Bell=1;
if(Bell_f==10||Bell_f==10)
{
Bell=0;
}
if(Bell_f==12)
{
Bell=1;
Bell_f=0;
}
}
}
else
{
Bell=1;//close
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -