Display one color after the other
This commit is contained in:
parent
7bc6ec1fbe
commit
91c0a15212
@ -2,8 +2,30 @@
|
|||||||
local M
|
local M
|
||||||
do
|
do
|
||||||
local updateColor = function (data)
|
local updateColor = function (data)
|
||||||
--FIXME magic missing to start on the left side
|
if (data.amountOfChars > 0) then
|
||||||
return data.colorFg
|
local div = tonumber(data.drawnCharacters/data.amountOfChars)
|
||||||
|
if (div < 1) then
|
||||||
|
print(tostring(data.drawnCharacters) .. " blocks: " .. tostring(data.amountOfChars) .. " FG " .. tostring(string.byte(data.colorFg,1)) .. "x" .. tostring(string.byte(data.colorFg,2)) .. "x" .. tostring(string.byte(data.colorFg,3)) )
|
||||||
|
return data.colorFg
|
||||||
|
elseif (div < 2) then
|
||||||
|
print(tostring(data.drawnCharacters) .. " blocks: " .. tostring(data.amountOfChars) .. " C1")
|
||||||
|
return data.colorMin1
|
||||||
|
elseif (div < 3) then
|
||||||
|
print(tostring(data.drawnCharacters) .. " blocks: " .. tostring(data.amountOfChars) .. " C2")
|
||||||
|
return data.colorMin2
|
||||||
|
elseif (div < 4) then
|
||||||
|
print(tostring(data.drawnCharacters) .. " blocks: " .. tostring(data.amountOfChars) .. " C3")
|
||||||
|
return data.colorMin3
|
||||||
|
elseif (div < 5) then
|
||||||
|
print(tostring(data.drawnCharacters) .. " blocks: " .. tostring(data.amountOfChars) .. " C4")
|
||||||
|
return data.colorMin4
|
||||||
|
else
|
||||||
|
print(tostring(data.drawnCharacters) .. " blocks: " .. tostring(data.amountOfChars) .. " ELSE")
|
||||||
|
return data.colorFg
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return data.colorFg
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local drawLEDs = function(data, numberNewChars)
|
local drawLEDs = function(data, numberNewChars)
|
||||||
@ -38,7 +60,7 @@ end
|
|||||||
local data={}
|
local data={}
|
||||||
|
|
||||||
-- Module displaying of the words
|
-- Module displaying of the words
|
||||||
local generateLEDs = function(words, colorForground, colorMin1, colorMin2, colorMin3, colorMin4, invertRows, amountOfChars)
|
local generateLEDs = function(words, colorFg, colorMin1, colorMin2, colorMin3, colorMin4, invertRows, amountOfChars)
|
||||||
-- Set the local variables needed for the colored progress bar
|
-- Set the local variables needed for the colored progress bar
|
||||||
if (words == nil) then
|
if (words == nil) then
|
||||||
return nil
|
return nil
|
||||||
@ -47,7 +69,7 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
|
|||||||
invertRows=false
|
invertRows=false
|
||||||
end
|
end
|
||||||
|
|
||||||
local minutes=0
|
local minutes=1
|
||||||
if (words.min1 == 1) then
|
if (words.min1 == 1) then
|
||||||
minutes = minutes + 1
|
minutes = minutes + 1
|
||||||
elseif (words.min2 == 1) then
|
elseif (words.min2 == 1) then
|
||||||
@ -58,13 +80,12 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
|
|||||||
minutes = minutes + 4
|
minutes = minutes + 4
|
||||||
end
|
end
|
||||||
-- always set a foreground value
|
-- always set a foreground value
|
||||||
local colorFg = string.char(255,255,255)
|
if (colorFg == nil) then
|
||||||
if (colorForground ~= nil) then
|
colorFg = string.char(255,255,255)
|
||||||
colorFg = colorForground
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (amountOfChars ~= nil) then
|
if (amountOfChars ~= nil) then
|
||||||
data.amountOfChars = amountOfChars
|
data.amountOfChars = amountOfChars/minutes
|
||||||
else
|
else
|
||||||
data.amountOfChars = 0
|
data.amountOfChars = 0
|
||||||
end
|
end
|
||||||
|
7
main.lua
7
main.lua
@ -64,8 +64,10 @@ function displayTime()
|
|||||||
invertRows=true
|
invertRows=true
|
||||||
end
|
end
|
||||||
displayword.generateLEDs(words, color, color1, color2, color3, color4, invertRows)
|
displayword.generateLEDs(words, color, color1, color2, color3, color4, invertRows)
|
||||||
ledBuf = displayword.generateLEDs(words, color, color1, color2, color3, color4, invertRows, displayword.data.drawnCharacters)
|
if (displayword.data.drawnCharacters ~= nil) then
|
||||||
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " char: " .. tostring(displayword.data.drawnCharacters))
|
ledBuf = displayword.generateLEDs(words, color, color1, color2, color3, color4, invertRows, displayword.data.drawnCharacters)
|
||||||
|
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " char: " .. tostring(displayword.data.drawnCharacters))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
displayword = nil
|
displayword = nil
|
||||||
if (ledBuf ~= nil) then
|
if (ledBuf ~= nil) then
|
||||||
@ -101,6 +103,7 @@ function normalOperation()
|
|||||||
-- Color is defined as GREEN, RED, BLUE
|
-- Color is defined as GREEN, RED, BLUE
|
||||||
color=string.char(0,0,250)
|
color=string.char(0,0,250)
|
||||||
end
|
end
|
||||||
|
print("Fg Color: " .. tostring(string.byte(color,1)) .. "x" .. tostring(string.byte(color,2)) .. "x" .. tostring(string.byte(color,3)) )
|
||||||
|
|
||||||
connect_counter=0
|
connect_counter=0
|
||||||
-- Wait to be connect to the WiFi access point.
|
-- Wait to be connect to the WiFi access point.
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
green=0
|
green2=200
|
||||||
green2=128
|
|
||||||
red=128
|
red=128
|
||||||
blue=0
|
blue=200
|
||||||
|
|
||||||
color=string.char(0, 0, 128)
|
color=string.char(0, 0, blue)
|
||||||
color1=string.char(128, 0, 0)
|
color1=string.char(red, 0, 0)
|
||||||
color2=string.char(tonumber(green2*0.8), 0, 0)
|
color2=string.char(tonumber(red*0.8), 0, 0)
|
||||||
color3=string.char(tonumber(green2*0.4), 0, 0)
|
color3=string.char(0, tonumber(green2*0.4), 0)
|
||||||
color4=string.char(tonumber(green2*0.2), 0, 0)
|
color4=string.char(0,0 ,tonumber(blue*0.2))
|
||||||
|
|
||||||
colorBg=string.char(0,0,0) -- black is the default background color
|
colorBg=string.char(0,0,0) -- black is the default background color
|
||||||
sntpserverhostname="ptbtime1.ptb.de"
|
sntpserverhostname="ptbtime1.ptb.de"
|
||||||
|
Loading…
Reference in New Issue
Block a user