package org.usfirst.frc.team3501.robot.commands.shooter;
import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.subsystems.HallEffectSensor;
+import edu.wpi.first.wpilibj.Counter;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.command.Command;
*/
public class RunFlyWheel extends Command {
Timer timer;
+ HallEffectSensor hallSource;
+ Counter hall;
private double motorVal;
private double time;
+ private int bufferLength = 15;
+ private int hallChannel = 0; // hallChannel=DIO channeL
/**
* See JavaDoc comment in class for details
timer = new Timer();
this.motorVal = motorVal;
this.time = time;
+
+ hall = new Counter(hallChannel);
+ hall.setMaxPeriod(1);
+
+ hallSource = new HallEffectSensor(hall, bufferLength);
}
// Called just before this Command runs the first time
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
+ double rotVel = hallSource.getRPS();
+
}
// Called once after isFinished returns true
}
}
+ /**
+ * Gets average buffer value from array of existing buffer vals
+ *
+ * @return average buffered speed
+ */
public double getAverage() {
double total = 0;
- for (int i = 0; i < bufferVals.length; i++) {
+ for (int i = 0; i < index; i++) {
total += bufferVals[i];
}
- return total / bufferVals.length;
+ return total / index + 1;
}
}