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

📄 system.c

📁 带有LCD
💻 C
字号:
/****************************************************
*Copyright (c) 2007, 新芝股份
*All rights reserved.
*
*文件名称:system.c
*
*当前版本:1.1
*作者:黄文剑
*完成日期:2007.10.10
*
*取代版本:1.0
*原作者:
*完成日期:2007.9.26
****************************************************/
#include<pic.h>
#include<stdio.h>
#include "system.h"
#include "D:\ql200\key\key.h"
#include "D:\ql200\lcd\lcd.h"
#include "D:\ql200\com\com.h"
#include "D:\ql200\operate\run.h"
#include "D:\ql200\operate\enter.h"
#include "D:\ql200\operate\list.h"
#include "D:\ql200\operate\edit.h"
#include "D:\ql200\operate\file.h"
#include "D:\ql200\operate\lid.h"

__CONFIG(HS & LVPDIS & WDTDIS);

unsigned char		current_status = 0x00;
const unsigned char 	menu_main[] = "MAIN:";
const unsigned char 	menu_mg96g[] = "MG96G";
const unsigned char 	menu_run[] = "Run";
const unsigned char 	menu_enter[] = "Enter";
const unsigned char 	menu_list[] = "List";
const unsigned char 	menu_edit[] = "Edit";
const unsigned char 	menu_file[] = "File";
const unsigned char 	menu_lid[] = "Lid";
const unsigned char	main_name1[] = "SCIENTZ  MG96G";
const unsigned char	main_name2[] = "Version 3.20";
const unsigned char	main_name3[] = "Self Testing......";	

void Dsp_Main_Menu(void);
void Dsp_Self_Testing(void);

/*****************************************************
Function Name:		main
Function Description:	system main function
Input Parameters:		None
Output Parameters:	None
Return Value:			None
Example of Use Case:	None			
*****************************************************/
void main(void)
{
	unsigned char 	i = 0;

	Key_Init();
	Lcd_Init();
	Dsp_Self_Testing();
	Eep_Rom_Init();
	Delay_10ms_ISR(200);	
	current_status = MAIN_MENU_STATUS;
	while(1)
	{
		Delay_10ms_ISR(200);
		switch(current_status)
		{
			case MAIN_MENU_STATUS:
			{
				Main_Menu();
				break;		
			}
			case RUN_MENU_STATUS:
			{
				Run_Menu();
				current_status= MAIN_MENU_STATUS;
				break;
			}
			case ENTER_MENU_STATUS:
			{
				Enter_Menu();
				current_status= MAIN_MENU_STATUS;
				break;
			}
			case LIST_MENU_STATUS:
			{
				List_Menu();
				current_status= MAIN_MENU_STATUS;
				break;
			}
			case EDIT_MENU_STATUS:
			{
				Edit_Menu();
				current_status= MAIN_MENU_STATUS;
				break;
			}
			case FILE_MENU_STATUS:
			{
				File_Menu();
				current_status= MAIN_MENU_STATUS;
				break;
			}	
			case LID_MENU_STATUS:
			{
				Lid_Menu();
				current_status= MAIN_MENU_STATUS;
				break;
			}				
		}
	}
}

