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

📄 menu.c

📁 这个是单片机4200的ui程序
💻 C
📖 第 1 页 / 共 5 页
字号:
			break;
		case PANEL_NUM0:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM0, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM1:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM1, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM2:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM2, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM3:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM3, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM4:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM4, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM5:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM5, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM6:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM6, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM7:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM7, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM8:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM8, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		case PANEL_NUM9:
			if(setconfirm == TRUE)
				{
				EditorDateTimeInput(PANEL_NUM9, curStep);
				if (curStep < stepmax)     
				   	curStep++;
	        		else                    
					curStep = 0;
			       curindex= GetDateTimeCursorXPos(curStep);
				}
			break;
		default:
			break;		
		}
//		sprintf(buf,"%-20s\n%-20s",firstlinebuf,secondlinebuf);
//		DisplayLCD(0, buf, strlen(buf));
		LCDDisplayClear();
		if(setconfirm != FALSE)
			{
			DisplayLCD(0, firstlinebuf, AlignL1,FALSE);
			DisplayLCD(1, secondlinebuf, LEFT,FALSE);
			}
		else
			{
			DisplayLCD(0, firstlinebuf, AlignL1,FALSE);
			DisplayLCD(1, secondlinebuf, AlignL2,TRUE);
			}
		if(curindex<=15)
			LCDCursorPos(curindex,0);
		else
			LCDCursorPos((curindex-16),1);
}

Bool DateTimeValid(DateTimeSct dt)
{
	Uint8   month, day, hour, minute, year;

	month = dt.Month;
	day = dt.Date;
	hour = dt.Hour;
	minute = dt.Minute;
	year = dt.Year;
	
	if(IsLeapYear(year))
		{
		if(month>12||month == 0)
			return FALSE;
		else if(day > monthday[month]||hour >= 24||minute >= 60||day == 0||year > 37)
			return FALSE;		
		}
	else
		{
		if(month>12||month == 0)
			return FALSE;
		else if(day > monthday2[month]||hour >= 24||minute >= 60||day == 0||year > 37)
			return FALSE;		
		}
	return TRUE;	
}

/*
void UpdateDateTime(DateTimeSct dt)
{
	dt.Minute++;
	
	if(dt.Minute > 59)
		{
		dt.Minute = 0;
		dt.Hour++;
		}
	if(dt.Hour > 23)
		{
		dt.Hour = 0;
		dt.Date++;
		}
	if(IsLeapYear(dt.Year))
		{
		if(dt.Date >= monthday[dt.Month])
			{
			dt.Date = 1;
			dt.Month++;
			}
		if(dt.Month >12)
			{
			dt.Month = 1;
			dt.Year++;
			}
		}
	else
		{
		if(dt.Date >= monthday2[dt.Month])
			{
			dt.Date = 1;
			dt.Month++;
			}
		if(dt.Month >12)
			{
			dt.Month = 1;
			dt.Year++;
			}
		}
	if(dt.Year > 99)
		dt.Year = 0;
}
*/

Bool  IsLeapYear(Uint8 year)
{
	Uint16 yt;

	yt = 2000 + year;
	if (!(year % 4) && (year % 100) || !(year % 400)) {
		return TRUE;
	} else {
		return FALSE;
	}
}

void CalDateTimeFormat(Uint32 dtdata,P_DateTimeSct dt)
{
	Uint32 daycount,dayleft,secleft;
	Uint8 i;

	daycount = dtdata/(60*60*24);
	secleft = dtdata - daycount*(60*60*24);

	dt->Hour = (Uint8)(secleft/(60*60));
	dt->Minute = (Uint8)((secleft - dt->Hour*(60*60))/60);
	dt->Second = (Uint8)(secleft-dt->Hour*(60*60)-dt->Minute*60);

	for(i = 0; i < 101; i++)
		{
		if(daycount < daysofyear[i])
			break;
		}
	dt->Year = i-1;
	dayleft = daycount - daysofyear[dt->Year];
	for(i = 0; i < 13; i++)
		{
		if(IsLeapYear(dt->Year))
			{
			if(dayleft<monthdays[i])
				break;
			}
		else
			{
			if(dayleft<monthdays2[i])
				break;
			}
		}
	dt->Month = i;
	if(IsLeapYear(dt->Year))
		{
		dt->Date = dayleft - monthdays[(dt->Month-1)] + 1;
		}
	else
		{
		dt->Date = dayleft - monthdays2[(dt->Month-1)] + 1;
		}
}

Uint32 CalDateTimeData(P_DateTimeSct dt)
{
	Uint32 dtdata;

	if(IsLeapYear(dt->Year))
		dtdata = (daysofyear[dt->Year]+monthdays[dt->Month-1]
				+(dt->Date) - 1)*(24*60*60)+(dt->Hour)*(60*60) + (dt->Minute)*60;
	else
		dtdata = (daysofyear[dt->Year]+monthdays2[dt->Month-1]
				+(dt->Date) - 1)*(24*60*60)+(dt->Hour)*(60*60) + (dt->Minute)*60;

	return dtdata;
}

void	CalZoomRatio()
{
	switch(gUIMain.copysetting.Presetratio)
		{
		case PR100:
			gUIMain.copysetting.Zoomratio = 100;
			break;
		case PR78:
			gUIMain.copysetting.Zoomratio = 78;
			break;
		case pr83:
			gUIMain.copysetting.Zoomratio = 83;
			break;
		case PR94:
			gUIMain.copysetting.Zoomratio = 94;
			break;
		case PR104:
			gUIMain.copysetting.Zoomratio = 104;
			break;
		default:
			break;
		}
}

