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