ui.c
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <stdbool.h>
#include <termios.h>
#include "ui.h"
#include "bus.h"
#include "usb.h"
#define TIME_LENGTH 24
#define HEADER_TEXT_LENGTH 24
#define LOG_LINES 35
#define LOG_LENGTH 82
#define IPS 2
#define SCREEN_TIME 1000000/IPS
#define SC_HOME 0
#define SC_MAIN 1
#define SPACES " "
char started[TIME_LENGTH];
char uid[HEADER_TEXT_LENGTH];
char cmd[LOG_LENGTH];
pid_t mainPid;
bool heat = false;
bool pump = false;
unsigned int temp = 1;
unsigned int debit = 1;
struct termios old={0};
bool uiStop = false;
int actScreen = SC_HOME;
void stopUI()
{
uiStop = true;
}
void setHeat(bool s)
{
heat = s;
}
void setPump(bool s)
{
pump = s;
}
void setTemp(unsigned int t)
{
temp = t;
}
void setDebit(unsigned int d)
{
debit = d;
}
void processScreen()
{
if(actScreen == SC_HOME)
{
if(uid[0] == '\0')
return;
else
{
actScreen = SC_MAIN;
displayPicture("img/main.boz");
}
}
}
void* drawUI(void* we)
{
while(!uiStop)
{
processScreen();
usleep(SCREEN_TIME);
}
return NULL;
}
void setTagName(char* tag)
{
//time_t now = time(NULL);
strcpy(uid, tag);
//strftime(uidDate, HEADER_TEXT_LENGTH, "%F-%T:%d", localtime(&now));
}
void initUILog()
{
cmd[0]='\0';
started[0]='\0';
mainPid = getpid();
uid[0]='\0';
initUSB();
}
void setStartTime(char* sT)
{
strcpy(started, sT);
}