1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
30
38
41
42
43
48
96
97
102
103
104
105
106
107
108
109
110
111
112
113
114
119
120
121
122
123
124
125
126
127
133
134
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
179
180
181
/* ... */
#include "main.h"
Includes
#define KYBRD_FIRST_COLUMN (uint16_t)7
#define KYBRD_LAST_COLUMN (uint16_t)319
#define KYBRD_FIRST_LINE (uint8_t) 70
#define SMALL_FONT_COLUMN_WIDTH 8
#define SMALL_FONT_LINE_WIDTH 15
#define KYBRD_LAST_LINE (uint16_t)155
6 definesPrivate define
extern uint8_t *DEMO_KEYBOARD_menu[];
extern uint8_t prev_select;
extern uint32_t hid_demo_ready;
extern DEMO_StateMachine demo;
uint8_t KeybrdCharXpos = 0;
uint16_t KeybrdCharYpos = 0;
Private variables
static void USR_KEYBRD_Init(void);
Private function prototypes
/* ... */
void HID_KeyboardMenuProcess(void)
{
switch(demo.keyboard_state)
{
case HID_KEYBOARD_IDLE:
demo.keyboard_state = HID_KEYBOARD_START;
Demo_SelectItem(DEMO_KEYBOARD_menu, 0);
demo.select = 0;
break;
case HID_KEYBOARD_IDLE:
case HID_KEYBOARD_WAIT:
if(demo.select != prev_select)
{
prev_select = demo.select;
Demo_SelectItem(DEMO_KEYBOARD_menu, demo.select & 0x7F);
if(demo.select & 0x80)
{
demo.select &= 0x7F;
switch(demo.select)
{
case 0:
demo.keyboard_state = HID_KEYBOARD_START;
break;
case 0:
case 1:
LCD_LOG_ClearTextZone();
demo.state = DEMO_IDLE;
LCD_UsrLogY("> HID application closed.\n");
demo.select = 0;
break;
case 1:
default:
break;default
}switch (demo.select) { ... }
}if (demo.select & 0x80) { ... }
}if (demo.select != prev_select) { ... }
break;
case HID_KEYBOARD_WAIT:
case HID_KEYBOARD_START:
USR_KEYBRD_Init();
demo.keyboard_state = HID_KEYBOARD_WAIT;
break;
case HID_KEYBOARD_START:
default:
break;default
}switch (demo.keyboard_state) { ... }
}{ ... }
/* ... */
static void USR_KEYBRD_Init(void)
{
LCD_LOG_ClearTextZone();
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
BSP_LCD_DisplayStringAtLine(4, (uint8_t *)"Use Keyboard to tape characters: ");
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
KeybrdCharXpos = KYBRD_FIRST_LINE;
KeybrdCharYpos = KYBRD_FIRST_COLUMN;
}{ ... }
/* ... */
void USR_KEYBRD_ProcessData(uint8_t data)
{
if(data == '\n')
{
KeybrdCharYpos = KYBRD_FIRST_COLUMN;
KeybrdCharXpos += SMALL_FONT_LINE_WIDTH;
if(KeybrdCharXpos > KYBRD_LAST_LINE)
{
LCD_LOG_ClearTextZone();
KeybrdCharXpos = KYBRD_FIRST_LINE;
KeybrdCharYpos = KYBRD_FIRST_COLUMN;
}if (KeybrdCharXpos > KYBRD_LAST_LINE) { ... }
}if (data == '\n') { ... }
else if(data == '\r')
{
if( KeybrdCharYpos == KYBRD_FIRST_COLUMN)
{
if(KeybrdCharXpos == KYBRD_FIRST_LINE)
{
KeybrdCharYpos = KYBRD_FIRST_COLUMN;
}if (KeybrdCharXpos == KYBRD_FIRST_LINE) { ... }
else
{
KeybrdCharXpos += SMALL_FONT_LINE_WIDTH;
KeybrdCharYpos = (KYBRD_LAST_COLUMN + SMALL_FONT_COLUMN_WIDTH);
}else { ... }
}if (KeybrdCharYpos == KYBRD_FIRST_COLUMN) { ... }
else
{
KeybrdCharYpos += SMALL_FONT_COLUMN_WIDTH;
}else { ... }
BSP_LCD_DisplayChar(KeybrdCharYpos, KeybrdCharXpos, ' ');
}else if (data == '\r') { ... }
else
{
BSP_LCD_DisplayChar(KeybrdCharYpos, KeybrdCharXpos, data);
KeybrdCharYpos += SMALL_FONT_COLUMN_WIDTH;
if(KeybrdCharYpos == KYBRD_LAST_COLUMN)
{
KeybrdCharYpos = KYBRD_FIRST_COLUMN;
KeybrdCharXpos += SMALL_FONT_LINE_WIDTH;
if(KeybrdCharXpos > KYBRD_LAST_LINE)
{
LCD_LOG_ClearTextZone();
KeybrdCharXpos = KYBRD_FIRST_LINE;
BSP_LCD_DisplayChar(KeybrdCharYpos,KeybrdCharXpos, data);
}if (KeybrdCharXpos > KYBRD_LAST_LINE) { ... }
}if (KeybrdCharYpos == KYBRD_LAST_COLUMN) { ... }
}else { ... }
}{ ... }