Merge pull request #375 from Sniffleupagus/fixRot90

Allow rotation 90 and 270 degrees on screens
This commit is contained in:
Jayofelony
2025-03-21 15:47:00 +01:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@ -319,7 +319,7 @@ class Display(View):
def image(self):
img = None
if self._canvas is not None:
img = self._canvas if self._rotation == 0 else self._canvas.rotate(-self._rotation)
img = self._canvas if self._rotation == 0 else self._canvas.rotate(-self._rotation, expand=True)
return img
def _render_thread(self):
@ -338,7 +338,7 @@ class Display(View):
logging.error("%s" % e)
if self._enabled:
self._canvas = (img if self._rotation == 0 else img.rotate(self._rotation))
self._canvas = (img if self._rotation == 0 else img.rotate(self._rotation, expand=True))
if self._implementation is not None:
self._canvas_next = self._canvas
self._canvas_next_event.set()

View File

@ -49,8 +49,14 @@ class View(object):
self._voice = Voice(lang=config['main']['lang'])
self._implementation = impl
self._layout = impl.layout()
self._width = self._layout['width']
self._height = self._layout['height']
self._rotation = config['ui']['display'].get('rotation',0)
if (self._rotation/90)%2 == 0:
self._width = self._layout['width']
self._height = self._layout['height']
else:
self._width = self._layout['height']
self._height = self._layout['width']
self._state = State(state={
'channel': LabeledValue(color=BLACK, label='CH', value='00', position=self._layout['channel'],
label_font=fonts.Bold,