PicoLowLevel
Loading...
Searching...
No Matches
Battery.h
Go to the documentation of this file.
1#ifndef BATTERY_H
2#define BATTERY_H
3
4#include <Arduino.h>
5#include "Debug.h"
6#include "definitions.h"
7
11class Battery {
12 public:
13 Battery(byte pin = BAT_PIN, int r1 = BAT_R1, int r2 = BAT_R2) : pin(pin), r1(r1), r2(r2) {}
14 float readVoltage();
15 float chargePercent();
16 bool charged();
17 bool USB();
18
19 private:
20 byte pin;
21 int r1, r2;
22};
23
24extern Battery battery;
25
26#endif
Battery battery
Definition Battery.cpp:37
Class to measure battery level and status.
Definition Battery.h:11
bool USB()
Check if the Pico is being powered from the USB port.
Definition Battery.cpp:33
float chargePercent()
Estimates the current battery charge.
Definition Battery.cpp:16
float readVoltage()
Reads the current battery voltage.
Definition Battery.cpp:7
bool charged()
Check the battery charge status.
Definition Battery.cpp:25
Battery(byte pin=BAT_PIN, int r1=BAT_R1, int r2=BAT_R2)
Definition Battery.h:13
#define BAT_R2
Definition definitions.h:28
#define BAT_R1
Definition definitions.h:27
#define BAT_PIN
Definition definitions.h:26