Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DO NOT MERGE) Code Review: Bling Strobe + Battery #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 57 additions & 3 deletions src/main/java/frc/robot/commands/SetBlingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package frc.robot.commands;

import edu.wpi.first.wpilibj.PowerDistribution;
import edu.wpi.first.wpilibj.PowerDistribution.ModuleType;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import frc.robot.subsystems.BlingSubsystem;
import com.ctre.phoenix.led.FireAnimation;
Expand Down Expand Up @@ -69,6 +71,21 @@ public void initialize() {
case 9:
setRgbFade();
break;
case 10: //TODO: for testing purposes, may add to robot
bling.setOrange(); //Special set (only a certain amount of LEDs light up)
break; //remove break?
case 11:
setBlueStrobe();
break;
case 12:
setYellowStrobe();
break;
case 13:
setRedStrobe();
break;
case 14:
setPurpleStrobe();
break;
default:
break;
}
Expand All @@ -89,14 +106,35 @@ public void setRainbow() {

public void setFire()
{
FireAnimation fireAnimation = new FireAnimation(1, 0.000001, 64, 0.8, 0.4);
FireAnimation fireAnimation = new FireAnimation(1, 0.000001, 64, 3, 1);

bling.candle.animate(fireAnimation);
}

public void setStrobe()
public void setPurpleStrobe()
{
StrobeAnimation strobeAnimation = new StrobeAnimation(255, 255, 255, 255, 0.8, 64);
StrobeAnimation strobeAnimation = new StrobeAnimation(138, 43, 226, 127, 0.001, 64); //TODO: test all of the rgbw bling values

bling.candle.animate(strobeAnimation);
}

public void setRedStrobe()
{
StrobeAnimation strobeAnimation = new StrobeAnimation(255, 0, 0, 127, 0.001, 64);

bling.candle.animate(strobeAnimation);
}

public void setBlueStrobe()
{
StrobeAnimation strobeAnimation = new StrobeAnimation(0, 0, 255, 127, 0.001, 64);

bling.candle.animate(strobeAnimation);
}

public void setYellowStrobe()
{
StrobeAnimation strobeAnimation = new StrobeAnimation(255, 255, 0, 127, 0.001, 64);

bling.candle.animate(strobeAnimation);
}
Expand All @@ -108,5 +146,21 @@ public void setRgbFade()
bling.candle.animate(rgbFadeAnimation);
}

PowerDistribution pd = new PowerDistribution(0, ModuleType.kCTRE);

boolean checkBatteryVoltageConstantly = true;

// Get the voltage going into the PDP, in Volts.
// The PDP returns the voltage in increments of 0.05 Volts.
double voltage = PowerDistribution.ModuleType.class.m_pdp.getVoltage();
SmartDashboard.putNumber("Voltage", voltage);

while (checkBatteryVoltageConstantly = true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't put a while loop here.
Checking battery and set bling could be in periodic method of some command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to remove the codes related to voltage. This pull request is only for bling.
Create a new branch which is only for battery voltage detection.

if (voltage <= 12.50); { //TODO: Using 12.50 Volts for now, may change later
bling.setOrange(); //Test to see if this replaces a current bling colour or not
checkBatteryVoltageConstantly = false; //TODO: Check if its ok that: putting this basically means it will be low voltage once below or equal to 12.50 V all the way until the robot is turned off (because then the battery would be changed)
}
}

}

5 changes: 5 additions & 0 deletions src/main/java/frc/robot/subsystems/BlingSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public void setYellow()
candle.setLEDs(255, 255, 0);
}

public void setOrange()
{
candle.setLEDs(255, 165, 0, 127, 1, 10); //test to see how many leds this is and if it works cuz the white is 127
}

@Override
public void periodic() {
// This method will be called once per scheduler run
Expand Down