some changes
This commit is contained in:
@@ -47,7 +47,6 @@ int main(int argc, char const *argv[])
|
||||
pthread_create(&uart_thread, NULL, uartListener, NULL);
|
||||
|
||||
//
|
||||
getch();
|
||||
|
||||
pthread_join(uart_thread, NULL);
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void uartDialog(int terminal_x, int terminal_y)
|
||||
char *uartDialog(int terminal_x, int terminal_y)
|
||||
{
|
||||
char *prompt = "Please enter UART device address for RFID reader (probably /dev/ttyUSB0): ";
|
||||
char *header = "Enter UART Address";
|
||||
char input[51] = {"\0"};
|
||||
|
||||
int win_height = 15;
|
||||
int win_width = 80;
|
||||
@@ -15,6 +16,7 @@ void uartDialog(int terminal_x, int terminal_y)
|
||||
|
||||
start_color();
|
||||
init_pair(1, COLOR_BLACK, COLOR_WHITE);
|
||||
init_pair(2, COLOR_WHITE, COLOR_RED);
|
||||
|
||||
WINDOW *uartwin = newwin(win_height, win_width, start_y, start_x);
|
||||
|
||||
@@ -27,12 +29,64 @@ void uartDialog(int terminal_x, int terminal_y)
|
||||
wattroff(uartwin, COLOR_PAIR(1));
|
||||
wrefresh(uartwin);
|
||||
|
||||
getch();
|
||||
// menu...
|
||||
int choice;
|
||||
int highlight = 0;
|
||||
|
||||
wclear(uartwin);
|
||||
wrefresh(uartwin);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
delwin(uartwin);
|
||||
refresh();
|
||||
}
|
||||
keypad(uartwin, TRUE);
|
||||
while (1)
|
||||
{
|
||||
int text_x = (win_width - 52) / 2;
|
||||
if (highlight == 0)
|
||||
{
|
||||
wattron(uartwin, COLOR_PAIR(2));
|
||||
mvwprintw(uartwin, 5, text_x, "[__________________________________________________]");
|
||||
wattroff(uartwin, COLOR_PAIR(2));
|
||||
}
|
||||
mvwprintw(uartwin, 5, text_x, "[%50s]", input);
|
||||
|
||||
int button_x = (win_width - 7) / 2;
|
||||
if (highlight == 1)
|
||||
{
|
||||
wattron(uartwin, COLOR_PAIR(2));
|
||||
mvwprintw(uartwin, 7, button_x, "<Enter>");
|
||||
wattroff(uartwin, COLOR_PAIR(2));
|
||||
}
|
||||
mvwprintw(uartwin, 7, button_x, "<Enter>");
|
||||
|
||||
wrefresh(uartwin);
|
||||
|
||||
choice = wgetch(uartwin);
|
||||
if (choice == '\t')
|
||||
{
|
||||
highlight=!highlight;
|
||||
}
|
||||
|
||||
if (highlight == 0)
|
||||
{
|
||||
wattron(uartwin, COLOR_PAIR(2));
|
||||
mvwprintw(uartwin, 5, (win_width - 52) / 2, "[__________________________________________________]");
|
||||
echo();
|
||||
wmove(uartwin, 5, ((win_width - 52) / 2) + 1);
|
||||
curs_set(1);
|
||||
flushinp();
|
||||
wgetnstr(uartwin, input, 50);
|
||||
curs_set(0);
|
||||
wattroff(uartwin, COLOR_PAIR(2));
|
||||
noecho();
|
||||
}
|
||||
else if (highlight == 1)
|
||||
{
|
||||
if (choice == '\n')
|
||||
{
|
||||
wclear(uartwin);
|
||||
wrefresh(uartwin);
|
||||
touchwin(stdscr);
|
||||
refresh();
|
||||
delwin(uartwin);
|
||||
refresh();
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user