Skip to content
Snippets Groups Projects
Commit bc541c0c authored by Christoph Heinen's avatar Christoph Heinen
Browse files

use arrays of displays as one multiline display

parent bd24563b
No related branches found
No related tags found
No related merge requests found
...@@ -442,15 +442,16 @@ F.typeset_arrivals = function(arrivals, screen_width) ...@@ -442,15 +442,16 @@ F.typeset_arrivals = function(arrivals, screen_width)
local screen_lines = {} local screen_lines = {}
for platform, lines in pairs(arrivals.by_platform) do for platform, lines in pairs(arrivals.by_platform) do
local start = platform .. ": " local start = platform .. ": "
local new_lines = {}
for i, line in ipairs(lines) do for i, line in ipairs(lines) do
lines[i] = "[" .. line .. "]" new_lines[i] = "[" .. line .. "]"
end end
local lines = table.concat(lines, ", ") new_lines = table.concat(new_lines, ", ")
if #start + #lines <= screen_width then if #start + #new_lines <= screen_width then
table.insert(screen_lines, start .. F.util.pad_left(lines, screen_width - #start - #lines, pad_char)) table.insert(screen_lines, start .. F.util.pad_left(new_lines, screen_width - #start - #new_lines, pad_char))
else else
table.insert(screen_lines, F.util.pad_right(start, screen_width - #start, pad_char)) table.insert(screen_lines, F.util.pad_right(start, screen_width - #start, pad_char))
table.insert(screen_lines, F.util.pad_left(lines, screen_width - #lines, pad_char)) table.insert(screen_lines, F.util.pad_left(new_lines, screen_width - #new_lines, pad_char))
end end
end end
if #screen_lines < 1 then if #screen_lines < 1 then
...@@ -461,7 +462,7 @@ F.typeset_arrivals = function(arrivals, screen_width) ...@@ -461,7 +462,7 @@ F.typeset_arrivals = function(arrivals, screen_width)
end end
-- display a nice table over multiple screens -- display a nice table over multiple screens
F.display_arrivals = function(arrivals, lcds,screen_width,screen_heigth) F.display_arrivals = function(arrivals, lcds,screen_width,screen_height)
if S.deactivated then if S.deactivated then
return return
end end
...@@ -473,6 +474,67 @@ F.display_arrivals = function(arrivals, lcds,screen_width,screen_heigth) ...@@ -473,6 +474,67 @@ F.display_arrivals = function(arrivals, lcds,screen_width,screen_heigth)
for i, lcd in ipairs(lcds) do for i, lcd in ipairs(lcds) do
if type(lcd) == "table" then if type(lcd) == "table" then
local multi_screen_width = #lcd[1] * (screen_width-1)
local multi_screen_lines = F.typeset_arrivals(arrivals, multi_screen_width)
local display_line = 1
local lcd_strings = {}
for i,line in ipairs(multi_screen_lines) do
display_line = (i-1)%screen_height+1
--print("displayline " .. display_line)
for j,lcd_name in ipairs(lcd[display_line]) do
lcd_strings[lcd_name] = (lcd_strings[lcd_name] or "") .. string.sub(line,(j-1)*screen_width+1,j*screen_width-1) .. line_break
end
end
--[[for lcd_name,string in pairs(lcd_strings) do
print(lcd_name .. ' ' .. string)
digiline_send(lcd_name, string)
end ]]
for i,lcda in ipairs(lcd) do
for j,lcdb in ipairs(lcda) do
--print(lcdb .. ' ' .. (lcd_strings[lcdb] or "nil"))
digiline_send(lcdb,lcd_strings[lcdb] or line_break)
end
end
--[[local multi_screen_width = #lcd[1] * screen_width-1
--print("multi_screen_width="..multi_screen_width)
--print('number of screens horizontal: ' .. #lcd[1])
local multi_screen_lines = F.typeset_arrivals(arrivals, multi_screen_width)
--print(F.util.pretty(multi_screen_lines))
for i,lcd1 in ipairs(lcd) do
counter = 1
for j,lcd2 in ipairs(lcd1) do
local string = ""
local break_after = false
for k=counter,#multi_screen_lines do
string = string .. string.sub(multi_screen_lines[k],(j-1)*screen_width+1,j*screen_width-1) .. line_break
if k - counter == screen_height then
counter = k
break_after = true
break
end
end
--print( lcd2 .. ' ' .. string )
digiline_send(lcd2, string)
if break_after then
break
end
end
return ]]
else else
digiline_send(lcd, table.concat(screen_lines, line_break)) digiline_send(lcd, table.concat(screen_lines, line_break))
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment