Output on panel added while starting

This commit is contained in:
Ollo 2021-03-19 19:55:15 +01:00
parent 54a3761cee
commit 48b7751092
2 changed files with 24 additions and 9 deletions

View File

@ -59,19 +59,20 @@ function displayTime()
invertRows=true
end
local c = dw.countChars(words)
ledBuf = dw.generateLEDs(rgbBuffer, words, colorBg, color, color1, color2, color3, color4, invertRows, c)
dw.generateLEDs(rgbBuffer, words, colorBg, color, color1, color2, color3, color4, invertRows, c)
end
dw = nil
collectgarbage()
print("dw: " .. tostring(node.heap()))
if (ledBuf ~= nil) then
ws2812.write(ledBuf)
if (rgbBuffer ~= nil) then
ws2812.write(rgbBuffer)
else
-- set FG to fix value: RED
local color = string.char(255,0,0)
rgbBuffer:fill(0,0,0) -- disable all LEDs
for i=108,110, 1 do rgbBuffer:set(i, color) end
ws2812.write(rgbBuffer)
print("Fallback no time displayed")
end
-- cleanup
@ -95,6 +96,7 @@ function normalOperation()
local alive=0
mlt:register(2500, tmr.ALARM_AUTO, function (lt)
if (setupCounter > 4) then
rgbBuffer:fill(0,0,0) -- disable all LEDs
syncTimeFromInternet()
setupCounter=setupCounter-1
alive = 1
@ -159,6 +161,9 @@ function normalOperation()
wifitimer=nil
connect_counter=nil
print('IP: ',wifi.sta.getip(), " heap: ", node.heap())
rgbBuffer:fill(0,0,0) -- clear all LEDs
rgbBuffer:set(13, color)
ws2812.write(rgbBuffer)
mlt:start()
end
end)

View File

@ -5,6 +5,7 @@ import java.io.File;
import javax.swing.SwingUtilities;
import org.luaj.vm2.LuaNil;
import org.luaj.vm2.LuaString;
import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue;
@ -162,10 +163,12 @@ public class ESP8266Ws2812 extends TwoArgFunction {
private class bufferWrite extends VarArgFunction {
public Varargs invoke(Varargs varargs) {
if (varargs.narg() == 2) {
final int index = varargs.arg(1).toint();
final LuaString color = varargs.arg(2).checkstring();
final int length = color.rawlen();
if (varargs.narg() == 3) {
final int index = varargs.arg(2).toint();
final LuaString color = varargs.arg(3).checkstring();
final int length = color.rawlen();
if (length == 3) {
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -177,10 +180,17 @@ public class ESP8266Ws2812 extends TwoArgFunction {
ESP8266Ws2812.layout.updateLED(index, r, g, b);
}
});
}
return LuaValue.valueOf(true);
} else {
for(int i=0; i <= varargs.narg(); i++) {
System.err.println("[WS2812] write ["+(i) + "] (" + varargs.arg(i).typename() + ") " + varargs.arg(i).toString() );
}
return LuaValue.valueOf(true);
System.err.println("[WS2812] set with " + varargs.narg() + " arguments at index="+ index + " and "+ length + " charactes not matching");
return LuaValue.NIL;
}
} else {
System.err.println("[WS2812] set with " + varargs.narg() + " arguments undefined.");
return LuaValue.NIL;
}
}