-
Notifications
You must be signed in to change notification settings - Fork 0
/
Contactor.h
30 lines (27 loc) · 1.15 KB
/
Contactor.h
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
struct ContactorDataStruct {
bool* turnOnReqPtr;
//String* hvilInterruptPtr;
bool* hvilAlarmFlagPtr;
bool* hvilInterruptAlarmFlagPtr;
bool* overCurrentAlarmFlagPtr;
bool* outOfRangeVoltageFlagPtr;
};
typedef struct ContactorDataStruct ContactorData;
// toggle the LED based on the press of the battery on/off button
void contactorTaskFnc(void* arg)
{
ContactorData* localDataPtr = arg;
//Saving the pointer values into variables for readibility
bool hvilAlarmFlag = *(localDataPtr->hvilAlarmFlagPtr);
bool hvilInterruptAlarmFlag = *(localDataPtr->hvilInterruptAlarmFlagPtr);
bool overCurrentAlarmFlag = *(localDataPtr->overCurrentAlarmFlagPtr);
bool outOfRangeVoltageFlag = *(localDataPtr->outOfRangeVoltageFlagPtr);
bool turnOn = *(localDataPtr->turnOnReqPtr);
if(hvilAlarmFlag || hvilInterruptAlarmFlag || overCurrentAlarmFlag || outOfRangeVoltageFlag) {
digitalWrite(24, LOW); // don't turn on the battery/LED on if any of the alarms were triggered
} else if (turnOn) {
digitalWrite(24, HIGH); // handle the turn on request
} else {
digitalWrite(24, LOW); // handle the turn off request
}
};