Blame view

ui.c 1.86 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()
  {
8b194ee7   henyxia   Getting touch inf...
60
61
  	int x = -1;
  	int y = -1;
fbc5816b   henyxia   UI should be upda...
62
63
  	if(actScreen == SC_HOME)
  	{
bc20374b   henyxia   Low IPS
64
  		if(uid[0] == '\0')
fbc5816b   henyxia   UI should be upda...
65
66
67
68
69
70
71
  			return;
  		else
  		{
  			actScreen = SC_MAIN;
  			displayPicture("img/main.boz");
  		}
  	}
8b194ee7   henyxia   Getting touch inf...
72
73
74
75
76
77
  	else if(actScreen == SC_MAIN)
  	{
  		if(screenTouched(&x, &y))
  			displayPicture("img/home.boz");
  			//displayPicture = calculateInteraction(displayPicture, x, y);
  	}
ac55328a   henyxia   No more UI
78
79
  }
  
cdaa873f   henyxia   Log fixed
80
81
  void* drawUI(void* we)
  {
d4d5bb6d   henyxia   Bus working
82
  	while(!uiStop)
cdaa873f   henyxia   Log fixed
83
  	{
bc20374b   henyxia   Low IPS
84
  		processScreen();
cdaa873f   henyxia   Log fixed
85
86
87
88
89
  		usleep(SCREEN_TIME);
  	}
  
  	return NULL;
  }
ea1218f1   henyxia   UI finished
90
  
3bdc9daf   henyxia   NFC Added
91
92
  void setTagName(char* tag)
  {
fbc5816b   henyxia   UI should be upda...
93
  	//time_t now = time(NULL);
3bdc9daf   henyxia   NFC Added
94
  	strcpy(uid, tag);
fbc5816b   henyxia   UI should be upda...
95
  	//strftime(uidDate, HEADER_TEXT_LENGTH, "%F-%T:%d", localtime(&now));
3bdc9daf   henyxia   NFC Added
96
97
  }
  
ea1218f1   henyxia   UI finished
98
99
  void initUILog()
  {
d4d5bb6d   henyxia   Bus working
100
  	cmd[0]='\0';
cdaa873f   henyxia   Log fixed
101
102
  	started[0]='\0';
  	mainPid = getpid();
ea1218f1   henyxia   UI finished
103
  	uid[0]='\0';
fbc5816b   henyxia   UI should be upda...
104
  	initUSB();
ea1218f1   henyxia   UI finished
105
106
  }
  
ea1218f1   henyxia   UI finished
107
108
109
110
  void setStartTime(char* sT)
  {
  	strcpy(started, sT);
  }