/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:AlarmScrolls()
 *
 *  Purpose:
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns:
 *          1 - if successful execution completed
 *          0 - if error
\****************************************************************/
VOID  AlarmVScrolls(HWND hwnd, USHORT ScrollMsg, MPARAM idScroll)
{
   UCHAR uchHours, uchMinutes;

   GetAlarmTime(hwnd, &uchHours, &uchMinutes);

   switch(ScrollMsg)
   {
   case SB_LINEUP:
   case SB_PAGEUP:
      if (idScroll == (MPARAM)SCROLL_HOURS)
         if (uchHours == 23)
            uchHours = 0;
         else uchHours++;
      else
         if (uchMinutes == 59)
            uchMinutes = 0;
         else
            uchMinutes++;
         break;


   case SB_LINEDOWN:
   case SB_PAGEDOWN:
      if (idScroll == (MPARAM)SCROLL_HOURS)
         if (uchHours == 0)
            uchHours = 23;
         else uchHours--;
      else
         if (uchMinutes == 00)
            uchMinutes = 59;
         else
            uchMinutes--;
      break;


    }
    SetAlarmField(hwnd, uchHours, uchMinutes);
    WinSendDlgItemMsg(hwnd,
                        IDC_HOURMINUTES,
                        EM_SETSEL,
                        (idScroll == (MPARAM)SCROLL_HOURS) ?MPFROM2SHORT(0,0):MPFROM2SHORT(3,3),
                        MPVOID);
}
/**************************************************************************
* AlarmSet
***************************************************************************/
VOID AlarmSet(HWND hwnd)
{
   GetAlarmTime(hwnd, &cp.alarm.uchHour, &cp.alarm.uchMinutes);
   cp.alarm.usMode = (AM_ACTIVE * ((ULONG)WinSendDlgItemMsg(hwnd,
                                                    RB_ALARMON,
                                                    BM_QUERYCHECK,
                                                    MPVOID,
                                                    MPVOID)))
                      |
                      (AM_AUDIO  * ((ULONG)WinSendDlgItemMsg(hwnd,
                                                    IDC_BEEP,
                                                    BM_QUERYCHECK,
                                                    MPVOID,
                                                    MPVOID)))
                      |
                      (AM_MSGBOX * ((ULONG)WinSendDlgItemMsg(hwnd,
                                                    IDC_MSG,
                                                    BM_QUERYCHECK,
                                                    MPVOID,
                                                    MPVOID)));
   AlarmSetTimer(cp.alarm.uchHour, cp.alarm.uchMinutes);
}
Esempio n. 3
0
static VOID RtcTimeDown(RTC_DATE_TIME* Time)
{
	switch(RtcSubState)
	{
#ifdef FUNC_ALARM_EN
		case RTC_SET_ALARM_NUM:
			RtcAlarmNum--;	
			if(RtcAlarmNum < 1)
			{
				//RtcAlarmNum = 8; 
				RtcAlarmNum = MAX_ALARM_NUM;    
			}
			gAlarmMode = GetAlarmTime(RtcAlarmNum, Time);
			DBG(("RtcAlarmNum:%bu\n", RtcAlarmNum));	
			break;
       
		case RTC_SET_ALARM_MODE:
			if(ALARM_MODE_ONCE_ONLY == gAlarmMode)
			{
				AlarmTemp = *Time;
			}
			else if(ALARM_MODE_PER_WEEK == gAlarmMode)
			{
				AlarmTemp.WDay = Time->WDay;
			}
			
			gAlarmMode--;		
			if(gAlarmMode < ALARM_MODE_ONCE_ONLY)
			{
				gAlarmMode = ALARM_MODE_PER_WEEK;    
			}
			
			if(ALARM_MODE_ONCE_ONLY == gAlarmMode)
			{
				Time->Year = AlarmTemp.Year;
				Time->Mon = AlarmTemp.Mon;
				Time->Date = AlarmTemp.Date;
				Time->WDay = AlarmTemp.WDay;
			}
			else if(ALARM_MODE_PER_WEEK == gAlarmMode)
			{
				Time->WDay = AlarmTemp.WDay;
			}
			DBG(("gAlarmMode[%bu]=%s\n", gAlarmMode, ModeDisp[gAlarmMode - 1]));
			break;
		 
#ifdef	AU6210K_CAR_MODEL_DEMO
		 case RTC_SET_ALARM_ONOFF:
			 if(gAlarmState == ALARM_STATUS_OPEN)
			 {
				 gAlarmState = ALARM_STATUS_CLOSE;
				 DBG(("ALARM_STATUS_CLOSE\n"));
			 }
			 else
			 {
				 gAlarmState = ALARM_STATUS_OPEN;
				 DBG(("ALARM_STATUS_OPEN\n"));
			 }
			 break;
#endif
#endif

		case RTC_SET_YEAR:
			Time->Year--;
			if(Time->Year < RTC_START_YEAR)
			{
				Time->Year = RTC_END_YEAR;
			}
			Time->WDay = WeekDayGet(DateToDays(Time));
			break;
	
		case RTC_SET_MON:
			Time->Mon--;
			if(Time->Mon == 0)
			{
				Time->Mon = 12;
			}
			if(Time->Date > GetMonthDays(Time->Year, Time->Mon))
			{
				Time->Date = GetMonthDays(Time->Year, Time->Mon);
			}
			Time->WDay = WeekDayGet(DateToDays(Time));
			break;
	
		case RTC_SET_DATE:
			Time->Date--;
			if(Time->Date == 0)
			{
				Time->Date = GetMonthDays(Time->Year, Time->Mon);
			}
			Time->WDay = WeekDayGet(DateToDays(Time));				
			break;
	
#ifdef FUNC_ALARM_EN	
		case RTC_SET_WEEK:
			if(Time->WDay > 0)
			{
				Time->WDay--;			
			}
			else
			{
				Time->WDay = 6;	
			}
			break;
#endif
	
		case RTC_SET_HR:
			Time->Sec = 0;	
			Time->Hour--;
			if(Time->Hour > 23)
			{
				Time->Hour = 23;
			}
			break;
	
		case RTC_SET_MIN:
			Time->Sec = 0;		
			Time->Min--;
			if(Time->Min > 59)
			{
				Time->Min = 59;
			}
			break;

#ifdef AU6210K_BOOMBOX_DEMO
		case RTC_SET_ALARM_SOURCE:
			if(gAlarmSource > RTC_ALARM_SOURCE_RADIO)
			{
				gAlarmSource--;
			}
			break;

		case RTC_SET_ALARM_VOLUME:
			if(gAlarmVolume > VOLUME_MIN)
			{
				gAlarmVolume--; 
			}		
			break;
#endif

		default:
			break;
	}
}
Esempio n. 4
0
static VOID RtcTimeUp(RTC_DATE_TIME* Time)
{
	switch(RtcSubState)
	{
#ifdef FUNC_ALARM_EN
		case RTC_SET_ALARM_NUM:
			RtcAlarmNum++;	
			if(RtcAlarmNum > MAX_ALARM_NUM)
			{
			    RtcAlarmNum = 1;    
			}
			gAlarmMode = GetAlarmTime(RtcAlarmNum, Time);
			DBG(("RtcAlarmNum:%bu\n", RtcAlarmNum));	
			break;

		case RTC_SET_ALARM_MODE:
			if(ALARM_MODE_ONCE_ONLY == gAlarmMode)
			{
				AlarmTemp = *Time;
			}
			else if(ALARM_MODE_PER_WEEK == gAlarmMode)
			{
				AlarmTemp.WDay = Time->WDay;
			}

			gAlarmMode++;
			if(gAlarmMode > ALARM_MODE_PER_WEEK)
			{
				gAlarmMode = ALARM_MODE_ONCE_ONLY;    
			}
			if(ALARM_MODE_ONCE_ONLY == gAlarmMode)
			{
				Time->Year = AlarmTemp.Year;
				Time->Mon = AlarmTemp.Mon;
				Time->Date = AlarmTemp.Date;
				Time->WDay = AlarmTemp.WDay;
			}
			else if(ALARM_MODE_PER_WEEK == gAlarmMode)
			{
				Time->WDay = AlarmTemp.WDay;
			}
			DBG(("gAlarmMode[%bu]=%s\n", gAlarmMode,ModeDisp[gAlarmMode-1]));
			break;
		
#ifdef	AU6210K_CAR_MODEL_DEMO
		case RTC_SET_ALARM_ONOFF:
			if(gAlarmState == ALARM_STATUS_OPEN)
			{
				gAlarmState = ALARM_STATUS_CLOSE;
				DBG(("ALARM_STATUS_CLOSE\n"));
			}
			else
			{
				gAlarmState = ALARM_STATUS_OPEN;
				DBG(("ALARM_STATUS_OPEN\n"));
			}	
   		 	break;
#endif
#endif

		case RTC_SET_YEAR:
			DBG(("Time->Year:%u\n", Time->Year));
			Time->Year++;
			if(Time->Year > RTC_END_YEAR)
			{
				Time->Year = RTC_START_YEAR;
			}
			Time->WDay = WeekDayGet(DateToDays(Time));
			break;
	
		case RTC_SET_MON:
			Time->Mon++;
			if(Time->Mon > 12)
			{
				Time->Mon = 1;
			}
			if(Time->Date > GetMonthDays(Time->Year, Time->Mon))
			{
				Time->Date = GetMonthDays(Time->Year, Time->Mon);
			}
			Time->WDay = WeekDayGet(DateToDays(Time));
			break;
	
		case RTC_SET_DATE:
			Time->Date++;
			if(Time->Date > GetMonthDays(Time->Year, Time->Mon))
			{
				Time->Date = 1;
			}
			Time->WDay = WeekDayGet(DateToDays(Time));
			break;

#ifdef FUNC_ALARM_EN	
		case RTC_SET_WEEK:
			if(Time->WDay < 6)
			{
				Time->WDay++;			
			}
			else
			{
				Time->WDay = 0;	
			}
			break;
#endif
	
		case RTC_SET_HR:
			Time->Sec = 0;
			Time->Hour++;
			if(Time->Hour > 23)
			{
				Time->Hour = 0;
			}
			break;
	
		case RTC_SET_MIN:
			Time->Sec = 0;
			Time->Min++;
			if(Time->Min > 59)
			{
				Time->Min = 0;
			}
			break;

#ifdef AU6210K_BOOMBOX_DEMO
		case RTC_SET_ALARM_SOURCE:
			if(gAlarmSource < RTC_ALARM_ONOFF)
			{
				gAlarmSource++;
			}
			break;

		case RTC_SET_ALARM_VOLUME:
			if(gAlarmVolume < VOLUME_MAX)
			{
				gAlarmVolume++;	
			}		
			break;
#endif

		default:
			break;
	}
}
Esempio n. 5
0
//如果有和此函数类似用法(嵌入到各个模式)的函数位于其后,此函数不要有default,防止拦截后者有用的消息
VOID RtcMsgPro(BYTE Msg)
{	
	if(RtcState == RTC_STATE_IDLE)
	{
#ifdef	AU6210K_CAR_MODEL_DEMO
		if((Msg != MSG_NONE) && (gAlarmOnFlag == TRUE))
		{
			gAlarmOnFlag = FALSE;
		}
#endif
		
		switch(Msg)
		{	
#ifdef	AU6210K_CAR_MODEL_DEMO
			case MSG_REPEAT:
#endif
#ifdef AU6210K_BOOMBOX_DEMO
			case MSG_CLOCK:
#endif
			case MSG_RTC_SET:
				DBG(("RTC_SET\n"));
				RtcFlag = 1;
				RtcUpdateDisplay = TRUE;
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
#ifdef AU6210K_BOOMBOX_DEMO
				RtcSubState = RTC_SET_HR;
				RtcState = RTC_STATE_SET_TIME;
				break;
#endif
				RtcState = RTC_STATE_SET_TIME;
				RtcSubState = RTC_SET_NONE;
				
#ifdef	AU6210K_CAR_MODEL_DEMO
				if(Msg == MSG_REPEAT)
#else
				if(Msg == MSG_RTC_SET)
#endif
				{
					gRtcRdWrFlag = SET_RTC_TIME_YEAR;
				}
				else 
				{
					gRtcRdWrFlag = READ_RTC_TIME;
				}
				RtcNextSubState();
				break;

#ifdef FUNC_ALARM_EN
#ifdef AU6210K_BOOMBOX_DEMO
			case MSG_ALARM1_SET:
			case MSG_ALARM2_SET:
#endif
			case MSG_ALARM_SET:
#ifndef	AU6210K_CAR_MODEL_DEMO
				DBG(("ALARM_SET\n"));
				RtcFlag = 2;
				RtcUpdateDisplay = TRUE;
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
#ifdef AU6210K_BOOMBOX_DEMO
				if(Msg == MSG_ALARM1_SET)
				{
					RtcAlarmNum = 1;
				}
				else if(Msg == MSG_ALARM2_SET)
				{
					RtcAlarmNum = 2;
				}
#endif
	
				if((RtcAlarmNum > 0) && (RtcAlarmNum <= MAX_ALARM_NUM))
				{
					gAlarmMode = GetAlarmTime(RtcAlarmNum, &gAlarmTime);
					if((gAlarmMode < ALARM_MODE_ONCE_ONLY) || (gAlarmMode > ALARM_MODE_PER_WEEK))
					{
						gAlarmMode = ALARM_MODE_PER_DAY;	
					}
					CheckAlarmTime(RtcAlarmNum, gAlarmMode, &gAlarmTime);									
				}
				else
				{
					DBG(("闹钟错误\n"));
				}
				
#ifdef AU6210K_BOOMBOX_DEMO
				RtcSubState = RTC_SET_HR;
				RtcState = RTC_STATE_SET_ALARM;
				break;
#endif
				RtcState = RTC_STATE_SET_ALARM;
				RtcSubState = RTC_SET_NONE;
				RtcNextSubState();
#endif
#endif
				break;
								
			default:
				break;
		}
	}
	else if(RtcState == RTC_STATE_SET_TIME)
	{
		switch(Msg)
		{
#ifdef	AU6210K_CAR_MODEL_DEMO
			case MSG_PRE:
#endif
#ifdef AU6210K_BOOMBOX_DEMO
			case MSG_PREV1:
#endif
			case MSG_RTC_DOWN:
				DBG(("RTC_DOWN\n"));
				RtcUpdateDisplay = TRUE;
				GetRTCCurrTime(&gRtcTime);
				RtcTimeDown(&gRtcTime);
				SetRTCCurrTime(&gRtcTime);
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
				break;

#ifdef	AU6210K_CAR_MODEL_DEMO
			case MSG_NEXT:
#endif
#ifdef AU6210K_BOOMBOX_DEMO
			case MSG_NEXT1:
#endif
			case MSG_RTC_UP:
				DBG(("RTC_UP\n"));
				RtcUpdateDisplay = TRUE;
				GetRTCCurrTime(&gRtcTime);
				RtcTimeUp(&gRtcTime);
				SetRTCCurrTime(&gRtcTime);
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
				break;

#ifdef	AU6210K_CAR_MODEL_DEMO
			case MSG_PLAY_PAUSE:
#endif
#ifdef	AU6210K_BOOMBOX_DEMO
			case MSG_CLOCK:
#endif
			case MSG_RTC_SW:
				DBG(("RTC_SW\n"));
#ifdef AU6210K_BOOMBOX_DEMO
				if(RtcSubState == RTC_SET_MIN)
				{
					RtcState = RTC_STATE_IDLE;
					RtcSubState = RTC_SET_NONE;
					RtcAutOutTimeCount = 0;
					break;
				}
#endif
				RtcUpdateDisplay = TRUE;
				RtcNextSubState();
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
				break;

			default:
				break;
		}

		if(TRUE == RtcAlarmSetWaitTime())
		{		
			//这样设置时间是因为SetRtcRefcnt函数有延时如果此时在播放mp3按键有卡声音	
			if(gRtcRdWrFlag != READ_RTC_TIME)
			{
				SetRTCCurrTime(&gRtcTime);
			}
		}
	}
#ifdef FUNC_ALARM_EN
	else if(RtcState == RTC_STATE_SET_ALARM)
	{
		switch(Msg)
		{
#ifdef	AU6210K_CAR_MODEL_DEMO
			case MSG_PRE:
#endif

#ifdef AU6210K_BOOMBOX_DEMO
			case MSG_PREV1:
#endif
			case MSG_RTC_DOWN:
				DBG(("ALARM RTC_DOWN\n"));
				RtcUpdateDisplay = TRUE;      				
				RtcTimeDown(&gAlarmTime);
				CheckAlarmTime(RtcAlarmNum, gAlarmMode, &gAlarmTime);
				SetAlarmTime(RtcAlarmNum, gAlarmMode, &gAlarmTime);
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
#ifdef FUNC_BREAK_POINT_EN
				BP_SaveInfo((BYTE*)&gBreakPointInfo.PowerMemory.AlarmList2Store, sizeof(gBreakPointInfo.PowerMemory.AlarmList2Store));
#endif
				break;

#ifdef	AU6210K_CAR_MODEL_DEMO
			case MSG_NEXT:
#endif

#ifdef AU6210K_BOOMBOX_DEMO
			case MSG_NEXT1:
#endif

			case MSG_RTC_UP:
				DBG(("ALARM RTC_UP\n"));
				RtcUpdateDisplay = TRUE;               				
				RtcTimeUp(&gAlarmTime);
				CheckAlarmTime(RtcAlarmNum, gAlarmMode, &gAlarmTime);
				SetAlarmTime(RtcAlarmNum, gAlarmMode, &gAlarmTime);
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
#ifdef FUNC_BREAK_POINT_EN
				BP_SaveInfo((BYTE*)&gBreakPointInfo.PowerMemory.AlarmList2Store, sizeof(gBreakPointInfo.PowerMemory.AlarmList2Store));
#endif
				break;

#ifdef	AU6210K_CAR_MODEL_DEMO
			case MSG_PLAY_PAUSE:
#endif
#ifdef AU6210K_BOOMBOX_DEMO
			case MSG_ALARM1_SET:
			case MSG_ALARM2_SET:
#endif
			case MSG_RTC_SW:
				DBG(("ALARM SW\n"));
#ifdef AU6210K_BOOMBOX_DEMO
				if(((RtcAlarmNum == 1) && (Msg != MSG_ALARM1_SET)) || ((RtcAlarmNum == 2) && (Msg != MSG_ALARM2_SET)))			
				{
					break;
				}

				if(RtcSubState == RTC_SET_ALARM_VOLUME)
				{					
					RtcState = RTC_STATE_IDLE;
					RtcSubState = RTC_SET_NONE;
					RtcAutOutTimeCount = 0;
					break;
				}
#endif
				RtcUpdateDisplay = TRUE;
				RtcNextSubState();		
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
				break;

			default:
				break;
		}

		if(TRUE == RtcAlarmSetWaitTime())
		{
			DBG(("EXIT RTC_STATE_SET_TIME!\n"));		
			RtcState = RTC_STATE_IDLE;
			RtcSubState = RTC_SET_NONE;
			RtcFlag = 1;		
		}
	}
#endif
#ifdef	AU6210K_CAR_MODEL_DEMO
	else if(RtcState == RTC_STATE_SET_SOURCE)
	{
		switch(Msg)
		{
			case MSG_PRE:			
				DBG(("RTC SOURCE_DOWN\n"));
				RtcUpdateDisplay = TRUE;
				RtcSourceDown();
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
				break;

			case MSG_NEXT:
				DBG(("RTC SOURCE_UP\n"));
				RtcUpdateDisplay = TRUE;
				RtcSourceUp();
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
				break;

			case MSG_REPEAT:
				DBG(("RTC SOURCE_Enter\n"));
				RtcUpdateDisplay = TRUE;
				RtcSourceEnter();
				RtcAutOutTimeCount = RTC_AUTO_OUT_TIME_COUNT;
				break;
				
			default:
				break;
		}

		if(TRUE == RtcAlarmSetWaitTime())
		{
			DBG(("EXIT RTC_STATE_SET_SOURCE!\n"));		
			RtcState = RTC_STATE_IDLE;
			RtcSubState = RTC_SET_NONE;
			RtcFlag = 1;		
		}	
	}
#endif
}
Esempio n. 6
0
static VOID RtcSourceEnter(VOID)
{
	RtcFlag = 1;
	
	switch(RtcSourceState)
	{
		case RTC_SOURCE_CLOCK:
			RtcSubState = RTC_SET_HR;
			RtcState = RTC_STATE_SET_TIME;
			DBG(("RTC_SOURCE_CLOCK\n"));
			break;
			
		case RTC_SOURCE_YEAR:
			RtcSubState = RTC_SET_YEAR;
			RtcState = RTC_STATE_SET_TIME;
			gRtcRdWrFlag = SET_RTC_TIME_YEAR;
			DBG(("RTC_SOURCE_YEAR\n"));
			break;

		case RTC_SOURCE_MON:
			RtcSubState = RTC_SET_MON;
			RtcState = RTC_STATE_SET_TIME;
			DBG(("RTC_SOURCE_MON\n"));
			break;

		case RTC_SOURCE_ALARM:
			RtcFlag = 2;
			RtcUpdateDisplay = TRUE;
			if((RtcAlarmNum > 0) && (RtcAlarmNum < MAX_ALARM_NUM))
			{
				gAlarmMode = GetAlarmTime(RtcAlarmNum, &gAlarmTime);
				if((gAlarmMode < ALARM_MODE_ONCE_ONLY) || (gAlarmMode > ALARM_MODE_PER_WEEK))
				 {
					gAlarmMode = ALARM_MODE_PER_DAY;	
				}

				CheckAlarmTime(RtcAlarmNum, gAlarmMode, &gAlarmTime);									
			}
			else
			{
				DBG(("闹钟错误\n"));
			}
			RtcSubState = RTC_SET_HR;
			RtcState = RTC_STATE_SET_ALARM;
			DBG(("RTC_SOURCE_ALARM\n"));
			break;

		case RTC_SOURCE_ONOFF:
			RtcSubState = RTC_SET_ALARM_ONOFF;
			RtcState = RTC_STATE_SET_ALARM;
			if(GetAlarmStatus(RtcAlarmNum))
			{
				gAlarmState = ALARM_STATUS_OPEN;
			}
			else
			{
				gAlarmState = ALARM_STATUS_CLOSE;
			}
			DBG(("RTC_SOURCE_ONOFF\n"));
			break;

		default:
			break;			
	}
}