RBCX
Library for the RB3204-RBCX board with the ESP32 by RoboticsBrno.
Loading...
Searching...
No Matches
RBCXBattery.h
Go to the documentation of this file.
1#pragma once
2
3#include "rbcx.pb.h"
4
5namespace rb {
6
7class Manager;
8
12class Battery {
13 friend class Manager;
14
15public:
16 static constexpr uint32_t VOLTAGE_MIN = 3300
17 * 2;
18 static constexpr uint32_t VOLTAGE_MAX
19 = 4200 * 2;
20 static constexpr uint32_t BATTERY_IN_THRESHOLD = 5000;
21
22 uint32_t pct() const;
23
25 uint32_t voltageMv() const { return m_state.vccMv; }
26
28 uint32_t bMidVoltageMv() const { return m_state.battMidMv; }
29
31 int32_t temperatureC() const { return m_state.temperatureC; }
32
33 void shutdown();
34
36 bool isPoweredByBattery() const {
38 }
39
40private:
41 Battery();
42 Battery(const Battery&) = delete;
43 ~Battery();
44
45 void setState(const CoprocStat_PowerAdcStat& msg) { m_state = msg; }
46
47 CoprocStat_PowerAdcStat m_state;
48};
49
50};
Contains the battery state and can control the robot's power.
Definition: RBCXBattery.h:12
bool isPoweredByBattery() const
Definition: RBCXBattery.h:36
static constexpr uint32_t VOLTAGE_MAX
Maximal battery voltage, in mV.
Definition: RBCXBattery.h:19
static constexpr uint32_t VOLTAGE_MIN
Minimal battery voltage, in mV, at which the robot shuts down.
Definition: RBCXBattery.h:16
uint32_t voltageMv() const
returns battery Mid point voltage in mV
Definition: RBCXBattery.h:25
uint32_t bMidVoltageMv() const
returns current temperature as measured by the STM32 coprocessor in °C
Definition: RBCXBattery.h:28
uint32_t pct() const
returns current battery percentage (0-100)
Definition: RBCXBattery.cpp:22
int32_t temperatureC() const
Definition: RBCXBattery.h:31
static constexpr uint32_t BATTERY_IN_THRESHOLD
Definition: RBCXBattery.h:20
void shutdown()
shuts the robot's battery power
Definition: RBCXBattery.cpp:14
The main library class for working with the RBCX board. Call the install() method at the start of you...
Definition: RBCXManager.h:61
Definition: RBCXAngle.cpp:3