Skip to content

Commit

Permalink
print MCP73871 status on splash, low battery protection (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
haklein authored Feb 23, 2025
1 parent 192d736 commit e72edc8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Software/src/Version 6/MorseOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ void MorseOutput::displayScrollBar(boolean visible) { /// display a scr
///// display battery status as text and icon, parameter v: Voltage in mV

void MorseOutput::displayBatteryStatus(int v) { /// v in millivolts!

int a, b, c; String s; double d;
s.reserve(20);
d = v / 50;
Expand All @@ -499,13 +498,41 @@ void MorseOutput::displayBatteryStatus(int v) { /// v in millivolts!
s = "U: " + String(a) + "." + String(b) + " V";
else
s = "Unknown ?";
#ifdef CONFIG_MCP73871
uint8_t powerpath_state = (digitalRead(CONFIG_MCP_STAT1_PIN)<<2) + ( digitalRead(CONFIG_MCP_STAT2_PIN) << 1) + digitalRead(CONFIG_MCP_PG_PIN);
switch (powerpath_state) {
case 0:
s = "Charger Fault!";
break;
case 2:
s = "Charging";
break;
case 3:
s = "Low Battery!";
break;
case 4:
s = "Charge complete";
break;
case 6:
s = "No Battery!";
break;
case 7:
// Serial.println("Shutdown No Input Power Present");
break;
default:
//Serial.print("Unknown State: ");
break;
}
#endif
printOnScroll(2, REGULAR, 0, s);
#ifndef CONFIG_MCP73871
int w = constrain(v, 3100, 4100);
w = map(w, 3100, 4100, 0, 31);
display.drawRect(75, SCROLL_TOP + 2 * LINE_HEIGHT + 3, 35, LINE_HEIGHT - 4);
display.drawRect(110, SCROLL_TOP + 2 * LINE_HEIGHT + 5, 4, LINE_HEIGHT - 8);
if (v > 1000)
display.fillRect(77, SCROLL_TOP + 2 * LINE_HEIGHT + 5 , w, LINE_HEIGHT - 8);
#endif
display.display();
}

Expand Down
11 changes: 11 additions & 0 deletions Software/src/Version 6/m32_v6.ino
Original file line number Diff line number Diff line change
Expand Up @@ -675,14 +675,25 @@ void displayStartUp(uint16_t volt) {
vsn += " beta";
s += vsn;
MorseOutput::printOnScroll(0, REGULAR, 0, s );
#ifdef CONFIG_DISPLAYWRAPPER
MorseOutput::printOnScroll(1, REGULAR, 0, "(c) 2018-2025");
#else
MorseOutput::printOnScroll(1, REGULAR, 0, "© 2018-2025");
#endif

// uint16_t volt = batteryVoltage(); // has been measured early in setup()

#ifndef SKIP_BATTERY_PROTECT
#ifdef CONFIG_MCP73871
uint8_t powerpath_state = (digitalRead(CONFIG_MCP_STAT1_PIN)<<2) + ( digitalRead(CONFIG_MCP_STAT2_PIN) << 1) + digitalRead(CONFIG_MCP_PG_PIN);
if (powerpath_state == 3) // low battery
MorseOutput::displayEmptyBattery(shutMeDown);
else
#else
if (volt > 1000 && volt < 2800)
MorseOutput::displayEmptyBattery(shutMeDown);
else
#endif
#endif
MorseOutput::displayBatteryStatus(volt);
//prepare board version, just in case we want to switch to M32protocol later on
Expand Down

0 comments on commit e72edc8

Please sign in to comment.