Skip to content

Commit

Permalink
Change PDP to PDH :)
Browse files Browse the repository at this point in the history
  • Loading branch information
ky28059 committed Jan 26, 2022
1 parent 1234d84 commit 323482a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/frc/robot/PowerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class PowerController {

private static PowerDistribution PDP = new PowerDistribution();
private static PowerDistribution PDH = new PowerDistribution();

// TODO: find current max value
// TODO: Calculate total sustainable current
Expand All @@ -24,14 +24,14 @@ public PowerController(ControllableSubsystem... subsystems) {
public void check() {
System.out.println("Checking for a brownout...");

// If the PDP is close to a brownout, trigger brownout scaling
if (PDP.getVoltage() < 7) {
// If the PDH is close to a brownout, trigger brownout scaling
if (PDH.getVoltage() < 7.0) {
System.out.println("close to brownout!");
setBrownoutScaling();
}

// Sum up total current drawn from all subsystems
double totalCurrent = PDP.getTotalCurrent();
double totalCurrent = PDH.getTotalCurrent();
System.out.println("total current drawn: " + totalCurrent);

// If current goes over sustainable current, scale subsystems down
Expand All @@ -41,19 +41,19 @@ public void check() {
}

/**
* Gets the total current drawn from the PDP by the specified channels.
* Gets the total current drawn from the PDH by the specified channels.
* @param channels The channels to sum.
* @return The total current drawn by the provided channels.
*/
public static double getCurrentDrawnFromPDP(int... channels) {
double sum = 0;

for (int channel : channels) {
sum += PDP.getCurrent(channel);
sum += PDH.getCurrent(channel);
}

// Is this necessary?
if (channels.length == 16 && (sum != PDP.getTotalCurrent())) {
if (channels.length == 16 && (sum != PDH.getTotalCurrent())) {
System.out.println("something is wrong, total current does not match");
}

Expand Down

0 comments on commit 323482a

Please sign in to comment.