Blame view

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