void	CalDFZoomRatio()
{
	switch(gMFPSettingNvram.Copy.Presetratio)
		{
		case PR100:
			gMFPSettingNvram.Copy.Zoomratio = 100;
			break;
		case PR78:
			gMFPSettingNvram.Copy.Zoomratio = 78;
			break;
		case pr83:
			gMFPSettingNvram.Copy.Zoomratio = 83;
			break;
		case PR94:
			gMFPSettingNvram.Copy.Zoomratio = 94;
			break;
		case PR104:
			gMFPSettingNvram.Copy.Zoomratio = 104;
			break;
		default:
			break;
		}
}

API_RET	GetCurrentDateTime(P_DateTimeSct dt)
{
	STATUS 	status;
	Uint32	curtime;
	static Uint32	datetimedata;
	static Uint32	lastreadRTCtime = 0;

	status = NU_Obtain_Semaphore(&gDateTimeSem,NU_SUSPEND);
	if(NU_SUCCESS != status)
		{
		PSPRINTF("Obtain Date&Time Sem fail");
		return API_FAIL;
		}
//	EnableRTCAccess();
	curtime = TaskGetSystemMilliTicks();

	if(curtime - lastreadRTCtime > 1000)
		{
		datetimedata = ReadRTC_C();
		PSPRINTF("\nRead new RTC\n");
		}
	CalDateTimeFormat(datetimedata,dt);

	lastreadRTCtime = TaskGetSystemMilliTicks();

	status = NU_Release_Semaphore(&gDateTimeSem);
	if(NU_SUCCESS != status)
		{
		PSPRINTF("Release Date&Time Sem fail");
		return API_FAIL;
		}
	return API_OK;
}

int ReadRTC(P_DATETIME pResult)
{
	STATUS	status;
	DateTimeSct	dt;
	P_DateTimeSct	dtt;
	
	dtt = &dt;
	status = GetCurrentDateTime(dtt);
	if(status == API_OK)
		{
		pResult ->tm_sec = (int)dtt->Second;
		pResult ->tm_min = (int)dtt->Minute;
		pResult ->tm_hour = (int)dtt->Hour;
		pResult ->tm_mday = (int)dtt->Date;
		pResult ->tm_mon = (int)dtt->Month-1;
		pResult ->tm_year = (int)dtt->Year+100;
		return 1;
		}
	else
		return 0;
}

int SetRTC(DATETIME* pSetup)
{
	return 1;
}

void ResetDCCount(void)
{
	gUIMain.DCExpire = FALSE;
	Write_DrumCarPageCnt(0);
}

void ClearDrum(void)
{

	Uint32 UI_ExeCmd[4];
	UI_ExeCmd[0] = Print_ClearDrum;
	//TaskMsgSend(UI_EXe_msgQue_id, &UI_ExeCmd);
	NU_Send_To_Mailbox(&UI_MailBox,(void *)UI_ExeCmd,NU_SUSPEND);
	return;
}

void Print_Test_Page(void)
{
       Uint32 UI_ExeCmd[4];
	UI_ExeCmd[0] = Print_Accuracy;
	//TaskMsgSend(UI_EXe_msgQue_id, &UI_ExeCmd);
	NU_Send_To_Mailbox(&UI_MailBox,(void *)UI_ExeCmd,NU_SUSPEND);
}

void Print_Test_Page_20Gray(void)
{
       Uint32 UI_ExeCmd[4];
	UI_ExeCmd[0] = Print_20Gray;
	//TaskMsgSend(UI_EXe_msgQue_id, &UI_ExeCmd);
	NU_Send_To_Mailbox(&UI_MailBox,(void *)UI_ExeCmd,NU_SUSPEND);
}

void Print_Test_Page_5Gray(void)
{
      // Msg UI_ExeCmd;
       Uint32 UI_ExeCmd[4];
	UI_ExeCmd[0] = Print_5percent;
	//TaskMsgSend(UI_EXe_msgQue_id, &UI_ExeCmd);
	NU_Send_To_Mailbox(&UI_MailBox,(void *)UI_ExeCmd,NU_SUSPEND);
}

void print_Percent100_chart(void)
{
       Uint32 UI_ExeCmd[4];
	UI_ExeCmd[0] = Print_100percent;
	//TaskMsgSend(UI_EXe_msgQue_id, &UI_ExeCmd);     
	NU_Send_To_Mailbox(&UI_MailBox,(void *)UI_ExeCmd,NU_SUSPEND);
}
void Print_White_chart(void)
{
       Uint32 UI_ExeCmd[4];
	UI_ExeCmd[0] = Print_WhiteLetter;
	//TaskMsgSend(UI_EXe_msgQue_id, &UI_ExeCmd);
	NU_Send_To_Mailbox(&UI_MailBox,(void *)UI_ExeCmd,NU_SUSPEND);
}

// ----- add 2006.12.01 Mytecs ------

Uint32	ReadRTC_Uint32(void)
{
	DateTimeSct dts;
	struct tm pp;
	
	GetCurrentDateTime(&dts);
	ConvertDateTime2tm(&dts, &pp);
	return mktime(&pp);
}
// -----------------------------------


⌨️ 快捷键说明

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