1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
22
23
31
37
40
41
42
47
51
52
57
58
59
60
61
62
63
64
65
66
67
68
69
74
75
76
90
125
126
127
128
129
130
131
132
133
134
135
142
143
150
151
/* ... */
#include "main.h"
Includes
#define KYBRD_FIRST_COLUMN (uint16_t)10
#define KYBRD_LAST_COLUMN (uint16_t)794
#define KYBRD_FIRST_LINE (uint16_t) 80
#define SMALL_FONT_COLUMN_WIDTH 8
#define SMALL_FONT_LINE_WIDTH 20
#define KYBRD_LAST_LINE (uint16_t)320
6 definesPrivate define
extern HID_DEMO_StateMachine hid_demo;
uint16_t KeybrdCharYpos = 0;
uint16_t KeybrdCharXpos = 0;
uint16_t CurrentLastXpos[KYBRD_LAST_LINE] = {0};
Private variables
static void USR_KEYBRD_Init(void);
Private function prototypes
/* ... */
void HID_KeyboardMenuProcess(void)
{
USR_KEYBRD_Init();
}{ ... }
/* ... */
static void USR_KEYBRD_Init(void)
{
LCD_LOG_ClearTextZone();
BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
BSP_LCD_DisplayStringAtLine(4, (uint8_t *)"Use Keyboard to type characters:");
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
KeybrdCharYpos = KYBRD_FIRST_LINE;
KeybrdCharXpos = KYBRD_FIRST_COLUMN;
}{ ... }
/* ... */
void USR_KEYBRD_ProcessData(uint8_t data)
{
if(data == '\n')
{
KeybrdCharXpos = KYBRD_FIRST_COLUMN;
KeybrdCharYpos += SMALL_FONT_LINE_WIDTH;
if(KeybrdCharYpos > KYBRD_LAST_LINE)
{
LCD_LOG_ClearTextZone();
KeybrdCharYpos = KYBRD_FIRST_LINE;
KeybrdCharXpos = KYBRD_FIRST_COLUMN;
}if (KeybrdCharYpos > KYBRD_LAST_LINE) { ... }
}if (data == '\n') { ... }
else if(data == '\r')
{
if(KeybrdCharXpos == KYBRD_FIRST_COLUMN)
{
if(KeybrdCharYpos == KYBRD_FIRST_LINE)
{
KeybrdCharXpos = KYBRD_FIRST_COLUMN;
}if (KeybrdCharYpos == KYBRD_FIRST_LINE) { ... }
else
{
KeybrdCharYpos -= SMALL_FONT_LINE_WIDTH;
KeybrdCharXpos = (KYBRD_LAST_COLUMN - SMALL_FONT_COLUMN_WIDTH);
}else { ... }
}if (KeybrdCharXpos == KYBRD_FIRST_COLUMN) { ... }
else
{
if(CurrentLastXpos[KeybrdCharYpos] > KYBRD_FIRST_COLUMN)
{
CurrentLastXpos[KeybrdCharYpos] -= SMALL_FONT_COLUMN_WIDTH;
KeybrdCharXpos = CurrentLastXpos[KeybrdCharYpos];
}if (CurrentLastXpos[KeybrdCharYpos] > KYBRD_FIRST_COLUMN) { ... }
else if(KeybrdCharYpos > KYBRD_FIRST_LINE)
{
KeybrdCharYpos -= SMALL_FONT_LINE_WIDTH;
CurrentLastXpos[KeybrdCharYpos] -= SMALL_FONT_COLUMN_WIDTH;
KeybrdCharXpos = CurrentLastXpos[KeybrdCharYpos];
}else if (KeybrdCharYpos > KYBRD_FIRST_LINE) { ... }
else
{
}else { ... }
}else { ... }
BSP_LCD_DisplayChar(CurrentLastXpos[KeybrdCharYpos], KeybrdCharYpos, ' ');
}else if (data == '\r') { ... }
else
{
BSP_LCD_DisplayChar(KeybrdCharXpos, KeybrdCharYpos, data);
KeybrdCharXpos += SMALL_FONT_COLUMN_WIDTH;
CurrentLastXpos[KeybrdCharYpos] = KeybrdCharXpos;
if(KeybrdCharXpos == KYBRD_LAST_COLUMN)
{
KeybrdCharXpos = KYBRD_FIRST_COLUMN;
KeybrdCharYpos += SMALL_FONT_LINE_WIDTH;
}if (KeybrdCharXpos == KYBRD_LAST_COLUMN) { ... }
if(KeybrdCharYpos > KYBRD_LAST_LINE)
{
LCD_LOG_ClearTextZone();
KeybrdCharYpos = KYBRD_FIRST_LINE;
BSP_LCD_DisplayChar(KeybrdCharXpos,KeybrdCharYpos, data);
}if (KeybrdCharYpos > KYBRD_LAST_LINE) { ... }
}else { ... }
}{ ... }