-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainClass.java
69 lines (58 loc) · 2.32 KB
/
mainClass.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package nxtblindes;
import nxtblindes.blinde;
import nxtblindes.window;
// import nxtblindes.BluetoothCom;
import lejos.nxt.Button;
import lejos.nxt.Motor;
import lejos.nxt.SensorPort;
import java.lang.Thread;
public class mainClass {
private static blinde blinde1;
private static blinde blinde2;
private static blinde blinde3;
private static window w;
private static Thread wThread;
// private static BluetoothCom com;
/** The angle to move the blindes 100% down */
private static final int maxAngle = 3600;
public static void init() {
// TODO
// init the three blindes
System.out.println("Assuming all blindes are up now.");
blinde1 = new blinde(lejos.nxt.Motor.A, maxAngle);
// blinde2 = new blinde(lejos.nxt.Motor.B, maxAngle);
// blinde3 = new blinde(lejos.nxt.Motor.C, maxAngle);
// connect the blindes to the buttons LEFT and RIGHT
lejos.nxt.Button.LEFT.addButtonListener(blinde1);
// lejos.nxt.Button.LEFT.addButtonListener(blinde2);
// lejos.nxt.Button.LEFT.addButtonListener(blinde3);
lejos.nxt.Button.RIGHT.addButtonListener(blinde1);
// lejos.nxt.Button.RIGHT.addButtonListener(blinde2);
// lejos.nxt.Button.RIGHT.addButtonListener(blinde3);
lejos.nxt.Button.ENTER.addButtonListener(blinde1);
// lejos.nxt.Button.ENTER.addButtonListener(blinde2);
// lejos.nxt.Button.ENTER.addButtonListener(blinde3);
// init the window
w = new window(SensorPort.S1);
// start checking the window state;
wThread = new Thread(w);
wThread.start();
// enable bluetooth communication
// com = new BluetoothCom();
}
public static void main(String[] args) {
// TODO
System.out.println("Initializing ...");
init();
System.out.println("Initialized!");
Button.ESCAPE.waitForPress();
w.stopWatching = true;
}
public static void printStatus() {
System.out.println("Window is " + (w.isOpen() ? "open" : "closed"));
System.out.println("Blinde 1: " + blinde1.getPosition() + "%");
System.out.println("Blinde 2: " + blinde2.getPosition() + "%");
System.out.println("Blinde 3: " + blinde3.getPosition() + "%");
System.out.println("");
}
}