aboutsummaryrefslogtreecommitdiff
path: root/PunchingBag/src
diff options
context:
space:
mode:
Diffstat (limited to 'PunchingBag/src')
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java2
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java18
2 files changed, 14 insertions, 6 deletions
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
index e03c4e6..01c38d4 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
@@ -111,7 +111,7 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
}
frame = new JFrame("Punching Bag GUI");
- frame.setUndecorated(true);
+ //frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// frame.setSize(600, 600);
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java b/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java
index b2d96a5..5a7b8fb 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java
@@ -28,23 +28,30 @@ public class SimpleKeyboard implements ButtonListener, Runnable {
static PunchingBag bag = PunchingBag.getBag();
long lastActionTime = System.currentTimeMillis();
+ boolean noising = false;
public static void main(String[] args) {
- new SimpleKeyboard();
- }
-
- public SimpleKeyboard() {
- bag.addButtonListener(this);
try {
bag.connectToArduinos();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+ new SimpleKeyboard();
+
+ }
+
+ public SimpleKeyboard() {
+ bag.addButtonListener(this);
+
new Thread (this).start();
}
public void buttonPressed(int x, int y) {
+ if (noising = true) {
+ bag.clearLEDs();
+ noising = false;
+ }
lastActionTime = System.currentTimeMillis();
System.out.println("Button Pressed: " + x + " " + y);
if (y < 3) {
@@ -99,6 +106,7 @@ public class SimpleKeyboard implements ButtonListener, Runnable {
while (true) {
if ((System.currentTimeMillis() - lastActionTime) > 4000) {
bag.noise(new Rectangle(0, 0, 9, 20));
+ noising = true;
}
}