Skip to content

Commit 2935fb0

Browse files
committed
更新:性能优化,文字背景透明功能
1 parent ea11cfe commit 2935fb0

File tree

2 files changed

+94
-121
lines changed

2 files changed

+94
-121
lines changed

drivers/st7735.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ def show(self):
142142
self._write(RAMWR, self.buffer)
143143

144144
@staticmethod
145-
def rgb(r, g, b):
146-
# return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3)
147-
# return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)
148-
c = (((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3)).to_bytes(2, "little")
149-
return (c[0] << 8) + c[1]
145+
def rgb(r, g, b): # 感谢 ChatGPT 对代码的性能优化,性能提升 30%
146+
c = ((b & 0xF8) << 8) | ((g & 0xFC) << 3) | (r >> 3)
147+
return (c >> 8) | ((c & 0xFF) << 8)

0 commit comments

Comments
 (0)