diff options
Diffstat (limited to 'PunchingBag/src/PunchingBag.java')
-rw-r--r-- | PunchingBag/src/PunchingBag.java | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java index 7833eaf..7f7b044 100644 --- a/PunchingBag/src/PunchingBag.java +++ b/PunchingBag/src/PunchingBag.java @@ -78,9 +78,9 @@ public class PunchingBag implements Runnable { return false; } } - + public void setLED(int x, int y, Colour colour) { - runningEffects.add(new Point(x,y,colour)); + runningEffects.add(new Point(x, y, colour)); } void circleExpand(int x, int y, int intensity) { @@ -99,21 +99,20 @@ public class PunchingBag implements Runnable { abstract public void draw(); } - + class Point extends Effect { final int x; final int y; final Colour colour; - + public Point(int x, int y, Colour colour) { this.x = x; this.y = y; this.colour = colour; } - public void draw() { - setLEDInternal(x,y,colour); + setLEDInternal(x, y, colour); } } @@ -252,18 +251,24 @@ public class PunchingBag implements Runnable { */ } - /* Clears the led grid and stops all running effects */ + /* Clears the led grid */ private void clearLEDGrid() { - /* - * for (Iterator<Effect> iter = runningEffects.iterator(); - * iter.hasNext();) { ((Effect) iter.next()).stop(); } - */ for (int x = 0; x < ledWidth; x++) { for (int y = 0; y < ledHeight; y++) { leds[x][y] = Colour.None; } } - // Arrays.fill(leds,Colour.None); + } + + private void clearEffects() { + for (Iterator<Effect> iter = runningEffects.iterator(); iter.hasNext();) { + ((Effect) iter.next()).stop(); + } + } + + public void clearLEDs() { + clearLEDGrid(); + clearEffects(); } public void setLEDGridIntensity(byte grid, byte intensity) { @@ -294,7 +299,7 @@ public class PunchingBag implements Runnable { if (ef.stop) { iter.remove(); } else {// if ((ef.lastRefresh + (1000 / - // ef.refreshRate)) <= + // ef.refreshRate)) <= // Systems.currentTimeMillis()) { ef.draw(); ef.lastRefresh = System.currentTimeMillis(); |