-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebugging.cpp
More file actions
170 lines (162 loc) · 5.59 KB
/
debugging.cpp
File metadata and controls
170 lines (162 loc) · 5.59 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
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
/************************************s
* Copyright (C) 2020-2025 Marina Egner <hello@sheepcs.de>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
************************************/
#include "debugging.h"
bool pulseStatus = false;
uint32_t StatusPreviousMillis = 0;
uint32_t blinkOnTime = 0;
bool serialIsSent[3] = { false };
void debuggingInit(uint8_t debugLevel, uint8_t outputLED) {
if(debugLevel >=1) pinMode(outputLED, OUTPUT);
if(debugLevel >=2) SerialUSB.begin(9600); // start Serial for Monitoring
}
void controllerStatus(bool errorFlag, uint8_t outputLED) {
if(errorFlag) {
digitalWrite(outputLED, true);
} else {
uint32_t currentMillis = millis();
if (currentMillis - StatusPreviousMillis >= 1000) { //Zeitverzoegerte Abfrage
StatusPreviousMillis = currentMillis;
pulseStatus = !pulseStatus;
} else if (currentMillis < StatusPreviousMillis) { //Reset
StatusPreviousMillis = currentMillis;
}
digitalWrite(outputLED, pulseStatus); //Flash if everything is OK
}
}
void debugChannelEvaluation(
uint16_t channelNumber,
uint16_t channel1,
uint16_t channel2,
uint16_t channel3,
uint16_t channel4,
uint16_t channel5,
uint16_t channel6,
uint16_t channel7,
uint16_t channel8
) {
if((millis()%1000 >= 500) && (serialIsSent[0] == false)) {
SerialUSB.print(F("--Multiswitch "));
SerialUSB.print(channelNumber);
SerialUSB.println(F(" --"));
SerialUSB.print(F("channel 1: "));
SerialUSB.println(channel1);
SerialUSB.print(F("channel 2: "));
SerialUSB.println(channel2);
SerialUSB.print(F("channel 3: "));
SerialUSB.println(channel3);
SerialUSB.print(F("channel 4: "));
SerialUSB.println(channel4);
SerialUSB.print(F("channel 5: "));
SerialUSB.println(channel5);
SerialUSB.print(F("channel 6: "));
SerialUSB.println(channel6);
SerialUSB.print(F("channel 7: "));
SerialUSB.println(channel7);
SerialUSB.print(F("channel 8: "));
SerialUSB.println(channel8);
SerialUSB.println(F("-------End-------"));
serialIsSent[0] = true;
} else if((millis()%1000 < 500) && (serialIsSent[0] == true)) {
serialIsSent[0] = false;
}
}
void debugFunctionState(bool parkLight,
bool lowBeamLight,
bool highBeamLight,
bool highBeamLightFlash,
bool fogLight,
bool beaconLight,
bool auxLight,
bool hazardLight,
bool leftIndicatorLight,
bool rightIndicatorLight,
bool reverseLight,
bool brakeLight) {
if((millis()%1000 >= 500) && (serialIsSent[1] == false)) {
SerialUSB.println(F("-- Light State --"));
SerialUSB.print(F("parkLight: "));
SerialUSB.println(parkLight);
SerialUSB.print(F("lowBeamLight: "));
SerialUSB.println(lowBeamLight);
SerialUSB.print(F("highBeamLight: "));
SerialUSB.println(highBeamLight);
SerialUSB.print(F("highBeamLightFlash: "));
SerialUSB.println(highBeamLightFlash);
SerialUSB.print(F("fogLight: "));
SerialUSB.println(fogLight);
SerialUSB.print(F("beaconLight: "));
SerialUSB.println(beaconLight);
SerialUSB.print(F("auxLight: "));
SerialUSB.println(auxLight);
SerialUSB.print(F("hazardLight: "));
SerialUSB.println(hazardLight);
SerialUSB.print(F("leftIndicatorLight: "));
SerialUSB.println(leftIndicatorLight);
SerialUSB.print(F("rightIndicatorLight: "));
SerialUSB.println(rightIndicatorLight);
SerialUSB.print(F("reverseLight: "));
SerialUSB.println(reverseLight);
SerialUSB.print(F("brakeLight: "));
SerialUSB.println(brakeLight);
SerialUSB.println(F("-------End-------"));
serialIsSent[1] = true;
} else if((millis()%1000 < 500) && (serialIsSent[1] == true)) {
serialIsSent[1] = false;
}
}
void debugFunctionOut(bool parkLight,
bool lowBeamLight,
bool highBeamLight,
bool highBeamLightFlash,
bool fogLight,
bool beaconLight,
bool auxLight,
bool hazardLight,
bool leftIndicatorLight,
bool rightIndicatorLight,
bool reverseLight,
bool brakeLight) {
if((millis()%1000 >= 500) && (serialIsSent[2] == false)) {
SerialUSB.println(F("-- Light Out --"));
SerialUSB.print(F("parkLight: "));
SerialUSB.println(parkLight);
SerialUSB.print(F("lowBeamLight: "));
SerialUSB.println(lowBeamLight);
SerialUSB.print(F("highBeamLight: "));
SerialUSB.println(highBeamLight);
SerialUSB.print(F("highBeamLightFlash: "));
SerialUSB.println(highBeamLightFlash);
SerialUSB.print(F("fogLight: "));
SerialUSB.println(fogLight);
SerialUSB.print(F("beaconLight: "));
SerialUSB.println(beaconLight);
SerialUSB.print(F("auxLight: "));
SerialUSB.println(auxLight);
SerialUSB.print(F("hazardLight: "));
SerialUSB.println(hazardLight);
SerialUSB.print(F("leftIndicatorLight: "));
SerialUSB.println(leftIndicatorLight);
SerialUSB.print(F("rightIndicatorLight: "));
SerialUSB.println(rightIndicatorLight);
SerialUSB.print(F("reverseLight: "));
SerialUSB.println(reverseLight);
SerialUSB.print(F("brakeLight: "));
SerialUSB.println(brakeLight);
SerialUSB.println(F("-------End-------"));
serialIsSent[2] = true;
} else if((millis()%1000 < 500) && (serialIsSent[2] == true)) {
serialIsSent[2] = false;
}
}