Adapted multithreadding
This commit is contained in:
parent
639ce7ea72
commit
db22d50c26
@ -131,12 +131,17 @@ public class ESP8266Ws2812 extends TwoArgFunction {
|
||||
final LuaString color = varargs.arg(2).checkstring();
|
||||
final int length = color.rawlen();
|
||||
if (length == 3) {
|
||||
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 {
|
||||
System.err.println("[WS2812] fill with " + varargs.narg() + " arguments undefined.");
|
||||
@ -153,12 +158,17 @@ public class ESP8266Ws2812 extends TwoArgFunction {
|
||||
final LuaString color = varargs.arg(2).checkstring();
|
||||
final int length = color.rawlen();
|
||||
if (length == 3) {
|
||||
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);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user