1 package org
.usfirst
.frc
.team3501
.robot
.utils
;
3 import edu
.wpi
.first
.wpilibj
.Counter
;
5 public class HallEffectSensor
{
6 private Counter counter
;
8 public HallEffectSensor(int port
, int bufferLength
) {
9 counter
= new Counter(port
);
10 counter
.setSamplesToAverage(bufferLength
);
14 * Returns rotations per second(buffered) of hall effect sensor counter
16 * @return rotations per second of hall effect counter
18 public double getRPS() {
19 return 1.0 / counter
.getPeriod();
23 * Get the period of the most recent count.
25 * @return period of latest count in seconds
27 public double getCounterPeriod() {
28 return counter
.getPeriod();
32 * Returns rotations per minute(buffered) of hall effect sensor counter
34 * @return rotations per minute of hall effect sensor
36 public double getRPM() {
37 return this.getRPS() * 60;