Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit bb2069d

Browse files
committed
added listener (hopefully)
1 parent 447e316 commit bb2069d

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package org.usfirst.frc.team199.Robot2018;
2+
3+
import org.usfirst.frc.team199.Robot2018.commands.SetDistancePerPulse;
4+
import org.usfirst.frc.team199.Robot2018.commands.UpdatePIDConstants;
5+
6+
import edu.wpi.first.networktables.EntryListenerFlags;
7+
import edu.wpi.first.networktables.NetworkTable;
8+
import edu.wpi.first.networktables.NetworkTableEntry;
9+
import edu.wpi.first.networktables.NetworkTableValue;
10+
import edu.wpi.first.networktables.TableEntryListener;
11+
import edu.wpi.first.wpilibj.command.Command;
12+
import edu.wpi.first.wpilibj.command.Scheduler;
13+
14+
public class Listener implements TableEntryListener {
15+
16+
private void addCommand(Command com) {
17+
Scheduler.getInstance().add(com);
18+
}
19+
20+
@Override
21+
public void valueChanged(NetworkTable arg0, String arg1, NetworkTableEntry arg2, NetworkTableValue arg3, int arg4) {
22+
if(arg4 == EntryListenerFlags.kNew) return;
23+
switch (arg1) {
24+
case "Const/Distance Per Pulse Left":
25+
addCommand(new SetDistancePerPulse());
26+
break;
27+
case "Const/Distance Per Pulse Right":
28+
addCommand(new SetDistancePerPulse());
29+
break;
30+
case "Const/TurnkP":
31+
addCommand(new UpdatePIDConstants());
32+
break;
33+
case "Const/TurnkI":
34+
addCommand(new UpdatePIDConstants());
35+
break;
36+
case "Const/TurnkD":
37+
addCommand(new UpdatePIDConstants());
38+
break;
39+
case "Const/MovekP":
40+
addCommand(new UpdatePIDConstants());
41+
break;
42+
case "Const/MovekI":
43+
addCommand(new UpdatePIDConstants());
44+
break;
45+
case "Const/MovekD":
46+
addCommand(new UpdatePIDConstants());
47+
break;
48+
49+
}
50+
}
51+
52+
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/Robot.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Robot extends IterativeRobot {
2828
public static final Lift lift = new Lift();
2929
public static RobotMap rmap;
3030
public static Drivetrain dt;
31+
public static Listener listen;
3132

3233
public static OI oi;
3334

@@ -57,6 +58,7 @@ public void robotInit() {
5758
rmap = new RobotMap();
5859
dt = new Drivetrain();
5960
oi = new OI();
61+
listen = new Listener();
6062
// chooser.addObject("My Auto", new MyAutoCommand());
6163
SmartDashboard.putData("Auto mode", chooser);
6264
}

0 commit comments

Comments
 (0)