diff --git a/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java b/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java index 50b55ec..a8f4110 100644 --- a/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java +++ b/simulation/src/de/c3ma/ollo/mockup/ESP8266Ws2812.java @@ -131,11 +131,16 @@ public class ESP8266Ws2812 extends TwoArgFunction { 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); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + 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 { @@ -153,11 +158,16 @@ public class ESP8266Ws2812 extends TwoArgFunction { 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.updateLED(index, r, g, b); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + 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.updateLED(index, r, g, b); + } + }); } return LuaValue.valueOf(true);