Fix reading color from buffer
This commit is contained in:
parent
e924b638f1
commit
93504e3d96
@ -196,11 +196,11 @@ public class ESP8266Ws2812 extends TwoArgFunction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class bufferRead extends OneArgFunction {
|
private class bufferRead extends VarArgFunction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public Varargs invoke(Varargs varargs) {
|
||||||
final int offset = arg.toint();
|
final int offset = varargs.arg(2).toint();
|
||||||
if (ESP8266Ws2812.layout != null) {
|
if (ESP8266Ws2812.layout != null) {
|
||||||
|
|
||||||
Element e = ESP8266Ws2812.layout.getLED(offset - 1);
|
Element e = ESP8266Ws2812.layout.getLED(offset - 1);
|
||||||
|
@ -331,6 +331,11 @@ public class WS2812Layout extends JFrame {
|
|||||||
if (i % 2 == 1) {
|
if (i % 2 == 1) {
|
||||||
j = (mColumn-1) - j;
|
j = (mColumn-1) - j;
|
||||||
}
|
}
|
||||||
|
if (i < 0 || j < 0) {
|
||||||
|
System.err.println("LED index" + index + " results in " + i + "x" + j + " coordinate");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ((i < mElements.length) && (j < mElements[i].length) && (mElements[i][j] != null)) {
|
if ((i < mElements.length) && (j < mElements[i].length) && (mElements[i][j] != null)) {
|
||||||
return mElements[i][j];
|
return mElements[i][j];
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user