Skip to content

Instantly share code, notes, and snippets.

@seanboe
Created June 17, 2023 03:07
Show Gist options
  • Save seanboe/db9fdb907acdd44628058c94613f3129 to your computer and use it in GitHub Desktop.
Save seanboe/db9fdb907acdd44628058c94613f3129 to your computer and use it in GitHub Desktop.
if (batt1On && batt1V < BATT_EMPTY && batt2Installed && !batt2On) {
ISR_Override = true;
digitalWrite(BATT_2_CTL, HIGH);
batt2On = true;
prevSwitchTime = micros();
Serial.println("Switched to batt 2!");
buffer += "Switching to batt 2";
if (batt2V > BATT_EMPTY) {
digitalWrite(BATT_1_CTL, LOW);
batt1On = false;
prevSwitchTime = micros();
buzzerTimer.set(BUZZ_INTERVAL_SLOW, 4);
}
else {
buzzerTimer.set(BUZZ_INTERVAL_RAPID, 20);
}
ISR_Override = false;
}
if (batt2On && batt2V < BATT_EMPTY && batt1Installed && !batt1On) {
ISR_Override = true;
digitalWrite(BATT_1_CTL, HIGH);
batt1On = true;
prevSwitchTime = micros();
Serial.println("Switched to batt 1!");
buffer += "Switching to batt 1";
if (batt1V > BATT_EMPTY) {
digitalWrite(BATT_2_CTL, LOW);
batt2On = false;
prevSwitchTime = micros();
buzzerTimer.set(BUZZ_INTERVAL_SLOW, 4);
}
else {
buzzerTimer.set(BUZZ_INTERVAL_RAPID, 20);
}
ISR_Override = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment