⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtc.c

📁 arm电子日历arm electricity calendar
💻 C
📖 第 1 页 / 共 4 页
字号:
				h=time->Min/10;
				l=time->Min%10;
				
				if(h>=5)
				{
					h=0;
				}
				else
				{
					h++;
				}
				
				time->Min=(h*10)+l;
				
				return;
				
				////
				
		case	Set_Min_L:
				
				h=time->Min/10;
				l=time->Min%10;
				
				if(l>=9)
				{
					l=0;
				}
				else
				{
					l++;
				}
				
				time->Min=(h*10)+l;
				
				return;
				
				////////
				
		case	Set_Sec_H:
				
				h=time->Sec/10;
				l=time->Sec%10;
				
				if(h>=5)
				{
					h=0;
				}
				else
				{
					h++;
				}
				
				time->Sec=(h*10)+l;
				
				return;
				
				////
				
		case	Set_Sec_L:
				
				h=time->Sec/10;
				l=time->Sec%10;
				
				if(l>=9)
				{
					l=0;
				}
				else
				{
					l++;
				}
				
				time->Sec=(h*10)+l;
				
				return;
				
				////////
	
	

				
							
	
	}

}

/*============================================================================*/
/*============================================================================*/

void	RTC_Set_Dec(struct	RTC_TIME *time,U8 *Object)
{

	int	h,l;
	////
	
	if(*Object>Set_Sec_L)	*Object=Set_Year_H;
	////
	
	switch(*Object)
	{
			
		case	Set_Year_H:
				
				h=(time->Year-2000)/10;
				l=(time->Year-2000)%10;
				
				if(h<=0)
				{
					h=9;
				}
				else
				{
					h--;
				}
				
				time->Year=2000+(h*10)+l;
				
				return;
				
				////
				
		case	Set_Year_L:
				
				h=(time->Year-2000)/10;
				l=(time->Year-2000)%10;
				
				if(l<=0)
				{
					l=9;
				}
				else
				{
					l--;
				}
				
				time->Year=2000+(h*10)+l;
				
				return;
				
				////////
	
		case	Set_Month_H:
				
				h=time->Month/10;
				l=time->Month%10;
				
				if(h<=0)
				{
					h=1;
				}
				else
				{
					h--;
				}
				
				time->Month=(h*10)+l;
				
				return;
				
				////
				
		case	Set_Month_L:
				
				h=time->Month/10;
				l=time->Month%10;
				
				if(l<=0)
				{
					l=9;
				}
				else
				{
					l--;
				}
				
				time->Month=(h*10)+l;
				
				return;
				
				////////
	
		case	Set_Day_H:
				
				h=time->Day/10;
				l=time->Day%10;
				
				if(h<=0)
				{
					h=3;
				}
				else
				{
					h--;
				}
				
				time->Day=(h*10)+l;
				
				return;
				
				////
				
		case	Set_Day_L:
				
				h=time->Day/10;
				l=time->Day%10;
				
				if(l<=0)
				{
					l=9;
				}
				else
				{
					l--;
				}
				
				time->Day=(h*10)+l;
				
				return;
				
				////////
	
		case	Set_Hour_H:
				
				h=time->Hour/10;
				l=time->Hour%10;
				
				if(h<=0)
				{
					h=2;
				}
				else
				{
					h--;
				}
				
				time->Hour=(h*10)+l;
				
				return;
				
				////
				
		case	Set_Hour_L:
				
				h=time->Hour/10;
				l=time->Hour%10;
				
				if(l<=0)
				{
					l=9;
				}
				else
				{
					l--;
				}
				
				time->Hour=(h*10)+l;
				
				return;
				
				////////
	
		case	Set_Min_H:
				
				h=time->Min/10;
				l=time->Min%10;
				
				if(h<=0)
				{
					h=5;
				}
				else
				{
					h--;
				}
				
				time->Min=(h*10)+l;
				
				return;
				
				////
				
		case	Set_Min_L:
				
				h=time->Min/10;
				l=time->Min%10;
				
				if(l<=0)
				{
					l=9;
				}
				else
				{
					l--;
				}
				
				time->Min=(h*10)+l;
				
				return;
				
				////////
	
		case	Set_Sec_H:
				
				h=time->Sec/10;
				l=time->Sec%10;
				
				if(h<=0)
				{
					h=5;
				}
				else
				{
					h--;
				}
				
				time->Sec=(h*10)+l;
				
				return;
				
				////
				
		case	Set_Sec_L:
				
				h=time->Sec/10;
				l=time->Sec%10;
				
				if(l<=0)
				{
					l=9;
				}
				else
				{
					l--;
				}
				
				time->Sec=(h*10)+l;
				
				return;
				
				////////
	
				
							
	
	}

}

