Skip to content

lcd.getWindowSize

since 1.1.0

Get the window size.

local width = lcd.getWindowSize()

Parameters

None.

Returns

width (integer): window with

Examples

local function paint(widget)
  local w, h = lcd.getWindowSize()   -- size of this widget / tool page / dialog
  lcd.drawRectangle(0, 0, w, h)      -- outline the whole window
  lcd.drawText(w / 2, h / 2, "middle", CENTERED)
end

The same widget can be placed in slots of very different sizes (and radios range from 480×320 to 800×480). Always lay out relative to this size.

Used in

Real-world usage

Called 231 times across 13 open-source Ethos Lua projects. A few short excerpts:
local w, h = lcd.getWindowSize()

src/rfsuite/app/alignment_visual.lua:162

local W, H = lcd.getWindowSize()

src/dashx/widgets/dashboard/lib/utils.lua:572

lcdW, lcdH = lcd.getWindowSize()

src/rfsuite/app/modules/alignment/alignment.lua:559