ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
Public Member Functions | Protected Member Functions | List of all members
arpirobot::VoltageMonitor Class Reference

#include <arpirobot/arduino/sensor/VoltageMonitor.hpp>

Inheritance diagram for arpirobot::VoltageMonitor:
arpirobot::ArduinoDevice arpirobot::MainVmon

Public Member Functions

 VoltageMonitor (std::string pin, double vboard, int r1, int r2, bool createDevice=true, int deviceId=-1)
 
 VoltageMonitor (int pin, double vboard, int r1, int r2, bool createDevice=true, int deviceId=-1)
 
double getVoltage ()
 
- Public Member Functions inherited from arpirobot::ArduinoDevice
 ArduinoDevice (bool createDevice, int deviceId)
 
virtual std::string getDeviceName ()
 
- Public Member Functions inherited from arpirobot::MainVmon
void makeMainVmon ()
 

Protected Member Functions

void applyDefaultState () override
 
std::vector< uint8_t > getCreateData () override
 
void handleData (const std::vector< uint8_t > &data) override
 
- Protected Member Functions inherited from arpirobot::ArduinoDevice
void setArduino (BaseArduinoInterface *arduino)
 
void setDeviceId (int deviceId)
 
bool sendData (const std::vector< uint8_t > &data)
 
bool sendData (const std::string &data)
 
- Protected Member Functions inherited from arpirobot::MainVmon
bool isMainVmon ()
 
void sendMainBatteryVoltage (double voltage)
 

Additional Inherited Members

- Static Protected Member Functions inherited from arpirobot::ArduinoDevice
static std::vector< uint8_t > stringToData (const std::string &str)
 
- Protected Attributes inherited from arpirobot::ArduinoDevice
bool createDevice
 
int deviceId
 
std::string deviceName
 
BaseArduinoInterfacearduino = nullptr
 

Detailed Description

Simple analog input voltage monitor (using voltage divider) connected to arduino analog input.

Constructor & Destructor Documentation

◆ VoltageMonitor() [1/2]

arpirobot::VoltageMonitor::VoltageMonitor ( std::string  pin,
double  vboard,
int  r1,
int  r2,
bool  createDevice = true,
int  deviceId = -1 
)
Parameters
pinThe analog input pin this voltage monitor is connected to (can be prefixed with letter A)
vboardThe board voltage for this arduino (usually 5V or 3.3V).
r1The top resistor of the voltage divider
r2The bottom resistor of the voltage divider (the one voltage is measured across)
createDeviceLeave this true unless the device is hard-coded in arduino firmware
deviceIdSet this to the hard-coded deviceId if createDevice is false

◆ VoltageMonitor() [2/2]

arpirobot::VoltageMonitor::VoltageMonitor ( int  pin,
double  vboard,
int  r1,
int  r2,
bool  createDevice = true,
int  deviceId = -1 
)
Parameters
pinThe analog input pin number this voltage monitor is connected
vboardThe board voltage for this arduino (usually 5V or 3.3V).
r1The top resistor of the voltage divider
r2The bottom resistor of the voltage divider (the one voltage is measured across)
createDeviceLeave this true unless the device is hard-coded in arduino firmware
deviceIdSet this to the hard-coded deviceId if createDevice is false

Member Function Documentation

◆ getVoltage()

double arpirobot::VoltageMonitor::getVoltage ( )

Get the voltage read by this voltage monitor (in volts)

Returns
The voltage in volts

The documentation for this class was generated from the following file: