uart dialog
This commit is contained in:
@@ -5,4 +5,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define MIN_X_TERMINAL_SIZE 80
|
||||||
|
#define MIN_Y_TERMINAL_SIZE 30
|
||||||
|
|
||||||
|
void uartDialog(int terminal_x, int terminal_y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
BIN
Binary file not shown.
+15
@@ -3,8 +3,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
#include "users.h"
|
#include "users.h"
|
||||||
|
#include "tui.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void *uartListener(void *arg)
|
void *uartListener(void *arg)
|
||||||
{
|
{
|
||||||
@@ -15,11 +21,17 @@ void *uartListener(void *arg)
|
|||||||
int main(int argc, char const *argv[])
|
int main(int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
int y_max, x_max;
|
int y_max, x_max;
|
||||||
|
char * uart_address;
|
||||||
pthread_t uart_thread;
|
pthread_t uart_thread;
|
||||||
|
|
||||||
initscr();
|
initscr();
|
||||||
|
|
||||||
getmaxyx(stdscr, y_max, x_max);
|
getmaxyx(stdscr, y_max, x_max);
|
||||||
|
if (x_max <= MIN_X_TERMINAL_SIZE || y_max <= MIN_Y_TERMINAL_SIZE)
|
||||||
|
{
|
||||||
|
puts("Terminal is too small. Exiting...\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
noecho();
|
noecho();
|
||||||
noraw();
|
noraw();
|
||||||
@@ -30,9 +42,12 @@ int main(int argc, char const *argv[])
|
|||||||
erase();
|
erase();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
uartDialog(x_max, y_max);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,38 @@
|
|||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void 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";
|
||||||
|
|
||||||
|
int win_height = 15;
|
||||||
|
int win_width = 80;
|
||||||
|
int start_y = (terminal_y - win_height) / 2;
|
||||||
|
int start_x = (terminal_x - win_width) / 2;
|
||||||
|
|
||||||
|
start_color();
|
||||||
|
init_pair(1, COLOR_BLACK, COLOR_WHITE);
|
||||||
|
|
||||||
|
WINDOW *uartwin = newwin(win_height, win_width, start_y, start_x);
|
||||||
|
|
||||||
|
wbkgd(uartwin, COLOR_PAIR(1));
|
||||||
|
|
||||||
|
box(uartwin, 0, 0);
|
||||||
|
wattron(uartwin, COLOR_PAIR(1));
|
||||||
|
mvwprintw(uartwin, 0, (win_width - strlen(header)) / 2, "%s", header);
|
||||||
|
mvwprintw(uartwin, 3, (win_width - strlen(prompt)) / 2, "%s", prompt);
|
||||||
|
wattroff(uartwin, COLOR_PAIR(1));
|
||||||
|
wrefresh(uartwin);
|
||||||
|
|
||||||
|
getch();
|
||||||
|
|
||||||
|
wclear(uartwin);
|
||||||
|
wrefresh(uartwin);
|
||||||
|
touchwin(stdscr);
|
||||||
|
refresh();
|
||||||
|
delwin(uartwin);
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user