-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLineTracker.java
49 lines (40 loc) · 1 KB
/
LineTracker.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
45
46
47
48
49
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates.subsystems;
import edu.wpi.first.wpilibj.DigitalInput;
/**
*
* @author Sean Halloran
*/
public class LineTracker {
private DigitalInput sensor;
private boolean signal, lastSignal, movingUp;
double barHeight, height;
public LineTracker(int port, double barHeight){
sensor = new DigitalInput(port);
this.barHeight=barHeight;
movingUp=false;
height = 0;
}
public void update(){
lastSignal = signal;
signal = sensor.get();
if(signal!=lastSignal){
if(movingUp)
height+=barHeight;
else
height-=barHeight;
}
}
public void setMovingUp(boolean x){
movingUp = x;
}
public double getHeight(){
return height;
}
public void resetHeight(){
height=0;
}
}