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
|
invertRows=true
|
||||||
end
|
end
|
||||||
local c = dw.countChars(words)
|
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
|
end
|
||||||
dw = nil
|
dw = nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print("dw: " .. tostring(node.heap()))
|
print("dw: " .. tostring(node.heap()))
|
||||||
if (ledBuf ~= nil) then
|
if (rgbBuffer ~= nil) then
|
||||||
ws2812.write(ledBuf)
|
ws2812.write(rgbBuffer)
|
||||||
else
|
else
|
||||||
-- set FG to fix value: RED
|
-- set FG to fix value: RED
|
||||||
local color = string.char(255,0,0)
|
local color = string.char(255,0,0)
|
||||||
rgbBuffer:fill(0,0,0) -- disable all LEDs
|
rgbBuffer:fill(0,0,0) -- disable all LEDs
|
||||||
for i=108,110, 1 do rgbBuffer:set(i, color) end
|
for i=108,110, 1 do rgbBuffer:set(i, color) end
|
||||||
ws2812.write(rgbBuffer)
|
ws2812.write(rgbBuffer)
|
||||||
|
print("Fallback no time displayed")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- cleanup
|
-- cleanup
|
||||||
@ -95,6 +96,7 @@ function normalOperation()
|
|||||||
local alive=0
|
local alive=0
|
||||||
mlt:register(2500, tmr.ALARM_AUTO, function (lt)
|
mlt:register(2500, tmr.ALARM_AUTO, function (lt)
|
||||||
if (setupCounter > 4) then
|
if (setupCounter > 4) then
|
||||||
|
rgbBuffer:fill(0,0,0) -- disable all LEDs
|
||||||
syncTimeFromInternet()
|
syncTimeFromInternet()
|
||||||
setupCounter=setupCounter-1
|
setupCounter=setupCounter-1
|
||||||
alive = 1
|
alive = 1
|
||||||
@ -159,6 +161,9 @@ function normalOperation()
|
|||||||
wifitimer=nil
|
wifitimer=nil
|
||||||
connect_counter=nil
|
connect_counter=nil
|
||||||
print('IP: ',wifi.sta.getip(), " heap: ", node.heap())
|
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()
|
mlt:start()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -5,6 +5,7 @@ import java.io.File;
|
|||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import org.luaj.vm2.LuaNil;
|
||||||
import org.luaj.vm2.LuaString;
|
import org.luaj.vm2.LuaString;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
import org.luaj.vm2.LuaValue;
|
||||||
@ -162,10 +163,12 @@ public class ESP8266Ws2812 extends TwoArgFunction {
|
|||||||
private class bufferWrite extends VarArgFunction {
|
private class bufferWrite extends VarArgFunction {
|
||||||
|
|
||||||
public Varargs invoke(Varargs varargs) {
|
public Varargs invoke(Varargs varargs) {
|
||||||
if (varargs.narg() == 2) {
|
if (varargs.narg() == 3) {
|
||||||
final int index = varargs.arg(1).toint();
|
final int index = varargs.arg(2).toint();
|
||||||
final LuaString color = varargs.arg(2).checkstring();
|
|
||||||
final int length = color.rawlen();
|
|
||||||
|
final LuaString color = varargs.arg(3).checkstring();
|
||||||
|
final int length = color.rawlen();
|
||||||
if (length == 3) {
|
if (length == 3) {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -177,10 +180,17 @@ public class ESP8266Ws2812 extends TwoArgFunction {
|
|||||||
ESP8266Ws2812.layout.updateLED(index, r, g, b);
|
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 {
|
} else {
|
||||||
|
System.err.println("[WS2812] set with " + varargs.narg() + " arguments undefined.");
|
||||||
return LuaValue.NIL;
|
return LuaValue.NIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user