package com.thegongoliers.input.vision;

import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;

public class LimelightCamera implements TargetingCamera {

    private static final String TABLE_NAME = "limelight";
    private static final String HAS_TARGET_KEY = "tv";
    private static final String HORIZONTAL_OFFSET_KEY = "tx";
    private static final String VERTICAL_OFFSET_KEY = "ty";
    private static final String TARGET_AREA_KEY = "ta";
    private static final String LED_MODE_KEY = "ledMode";
    private static final String CAMERA_MODE_KEY = "camMode";

    private NetworkTable mNetworkTable;

    public LimelightCamera(){
        mNetworkTable = NetworkTableInstance.getDefault().getTable(TABLE_NAME);
    }

    @Override
    public boolean hasTarget() {
        return mNetworkTable.getEntry(HAS_TARGET_KEY).getDouble(0.0) > 0;
    }

    @Override
    public double getHorizontalOffset() {
        return mNetworkTable.getEntry(HORIZONTAL_OFFSET_KEY).getDouble(0.0);
    }

    @Override
    public double getVerticalOffset() {
        return mNetworkTable.getEntry(VERTICAL_OFFSET_KEY).getDouble(0.0);
    }

    @Override
    public double getTargetArea() {
        return mNetworkTable.getEntry(TARGET_AREA_KEY).getDouble(0.0);
    }


    public void setLEDMode(LEDMode mode){
        mNetworkTable.getEntry(LED_MODE_KEY).setNumber(mode.modeNumber);
    }

    public void switchToDriverMode(){
        mNetworkTable.getEntry(CAMERA_MODE_KEY).setNumber(1);
    }

    public void switchToTargetingMode(){
        mNetworkTable.getEntry(CAMERA_MODE_KEY).setNumber(0);
    }

    public static enum LEDMode {
        UseDefault(0),
        Off(1),
        Blink(2),
        On(3);

        public final int modeNumber;

        LEDMode(int modeNumber){
            this.modeNumber = modeNumber;
        }
    }

}
@@ -609,16 +609,138 @@
 amMode%22;
+%0A    private static final String PIPELINE_KEY = %22pipeline%22;%0A    private static final String STREAMING_MODE_KEY = %22stream%22;
 %0A%0A    pr
@@ -1755,32 +1755,527 @@
 mber(0);%0A    %7D%0A%0A
+    public void selectPipeline(int pipeline)%7B%0A        mNetworkTable.getEntry(PIPELINE_KEY).setNumber(pipeline);%0A    %7D%0A%0A    public void setStreamingMode(StreamingMode mode)%7B%0A        mNetworkTable.getEntry(STREAMING_MODE_KEY).setNumber(mode.modeNumber);%0A    %7D%0A%0A    public static enum StreamingMode %7B%0A        Standard(0),%0A        Main(1),%0A        Secondary(2);%0A%0A        public final int modeNumber;%0A%0A        StreamingMode(int modeNumber)%7B%0A            this.modeNumber = modeNumber;%0A        %7D%0A    %7D%0A%0A
     public stati

Add more limelight configuration options