Dolda2000 GitWeb
/
kaka
/
cakelight.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f722ee0
)
Refactored the LED frames backing data
author
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sun, 23 Apr 2017 15:07:41 +0000
(17:07 +0200)
committer
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sun, 23 Apr 2017 15:07:41 +0000
(17:07 +0200)
config.properties
patch
|
blob
|
blame
|
history
src/kaka/cakelight/Configuration.java
patch
|
blob
|
blame
|
history
src/kaka/cakelight/GuiTest.java
patch
|
blob
|
blame
|
history
src/kaka/cakelight/LedFrame.java
patch
|
blob
|
blame
|
history
diff --git
a/config.properties
b/config.properties
index
2e2934d
..
4fec08b
100644
(file)
--- a/
config.properties
+++ b/
config.properties
@@
-13,4
+13,4
@@
video.crop.top=18
video.crop.bottom=18
leds.cols=32
video.crop.bottom=18
leds.cols=32
-leds.rows=1
8
+leds.rows=1
7
diff --git
a/src/kaka/cakelight/Configuration.java
b/src/kaka/cakelight/Configuration.java
index
94c5ddd
..
d91bfb6
100644
(file)
--- a/
src/kaka/cakelight/Configuration.java
+++ b/
src/kaka/cakelight/Configuration.java
@@
-101,5
+101,9
@@
public class Configuration {
cols = Integer.parseInt(get(prop, "leds.cols"));
rows = Integer.parseInt(get(prop, "leds.rows"));
}
cols = Integer.parseInt(get(prop, "leds.cols"));
rows = Integer.parseInt(get(prop, "leds.rows"));
}
+
+ public int getCount() {
+ return cols * 2 + rows * 2;
+ }
}
}
}
}
diff --git
a/src/kaka/cakelight/GuiTest.java
b/src/kaka/cakelight/GuiTest.java
index
5aaba2f
..
c72519a
100644
(file)
--- a/
src/kaka/cakelight/GuiTest.java
+++ b/
src/kaka/cakelight/GuiTest.java
@@
-83,15
+83,19
@@
public class GuiTest extends Application {
float rowSize = 9f * BLOCK / config.leds.rows;
// DropShadow shadow = new DropShadow(BlurType.ONE_PASS_BOX, Color.RED, colSize * 2, colSize, 0, 0);
for (int x = 0; x < config.leds.cols; x++) {
float rowSize = 9f * BLOCK / config.leds.rows;
// DropShadow shadow = new DropShadow(BlurType.ONE_PASS_BOX, Color.RED, colSize * 2, colSize, 0, 0);
for (int x = 0; x < config.leds.cols; x++) {
- gc.setFill(getLedColor(frame, x + config.leds.rows));
+ // Top
+ gc.setFill(getLedColor(frame, config.leds.cols * 2 + config.leds.rows - x - 1));
gc.fillRect(GUTTER + x * colSize, GUTTER - ledLength, colSize, ledLength);
gc.fillRect(GUTTER + x * colSize, GUTTER - ledLength, colSize, ledLength);
- gc.setFill(getLedColor(frame, config.leds.rows * 2 + config.leds.cols * 2 - 1 - x));
+ // Bottom
+ gc.setFill(getLedColor(frame, x));
gc.fillRect(GUTTER + x * colSize, GUTTER + 9 * BLOCK, colSize, ledLength);
}
for (int y = 0; y < config.leds.rows; y++) {
gc.fillRect(GUTTER + x * colSize, GUTTER + 9 * BLOCK, colSize, ledLength);
}
for (int y = 0; y < config.leds.rows; y++) {
- gc.setFill(getLedColor(frame, config.leds.rows - 1 - y));
+ // Left
+ gc.setFill(getLedColor(frame, config.leds.cols * 2 + config.leds.rows + y));
gc.fillRect(GUTTER - ledLength, GUTTER + y * rowSize, ledLength, rowSize);
gc.fillRect(GUTTER - ledLength, GUTTER + y * rowSize, ledLength, rowSize);
- gc.setFill(getLedColor(frame, y + config.leds.rows + config.leds.cols));
+ // Right
+ gc.setFill(getLedColor(frame, config.leds.rows + config.leds.cols - y - 1));
gc.fillRect(GUTTER + 16 * BLOCK, GUTTER + y * rowSize, ledLength, rowSize);
}
}
gc.fillRect(GUTTER + 16 * BLOCK, GUTTER + y * rowSize, ledLength, rowSize);
}
}
diff --git
a/src/kaka/cakelight/LedFrame.java
b/src/kaka/cakelight/LedFrame.java
index
f739e38
..
4d6b68a
100644
(file)
--- a/
src/kaka/cakelight/LedFrame.java
+++ b/
src/kaka/cakelight/LedFrame.java
@@
-1,19
+1,44
@@
package kaka.cakelight;
public class LedFrame {
package kaka.cakelight;
public class LedFrame {
- private Color[] leds;
+ private byte[] bytes;
+ private int roff = 0, goff = 2, boff = 1; // Color values are stored as RBG, which is what the LED list takes.
public static LedFrame from(Configuration config) {
LedFrame frame = new LedFrame();
public static LedFrame from(Configuration config) {
LedFrame frame = new LedFrame();
- frame.
leds = new Color[config.leds.cols * 2 + config.leds.rows * 2
];
+ frame.
bytes = new byte[config.leds.getCount() * 3
];
return frame;
}
return frame;
}
+ public void fillColor(int r, int g, int b) {
+ for (int i = 0; i < bytes.length; i += 3) {
+ bytes[i + roff] = (byte)r;
+ bytes[i + goff] = (byte)g;
+ bytes[i + boff] = (byte)b;
+ }
+ }
+
+ public void fillColor(Color color) {
+ fillColor(color.r(), color.g(), color.b());
+ }
+
public void setLedColor(int led, Color color) {
public void setLedColor(int led, Color color) {
- leds[led] = color;
+ int offset = led * 3;
+ bytes[offset + roff] = (byte)color.r();
+ bytes[offset + goff] = (byte)color.g();
+ bytes[offset + boff] = (byte)color.b();
}
public Color getLedColor(int led) {
}
public Color getLedColor(int led) {
- return leds[led];
+ int offset = led * 3;
+ return Color.rgb(
+ bytes[offset + roff] & 0xff,
+ bytes[offset + goff] & 0xff,
+ bytes[offset + boff] & 0xff
+ );
+ }
+
+ public byte[] getBytes() {
+ return bytes;
}
}
}
}