-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathscreenSaveHM.c
273 lines (250 loc) · 8.64 KB
/
screenSaveHM.c
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
gcc -g -o screenSaveHM screenSaveHM.c
*/
#include <linux/input.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "checkPara.h"
#include "Frame/touch.h"
#include "Frame/touch.c"
#include "Frame/framebuffer.c"
#include "Frame/DrawCorner.c"
#include "Frame/DrawImage.h"
#include "funktion.h"
int main()
{
//Parameter einbinden, checken oder default setzen
checkDefinePara(0);
signal(SIGINT, INThandler);
int xres,yres;
int screenXmax, screenXmin;
int screenYmax, screenYmin;
float scaleXvalue, scaleYvalue;
int rawX, rawY, rawPressure, scaledX, scaledY;
int screenChange;
//Umschalten auf 16Bit Display
char OUT[128];
snprintf (OUT, (size_t)128, "fbset -fb %s -depth 16", framebuffer_File);
system(OUT);
//system("setterm -cursor off"); //Courser Abschalten
int screenShutdown = ShutdownRun;
char Value[20];
screenOn();
int Screen[ScreenMAX];
if (openTouchScreen() == 1)
perror("error opening touch screen");
getTouchScreenDetails(&screenXmin,&screenXmax,&screenYmin,&screenYmax);
framebufferInitialize(&xres,&yres);
scaleXvalue = ((float)screenXmax-screenXmin) / xres;
printf ("X Scale Factor = %f\n", scaleXvalue);
scaleYvalue = ((float)screenYmax-screenYmin) / yres;
printf ("Y Scale Factor = %f\n", scaleYvalue);
int buttonCordsSaveHalb[4] = {5,110,400,280};
int buttonSaveHalb= BUTTON_OFF;
int buttonTimerSaveHalb = mymillis();
int buttonCordsHMrefresh[4] = {760,440,20,20};
int buttonTimerHMrefresh = mymillis();
//Homematic Touch-Button
int buttonCordsParty[4] = {S7-3,R2,Fw+6,21+3};
int buttonParty= BUTTON_OFF;
int buttonTimerParty = mymillis();
int buttonCordsKueche[4] = {(S6-3),(R2),(Fw+6),(21+3)};
int buttonKueche= BUTTON_OFF;
int buttonTimerKueche = mymillis();
int buttonCordsBrunnen[4] = {(S8-3),(R4),(Fw+6),(21+3)};
int buttonBrunnen= BUTTON_OFF;
int buttonTimerBrunnen = mymillis();
int buttonCordsMac[4] = {(S8-3),(R1),(Fw+6),(21+3)};
int buttonMac= BUTTON_OFF;
int buttonTimerMac = mymillis();
int buttonCordsOGWL[4] = {(S6-3),(R1),(Fw+6),(21+3)};
int buttonOGWL= BUTTON_OFF;
int buttonTimerOGWL = mymillis();
int buttonCordsJOGWST[4] = {(S7-3),(R1),(Fw+6),(21+3)};
int buttonJOGWST= BUTTON_OFF;
int buttonTimerJOGWST = mymillis();
while(1){
getTouchSample(&rawX, &rawY, &rawPressure);
scaledX = rawX/scaleXvalue;
scaledY = rawY/scaleYvalue;
Screen[ScreenChange] = readScreen(ScreenChange);
screenChange = Screen[ScreenChange];
Screen[ScreenShutdown] = readScreen(ScreenShutdown);
screenShutdown = Screen[ScreenShutdown];
switch(screenChange){
case ScreenAktuell:{
//siehe screnSave.c
break; // ScreenAktuell
}
case ScreenLangzeit:{
//siehe screnSave.c
break; // ScreenLangzeit
}
case ScreenSetup:{
//siehe screnSave.c
break; // ScreenSetup
}
case ScreenWetter:{
//siehe screnSave.c
break; // ScreenWetter
}
case ScreenSmart:{
//siehe screnSave.c
break; // ScreenSmart
}
case ScreenWallbox:{
//siehe screnSave.c
break; // ScreenWallbox
}
case ScreenFunktion:{
//siehe screnSave.c
break; // ScreenFunktion
}
case ScreenMonitor:{
//siehe screnSave.c
break; // ScreenMonitor
}
case ScreenHM:{
if((scaledX > buttonCordsSaveHalb[X] && scaledX < (buttonCordsSaveHalb[X]+buttonCordsSaveHalb[W])) && (scaledY > buttonCordsSaveHalb[Y] && scaledY < (buttonCordsSaveHalb[Y]+buttonCordsSaveHalb[H]))){
if (mymillis() - buttonTimerSaveHalb > 500)
if(buttonSaveHalb){
screenOff();
buttonSaveHalb= BUTTON_OFF;
buttonTimerSaveHalb = mymillis();
}
else{
screenOn();
writeScreen(ScreenCounter, 0);
writeScreen(ScreenSaver, false);
buttonSaveHalb= BUTTON_ON;
buttonTimerSaveHalb = mymillis();
}
}
if((scaledX > buttonCordsHMrefresh[X] && scaledX < (buttonCordsHMrefresh[X]+buttonCordsHMrefresh[W])) && (scaledY > buttonCordsHMrefresh[Y] && scaledY < (buttonCordsHMrefresh[Y]+buttonCordsHMrefresh[H]))){
if (mymillis() - buttonTimerHMrefresh > 500){
buttonTimerHMrefresh = mymillis();
drawSquare(760,440,20,20,LIGHT_GREEN);
drawCorner(760,440,20,20,WHITE);
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
}
}
if((scaledX > buttonCordsParty[X] && scaledX < (buttonCordsParty[X]+buttonCordsParty[W])) && (scaledY > buttonCordsParty[Y] && scaledY < (buttonCordsParty[Y]+buttonCordsParty[H]))){
if (mymillis() - buttonTimerParty > 500)
if(buttonParty){
buttonParty= BUTTON_OFF;
buttonTimerParty = mymillis();
drawSquare(S7-3,R2,Fw+6,21+3,LTGREY);
printsendHM(ISE_OGParty, "false");
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
}
else{
buttonParty= BUTTON_ON;
buttonTimerParty = mymillis();
drawSquare(S7-3,R2,Fw+6,21+3,LIGHT_GREEN);
printsendHM(ISE_OGParty, "true");
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
}
}
if((scaledX > buttonCordsKueche[X] && scaledX < (buttonCordsKueche[X]+buttonCordsKueche[W])) && (scaledY > buttonCordsKueche[Y] && scaledY < (buttonCordsKueche[Y]+buttonCordsKueche[H]))){
if (mymillis() - buttonTimerKueche > 500){
buttonTimerKueche = mymillis();
drawSquare(S6-3,R2,Fw+6,21+3,LIGHT_GREEN);
printsendHM(ISE_Send_OGKSpul, "true");
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
}
}
if((scaledX > buttonCordsBrunnen[X] && scaledX < (buttonCordsBrunnen[X]+buttonCordsBrunnen[W])) && (scaledY > buttonCordsBrunnen[Y] && scaledY < (buttonCordsBrunnen[Y]+buttonCordsBrunnen[H]))){
if (mymillis() - buttonTimerBrunnen > 500){
buttonTimerBrunnen = mymillis();
char Brunnen[20];
read_HM(ISE_Brunnen, 4, Brunnen);
if (strcmp ("true",Brunnen) == 0){
drawSquare(S8-3,R4,Fw+6,21+3,LTGREY);
printsendHM(ISE_Brunnen, "false");
}
else if (strcmp ("fals",Brunnen) == 0){
drawSquare(S8-3,R4,Fw+6,21+3,LIGHT_BLUE);
printsendHM(ISE_Brunnen, "true");
}
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
}
}
if((scaledX > buttonCordsMac[X] && scaledX < (buttonCordsMac[X]+buttonCordsMac[W])) && (scaledY > buttonCordsMac[Y] && scaledY < (buttonCordsMac[Y]+buttonCordsMac[H]))){
if (mymillis() - buttonTimerMac > 500){
buttonTimerMac = mymillis();
char MacSchrank[20];
read_HM(ISE_MacSchrankValue, 4, MacSchrank);
if (strcmp ("true",MacSchrank) == 0){
drawSquare(S8-3,R1,Fw+6,21+3,LIGHT_GREEN);
printsendHM(ISE_MacSchrank, "false");
}
else if (strcmp ("fals",MacSchrank) == 0){
drawSquare(S8-3,R1,Fw+6,21+3,LIGHT_RED);
printsendHM(ISE_MacSchrank, "true");
}
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
}
}
if((scaledX > buttonCordsOGWL[X] && scaledX < (buttonCordsOGWL[X]+buttonCordsOGWL[W])) && (scaledY > buttonCordsOGWL[Y] && scaledY < (buttonCordsOGWL[Y]+buttonCordsOGWL[H]))){
if (mymillis() - buttonTimerOGWL > 500){
buttonTimerOGWL = mymillis();
char OGWLicht[20];
read_HM(ISE_OGWLicht, 1, OGWLicht);
if ((strcmp ("1",OGWLicht) == 0) || (strcmp ("2",OGWLicht) == 0) || (strcmp ("3",OGWLicht) == 0)){
drawSquare(S6-3,R1,Fw+6,21+3,GREY);
printsendHM(ISE_OGWLicht, "0");
}
else if (strcmp ("0",OGWLicht) == 0){
drawSquare(S6-3,R1,Fw+6,21+3,GREEN);
printsendHM(ISE_OGWLicht, "1");
}
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
}
}
if((scaledX > buttonCordsJOGWST[X] && scaledX < (buttonCordsJOGWST[X]+buttonCordsJOGWST[W])) && (scaledY > buttonCordsJOGWST[Y] && scaledY < (buttonCordsJOGWST[Y]+buttonCordsJOGWST[H]))){
if (mymillis() - buttonTimerJOGWST > 500){
buttonTimerJOGWST = mymillis();
char OGWJalSt[20];
readJalou_HM(ISE_OGWJalSt, OGWJalSt); //Jalousie Wert aus der Homematic Abfrage
if (strcmp ("100",OGWJalSt) == 0){
drawSquare(S7-3,R1,Fw+6,21+3,GREEN);
printsendHM(ISE_OGWJalSt, "0.50");
}
else {
drawSquare(S7-3,R1,Fw+6,21+3,GREY);
printsendHM(ISE_OGWJalSt, "1.00");
}
writeScreen(ScreenCounter, 0);
writeScreen(ScreenChange, ScreenHM);
sleep(2);
}
}
break; // ScreenHM
}
case ScreenGB:{
//siehe screnSave.c
break; // ScreenGB
}
case ScreenMuell:{
//siehe screnSave.c
break; // ScreenMuell
}
default:{
//siehe screnSave.c
}
} // Switch screenChange
} //while
} //main