void interrupt ISR(void)
{
	KEY_VALUE key_value = 0;
	unsigned char	i = 0;

	//key_value = Keypad_HighISR();
	//Delay_10ms_ISR(1);
	if(key_value == KEY_1)
	{
		i++;
	}
}
/*****************************************************
Function Name:		Main_Menu
Function Description:	main menu function
Input Parameters:		None
Output Parameters:	None
Return Value:			None
Example of Use Case:	None			
*****************************************************/
void Main_Menu(void)
{
	KEY_VALUE 		key_value = 0;
	unsigned char		bExit = 0;

	Lcd_Clr();
	Dsp_Main_Menu();
	while(!bExit)
	{
		key_value = Keypad_HighISR();
#pragma switch direct		
		switch(key_value)
		{
			case KEY_ERROR:
			{
				break;
			}
			case KEY_0:
			{
				break;				
			}
			case KEY_1:
			{
				break;
			}
			case KEY_2:
			{
				break;
			}
			case KEY_3:
			{
				break;
			}
			case KEY_4:
			{
				break;
			}
			case KEY_5:
			{
				break;
			}	
			case KEY_6:
			{
				break;
			}
			case KEY_7:
			{
				break;
			}
			case KEY_8:
			{
				break;
			}
			case KEY_9:
			{
				break;
			}	
			case KEY_DOWN:
			{
				Lcd_Cursor_Down();
				break;
			}
			case KEY_UP:
			{
				Lcd_Cursor_Up();
				break;
			}
			case KEY_LEFT:
			{
				Lcd_Cursor_Left();
				break;
			}
			case KEY_RIGHT:
			{
				Lcd_Cursor_Right();
				break;
			}		
			case KEY_ENTER:
			{
				unsigned char cur_potion = 0;
			
				cur_potion = Lcd_Get_Current_position();
				if((cur_potion >= 20) && (cur_potion <= 22))
				{
					current_status = RUN_MENU_STATUS;
					bExit = 1;
				}
				else if((cur_potion >= 32) && (cur_potion <= 36))
				{
					current_status = ENTER_MENU_STATUS;
					bExit = 1;
				}
				else if((cur_potion >= 40) && (cur_potion <= 43))
				{
					current_status = LIST_MENU_STATUS;
					bExit = 1;
				}
				else if((cur_potion >= 52) && (cur_potion <= 55))
				{
					current_status = EDIT_MENU_STATUS;
					bExit = 1;
				}
				else if((cur_potion >= 60) && (cur_potion <= 63))
				{
					current_status = FILE_MENU_STATUS;
					bExit = 1;
				}	
				else if((cur_potion >= 72) && (cur_potion <= 74))
				{
					current_status = LID_MENU_STATUS;
					bExit = 1;
				}					
				break;
			}
			case KEY_BACK:
				//Lcd_MoveTo_Position(0);
				break;			
			case KEY_NONE:
				break;
			default:
				break;
		}		
	}
	
}
/*****************************************************
Function Name:		Dsp_Main_Menu
Function Description:	display the main menu
Input Parameters:		None
Output Parameters:	None
Return Value:			None
Example of Use Case:	None			
*****************************************************/
void Dsp_Main_Menu(void)
{
	Lcd_MoveTo_Position(0);
	Lcd_Show_RomString(menu_main);
	Lcd_MoveTo_Position(12);
	Lcd_Show_RomString(menu_mg96g);
	Lcd_MoveTo_Position(20);
	Lcd_Show_RomString(menu_run);
	Lcd_MoveTo_Position(32);
	Lcd_Show_RomString(menu_enter);

	Lcd_MoveTo_Position(40);
	Lcd_Show_RomString(menu_list);
	Lcd_MoveTo_Position(52);
	Lcd_Show_RomString(menu_edit);	
	Lcd_MoveTo_Position(60);
	Lcd_Show_RomString(menu_file);
	Lcd_MoveTo_Position(72);
	Lcd_Show_RomString(menu_lid);	
	Lcd_MoveTo_Position(0);        //光标停在RUN位置
}
/*****************************************************
Function Name:		Dsp_Self_Testing
Function Description:	display system self testing
Input Parameters:		None
Output Parameters:	None
Return Value:			None
Example of Use Case:	None			
*****************************************************/
void Dsp_Self_Testing(void)
{
	Lcd_MoveTo_Position(3);
	Lcd_Show_RomString(main_name1);
	Lcd_MoveTo_Position(43);
	Lcd_Show_RomString(main_name2);
	Lcd_MoveTo_Position(62);
	Lcd_Show_RomString(main_name3);	
}

⌨️ 快捷键说明

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