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:
@@ -15,24 +15,41 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
public class Robot extends TimedRobot {
|
||||
private final PowerDistribution m_pdp = new PowerDistribution();
|
||||
|
||||
@Override
|
||||
public void robotInit() {
|
||||
// Put the PDP itself to the dashboard
|
||||
SmartDashboard.putData("PDP", m_pdp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void robotPeriodic() {
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
SmartDashboard.putNumber("Current Channel 7", m_pdp.getCurrent(7));
|
||||
// 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);
|
||||
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.
|
||||
*/
|
||||
SmartDashboard.putNumber("Voltage", m_pdp.getVoltage());
|
||||
// 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();
|
||||
SmartDashboard.putNumber("Voltage", voltage);
|
||||
|
||||
/*
|
||||
* Retrieves the temperature of the PDP, in degrees Celsius.
|
||||
*/
|
||||
SmartDashboard.putNumber("Temperature", m_pdp.getTemperature());
|
||||
// Retrieves the temperature of the PDP, in degrees Celsius.
|
||||
double temperatureCelsius = m_pdp.getTemperature();
|
||||
SmartDashboard.putNumber("Temperature", temperatureCelsius);
|
||||
|
||||
// Get the total current of all channels.
|
||||
double totalCurrent = m_pdp.getTotalCurrent();
|
||||
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();
|
||||
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();
|
||||
SmartDashboard.putNumber("Total Energy", totalEnergy);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user