Blame view

ui.c 1.77 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
fbc5816b   henyxia   UI should be upda...
18
19
  #define	SC_HOME				0
  #define	SC_MAIN				0
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
62
63
64
65
66
67
68
69
  	if(actScreen == SC_HOME)
  	{
  		if(strcmp(uid, "") == 0)
  			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
  	{
bf0cbb04   Pierre Letousey   Automatic regulation
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
  <<<<<<< Updated upstream
ea1218f1   henyxia   UI finished
97
  	uidDate[0]='\0';
bf0cbb04   Pierre Letousey   Automatic regulation
98
  	//initUSB();
fbc5816b   henyxia   UI should be upda...
99
100
101
  =======
  	initUSB();
  >>>>>>> Stashed changes
ea1218f1   henyxia   UI finished
102
103
  }
  
ea1218f1   henyxia   UI finished
104
105
106
107
  void setStartTime(char* sT)
  {
  	strcpy(started, sT);
  }