Bläddra i källkod

Fixed clear and add alerts

tags/v1.2.0
Bertrand Lemasle 6 år sedan
förälder
incheckning
aa1761ed04
1 ändrade filer med 11 tillägg och 5 borttagningar
  1. +11
    -5
      Alerts.cpp

+ 11
- 5
Alerts.cpp Visa fil

@@ -22,23 +22,29 @@ namespace alerts {
}

void add(uint8_t mask) {
if (!mask) return; //save a write to eeprom if there is no change

config_t* config = &config::main::value;
config->activeAlerts |= mask;
uint8_t active = config->activeAlerts;

active |= mask;
if (config->activeAlerts == active) return; //save a write to eeprom if there is no change

config->activeAlerts = active;
config::main::save();
}

void clear(PositionEntryMetadata &metadata) {
config_t* config = &config::main::value;
uint8_t clearMask = 0;
uint8_t active = config->activeAlerts;

if (metadata.batteryLevel >= config->alertBatteryLevelClear) clearMask |= _BV(ALERT_BATTERY_LEVEL_1) | _BV(ALERT_BATTERY_LEVEL_2);
if (metadata.temperature != ALERT_SUSPICIOUS_RTC_TEMPERATURE) bitSet(clearMask, ALERT_RTC_TEMPERATURE_FAILURE);
if (rtc::isAccurate()) bitSet(clearMask, ALERT_RTC_CLOCK_FAILURE);

if (!config->activeAlerts || !clearMask) return; //save a write to eeprom if there is no change
config->activeAlerts &= ~clearMask;
active &= ~clearMask;
if (config->activeAlerts == active) return; //save a write to eeprom if there is no change

config->activeAlerts = active;
config::main::save();
}
}

Laddar…
Avbryt
Spara