我正在与Minicom Terminal (VT102)
. 我有一个微控制器节点,它通过串行(UART)向 minicom 发送数据。我写了一些函数来使用终端。
typedef unsigned char uchar_t;
uchar_t clear_cmd[] = {0x1B, '[', '2', 'J', '\0'};
uchar_t gotoxy_cmd[] = {0x1B, '[', 0, ';', 0, 'H', '\0'};
void clearTerminal()
{
puts(clear_cmd); // puts() sends data serially to PC
}
void terminalWrite(uchar_t row, uchar_t col, const uchar_t *str)
{
gotoxy_cmd[2] = row;
gotoxy_cmd[4] = col;
puts(gotoxy_cmd);
puts(str);
}
void main()
{
init_uart(); // Initialize UART
clearTerminal();
terminalWrite(2, 12, "Admin Login"); // 2nd line 12th column
terminalWrite(4, 6, "Password: "); // 4th line 6th column
while(1);
}
[Assume all necessary header files are added]