Skip to content

Commit 38b6cf4

Browse files
committed
Update docs in charger sketch
1 parent 50867e6 commit 38b6cf4

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

examples/Charger/Charger.ino

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
/*
2-
Charger Demo
2+
Charger Demo
33
4-
This sketch demonstrates how to write charging parameters,read charger state and monitor charging using the PowerManagement library:
5-
* In the setup() function, it sets the charging parameters
6-
* In the loop() functionit prints the battery's voltage, current, percentage and the charger's state allowing you to monitor charging.
4+
This sketch demonstrates how to write charging parameters,read charger state and monitor charging using the PowerManagement library:
5+
* In the setup() function, it sets the charging parameters
6+
* In the loop() functionit prints the battery's voltage, current, percentage and the charger's state allowing you to monitor charging.
77
88
Requirements:
99
- Arduino Portenta C33, Arduino Portenta H7, Arduino Nicla Vision
1010
- Arduino IDE
1111
- PowerManagement library (installable from the Arduino Library Manager)
1212
1313
Usage:
14-
1. Install the required library:
15-
- Open the Arduino IDE.
16-
- Go to "Sketch" -> "Include Library" -> "Manage Libraries..."
17-
- Search for "PowerManagement" and install it.
1814
15+
1. Connect the Battery:
16+
1917
2. Upload the Sketch:
20-
- Open the provided sketch in the Arduino IDE.
21-
- Select your board type and port from the "Tools" menu.
22-
- Click the "Upload" button to upload the sketch to your board.
18+
- Open the provided sketch in the Arduino IDE.
19+
- Select your board type and port from the "Tools" menu.
20+
- Click the "Upload" button to upload the sketch to your board.
2321
2422
3. Monitor Serial Output:
25-
- Open the Serial Monitor in the Arduino IDE.
26-
- Set the baud rate to 115200.
27-
- You will see the sketch continuously printing battery status and charger state.
23+
- Open the Serial Monitor in the Arduino IDE.
24+
- Set the baud rate to 115200.
25+
- You will see the sketch continuously printing charger state information.
2826
*/
2927
#include "Arduino_PowerManagement.h"
3028

@@ -75,34 +73,34 @@ String getChargerState(){
7573
ChargingState status = charger.getState();
7674

7775
switch (status) {
78-
case ChargingState::PreCharge:
76+
case ChargingState::preCharge:
7977
return "precharge";
8078
break;
81-
case ChargingState::FastChargeConstantCurrent:
79+
case ChargingState::fastChargeConstantCurrent:
8280
return "fast-charge constant current";
8381
break;
84-
case ChargingState::FastChargeConstantVoltage:
82+
case ChargingState::fastChargeConstantVoltage:
8583
return "fast-charge constant voltage";
8684
break;
87-
case ChargingState::EndOfCharge:
85+
case ChargingState::endOfCharge:
8886
return "end-of-charge";
8987
break;
90-
case ChargingState::Done:
88+
case ChargingState::done:
9189
return "done";
9290
break;
93-
case ChargingState::TimerFaultError:
91+
case ChargingState::timerFaultError:
9492
return "timer fault";
9593
break;
96-
case ChargingState::ThermistorSuspendError:
94+
case ChargingState::thermistorSuspendError:
9795
return "thermistor suspend";
9896
break;
99-
case ChargingState::ChargerDisabled:
97+
case ChargingState::chargerDisabled:
10098
return "off";
10199
break;
102-
case ChargingState::BatteryOvervoltageError:
100+
case ChargingState::batteryOvervoltageError:
103101
return "overvoltage condition";
104102
break;
105-
case ChargingState::ChargerBypassed:
103+
case ChargingState::chargerBypassed:
106104
return "disabled";
107105
break;
108106
default:
@@ -112,7 +110,7 @@ String getChargerState(){
112110
}
113111

114112
void loop(){
115-
static ChargingState status = ChargingState::None;
113+
static ChargingState status = ChargingState::none;
116114

117115
if (status != charger.getState()) {
118116
status = charger.getState();

0 commit comments

Comments
 (0)