Adapted multithreadding

This commit is contained in:
Ollo 2021-03-19 18:45:07 +01:00
parent 639ce7ea72
commit db22d50c26

View File

@ -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);