Removed display timer, for timer in display driver
This commit is contained in:
59
display.c
59
display.c
@@ -44,7 +44,7 @@ int write_device(char *ln, size_t len){
|
||||
}
|
||||
|
||||
//write data to de h1502display device
|
||||
int write_line(int y, int x, int invert, char *txt){
|
||||
int write_line(int y, int x, int invert, char *txt, int time){
|
||||
size_t len = strlen(txt);
|
||||
if(len <= 0 ){
|
||||
return -1;
|
||||
@@ -56,7 +56,7 @@ int write_line(int y, int x, int invert, char *txt){
|
||||
return -1;
|
||||
}
|
||||
|
||||
int length = sprintf(buf, "%03d%03d%d%s", x, y, invert, txt);
|
||||
int length = sprintf(buf, "%03d%03d%03d%d%s", x, y, time, invert, txt);
|
||||
|
||||
int ret = 0;
|
||||
if(length > 0){
|
||||
@@ -72,55 +72,12 @@ int write_line(int y, int x, int invert, char *txt){
|
||||
}
|
||||
|
||||
void clear_display(void){
|
||||
write_line(line[0], MENU_OFFSET, 0, " ");
|
||||
write_line(line[1], 0, 0, " ");
|
||||
write_line(line[2], 0, 0, " ");
|
||||
write_line(line[3], MENU_OFFSET, 0, " ");
|
||||
write_line(line[0], MENU_OFFSET, 0, " ", 0);
|
||||
write_line(line[1], 0, 0, " ", 0);
|
||||
write_line(line[2], 0, 0, " ", 0);
|
||||
write_line(line[3], MENU_OFFSET, 0, " ", 0);
|
||||
}
|
||||
|
||||
void write_display(int ln, int pos, int invert, char *txt){
|
||||
write_line(line[ln], pos, invert, txt);
|
||||
void write_display(int ln, int pos, int invert, char *txt, int time){
|
||||
write_line(line[ln], pos, invert, txt, time);
|
||||
}
|
||||
|
||||
|
||||
static volatile int displaytimersemaphore = 0;
|
||||
|
||||
void display_timer_handler(union sigval arg){
|
||||
displaytimersemaphore -= 1;
|
||||
if(displaytimersemaphore == 0){
|
||||
//clear_display();
|
||||
writesyslog(LOG_ERR, "Clear display timer handler");
|
||||
}
|
||||
}
|
||||
|
||||
void display_timer(long int time){
|
||||
timer_t timer_id;
|
||||
struct itimerspec ts;
|
||||
struct sigevent se;
|
||||
|
||||
se.sigev_notify = SIGEV_THREAD;
|
||||
se.sigev_value.sival_ptr = NULL;
|
||||
se.sigev_notify_function = display_timer_handler;
|
||||
se.sigev_notify_attributes = NULL;
|
||||
|
||||
ts.it_value.tv_sec = time;
|
||||
ts.it_value.tv_nsec = (long int)0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
|
||||
int status = timer_create(CLOCK_REALTIME, &se, &timer_id);
|
||||
if (status == -1){
|
||||
writesyslog(LOG_ERR, "error create display timer");
|
||||
return;
|
||||
}
|
||||
|
||||
status = timer_settime(timer_id, 0, &ts, 0);
|
||||
if (status == -1){
|
||||
writesyslog(LOG_ERR, "error set display timer");
|
||||
return;
|
||||
}
|
||||
|
||||
displaytimersemaphore += 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define DISPLAY_FILE
|
||||
|
||||
void clear_display(void);
|
||||
void write_display(int ln, int pos, int invert, char *txt);
|
||||
void write_display(int ln, int pos, int invert, char *txt, int time);
|
||||
void display_timer(long int time);
|
||||
|
||||
#endif
|
||||
|
||||
1
global.h
1
global.h
@@ -3,6 +3,7 @@
|
||||
|
||||
//#define TRUE 1
|
||||
//#define FALSE 0
|
||||
#define DISPLAY_TIME 60
|
||||
|
||||
volatile int doorlockedflag;
|
||||
|
||||
|
||||
5
inputs.c
5
inputs.c
@@ -103,12 +103,11 @@ void *readinputs(void *ptr){
|
||||
clear_display();
|
||||
char *ln1;
|
||||
asprintf(&ln1, "Manual open - %ld sec", switchtime);
|
||||
write_display(1, 0, 0, ln1);
|
||||
write_display(1, 0, 0, ln1, switchtime);
|
||||
char *ln2;
|
||||
asprintf(&ln2, "In: %ld - Relay: %ld", config->manualinput, config->relay);
|
||||
write_display(2, 0, 0, ln2);
|
||||
write_display(2, 0, 0, ln2, switchtime);
|
||||
free(ln2);
|
||||
display_timer(switchtime);
|
||||
|
||||
writesyslog(LOG_INFO, ln1);
|
||||
server_send_log(config, ln1);
|
||||
|
||||
5
main.c
5
main.c
@@ -28,9 +28,8 @@
|
||||
int main(int argc, char **argv){
|
||||
writesyslog(LOG_INFO, STARTMSG);
|
||||
clear_display();
|
||||
write_display(1, 0, 0, "Starting");
|
||||
write_display(2, 0, 0, "ACSreader");
|
||||
display_timer(5);
|
||||
write_display(1, 0, 0, "Starting", 5);
|
||||
write_display(2, 0, 0, "ACSreader", 5);
|
||||
|
||||
createpidfile("/var/run/acsreader.pid");
|
||||
sighandlerinit();
|
||||
|
||||
10
reader.c
10
reader.c
@@ -41,9 +41,8 @@ void readerrequest(struct reader_t *reader, struct config_t *config){
|
||||
char *log;
|
||||
if(asprintf(&log, "CARD ID %d - %ld sec", reader->cardnumber, reader->opentime) > 0){
|
||||
clear_display();
|
||||
write_display(1, 0, 0, log);
|
||||
write_display(2, 0, 0, "access granted");
|
||||
display_timer(reader->opentime);
|
||||
write_display(1, 0, 0, log, reader->opentime);
|
||||
write_display(2, 0, 0, "access granted", reader->opentime);
|
||||
}
|
||||
free(log);
|
||||
if(asprintf(&log, "Card %d - access granted - %ld sec", reader->cardnumber, reader->opentime) > 0 ){
|
||||
@@ -59,9 +58,8 @@ void readerrequest(struct reader_t *reader, struct config_t *config){
|
||||
char *log;
|
||||
if(asprintf(&log, "CARD ID %d", reader->cardnumber) > 0){
|
||||
clear_display();
|
||||
write_display(1, 0, 0, log);
|
||||
write_display(2, 0, 0, "access denied");
|
||||
display_timer(3);
|
||||
write_display(1, 0, 0, log, 3);
|
||||
write_display(2, 0, 0, "access denied", 3);
|
||||
}
|
||||
free(log);
|
||||
if(asprintf(&log, "Card %d - access denied", reader->cardnumber) > 0 ){
|
||||
|
||||
6
web.c
6
web.c
@@ -165,9 +165,9 @@ void server_display_error(returnstate_t state, struct config_t *config){
|
||||
}
|
||||
if(len > 0){
|
||||
clear_display();
|
||||
write_display(1, 0, 0, ln1);
|
||||
write_display(2, 0, 0, ln2);
|
||||
display_timer(15);
|
||||
write_display(1, 0, 0, ln1, DISPLAY_TIME);
|
||||
write_display(2, 0, 0, ln2, DISPLAY_TIME);
|
||||
//display_timer(15);
|
||||
|
||||
writesyslog(LOG_ERR, log);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user