Calculate the amount of words
This commit is contained in:
parent
cb5205d4af
commit
0038a7997e
3
main.lua
3
main.lua
@ -51,10 +51,11 @@ function displayTime()
|
||||
words = display_timestat(time.hour, time.minute)
|
||||
|
||||
local charactersOfTime = display_countcharacters_de(words)
|
||||
local wordsOfTime = display_countwords_de(words)
|
||||
ledBuf = generateLEDs(words, color, color1, color2, color3, color4,
|
||||
charactersOfTime)
|
||||
|
||||
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " in " .. charactersOfTime .. " chars")
|
||||
print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " in " .. charactersOfTime .. " chars " .. wordsOfTime .. " words")
|
||||
|
||||
-- Write the buffer to the LEDs
|
||||
ws2812.write(ledBuf)
|
||||
|
@ -139,7 +139,7 @@ end
|
||||
-- @fn display_countcharacters_de
|
||||
-- Count the amount of characters, used to describe the current time in words
|
||||
-- @param words the same structure, as generated with the function @see display_timestat
|
||||
-- @return the amount of words, used to describe the time or <code>0</code> on errors
|
||||
-- @return the amount of characters, used to describe the time or <code>0</code> on errors
|
||||
function display_countcharacters_de(words)
|
||||
local amount=0
|
||||
if (words.itis == 1) then
|
||||
@ -214,3 +214,17 @@ function display_countcharacters_de(words)
|
||||
|
||||
return amount
|
||||
end
|
||||
|
||||
-- @fn display_countcharacters_de
|
||||
-- Count the amount of words, used to describe the current time in words
|
||||
-- @param words the same structure, as generated with the function @see display_timestat
|
||||
-- @return the amount of words, used to describe the time or <code>0</code> on errors
|
||||
function display_countwords_de(words)
|
||||
local amount = 0
|
||||
for k,v in pairs(words) do
|
||||
if (v ~= nil and v == 1) then
|
||||
amount = amount + 1
|
||||
end
|
||||
end
|
||||
return amount
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user