Skip to content

Commit d418cfa

Browse files
committed
Get properties from charger
1 parent 687525d commit d418cfa

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Diff for: examples/Battery/Battery.ino

+11-5
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,21 @@ void setup() {
3838
while (!Serial);
3939
delay(1000); // Delay to give time to load the Serial Monitor
4040

41-
42-
// Charger charger = Charger();
43-
// charger.begin();
41+
charger = Charger();
42+
charger.begin();
43+
auto chargeVoltage = charger.getChargeVoltage();
44+
auto endOfChargeCurrent = charger.getEndOfChargeCurrent();
45+
// charger.setChargeVoltage(4.2); // Set the charge voltage in V
4446
// charger.setEndOfChargeCurrent(5); // Set the end of charge current in mA
45-
Serial.println("Charger initialized.");
47+
Serial.println("* 🔌 Charger initialized.");
48+
Serial.println("* ⚡️ Charge voltage: " + String(chargeVoltage) + " V");
49+
Serial.println("* ⚡️ End of charge current: " + String(endOfChargeCurrent) + " mA");
4650

4751
BatteryCharacteristics characteristics = BatteryCharacteristics();
4852
characteristics.capacity = 200; // Battery capacity in mAh. Change this value to match your battery's capacity.
49-
characteristics.endOfChargeCurrent = 5; // End of charge current in mA
53+
characteristics.ntcResistor = NTCResistor::Resistor10K; // NTC resistor value 10 or 100 kOhm
54+
characteristics.endOfChargeCurrent = endOfChargeCurrent; // End of charge current in mA
55+
characteristics.chargeVoltage = chargeVoltage; // Charge voltage in V
5056

5157
battery = Battery(characteristics);
5258
bool batteryInitialized = battery.begin(true);

Diff for: src/Board.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ Board::Board() {
5757
}
5858

5959
bool Board::begin() {
60-
if (PMIC.begin() != 0){
61-
return false;
62-
}
63-
return true;
60+
return PMIC.begin() == 0;
6461
}
6562

6663
bool Board::isUSBPowered() {

0 commit comments

Comments
 (0)