aboutsummaryrefslogtreecommitdiff
path: root/PunchingBag/src/PunchingBag.java
diff options
context:
space:
mode:
Diffstat (limited to 'PunchingBag/src/PunchingBag.java')
-rw-r--r--PunchingBag/src/PunchingBag.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java
index d6eca55..bcaf220 100644
--- a/PunchingBag/src/PunchingBag.java
+++ b/PunchingBag/src/PunchingBag.java
@@ -20,6 +20,8 @@ public class PunchingBag implements Runnable {
boolean buttonsChanged = false;
private ArrayList<Effect> runningEffects = new ArrayList<Effect>();
+
+ ButtonArduino buttonArduino = new ButtonArduino();
public enum Colour {
None, Red, Yellow, Green
@@ -32,6 +34,8 @@ public class PunchingBag implements Runnable {
// Is there a better class for this? One that it is not a swing class.
private EventListenerList buttonListenerList = new EventListenerList();
private EventListenerList ledListenerList = new EventListenerList();
+ private EventListenerList accelListenerList = new EventListenerList();
+
public PunchingBag() {
new Thread(this).start();
@@ -50,6 +54,10 @@ public class PunchingBag implements Runnable {
public void addLEDChangeListener(LEDListener l) {
ledListenerList.add(LEDListener.class, l);
}
+
+ public void addLEDChangeListener(AccelListener l) {
+ accelListenerList.add(AccelListener.class, l);
+ }
public Colour getLED(int x, int y) {
return leds[x][y];
@@ -75,7 +83,8 @@ public class PunchingBag implements Runnable {
abstract class Effect {
long lastRefresh = 0;
boolean stop = false;
- int refreshRate = 60; // Times per second to refresh
+
+ // int refreshRate = 60; // Times per second to refresh
public void stop() {
stop = true;
@@ -254,16 +263,16 @@ public class PunchingBag implements Runnable {
public void run() {
while (true) {
synchronized (runningEffects) { // Should prevent
- // ConcurrentModificationException's
- // (havent managed to produce one
- // though
+ // ConcurrentModificationException's
+ // (havent managed to produce one
+ // though
for (Iterator<Effect> iter = runningEffects.iterator(); iter
.hasNext();) {
Effect ef = (Effect) iter.next();
if (ef.stop) {
iter.remove();
- } else if ((ef.lastRefresh + (1000 / ef.refreshRate)) <= System
- .currentTimeMillis()) {
+ } else {// if ((ef.lastRefresh + (1000 / ef.refreshRate)) <=
+ // Systems.currentTimeMillis()) {
ef.draw();
ef.lastRefresh = System.currentTimeMillis();
}