some changes
This commit is contained in:
Vendored
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"users.h": "c"
|
"users.h": "c",
|
||||||
|
"ncurses.h": "c",
|
||||||
|
"stdlib.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -8,6 +8,6 @@
|
|||||||
#define MIN_X_TERMINAL_SIZE 80
|
#define MIN_X_TERMINAL_SIZE 80
|
||||||
#define MIN_Y_TERMINAL_SIZE 30
|
#define MIN_Y_TERMINAL_SIZE 30
|
||||||
|
|
||||||
void uartDialog(int terminal_x, int terminal_y);
|
char * uartDialog(int terminal_x, int terminal_y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
BIN
Binary file not shown.
@@ -47,7 +47,6 @@ int main(int argc, char const *argv[])
|
|||||||
pthread_create(&uart_thread, NULL, uartListener, NULL);
|
pthread_create(&uart_thread, NULL, uartListener, NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
getch();
|
|
||||||
|
|
||||||
pthread_join(uart_thread, NULL);
|
pthread_join(uart_thread, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.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 *prompt = "Please enter UART device address for RFID reader (probably /dev/ttyUSB0): ";
|
||||||
char *header = "Enter UART Address";
|
char *header = "Enter UART Address";
|
||||||
|
char input[51] = {"\0"};
|
||||||
|
|
||||||
int win_height = 15;
|
int win_height = 15;
|
||||||
int win_width = 80;
|
int win_width = 80;
|
||||||
@@ -15,6 +16,7 @@ void uartDialog(int terminal_x, int terminal_y)
|
|||||||
|
|
||||||
start_color();
|
start_color();
|
||||||
init_pair(1, COLOR_BLACK, COLOR_WHITE);
|
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);
|
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));
|
wattroff(uartwin, COLOR_PAIR(1));
|
||||||
wrefresh(uartwin);
|
wrefresh(uartwin);
|
||||||
|
|
||||||
getch();
|
// menu...
|
||||||
|
int choice;
|
||||||
|
int highlight = 0;
|
||||||
|
|
||||||
|
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);
|
wclear(uartwin);
|
||||||
wrefresh(uartwin);
|
wrefresh(uartwin);
|
||||||
touchwin(stdscr);
|
touchwin(stdscr);
|
||||||
refresh();
|
refresh();
|
||||||
delwin(uartwin);
|
delwin(uartwin);
|
||||||
refresh();
|
refresh();
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user