aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java4
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java17
2 files changed, 18 insertions, 3 deletions
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
index 2af7996..eee961c 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java
@@ -104,14 +104,14 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
// Mixer mix = AudioSystem.getMixer(AudioSystem.getMixerInfo()[0]);
try {
- bag.connectToArduinos();
+ // bag.connectToArduinos();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
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 882a32f..7c6c655 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java
@@ -38,6 +38,10 @@ public class SimpleKeyboard implements ButtonListener, Runnable {
static PunchingBag bag = PunchingBag.getBag();
long lastActionTime = System.currentTimeMillis();
+ boolean noising = false;
+
+
+
public static final int DAMPER_PEDAL = 64;
@@ -52,13 +56,15 @@ public class SimpleKeyboard implements ButtonListener, Runnable {
-4, -2, 0, 1, 3, 5, 7 };
public static void main(String[] args) throws InvalidMidiDataException, MidiUnavailableException, IOException {
+
try {
bag.connectToArduinos();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
+
new SimpleKeyboard();
/*int instrument = 0;
@@ -128,10 +134,15 @@ public class SimpleKeyboard implements ButtonListener, Runnable {
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) {
@@ -298,6 +309,9 @@ public class SimpleKeyboard implements ButtonListener, Runnable {
if ((System.currentTimeMillis() - lastActionTime) > 60000) {
System.out.println("Activating Noise");
bag.noise(new Rectangle(0, 0, 9, 20));
+
+ noising = true;
+
} else {
System.out.println("Waiting more");
}
@@ -306,6 +320,7 @@ public class SimpleKeyboard implements ButtonListener, Runnable {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
+
}
}