From 6f7b4b111e4de43e5ef98956e72f1c407cf66eb6 Mon Sep 17 00:00:00 2001 From: Ollo Date: Thu, 18 Mar 2021 21:58:59 +0100 Subject: [PATCH] next step: one argument, started --- .../src/de/c3ma/ollo/mockup/ESP8266Ws2812.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java b/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java index 109e8ce..d739b3d 100644 --- a/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java +++ b/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java @@ -122,6 +122,18 @@ public class ESP8266Ws2812 extends TwoArgFunction { } 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."); return LuaValue.NIL;