mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[examples] CANPDP: Expand properties shown (#4687)
This commit is contained in:
@@ -13,20 +13,40 @@
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void TeleopPeriodic() override {
|
||||
/* Get the current going through channel 7, in Amperes. The PDP returns the
|
||||
* current in increments of 0.125A. At low currents the current readings
|
||||
* tend to be less accurate.
|
||||
*/
|
||||
frc::SmartDashboard::PutNumber("Current Channel 7", m_pdp.GetCurrent(7));
|
||||
void RobotInit() override {
|
||||
// Put the PDP itself to the dashboard
|
||||
frc::SmartDashboard::PutData("PDP", &m_pdp);
|
||||
}
|
||||
|
||||
/* Get the voltage going into the PDP, in Volts. The PDP returns the voltage
|
||||
* in increments of 0.05 Volts.
|
||||
*/
|
||||
frc::SmartDashboard::PutNumber("Voltage", m_pdp.GetVoltage());
|
||||
void RobotPeriodic() override {
|
||||
// Get the current going through channel 7, in Amperes.
|
||||
// The PDP returns the current in increments of 0.125A.
|
||||
// At low currents the current readings tend to be less accurate.
|
||||
double current7 = m_pdp.GetCurrent(7);
|
||||
frc::SmartDashboard::PutNumber("Current Channel 7", current7);
|
||||
|
||||
// Get the voltage going into the PDP, in Volts.
|
||||
// The PDP returns the voltage in increments of 0.05 Volts.
|
||||
double voltage = m_pdp.GetVoltage();
|
||||
frc::SmartDashboard::PutNumber("Voltage", voltage);
|
||||
|
||||
// Retrieves the temperature of the PDP, in degrees Celsius.
|
||||
frc::SmartDashboard::PutNumber("Temperature", m_pdp.GetTemperature());
|
||||
double temperatureCelsius = m_pdp.GetTemperature();
|
||||
frc::SmartDashboard::PutNumber("Temperature", temperatureCelsius);
|
||||
|
||||
// Get the total current of all channels.
|
||||
double totalCurrent = m_pdp.GetTotalCurrent();
|
||||
frc::SmartDashboard::PutNumber("Total Current", totalCurrent);
|
||||
|
||||
// Get the total power of all channels.
|
||||
// Power is the bus voltage multiplied by the current with the units Watts.
|
||||
double totalPower = m_pdp.GetTotalPower();
|
||||
frc::SmartDashboard::PutNumber("Total Power", totalPower);
|
||||
|
||||
// Get the total energy of all channels.
|
||||
// Energy is the power summed over time with units Joules.
|
||||
double totalEnergy = m_pdp.GetTotalEnergy();
|
||||
frc::SmartDashboard::PutNumber("Total Energy", totalEnergy);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user