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:
parent
2df1d2f52d
commit
473b9088d8
9
lcd.lua
9
lcd.lua
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue