next step: one argument, started

This commit is contained in:
Ollo 2021-03-18 21:58:59 +01:00
parent a7bec14521
commit 6f7b4b111e

View File

@ -121,6 +121,18 @@ public class ESP8266Ws2812 extends TwoArgFunction {
ESP8266Ws2812.layout.fillLEDs(red, green, blue);
}
return LuaValue.valueOf(true);
} else if (varargs.isstring(2)) {
//FIXME to be tested
final LuaString color = varargs.arg(2).checkstring();
final int length = color.rawlen();
if (length == 3) {
final byte[] array = color.m_bytes;
int r = array[0]+(Byte.MIN_VALUE*-1);
int b = array[1]+(Byte.MIN_VALUE*-1);
int g = array[2]+(Byte.MIN_VALUE*-1);
ESP8266Ws2812.layout.fillLEDs(r, g, b);
}
return LuaValue.valueOf(true);
} else {
System.err.println("[WS2812] fill with " + varargs.narg() + " arguments undefined.");