Fix reading color from buffer

This commit is contained in:
Ollo 2021-03-20 16:19:28 +01:00
parent e924b638f1
commit 93504e3d96
2 changed files with 8 additions and 3 deletions

View File

@ -196,11 +196,11 @@ public class ESP8266Ws2812 extends TwoArgFunction {
}
}
private class bufferRead extends OneArgFunction {
private class bufferRead extends VarArgFunction {
@Override
public LuaValue call(LuaValue arg) {
final int offset = arg.toint();
public Varargs invoke(Varargs varargs) {
final int offset = varargs.arg(2).toint();
if (ESP8266Ws2812.layout != null) {
Element e = ESP8266Ws2812.layout.getLED(offset - 1);

View File

@ -331,6 +331,11 @@ public class WS2812Layout extends JFrame {
if (i % 2 == 1) {
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)) {
return mElements[i][j];
} else {