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

📄 interface.c

📁 此程序为出租车计价器
💻 C
📖 第 1 页 / 共 2 页
字号:
	unsigned int Minute;
	unsigned int Second;
	unsigned int uiTempPos;
	lTemp = Cost_GetWaitTime();
	Hour = (unsigned int)(lTemp / 3600);
	Minute = ((unsigned int)(lTemp % 3600) / 60);
	Second = (unsigned int)(lTemp % 60);
	uiTempPos = InterFace_In_DisNumber(54, 36, -1, Hour);
	LCD501_PutChar(uiTempPos, 36, '-');
	uiTempPos += 6;
	uiTempPos = InterFace_In_DisNumber(uiTempPos, 36, 2, Minute);
	LCD501_PutChar(uiTempPos, 36, '-');
	uiTempPos += 6;
	InterFace_In_DisNumber(uiTempPos, 36, 2, Second);
}

//=============================================================
// 语法格式:	void InterFace_UpdateCost(void)
// 实现功能:	更新费用显示
// 参数:		无
// 返回值:		无
//=============================================================
void InterFace_UpdateCost(void)
{
	unsigned int uiTemp;
	uiTemp = InterFace_In_DisFloat(30, 48, Cost_GetCost());
	LCD501_Bitmap(uiTemp, 44, (unsigned int *)encoding_19);				//	元
	LCD501_PutChar(uiTemp + 12, 44, ' ');
	LCD501_PutChar(uiTemp + 12, 48, ' ');
	LCD501_PutChar(uiTemp + 18, 44, ' ');
	LCD501_PutChar(uiTemp + 18, 48, ' ');
}

//=============================================================
// 语法格式:	void InterFace_UpdateStatus(Status Mode)
// 实现功能:	更新系统状态显示
// 参数:		Mode	-	 系统状态
//				IDLE :		空车状态
//				RUN :		载客状态
//				SYSSET :	系统设置状态
// 返回值:		无
//=============================================================
void InterFace_UpdateStatus(Status Mode)
{
	switch(Mode)
	{
		case IDLE:
			LCD501_Bitmap(104, 52, (unsigned int *)encoding_28);					//	空
			LCD501_Bitmap(116, 52, (unsigned int *)encoding_0e);					//	车
			InterFace_UpdateIcon();
			break;
		case RUN:
			LCD501_Bitmap(104, 52, (unsigned int *)encoding_26);					//	行
			LCD501_Bitmap(116, 52, (unsigned int *)encoding_27);					//	驶
			InterFace_RevIcon();
			break;
		case SYSSET:
			LCD501_Bitmap(104, 52, (unsigned int *)encoding_24);					//	设
			LCD501_Bitmap(116, 52, (unsigned int *)encoding_25);					//	定
			break;
		default:
			break;
	}
}

Date DateTemp;										//	日期时间设置临时变量
SetMap DateSettingMap[5] = {						//	日期时间设置菜单MAP
	{0, 0, 4, &DateTemp.Year, 0, 2099},
	{30, 0, 2, &DateTemp.Month, 1, 12},
	{48, 0, 2, &DateTemp.Day, 1, 31},
	{66, 0, 2, &DateTemp.Hour, 0, 23},
	{84, 0, 2, &DateTemp.Minute, 0, 59}
};

//=============================================================
// 语法格式:	void InterFace_SystemSet(void)
// 实现功能:	系统设置
// 参数:		无
// 返回值:		无
//=============================================================
void InterFace_SystemSet(void)
{
	DateTemp = Cal_GetTime();
	LCD501_PutChar(78, 0, ':');
	InterFace_GUISetting(5, DateSettingMap);
	Cal_SetSysTime(DateTemp);
	InterFace_UpdateDate();
	InterFace_UpdateTime();
}

//=============================================================
// 语法格式:	void InterFace_GUISetting(unsigned int ItemNum, SetMap *SettingMap)
// 实现功能:	设定菜单控制程序
// 参数:		ItemNum		-	需要设置的项的数量
//				SettingMap	-	设置菜单MAP
// 返回值:		无
//=============================================================
void InterFace_GUISetting(unsigned int ItemNum, SetMap *SettingMap)
{
	//	日期、时间设定
	unsigned int uiCursorPos = 0;
	unsigned int Key, KeyType;
	InterFace_In_UpdateCursor(0, 1);
	while(ItemNum != uiCursorPos)
	{
		Key = KeyScan_GetKey(&KeyType);
		if(C_NullKey != Key)
		{
			switch(Key)
			{
				case C_StartStopKey:
					if((C_SReleaseKeyState == KeyType) || (KeyScan_CheckRepeat() == 1))
					{
						if((*SettingMap[uiCursorPos].Value)-- <= SettingMap[uiCursorPos].MinValue)
						{
							*SettingMap[uiCursorPos].Value = SettingMap[uiCursorPos].MaxValue;
						}
						//	add for MaxMonthDay resetting
						if((1 == uiCursorPos) || (0 == uiCursorPos))
						{
							SettingMap[2].MaxValue = Cal_In_GetDayofMonth(*SettingMap[1].Value, *SettingMap[0].Value);
						}
						//	end of add
						InterFace_In_UpdateCursor(uiCursorPos, 1);
					}
					break;
				case C_ModeKey:
					if(C_SReleaseKeyState == KeyType)
					{
						InterFace_In_UpdateCursor(uiCursorPos, 0);
						if(++uiCursorPos == ItemNum)
							break;
						InterFace_In_UpdateCursor(uiCursorPos, 1);
					}
					else if(C_LReleaseKeyState == KeyType)
					{
						InterFace_In_UpdateCursor(uiCursorPos, 0);
						uiCursorPos = 5;
					}
					break;
				case C_SetKey:
					if((C_SReleaseKeyState == KeyType) || (KeyScan_CheckRepeat() == 1))
					{
						if((*SettingMap[uiCursorPos].Value)++ >= SettingMap[uiCursorPos].MaxValue)
						{
							*SettingMap[uiCursorPos].Value = SettingMap[uiCursorPos].MinValue;
						}
						//	add for MaxMonthDay resetting
						if((1 == uiCursorPos) || (0 == uiCursorPos))
						{
							SettingMap[2].MaxValue = Cal_In_GetDayofMonth(*SettingMap[1].Value, *DateSettingMap[0].Value);
						}
						//	end of add
						InterFace_In_UpdateCursor(uiCursorPos, 1);
					}
					break;
			}
		}
	}
}

