aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Arduino/LEDMatrix/LEDMatrix.pde50
-rw-r--r--PunchingBag/src/PunchingBag.java64
2 files changed, 82 insertions, 32 deletions
diff --git a/Arduino/LEDMatrix/LEDMatrix.pde b/Arduino/LEDMatrix/LEDMatrix.pde
index 0d3994b..18a00ae 100644
--- a/Arduino/LEDMatrix/LEDMatrix.pde
+++ b/Arduino/LEDMatrix/LEDMatrix.pde
@@ -9,26 +9,56 @@ const byte CsnPin = 2 ; // Chip select (Low active)
const byte ClkPin = 3 ; // Serial Clockq
const byte DataPin = 4 ; // Serial Data
-byte buffer [ 8 ] ; // Screen buffer (No. of modules * 8)
+const int chips = 6;
+
+byte buffer [ chips * 8 ] ; // Screen buffer (No. of modules * 8)
AS1107 matrix ( CsnPin, ClkPin, DataPin ) ;
const byte d = 0 ;
int count= 1 ;
void setup ( )
{
- matrix. Init ( buffer, 7, 7, 0 ) ;
+ matrix. Init ( buffer, (chips*8)-1, 7, chips -1 ) ;
+ Serial.begin(9600);
}
void loop ( )
{
- for (int x=0; x<8; x++) {
- for (int y=0; y<8; y++) {
- matrix.SetLed(x,y,1);
- matrix.Update();
- delay(1000);
- matrix.SetLed(x,y,0);
- matrix.Update();
- delay(1000);
+ int timer = 0;
+
+ if (Serial.read() == ((byte)108)) {
+ Serial.println("L Recieved");
+ while (Serial.peek() == -1) {
+ }
+ if (Serial.read() == ((byte)101)) {
+ while (Serial.peek() == -1) {
+ }
+ Serial.println("E recieved");
+ for (int i = 0; i < (chips*8); i++) {
+ while (Serial.peek() == -1) {
+ }
+ buffer[i] = Serial.read();
+
+ Serial.println(buffer[i]);
+
+ }
+ Serial.println("Buffer Recieved");
+
+
}
+
+
+
+
}
+ matrix.Update();
}
+
+
+
+
+
+
+
+
+
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();