diff options
Diffstat (limited to 'PunchingBag')
-rw-r--r-- | PunchingBag/src/PunchingBag.java | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java index f39e666..00be6e0 100644 --- a/PunchingBag/src/PunchingBag.java +++ b/PunchingBag/src/PunchingBag.java @@ -1,6 +1,9 @@ import javax.swing.event.EventListenerList; +import java.awt.geom.Area; + import java.io.IOException; + import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -20,7 +23,7 @@ public class PunchingBag implements Runnable { boolean buttonsChanged = false; private ArrayList<Effect> runningEffects = new ArrayList<Effect>(); - + Arduino buttonArduino = new Arduino(); Arduino ledArduino = new Arduino(); @@ -28,12 +31,15 @@ public class PunchingBag implements Runnable { None, Red, Yellow, Green }; + public enum Direction { + Right, Left, Up, Down + }; + // 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(); } @@ -51,7 +57,7 @@ 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); } @@ -90,6 +96,26 @@ public class PunchingBag implements Runnable { abstract public void draw(); } + class Text extends Effect { + final String string; + final Area area; + final Direction direction; + final int speed; + + public Text(String string, Area area, Direction direction, int speed) { + this.string = string; + this.area = area; + this.direction = direction; + this.speed = speed; + + } + + public void draw() { + byte[] stringBytes = string.getBytes(); + + } + } + class CircleExpand extends Effect { final int x; final int y; @@ -194,21 +220,15 @@ public class PunchingBag implements Runnable { } } /* - int x = 7; - // TODO: Complete and test, or rethink the following? - for (int startY = 0; startY <= 4; startY++) { - for (int y = 0; y <= 3; y++) { - if (leds[x][startY + (y * 4)] == Colour.Red - || leds[x][startY + (y * 4)] == Colour.Yellow) { - rawLeds[(5 * 8) + startY] = (byte) (rawLeds[(int) Math - .floor(y / 4)] | (1 << (7 - x))); - } - if (leds[x][y] == Colour.Green || leds[x][y] == Colour.Yellow) { - rawLeds[(int) Math.floor(y / 4)] = (byte) (rawLeds[(int) Math - .floor(y / 4)] | (1 << (7 - x))); - } - } - }*/ + * int x = 7; // TODO: Complete and test, or rethink the following? for + * (int startY = 0; startY <= 4; startY++) { for (int y = 0; y <= 3; + * y++) { if (leds[x][startY + (y * 4)] == Colour.Red || leds[x][startY + * + (y * 4)] == Colour.Yellow) { rawLeds[(5 * 8) + startY] = (byte) + * (rawLeds[(int) Math .floor(y / 4)] | (1 << (7 - x))); } if + * (leds[x][y] == Colour.Green || leds[x][y] == Colour.Yellow) { + * rawLeds[(int) Math.floor(y / 4)] = (byte) (rawLeds[(int) Math + * .floor(y / 4)] | (1 << (7 - x))); } } } + */ } /* Clears the led grid and stops all running effects */ @@ -256,15 +276,15 @@ public class PunchingBag implements Runnable { } } } - + try { - ledArduino.write(((byte)108)); - ledArduino.write(((byte)101)); + ledArduino.write(((byte) 108)); + ledArduino.write(((byte) 101)); ledArduino.write(rawLeds); } catch (IOException e1) { e1.printStackTrace(); } - + try { while (true) { int value = ledArduino.read(); |