Example #1
0
void Key_Back() {
	uChar i;
	if (!isModify) {
		mainLoop = 0;
		for (i=0; i<ALARMNUM; i++) {
			if (isAlarm[i]) {			// 如果闹铃正在响则关闭
				isAlarm[i] = 0;
				if (1 == alarm[i][0])	// 如果闹铃为单一状态则设为关闭状态
					alarm[i][0] = 0;
			}
		}
		alarmNum = 0;
		beep = 1; 	// 按返回键关闭闹铃
		return;
	}
	if (0 == mainLoop) {	// 如果为设定时间
		isModify = 0;
		Set_RTC();
		return; 
	}
	if (1 == mainLoop) {	// 如果为设定日期
		isModify = 0;
		l_tmpdate[5] = GetWeek(l_tmpdate[6], l_tmpdate[4], l_tmpdate[3]);
							// 得到星期
		Set_RTC();
		return; 
	}	
	if (2 == mainLoop) {
		isModify = 0;
		return;
	}
	if (3 == mainLoop) {  // 如果为秒表
		if (isWatch) {
			sWatchFlag = 1;
			isWatch = 0;
			return;
		}
		isModify = 0;
		sWatchFlag = 0;
		return;
	}

	/********************继续添加功能***********************/
}
Example #2
0
/*******************************************************************************
* Function Set_MyRTCC()
* ------------------------------------------------------------------------------
* Overview: Function reads current Time and modifyies hours and minutes as set on display
* Input: Nothing
* Output: Nothing
*******************************************************************************/
char Set_MyRTCC(){
char temp;
  RTCC_Read(&MyTime);
  temp = Hour1Roll.currentlevel * 10 + Hour2Roll.currentlevel;
  if (temp > 12)
    return 0;
  MyTime.hours = temp;
  MyTime.minutes = Minute1Roll.currentlevel * 10 + Minute2Roll.currentlevel;
  MyTime.ampm = AmPm.currentlevel;
  Set_RTC(&MyTime);
  return 1;
}
Example #3
0
/*******************************************************************************
* Function check_time_server()
* ------------------------------------------------------------------------------
* Overview: Function updates Time which was retreived from Time server
* Input: Nothing
* Output: Nothing
*******************************************************************************/
void check_time_server(){
  if (Time_Obtained == 1){
    Time_Obtained = 0;
    MyTime.seconds = my_time.ss;
    MyTime.minutes = my_time.mn;
    if (my_time.hh == 0){
      MyTime.ampm  = 0;
      MyTime.hours = 12;
    }
    else if (my_time.hh == 12){
      MyTime.ampm  = 1;
      MyTime.hours = 12;
    }
    else{
      MyTime.hours   = my_time.hh % 12;
      MyTime.ampm    = my_time.hh / 12;
    }
    MyTime.day     = my_time.md;
    MyTime.month   = my_time.mo;
    MyTime.year    = my_time.yy;
    Set_RTC(&MyTime);
    
    Ethernet_Message("Synchronized with GMT");
    Roll_Set_Level(&Hour1Roll, MyTime.hours / 10);
    Roll_Set_Level(&Hour2Roll, MyTime.hours % 10);
    Roll_Set_Level(&Minute1Roll, MyTime.minutes / 10);
    Roll_Set_Level(&Minute2Roll, MyTime.minutes % 10);
    Roll_Set_Level(&AmPm, MyTime.ampm % 10);
    
    Set_Roller(&Hour1Roll, Hour1Roll.currentlevel, 5);
    Roller_Deactivate(&Hour1Roll, 111, 96);
    Set_Roller(&Hour2Roll, Hour1Roll.currentlevel, 5);
    Roller_Deactivate(&Hour2Roll, 149, 96);
    Set_Roller(&Minute1Roll, Hour1Roll.currentlevel, 5);
    Roller_Deactivate(&Minute1Roll, 215, 96);
    Set_Roller(&Minute2Roll, Hour1Roll.currentlevel, 5);
    Roller_Deactivate(&Minute2Roll, 253, 96);
    Set_Roller(&AmPm, AmPm.currentlevel, 5);
    Roller_Deactivate(&AmPm, 307, 96);
  }
}