/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.oastem.frc.sensor;

import edu.wpi.first.wpilibj.CounterBase;
import edu.wpi.first.wpilibj.Encoder;

/**
 *
 * @author mduong15
 */
public class QuadratureEncoder {
    private Encoder enc;
    
    public QuadratureEncoder(int channelA, int channelB)
    {
        enc = new Encoder(channelA, channelB);
    }
    
    public QuadratureEncoder(int channelA, int channelB, boolean isReversed)
    {
        enc = new Encoder(channelA, channelB, isReversed);
    }
    
    public QuadratureEncoder(int channelA, int channelB, int scaleValue)
    {
        if (scaleValue == 1)
            enc = new Encoder(channelA, channelB, false, CounterBase.EncodingType.k1X);
        else if (scaleValue == 2)
            enc = new Encoder(channelA, channelB, false, CounterBase.EncodingType.k2X);
        else if (scaleValue == 4)
            enc = new Encoder(channelA, channelB, false, CounterBase.EncodingType.k4X);
        else
            enc = new Encoder(channelA, channelB, false, CounterBase.EncodingType.k4X);
    }
    
    public QuadratureEncoder(int channelA, int channelB, boolean isReversed, int scaleValue)
    {
        if (scaleValue == 1)
            enc = new Encoder(channelA, channelB, isReversed, CounterBase.EncodingType.k1X);
        else if (scaleValue == 2)
            enc = new Encoder(channelA, channelB, isReversed, CounterBase.EncodingType.k2X);
        else if (scaleValue == 4)
            enc = new Encoder(channelA, channelB, isReversed, CounterBase.EncodingType.k4X);
        else
            enc = new Encoder(channelA, channelB, isReversed, CounterBase.EncodingType.k4X);
    }
    
    
    
    
}

@@ -380,16 +380,56 @@
 er enc;%0A
+    private double pulsesPerRevolution;%0A
     %0A   
@@ -603,34 +603,241 @@
 annelB, 
-boolean isReversed
+double pulsesPerRev)%0A    %7B%0A        enc = new Encoder(channelA, channelB);%0A        pulsesPerRevolution = pulsesPerRev;%0A    %7D%0A    %0A    public QuadratureEncoder(int channelA, int channelB, boolean isReversed, double pulsesPerRev
 )%0A    %7B%0A
@@ -895,16 +895,60 @@
 ersed);%0A
+        pulsesPerRevolution = pulsesPerRev;%0A
     %7D%0A  
@@ -1013,32 +1013,53 @@
 , int scaleValue
+, double pulsesPerRev
 )%0A    %7B%0A        
@@ -1504,32 +1504,85 @@
 odingType.k4X);%0A
+        %0A        pulsesPerRevolution = pulsesPerRev;%0A
     %7D%0A    %0A    p
@@ -1652,31 +1652,80 @@
 eversed,
- int scaleValue
+%0A                            int scaleValue, double pulsesPerRev
 )%0A    %7B%0A
@@ -2206,31 +2206,24 @@
 e.k4X);%0A    
-%7D%0A    %0A
     %0A    %0A  
@@ -2215,20 +2215,962 @@
        %0A    
+    pulsesPerRevolution = pulsesPerRev;%0A    %7D%0A    %0A    %0A    public void free()%0A    %7B%0A        enc.free();%0A    %7D%0A    %0A    public int get()%0A    %7B%0A        return enc.get();%0A    %7D%0A    %0A    public double getDistance()%0A    %7B%0A        return enc.getDistance();%0A    %7D%0A    %0A    public double getRate()%0A    %7B%0A        return enc.getRate();%0A    %7D%0A    %0A    public int getRaw()%0A    %7B%0A        return enc.getRaw();%0A    %7D%0A    %0A    public boolean isGoingForward()%0A    %7B%0A        return enc.getDirection();%0A    %7D%0A    %0A    public boolean isStopped()%0A    %7B%0A        return enc.getStopped();%0A    %7D%0A    %0A    public void reset()%0A    %7B%0A        enc.reset();%0A    %7D%0A    %0A    public void setDistancePerPulse(int wheelCircumference)%0A    %7B%0A        enc.setDistancePerPulse(wheelCircumference / pulsesPerRevolution);%0A    %7D%0A    %0A    public void setDistanceWithRatio(int distancePerPulse, double gearRatio)%0A    %7B%0A        enc.setDistancePerPulse(distancePerPulse * gearRatio);%0A    %7D
 %0A    %0A%7D%0A

Set up Encoder wrapper methods