I am working with Minicom Terminal (VT102)
. I have a micro-controller node which sends data to the minicom through serial (UART). I wrote some functions to work with terminal.
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]
I am getting output something like this Displayed on first line and not in the specified line.
Look up the documentation for "gotoxy" command: You send the coordinates in ASCII:
printf("\x1B[%u;%uH", row, col);