/*============================================================================*/

void	RTC_Set_Num(struct RTC_TIME *time,U8 *Object,U8 Data)
{

	int	i;
	////

	if(*Object>Set_Sec_L)	*Object=Set_Year_H;
	Data&=0x0f;

	////
	
	switch(*Object)
	{
			
		case	Set_Year_H:
				
				i=(time->Year-2000)%10;
				time->Year=2000+Data*10+i;
				
				return;
				////
				
		case	Set_Year_L:
				
				i=(time->Year-2000)/10;
				time->Year=2000+i*10+Data;
				return;
				
				////////
				
		case	Set_Month_H:
				
				i=time->Month%10;
				time->Month=Data*10+i;
				
				return;
				////
				
		case	Set_Month_L:
				
				i=time->Month/10;
				time->Month=i*10+Data;
				return;
				
				////////
				
		case	Set_Day_H:
				
				i=time->Day%10;
				time->Day=Data*10+i;
				
				return;
				////
				
		case	Set_Day_L:
				
				i=time->Day/10;
				time->Day=i*10+Data;
				return;
				
				////////
		
		case	Set_Hour_H:
				
				i=time->Hour%10;
				time->Hour=Data*10+i;
				
				return;
				////
				
		case	Set_Hour_L:
				
				i=time->Hour/10;
				time->Hour=i*10+Data;
				return;
				
				////////
				
		case	Set_Min_H:
				
				i=time->Min%10;
				time->Min=Data*10+i;
				
				return;
				////
				
		case	Set_Min_L:
				
				i=time->Min/10;
				time->Min=i*10+Data;
				return;
				
				////////
				
		case	Set_Sec_H:
				
				i=time->Sec%10;
				time->Sec=Data*10+i;
				
				return;
				////
				
		case	Set_Sec_L:
				
				i=time->Sec/10;
				time->Sec=i*10+Data;
				return;
				
				////////
				
		
													
	
	}
	

}

/*============================================================================*/
/*============================================================================*/

static char	ASC_TO_HEX(char asc)
{
	switch(asc)
	{
		case	'0'	:return	0;
		case	'1'	:return	1;
		case	'2'	:return	2;
		case	'3'	:return	3;
		case	'4'	:return	4;
		case	'5'	:return	5;
		case	'6'	:return	6;
		case	'7'	:return	7;
		case	'8'	:return	8;
		case	'9'	:return	9;
		
	}
	return	-1;

}

int		RTC_Date_Time_Setting(void *pdata)

{

		#define		BK_RGB	RGB565(20,40,20)
		
		U8	a,i;
		U8	Uart_Key;
		U16	BTN;
	
		/////////////	
		
		char	*s_Name[]={"Date&Time Setting","日期和时间设置","???"};
		
		//////
		
		if(pdata)
		{
			struct	PGM_INFO *pInfo	=pdata;
			pInfo->Name			=(char*)GUI_Language(s_Name);
			pInfo->pIcon		=0;
			pInfo->pSmallIcon	=(void*)Time_Date_SmallIcon;
			pInfo->ExtraInfo	="Version:1.2";
			return	1;
		
		}
		/////////////

		
		TS_Free();
		Key_Free();
		////
		GUI_MemdevEnable();
		GUI_ClrScreen(BK_RGB);

		GUI_ShadeRectangle(0,0,LCD_XSIZE,32,RGB_Blue(31),RGB_White);
		GUI_Label(0,0,LCD_XSIZE,32,RGB_Black,RGB_TRANS,RGB_TRANS,Center,FONT(ASCII8x16,HZ16x16),(char*)GUI_Language(s_Name));
		////
	
		//GUI_Rectangle(0,32,RGB_White,LCD_XSIZE,LCD_YSIZE,Fill);
		//GUI_MatrixButtons(&BTN_Cfg,Button);
		GUI_DecNumberKeyBoard(20,LCD_YSIZE-72,LCD_XSIZE-20*2,64,1);
		////////
		GUI_DisplayUpdate(0,0,LCD_XSIZE,LCD_YSIZE);
		GUI_MemdevDisable();
	
	    
		////
		RTC_GetTime(&RTCTime);
		////
		Uart_Key=0;
		i=Set_Year_H;
		
RTC_Set_ST:

		Updata_RTC_Date_Time_Setting(&RTCTime,&i);
										
		////		
		
		
		while(1)
		{
			
			
		////
		
		
		if(RTC_Up_Key_Pressed())	// Up Key.
		{
		
			RTC_Set_Inc(&RTCTime,&i);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -