some changes

This commit is contained in:
2025-04-02 21:45:33 +02:00
parent 334bda6a91
commit cca97e4a0c
5 changed files with 67 additions and 12 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
{
"files.associations": {
"users.h": "c"
"users.h": "c",
"ncurses.h": "c",
"stdlib.h": "c"
}
}
+1 -1
View File
@@ -8,6 +8,6 @@
#define MIN_X_TERMINAL_SIZE 80
#define MIN_Y_TERMINAL_SIZE 30
void uartDialog(int terminal_x, int terminal_y);
char * uartDialog(int terminal_x, int terminal_y);
#endif
BIN
View File
Binary file not shown.
-1
View File
@@ -47,7 +47,6 @@ int main(int argc, char const *argv[])
pthread_create(&uart_thread, NULL, uartListener, NULL);
//
getch();
pthread_join(uart_thread, NULL);
+63 -9
View File
@@ -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;
}
}
}
}