Disable alarms for 60s after clearing
This commit is contained in:
parent
661e1a2274
commit
c6793a2129
@ -178,6 +178,8 @@ String get_label(Value val) {
|
||||
|
||||
bool check_alarms() {
|
||||
static uint32_t poil_last_valid, tmot_last_valid, toil_last_valid;
|
||||
static int32_t poil_last_cleared = INT32_MIN, tmot_last_cleared = INT32_MIN,
|
||||
toil_last_cleared = INT32_MIN;
|
||||
uint32_t now = millis();
|
||||
if (Vehicle_data.p_oil >= POIL_ALARM_THRESH || Vehicle_data.speed == 0) {
|
||||
poil_last_valid = now;
|
||||
@ -189,21 +191,33 @@ bool check_alarms() {
|
||||
if (Vehicle_data.t_oil <= TOIL_ALARM_THRESH) {
|
||||
toil_last_valid = now;
|
||||
}
|
||||
// bool poil_alarm = now - poil_last_valid >= POIL_ALARM_TIME;
|
||||
// bool poil_alarm = now - poil_last_valid >= POIL_ALARM_TIME && now -
|
||||
// poil_last_cleared >= ALARM_CLEAR_TIME;
|
||||
bool poil_alarm = false;
|
||||
bool tmot_alarm = now - tmot_last_valid >= TMOT_ALARM_TIME;
|
||||
bool toil_alarm = now - toil_last_valid >= TOIL_ALARM_TIME;
|
||||
bool tmot_alarm = now - tmot_last_valid >= TMOT_ALARM_TIME &&
|
||||
now - tmot_last_cleared >= ALARM_CLEAR_TIME;
|
||||
bool toil_alarm = now - toil_last_valid >= TOIL_ALARM_TIME &&
|
||||
now - toil_last_cleared >= ALARM_CLEAR_TIME;
|
||||
bool alarm_active = poil_alarm || tmot_alarm || toil_alarm;
|
||||
|
||||
if (alarm_active) {
|
||||
String alarm_text = "";
|
||||
if (poil_alarm)
|
||||
alarm_text += "PO";
|
||||
alarm_text += "POIL";
|
||||
alarm_text += "|";
|
||||
if (tmot_alarm)
|
||||
alarm_text += "TM";
|
||||
alarm_text += "TMOT";
|
||||
alarm_text += "|";
|
||||
if (toil_alarm)
|
||||
alarm_text += "TO";
|
||||
alarm_text += "TOIL";
|
||||
alarm(alarm_text);
|
||||
now = millis();
|
||||
if (poil_alarm)
|
||||
poil_last_cleared = now;
|
||||
if (tmot_alarm)
|
||||
tmot_last_cleared = now;
|
||||
if (toil_alarm)
|
||||
toil_last_cleared = now;
|
||||
}
|
||||
|
||||
return alarm_active;
|
||||
@ -303,14 +317,12 @@ void update_display() {
|
||||
void alarm(String textstr) {
|
||||
uint8_t x = 1;
|
||||
;
|
||||
char text[7];
|
||||
textstr.toCharArray(text, 7);
|
||||
tft.setTextSize(8, 8);
|
||||
tft.setTextSize(6, 6);
|
||||
while (x == 1) {
|
||||
if (!tft.disconnected) {
|
||||
tft.setTextColor(EA_BLACK, EA_RED);
|
||||
tft.fillDisplayColor(EA_RED);
|
||||
tft.drawText(5, 68, 'L', text);
|
||||
tft.drawText(5, 10, 'L', textstr.c_str());
|
||||
}
|
||||
for (int j = 0; j < 16; j++) {
|
||||
digitalWrite(led_s[j], HIGH);
|
||||
@ -319,7 +331,7 @@ void alarm(String textstr) {
|
||||
if (!tft.disconnected) {
|
||||
tft.setTextColor(EA_BLACK, EA_WHITE);
|
||||
tft.fillDisplayColor(EA_WHITE);
|
||||
tft.drawText(5, 68, 'L', text);
|
||||
tft.drawText(5, 10, 'L', textstr.c_str());
|
||||
}
|
||||
for (int j = 0; j < 16; j++) {
|
||||
digitalWrite(led_s[j], LOW);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define TMOT_ALARM_TIME 20000 // ms
|
||||
#define TOIL_ALARM_THRESH (40 + 150)
|
||||
#define TOIL_ALARM_TIME 10000 // ms
|
||||
#define ALARM_CLEAR_TIME 60000 // ms
|
||||
#define ENC_DISPLAY_TIME 1000 // ms
|
||||
|
||||
String pad_left(String orig, int len, char pad_char = ' ');
|
||||
|
Loading…
x
Reference in New Issue
Block a user