From a00d7b418f88c1ff453f3477b278e25044fb61ed Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 21 Nov 2018 18:42:06 -0500 Subject: [PATCH] display: Add a get_dimensions() method to lcd chip classes Signed-off-by: Kevin O'Connor --- klippy/extras/display/hd44780.py | 2 ++ klippy/extras/display/menu.py | 6 +----- klippy/extras/display/st7920.py | 2 ++ klippy/extras/display/uc1701.py | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/klippy/extras/display/hd44780.py b/klippy/extras/display/hd44780.py index 3944ef42..20a58f40 100644 --- a/klippy/extras/display/hd44780.py +++ b/klippy/extras/display/hd44780.py @@ -105,6 +105,8 @@ class HD44780: return 0 def clear(self): self.text_framebuffer[:] = ' '*80 + def get_dimensions(self): + return (20, 4) HD44780_chars = [ # Extruder (a thermometer) diff --git a/klippy/extras/display/menu.py b/klippy/extras/display/menu.py index a930f073..de131b81 100644 --- a/klippy/extras/display/menu.py +++ b/klippy/extras/display/menu.py @@ -882,8 +882,6 @@ menu_items = { 'deck': MenuDeck, 'card': MenuCard } -# Default dimensions for lcds (rows, cols) -LCD_dims = {'st7920': (4, 16), 'hd44780': (4, 20), 'uc1701': (4, 16)} MENU_UPDATE_DELAY = .100 TIMER_DELAY = .200 @@ -912,9 +910,7 @@ class MenuManager: self.objs = {} self.root = None self._root = config.get('menu_root', '__main') - dims = config.getchoice('lcd_type', LCD_dims) - self.rows = config.getint('rows', dims[0]) - self.cols = config.getint('cols', dims[1]) + self.cols, self.rows = lcd_chip.get_dimensions() self.timeout = config.getint('menu_timeout', 0) self.timer = 0 # buttons diff --git a/klippy/extras/display/st7920.py b/klippy/extras/display/st7920.py index 1c725ab5..94dd6c69 100644 --- a/klippy/extras/display/st7920.py +++ b/klippy/extras/display/st7920.py @@ -164,3 +164,5 @@ class ST7920: zeros = bytearray(32) for gfb in self.graphics_framebuffers: gfb[:] = zeros + def get_dimensions(self): + return (16, 4) diff --git a/klippy/extras/display/uc1701.py b/klippy/extras/display/uc1701.py index a9d90fb1..ba564395 100644 --- a/klippy/extras/display/uc1701.py +++ b/klippy/extras/display/uc1701.py @@ -156,3 +156,5 @@ class UC1701: zeros = bytearray(128) for page in self.vram[self.CURRENT_BUF]: page[:] = zeros + def get_dimensions(self): + return (16, 4)