From: shainachen Date: Fri, 3 Feb 2017 04:17:16 +0000 (-0800) Subject: Edit getAverage() to calculate average over the bufferVals array length X-Git-Url: http://challenge-bot.com/repos/?a=commitdiff_plain;h=a24695fbb34be54d50c988c3d4a35119ba382cff;p=3501%2F2017steamworks Edit getAverage() to calculate average over the bufferVals array length --- diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/HallEffectBuffer.java b/src/org/usfirst/frc/team3501/robot/subsystems/HallEffectBuffer.java index 8816156..2e56ed0 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/HallEffectBuffer.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/HallEffectBuffer.java @@ -2,12 +2,13 @@ package org.usfirst.frc.team3501.robot.subsystems; public class HallEffectBuffer { int length; - int index = 0; + int index; double[] bufferVals; public HallEffectBuffer(int length) { this.length = length; bufferVals = new double[length]; + index = 0; } public void add(double val) { @@ -27,6 +28,6 @@ public class HallEffectBuffer { for (int i = 0; i < index; i++) { total += bufferVals[i]; } - return total / index + 1; + return total / bufferVals.length; } }