-
Notifications
You must be signed in to change notification settings - Fork 0
/
tunableNumber.java
44 lines (35 loc) · 1.07 KB
/
tunableNumber.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.team841.offseason2023.util;
import com.team841.offseason2023.Constants.Constants;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
public class tunableNumber {
public static final String tabKey = "Tunable Numbers";
private final String key;
private double defaultValue;
private double oldValue = defaultValue;
public tunableNumber(String DashboardKey) {
this.key = tabKey + "/" + DashboardKey;
}
public tunableNumber(String DashboardKey, double defaultValue) {
this(DashboardKey);
setDefault(defaultValue);
}
public void setDefault(double defaultValue) {
this.defaultValue = defaultValue;
if (Constants.inTune) {
SmartDashboard.putNumber(key, defaultValue);
} else {
SmartDashboard.clearPersistent(key);
}
}
public double get() {
return 0; // C.inTune ? SmartDashboard.getNumber(key, defaultValue) : defaultValue;
}
public boolean hasChanged() {
double currentValue = get();
if (currentValue != oldValue) {
oldValue = currentValue;
return true;
}
return false;
}
}