//=============================================================
// 语法格式:	void InterFace_In_UpdateCursor(unsigned int uiIndex, unsigned int RecONOFF)
// 实现功能:	更新设置光标显示
// 参数:		uiIndex		-	需要更新光标的设置项
//				RecONOFF	-	该项是否需要显示光标
// 返回值:		无
//=============================================================
void InterFace_In_UpdateCursor(unsigned int uiIndex, unsigned int RecONOFF)
{
	InterFace_In_DisNumber(DateSettingMap[uiIndex].Start_X, DateSettingMap[uiIndex].Start_Y, DateSettingMap[uiIndex].Len, *DateSettingMap[uiIndex].Value);
	if(RecONOFF)
	{
		LCD501_SetPaintMode(PAINT_REV);
		LCD501_Rectangle(DateSettingMap[uiIndex].Start_X, DateSettingMap[uiIndex].Start_Y, DateSettingMap[uiIndex].Start_X + DateSettingMap[uiIndex].Len * 6 - 1, DateSettingMap[uiIndex].Start_Y + 7, PAINT_SOLID);
		LCD501_SetPaintMode(PAINT_COVER);
	}
}

//=============================================================
// 语法格式:	unsigned int InterFace_In_DisNumber(unsigned int x, unsigned y, int len, unsigned int Number)
// 实现功能:	以十进制显示任意数字
// 参数:		x		-	数字显示位置的x坐标
//				y		-	数字显示位置的y坐标
//				len		-	数字显示的长度(-1表示根据数字大小自动调整长度)
//				Number	-	需要显示的数字
// 返回值:		数字显示之后的最右方x坐标
//=============================================================
unsigned int InterFace_In_DisNumber(unsigned int x, unsigned y, int len, unsigned int Number)
{
	unsigned long int ulTemp;
	unsigned int uiTemp, uiFlag;
	ulTemp = BCD(Number);
	if(len > 0)
	{
		while(len != 0)
		{
			len--;
			uiTemp = (unsigned int)(ulTemp >> (len * 4) & 0x000f);
			LCD501_PutChar(x, y, uiTemp + 0x30);
			x += 6;
		}
	}
	else
	{
		uiFlag = 0;
		len = 5;
		while(len != 0)
		{
			len--;
			uiTemp = (unsigned int)(ulTemp >> (len * 4) & 0x000f);
			if((uiFlag != 0) || (uiTemp != 0))
			{
				LCD501_PutChar(x, y, uiTemp + 0x30);
				uiFlag = 1;
				x += 6;
			}
		}
		if(0 == uiFlag)
		{
			LCD501_PutChar(x, y, 0x30);
			x += 6;
		}
	}
	return x;
}

//=============================================================
// 语法格式:	unsigned int InterFace_In_DisFloat(unsigned int x, unsigned y, float fNumber)
// 实现功能:	显示任意浮点数(显示至小数点后一位)
// 参数:		x		-	数字显示位置的x坐标
//				y		-	数字显示位置的y坐标
//				fNumber	-	需要显示的数字
// 返回值:		数字显示之后的最右方x坐标
//=============================================================
unsigned int InterFace_In_DisFloat(unsigned int x, unsigned y, float fNumber)
{
	unsigned int uiPointPos;
	unsigned int uiTemp;
	unsigned long int ulTemp;
	ulTemp = F_FloatToBCD(fNumber);
	if(HWORD(ulTemp) == 0)
	{
		LCD501_PutChar(x, y - 4, ' ');
		LCD501_PutChar(x, y, '0');
		x += 6;
		LCD501_PutChar(x, y - 4, ' ');
		LCD501_PutChar(x, y, '.');
		x += 6;
		LCD501_PutChar(x, y - 4, ' ');
		LCD501_PutChar(x, y, '0');
		x += 6;
	}
	else
	{
		uiPointPos = LWORD(ulTemp) & 0x0007;
		for(uiTemp = 0; uiTemp < uiPointPos; uiTemp++)
		{
			LCD501_PutChar(x, y - 4, ' ');
			LCD501_PutChar(x, y, (unsigned int)((ulTemp & (0xf0000000 >> (uiTemp * 4))) >> ((7 - uiTemp) * 4)) + 0x30);
			x += 6;
		}
		LCD501_PutChar(x, y - 4, ' ');
		LCD501_PutChar(x, y, '.');
		x += 6;
		LCD501_PutChar(x, y - 4, ' ');
		LCD501_PutChar(x, y, (unsigned int)((ulTemp & (0xf0000000 >> (uiTemp * 4))) >> ((7 - uiTemp) * 4)) + 0x30);
		x += 6;
	}
	return x;
}

⌨️ 快捷键说明

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