Blame view

ui.c 1.5 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
cdaa873f   henyxia   Log fixed
16
17
  #define	IPS					20
  #define	SCREEN_TIME			1000000/IPS
19082eeb   henyxia   UI design not wor...
18
  #define	SPACES				"                                                                                                                                                                                                                                                                  "
ea1218f1   henyxia   UI finished
19
20
21
  char	started[TIME_LENGTH];
  char	uid[HEADER_TEXT_LENGTH];
  char	uidDate[HEADER_TEXT_LENGTH];
d4d5bb6d   henyxia   Bus working
22
  char	cmd[LOG_LENGTH];
cdaa873f   henyxia   Log fixed
23
  pid_t	mainPid;
d4d5bb6d   henyxia   Bus working
24
25
26
27
28
29
30
31
32
33
34
  bool	heat = false;
  bool	pump = false;
  unsigned int	temp = 1;
  unsigned int	debit = 1;
  struct	termios old={0};
  bool uiStop = false;
  
  void stopUI()
  {
  	uiStop = true;
  }
cdaa873f   henyxia   Log fixed
35
  
9e9f365e   henyxia   Added HVC interface
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  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
56
57
  void processScreen()
  {
9c066355   henyxia   USB Initialized
58
  
ac55328a   henyxia   No more UI
59
60
  }
  
cdaa873f   henyxia   Log fixed
61
62
  void* drawUI(void* we)
  {
d4d5bb6d   henyxia   Bus working
63
  	while(!uiStop)
cdaa873f   henyxia   Log fixed
64
  	{
ac55328a   henyxia   No more UI
65
  		processScreen();
cdaa873f   henyxia   Log fixed
66
67
68
69
70
  		usleep(SCREEN_TIME);
  	}
  
  	return NULL;
  }
ea1218f1   henyxia   UI finished
71
  
3bdc9daf   henyxia   NFC Added
72
73
74
75
76
77
78
  void setTagName(char* tag)
  {
  	time_t now = time(NULL);
  	strcpy(uid, tag);
  	strftime(uidDate, HEADER_TEXT_LENGTH, "%F-%T:%d", localtime(&now));
  }
  
ea1218f1   henyxia   UI finished
79
80
  void initUILog()
  {
d4d5bb6d   henyxia   Bus working
81
  	cmd[0]='\0';
cdaa873f   henyxia   Log fixed
82
83
  	started[0]='\0';
  	mainPid = getpid();
ea1218f1   henyxia   UI finished
84
85
  	uid[0]='\0';
  	uidDate[0]='\0';
9c066355   henyxia   USB Initialized
86
  	initUSB();
ea1218f1   henyxia   UI finished
87
88
  }
  
ea1218f1   henyxia   UI finished
89
90
91
92
  void setStartTime(char* sT)
  {
  	strcpy(started, sT);
  }