diff options
author | Christopher Baines <cbaines8@gmail.com> | 2011-09-08 07:32:05 +0100 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2011-09-08 07:32:05 +0100 |
commit | c7d181a016ab908e47e8994bb62003f8aa61bbfd (patch) | |
tree | 5b025a6355ed6edf96444847bb650dbd98215f75 /PunchingBag/src/PunchingBag.java | |
parent | 15fa1dd190d8e211a790372156bf4d76c569c3a6 (diff) | |
download | punchingbag-c7d181a016ab908e47e8994bb62003f8aa61bbfd.tar punchingbag-c7d181a016ab908e47e8994bb62003f8aa61bbfd.tar.gz |
Added clear button to the LEDControlPanel. TODO for Adam, make the ripple effect start square around the button, then expand,
instead of expanding from a single point to the top left.
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(); |