[wpilibc] Add RobotController::GetBatteryVoltage() to C++ (#3179)

This function already exists in Java.
This commit is contained in:
Tyler Veness
2021-02-16 18:03:25 -08:00
committed by GitHub
parent 99b5ad9ebb
commit cb7f39afa1
2 changed files with 16 additions and 0 deletions

View File

@@ -42,6 +42,13 @@ bool RobotController::GetUserButton() {
return value;
}
units::volt_t RobotController::GetBatteryVoltage() {
int32_t status = 0;
double retVal = HAL_GetVinVoltage(&status);
wpi_setGlobalHALError(status);
return units::volt_t{retVal};
}
bool RobotController::IsSysActive() {
int32_t status = 0;
bool retVal = HAL_GetSystemActive(&status);

View File

@@ -6,6 +6,8 @@
#include <stdint.h>
#include <units/voltage.h>
namespace frc {
struct CANStatus {
@@ -55,6 +57,13 @@ class RobotController {
*/
static bool GetUserButton();
/**
* Read the battery voltage.
*
* @return The battery voltage in Volts.
*/
static units::volt_t GetBatteryVoltage();
/**
* Check if the FPGA outputs are enabled.
*