]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_display.py
only convert command to bytes
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _display.py
index 5ed157b53bb8a3e9c42be46a38c99f9c4789480a..e0c4026689c4739c33b251e37692479f4f015b74 100644 (file)
@@ -183,7 +183,7 @@ class Display:
         self._bus._begin_transaction()
         if self._data_as_commands:
             self._bus._send(
-                DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, bytes([command] + data)
+                DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, bytes([command]) + data
             )
         else:
             self._bus._send(
@@ -298,14 +298,10 @@ class Display:
         else:
             width, height = self._width, self._height
 
-        if rectangle.x1 < 0:
-            rectangle.x1 = 0
-        if rectangle.y1 < 0:
-            rectangle.y1 = 0
-        if rectangle.x2 > width:
-            rectangle.x2 = width
-        if rectangle.y2 > height:
-            rectangle.y2 = height
+        rectangle.x1 = max(rectangle.x1, 0)
+        rectangle.y1 = max(rectangle.y1, 0)
+        rectangle.x2 = min(rectangle.x2, width)
+        rectangle.y2 = min(rectangle.y2, height)
 
         return rectangle