-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5_ErrorHandling.ino
More file actions
76 lines (63 loc) · 1.76 KB
/
5_ErrorHandling.ino
File metadata and controls
76 lines (63 loc) · 1.76 KB
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
void watchDog() {
/*--- Serielle kommunikation Überwachen ---*/
if ((timeLastCommand + timeOutCommand) < millis()) {
isSerialError = true;
if (!skipSerialError){
storePower = newPower;
if (power != 0) { newPower = 0; }
}
} else {
isSerialError = false;
}
/*--- Induktionskochfeld Überwachen ---*/
if ((timeLastReaction + timeOutReaction) < millis()) {
isCommError = true;
} else {
isCommError = false;
}
updateError();
}
boolean updateError() {
boolean returnValue = false;
String errorMessageBuilder = "";
// Platte meldet Okay
if (newError == 0) {
resetInduErrors(); // Alle Plattenfehler zurücksetzen.
goto SerialErrors; // Fehler überspringen.
}
returnValue = true; // Nicht okay
switch (newError) {
case 2:
isInduError[0] = true;
break;
default:
isunknownError = true;
}
SerialErrors:
if (isCommError) { returnValue = true; errorMessageBuilder = "I"; }
if (isSerialError) { returnValue = true; errorMessageBuilder = errorMessageBuilder + "S"; }
for (int i = 0; i < 10; i++) {
if (isInduError[i]) { errorMessageBuilder = errorMessageBuilder + errorMessages[i]; }
}
if (isunknownError) { errorMessageBuilder = errorMessageBuilder + "F:" + newError; }
if (returnValue == false) {
errorMessageBuilder = " ";
}
if (errorMessageBuilder != errorMessage) {
errorMessage = errorMessageBuilder;
lcdPrintError();
}
return returnValue;
}
void handleError() {
if (power != 0) {
lcdPrintError();
newPower = 0;
updatePower();
}
};
void resetInduErrors() {
for (int i = 0; i < 10; i++) {
isInduError[i] = false;
}
}