Output on panel added while starting
This commit is contained in:
parent
54a3761cee
commit
48b7751092
11
main.lua
11
main.lua
@ -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)
|
||||
|
@ -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() );
|
||||
}
|
||||
|
||||
System.err.println("[WS2812] set with " + varargs.narg() + " arguments at index="+ index + " and "+ length + " charactes not matching");
|
||||
return LuaValue.NIL;
|
||||
}
|
||||
|
||||
return LuaValue.valueOf(true);
|
||||
} else {
|
||||
System.err.println("[WS2812] set with " + varargs.narg() + " arguments undefined.");
|
||||
return LuaValue.NIL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user