display: Add a get_dimensions() method to lcd chip classes

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-11-21 18:42:06 -05:00
parent cbbc6801a0
commit a00d7b418f
4 changed files with 7 additions and 5 deletions

View File

@ -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)

View File

@ -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

View File

@ -164,3 +164,5 @@ class ST7920:
zeros = bytearray(32)
for gfb in self.graphics_framebuffers:
gfb[:] = zeros
def get_dimensions(self):
return (16, 4)

View File

@ -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)