Skip to content

Commit 5d4f60e

Browse files
committed
Fix compatibility with Python < 3.11
1 parent d4ded9f commit 5d4f60e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

library/lcd/lcd_comm_rev_d.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def SetBrightness(self, level: int = 25):
109109
# Convert our brightness % to an absolute value.
110110
converted_level = level * 5
111111

112-
level_bytes = bytearray(converted_level.to_bytes(2))
112+
level_bytes = bytearray(converted_level.to_bytes(2, "big"))
113113

114114
# Send the command twice because sometimes it is not applied...
115115
self.SendCommand(cmd=Command.SETBL, payload=level_bytes)
@@ -166,10 +166,11 @@ def DisplayPILImage(
166166
image_width, image_height = image_height, image_width
167167

168168
# Send bitmap size
169-
image_data = bytearray(x0.to_bytes(2))
170-
image_data += bytearray(x1.to_bytes(2))
171-
image_data += bytearray(y0.to_bytes(2))
172-
image_data += bytearray(y1.to_bytes(2))
169+
image_data = bytearray()
170+
image_data += x0.to_bytes(2, "big")
171+
image_data += x1.to_bytes(2, "big")
172+
image_data += y0.to_bytes(2, "big")
173+
image_data += y1.to_bytes(2, "big")
173174
self.SendCommand(cmd=Command.BLOCKWRITE, payload=image_data)
174175

175176
# Prepare bitmap data transmission

0 commit comments

Comments
 (0)