fix placement for real this time

we don't use the padding constant for calculations anymore, but to assert the values are set correctly at loadtime
This commit is contained in:
Peter Nerlich 2020-12-07 18:20:31 +01:00
parent 2df1d2f52d
commit 473b9088d8
1 changed files with 7 additions and 2 deletions

View File

@ -30,6 +30,11 @@ local NUMBER_OF_LINES = 5
local LINE_HEIGHT = 14
local CHAR_WIDTH = 5
assert(CHAR_WIDTH * LINE_LENGTH <= LCD_WIDTH - LCD_PADDING*2, "LCD: Lines set too long!")
assert(LINE_HEIGHT * NUMBER_OF_LINES <= LCD_WIDTH - LCD_PADDING*2, "LCD: Too many lines!")
local split = function(s, pat)
-- adapted from https://stackoverflow.com/a/1647577/4067384
-- simplified for our only usecase
@ -139,7 +144,7 @@ local generate_line = function(s, ypos)
i = i + 1
end
if file ~= nil then
width = width + CHAR_WIDTH
width = width + CHAR_WIDTH + 1
table.insert(parsed, file)
chars = chars + 1
end
@ -147,7 +152,7 @@ local generate_line = function(s, ypos)
width = width - 1
local texture = ""
local xpos = math.floor((LCD_WIDTH - 2 * LCD_PADDING - width) / 2)
local xpos = math.floor((LCD_WIDTH - width) / 2)
for ii = 1, #parsed do
texture = texture..":"..xpos..","..ypos.."="..parsed[ii]..".png"
xpos = xpos + CHAR_WIDTH + 1