From 941f5f0a60ccf600ea1156a9680d3b45d278eb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Ko=C5=9Bci=C3=B3w?= Date: Mon, 22 May 2017 16:11:08 +0200 Subject: [PATCH] fix getting width and height --- gfxlcd/abstract/chip.py | 11 +++++++++-- gfxlcd/driver/ili9486/ili9486.py | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gfxlcd/abstract/chip.py b/gfxlcd/abstract/chip.py index 03bf3c0..699dd38 100644 --- a/gfxlcd/abstract/chip.py +++ b/gfxlcd/abstract/chip.py @@ -6,6 +6,7 @@ class Chip(metaclass=abc.ABCMeta): """Chip class""" def __init__(self, width, height, driver, auto_flush): self.options = {} + self.rotation = 0 self._width = width self._height = height self.driver = driver @@ -14,12 +15,18 @@ class Chip(metaclass=abc.ABCMeta): @property def width(self): """get width""" - return self._width + if self.rotation == 0 or self.rotation == 180: + return self._width + else: + return self._height @property def height(self): """get height""" - return self._height + if self.rotation == 0 or self.rotation == 180: + return self._height + else: + return self._width @abc.abstractmethod def _converted_background_color(self): diff --git a/gfxlcd/driver/ili9486/ili9486.py b/gfxlcd/driver/ili9486/ili9486.py index c7c3d72..cdcafb6 100644 --- a/gfxlcd/driver/ili9486/ili9486.py +++ b/gfxlcd/driver/ili9486/ili9486.py @@ -11,7 +11,6 @@ class ILI9486(Area, Chip): def __init__(self, width, height, driver): Chip.__init__(self, width, height, driver, True) Area.__init__(self, driver) - self.rotation = 0 def _converted_background_color(self): """color from 8-8-8 to 5-6-5"""