📄 ui.c
字号:
//
//*****************************************************************************
#define UI_FLAG_DEMO6 21
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when the pen is the
//! selected tool.
//
//*****************************************************************************
#define UI_FLAG_PEN 23
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when the router is
//! the selected tool.
//
//*****************************************************************************
#define UI_FLAG_ROUTER 24
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when a routing depth
//! of 25 mil is selected. This flag is only valid when #UI_FLAG_ROUTER is
//! also set, but maintains its state during the time that #UI_FLAG_ROUTER is
//! not set.
//
//*****************************************************************************
#define UI_FLAG_ROUTER_25 25
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when a routing depth
//! of 50 mil is selected. This flag is only valid when #UI_FLAG_ROUTER is
//! also set, but maintains its state during the time that #UI_FLAG_ROUTER is
//! not set.
//
//*****************************************************************************
#define UI_FLAG_ROUTER_50 26
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when a routing depth
//! of 75 mil is selected. This flag is only valid when #UI_FLAG_ROUTER is
//! also set, but maintains its state during the time that #UI_FLAG_ROUTER is
//! not set.
//
//*****************************************************************************
#define UI_FLAG_ROUTER_75 27
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when a routing depth
//! of 100 mil is selected. This flag is only valid when #UI_FLAG_ROUTER is
//! also set, but maintains its state during the time that #UI_FLAG_ROUTER is
//! not set.
//
//*****************************************************************************
#define UI_FLAG_ROUTER_100 28
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when the Luminary
//! Micro logo button is toggled on.
//
//*****************************************************************************
#define UI_FLAG_LMI_LOGO 29
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when the ARM logo
//! button is toggled on.
//
//*****************************************************************************
#define UI_FLAG_ARM_LOGO 30
//*****************************************************************************
//
//! The bit number in #g_ulUIFlags of the flag that is set when the shift
//! button is toggled on.
//
//*****************************************************************************
#define UI_FLAG_SHIFT 31
//*****************************************************************************
//
//! A set of flags the track the state of the user interface; contains the
//! #UI_FLAG_DOWN, #UI_FLAG_DIAG, #UI_FLAG_RUN, #UI_FLAG_UPDATE,
//! #UI_FLAG_RUNNING, #UI_FLAG_UPPER_CASE, #UI_FLAG_LOWER_CASE,
//! #UI_FLAG_UPDATE_SCREEN, #UI_FLAG_START, #UI_FLAG_STOP, #UI_FLAG_TICK,
//! #UI_FLAG_BACKSPACE, #UI_FLAG_DIAG_BUTTON, #UI_FLAG_STOP_ON_RELEASE,
//! #UI_FLAG_DEMO1, #UI_FLAG_DEMO2, #UI_FLAG_DEMO3, #UI_FLAG_DEMO4,
//! #UI_FLAG_DEMO5, #UI_FLAG_DEMO6, #UI_FLAG_PEN, #UI_FLAG_ROUTER,
//! #UI_FLAG_ROUTER_25, #UI_FLAG_ROUTER_50, #UI_FLAG_ROUTER_75,
//! #UI_FLAG_ROUTER_100, #UI_FLAG_LMI_LOGO, #UI_FLAG_ARM_LOGO, and
//! #UI_FLAG_SHIFT flags.
//
//*****************************************************************************
static unsigned long g_ulUIFlags;
//*****************************************************************************
//
//! The state of the touch screen debouncer. This contains the count of
//! consecutive user interface interrupts during which the state of the touch
//! screen (touched or not) does not match the current debounced state. Once
//! the count reaches DEBOUNCE_COUNT then the debounced state of the touch
//! screen toggles.
//
//*****************************************************************************
static unsigned long g_ulUIDebounce;
//*****************************************************************************
//
//! The count of user interface interrupts during which the touch screen is
//! pressed. This is used to supported time-delayed functions, such as having
//! to press the "Run" button for a second before the machine start operating.
//
//*****************************************************************************
static unsigned long g_ulUICount;
//*****************************************************************************
//
//! A buffer to contain the string that has been entered into the user
//! interface.
//
//*****************************************************************************
static unsigned char g_pucString[128];
//*****************************************************************************
//
//! The number of valid characters in the #g_pucString buffer.
//
//*****************************************************************************
static unsigned long g_ulUIChars;
//*****************************************************************************
//
//! The offset of the first character in the #g_pucString buffer that should be
//! displayed. This is updated as characters are added/removed from the string
//! such that the end of the string is always visible on the LCD.
//
//*****************************************************************************
static unsigned long g_ulUIStart;
//*****************************************************************************
//
//! An inverted button glyph to be used for highlighting a button on the LCD.
//
//*****************************************************************************
static const unsigned char g_pucInvert[32 * 4] =
{
0x00, 0x00, 0x0f, 0x1f, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x1f, 0x0f, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0xf0, 0xf8, 0xfc, 0xfc, 0xfc, 0xfc,
0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,
0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,
0xfc, 0xfc, 0xfc, 0xfc, 0xf8, 0xf0, 0x00, 0x00
};
//*****************************************************************************
//
//! A blank button glpyh to be used for clearing the highlight of a button on
//! the LCD.
//
//*****************************************************************************
static const unsigned char g_pucBlank[32 * 4] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
//*****************************************************************************
//
//! The pieces of the border that is drawn around the text area of the display.
//! The first column corresponds to the first column of the display, the second
//! column corresponds to the thirty eight middle columns of the display, and
//! the third column corresonds to the last column of the display.
//
//*****************************************************************************
static const unsigned char g_pucTextBox[48 * 3] =
{
0x00, 0x00, 0x00, 0x0f, 0x10, 0x20, 0x40, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x40, 0x20, 0x10, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf0, 0x08, 0x04, 0x02, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x02, 0x04, 0x08, 0xf0, 0x00, 0x00, 0x00,
};
//*****************************************************************************
//
//! The coefficients used to convert from touch screen coordinates to LCD
//! coordinates. Static calibration data is provided here since the
//! manufacturing variances are tiny within a single model of touch panel LCD.
//
//*****************************************************************************
static const long g_plMatrix[7] =
{
104496, 336, -3700320, 756, -81900, 79582392, 303234
};
//*****************************************************************************
//
//! A temporary array used to construct items to be displayed on the LCD. It
//! is used to generate the labeled buttons, strings, and the space bar.
//
//*****************************************************************************
static unsigned char g_pucTemp[32 * 4];
//*****************************************************************************
//
//! A temporary array used for a decompressed character from the raster font.
//
//*****************************************************************************
static unsigned char g_pucChar[32 * 3];
//*****************************************************************************
//
//! This structure is used to describe a set of buttons to be displayed on the
//! LCD.
//
//*****************************************************************************
typedef struct
{
//
//! The character to be displayed on this button.
//
unsigned char ucLabel;
//
//! The horizontal location of this button, described in bytes (groups of
//! eight columns) to the right of the left column.
//
unsigned char ucX;
//
//! The vertical location of this button, described in scan lines down from
//! the top scan line.
//
unsigned char ucY;
//
//! Can be one of two things; if less than 32, it is the flag in
//! g_ulUIFlags that is toggled when the button is pressed. If greater
//! than 31, it is the character to be added to the string when the shift
//! key is enabled.
//
unsigned char ucFlag;
}
tButton;
//*****************************************************************************
//
//! The buttons to be displayed on the virtual keyboard.
//
//*****************************************************************************
static const tButton g_sButtons[] =
{
{ FONT_CHAR_DEMO1, 2, 48, UI_FLAG_DEMO1 },
{ FONT_CHAR_DEMO2, 6, 48, UI_FLAG_DEMO2 },
{ FONT_CHAR_DEMO3, 10, 48, UI_FLAG_DEMO3 },
{ FONT_CHAR_DEMO4, 14, 48, UI_FLAG_DEMO4 },
{ FONT_CHAR_DEMO5, 18, 48, UI_FLAG_DEMO5 },
{ FONT_CHAR_DEMO6, 22, 48, UI_FLAG_DEMO6 },
{ FONT_CHAR_PEN, 30, 48, 0 },
{ FONT_CHAR_ROUTER_25, 34, 48, 0 },
{ '1', 0, 80, '!' },
{ '2', 4, 80, '@' },
{ '3', 8, 80, '#' },
{ '4', 12, 80, '$' },
{ '5', 16, 80, '%' },
{ '6', 20, 80, '^' },
{ '7', 24, 80, '&' },
{ '8', 28, 80, '*' },
{ '9', 32, 80, '(' },
{ '0', 36, 80, ')' },
{ 'Q', 0, 112, 0 },
{ 'W', 4, 112, 0 },
{ 'E', 8, 112, 0 },
{ 'R', 12, 112, 0 },
{ 'T', 16, 112, 0 },
{ 'Y', 20, 112, 0 },
{ 'U', 24, 112, 0 },
{ 'I', 28, 112, 0 },
{ 'O', 32, 112, 0 },
{ 'P', 36, 112, 0 },
{ 'A', 2, 144, 0 },
{ 'S', 6, 144, 0 },
{ 'D', 10, 144, 0 },
{ 'F', 14, 144, 0 },
{ 'G', 18, 144, 0 },
{ 'H', 22, 144, 0 },
{ 'J', 26, 144, 0 },
{ 'K', 30, 144, 0 },
{ 'L', 34, 144, 0 },
{ FONT_CHAR_Abc, 0, 176, 0 },
{ 'Z', 4, 176, 0 },
{ 'X', 8, 176, 0 },
{ 'C', 12, 176, 0 },
{ 'V', 16, 176, 0 },
{ 'B', 20, 176, 0 },
{ 'N', 24, 176, 0 },
{ 'M', 28, 176, 0 },
{ ',', 32, 176, '<' },
{ '.', 36, 176, '>' },
{ FONT_CHAR_LMI, 2, 208, UI_FLAG_LMI_LOGO },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -