aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <Adam Martindale@.(none)>2011-09-16 12:34:59 +0100
committerunknown <Adam Martindale@.(none)>2011-09-16 12:34:59 +0100
commite1a7613135ea099deaa82e16a9eba8bd02b83689 (patch)
tree3f6011ad81620173144ef3857e503853bc9f5b0b
parent8721d9014c86909910fbc9031e0c9e7668e49826 (diff)
downloadpunchingbag-e1a7613135ea099deaa82e16a9eba8bd02b83689.tar
punchingbag-e1a7613135ea099deaa82e16a9eba8bd02b83689.tar.gz
Noise will end and not go on forever.
-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;
}
}