Priprava Ncurses a vlakna pro UART
This commit is contained in:
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"users.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,12 @@
|
||||
CC = gcc
|
||||
|
||||
# define any compile-time flags
|
||||
CFLAGS := -Wall -Wextra -g
|
||||
CFLAGS := -Wall -Wextra -g -pedantic
|
||||
|
||||
# define library paths in addition to /usr/lib
|
||||
# if I wanted to include libraries not in /usr/lib I'd specify
|
||||
# their path using -Lpath, something like:
|
||||
LFLAGS =
|
||||
LFLAGS = -lncurses
|
||||
|
||||
# define output directory
|
||||
OUTPUT := output
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef __TUI_H__
|
||||
#define __TUI_H__
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef __USERS_H__
|
||||
#define __USERS_H__
|
||||
@@ -14,6 +16,8 @@ typedef struct person
|
||||
|
||||
time_t last_timestamp;
|
||||
uint32_t total;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
} person_t;
|
||||
|
||||
typedef struct node
|
||||
|
||||
Executable
BIN
Binary file not shown.
+35
-1
@@ -1,8 +1,42 @@
|
||||
#include <ncurses.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "users.h"
|
||||
|
||||
void *uartListener(void *arg)
|
||||
{
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
int y_max, x_max;
|
||||
pthread_t uart_thread;
|
||||
|
||||
return 0;
|
||||
initscr();
|
||||
|
||||
getmaxyx(stdscr, y_max, x_max);
|
||||
|
||||
noecho();
|
||||
noraw();
|
||||
start_color();
|
||||
curs_set(0);
|
||||
|
||||
assume_default_colors(COLOR_WHITE, COLOR_BLUE);
|
||||
erase();
|
||||
refresh();
|
||||
|
||||
pthread_create(&uart_thread, NULL, uartListener, NULL);
|
||||
|
||||
//
|
||||
|
||||
pthread_join(uart_thread, NULL);
|
||||
|
||||
clear();
|
||||
endwin();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user