📄 menu_data.c
字号:
/*------------------------------------------------------------------*-
Menu_Data.C (v1.00)
------------------------------------------------------------------
Use 'Hyperterminal' (under Windows 95, 98, 2000) or similar
terminal emulator program on other operating systems.
Terminal options:
- Data bits = 8
- Parity = None
- Stop bits = 1
- Flow control = Xon / Xoff
-*------------------------------------------------------------------*/
#include "Main.H"
#include "Port.H"
#include "Menu_Data.h"
#include "PC_IO.h"
// ------ Public variable declarations -----------------------------
// See Char_Map.c
extern const char code CHAR_MAP_G[10];
// ------ Private variables ----------------------------------------
static bit First_time_only_G;
/*------------------------------------------------------------------*-
MENU_Command_Processor()
This function is the main menu 'command processor' function.
-*------------------------------------------------------------------*/
void MENU_Command_Processor(void)
{
char Ch;
if (First_time_only_G == 0)
{
First_time_only_G = 1;
MENU_Show_Menu();
}
// Check for user inputs
PC_LINK_IO_Update();
Ch = PC_LINK_IO_Get_Char_From_Buffer();
if (Ch != PC_LINK_IO_NO_CHAR)
{
MENU_Perform_Task(Ch);
MENU_Show_Menu();
}
}
/*------------------------------------------------------------------*-
MENU_Show_Menu()
Display menu options on PC screen (via serial link)
- edit as required to meet the needs of your application.
-*------------------------------------------------------------------*/
void MENU_Show_Menu(void)
{
PC_LINK_IO_Write_String_To_Buffer("------------------------------\n");
PC_LINK_IO_Write_String_To_Buffer("Main Menu :\n");
PC_LINK_IO_Write_String_To_Buffer("A - Check P1 Status \n");
PC_LINK_IO_Write_String_To_Buffer("B - Check P2 status \n\n");
// PC_LINK_IO_Write_String_To_Buffer("c - Read P3\n");
// PC_LINK_IO_Write_String_To_Buffer("d - Read Download\n");
// PC_LINK_IO_Write_String_To_Buffer("e - Read Write\n");
// PC_LINK_IO_Write_String_To_Buffer("f - Read Status\n\n");
PC_LINK_IO_Write_String_To_Buffer("? : ");
}
/*------------------------------------------------------------------*-
MENU_Perform_Task()
Perform the required user task
- edit as required to match the needs of your application.
-*------------------------------------------------------------------*/
void MENU_Perform_Task(char c)
{
// Echo the menu option
PC_LINK_IO_Write_Char_To_Buffer(c);
PC_LINK_IO_Write_Char_To_Buffer('\n');
// Perform the task
switch (c)
{
case 'a': case 'A':
{
Get_Data_From_Port1();
break;
}
case 'b': case 'B':
{
Get_Data_From_Port2();
break;
}
case 'c': case 'D':
{
//Get_Data_From_Port3();
break;
}
case 'e': case 'E':
{
//Get_Data_From_TR();
break;
}
case 'f': case 'F':
{
//Get_Data_From_TX();
break;
}
}
}
/*------------------------------------------------------------------*-
Get_Data_From_Port1()
-*------------------------------------------------------------------*/
void Get_Data_From_Port1(void)
{
tByte Port1 = Data_Port1;
char String[11] = "\nP1 = XXX\n\n";
String[6] = CHAR_MAP_G[Port1 / 100];
String[7] = CHAR_MAP_G[(Port1 / 10) % 10];
String[8] = CHAR_MAP_G[Port1 % 10];
PC_LINK_IO_Write_String_To_Buffer(String);
}
/*------------------------------------------------------------------*-
Get_Data_From_Port2()
-*------------------------------------------------------------------*/
void Get_Data_From_Port2(void)
{
tByte Port2 = Data_Port2;
char String[11] = "\nP2 = XXX\n\n";
String[6] = CHAR_MAP_G[Port2 / 100];
String[7] = CHAR_MAP_G[(Port2 / 10) % 10];
String[8] = CHAR_MAP_G[Port2 % 10];
PC_LINK_IO_Write_String_To_Buffer(String);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -