1
0
forked from me/IronOS

Create checkUndervoltage.cpp

This commit is contained in:
Ben V. Brown
2022-11-22 18:07:34 +11:00
parent d2dbeee658
commit 3f8004e81c

View File

@@ -0,0 +1,35 @@
#ifdef POW_DC
// returns true if undervoltage has occured
bool checkForUnderVoltage(void) {
if (!getIsPoweredByDCIN()) {
return false;
}
uint16_t v = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
// Dont check for first 2 seconds while the ADC stabilizes and the DMA fills
// the buffer
if (xTaskGetTickCount() > (TICKS_SECOND * 2)) {
if ((v < lookupVoltageLevel())) {
currentTempTargetDegC = 0;
OLED::clearScreen();
OLED::setCursor(0, 0);
if (getSettingValue(SettingsOptions::DetailedSoldering)) {
OLED::print(translatedString(Tr->UndervoltageString), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->InputVoltageString), FontStyle::SMALL);
printVoltage();
OLED::print(SymbolVolts, FontStyle::SMALL);
} else {
OLED::print(translatedString(Tr->UVLOWarningString), FontStyle::LARGE);
}
OLED::refresh();
GUIDelay();
waitForButtonPress();
return true;
}
}
return false;
}
#endif