Skip to content

Commit 4348039

Browse files
author
funnygeeker
committed
update
1 parent 00506c5 commit 4348039

9 files changed

+22
-20
lines changed

drivers/st7735_buf.mpy

15 Bytes
Binary file not shown.

drivers/st7735_buf.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def _encode_pixel(c):
6767

6868
ROTATIONS = [0x00, 0x60, 0xC0, 0xA0] # 旋转方向
6969

70-
7170
BLACK = const(0x0000)
7271
BLUE = const(0x001F)
7372
RED = const(0xF800)
@@ -280,9 +279,10 @@ def set_window(self, x0, y0, x1, y1):
280279
x1 (int): column end address
281280
y1 (int): row end address
282281
"""
283-
self._set_columns(x0, x1)
284-
self._set_rows(y0, y1)
285-
self._write(RAMWR)
282+
if x0 < self.width and y0 < self.height:
283+
self._set_columns(x0, x1)
284+
self._set_rows(y0, y1)
285+
self._write(RAMWR)
286286

287287
def clear(self):
288288
"""

drivers/st7735_spi.mpy

15 Bytes
Binary file not shown.

drivers/st7735_spi.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def _encode_pixel(c):
6666

6767
ROTATIONS = [0x00, 0x60, 0xC0, 0xA0] # 旋转方向
6868

69-
7069
BLACK = const(0x0000)
7170
BLUE = const(0x001F)
7271
RED = const(0xF800)
@@ -277,9 +276,10 @@ def set_window(self, x0, y0, x1, y1):
277276
x1 (int): column end address
278277
y1 (int): row end address
279278
"""
280-
self._set_columns(x0, x1)
281-
self._set_rows(y0, y1)
282-
self._write(RAMWR)
279+
if x0 < self.width and y0 < self.height:
280+
self._set_columns(x0, x1)
281+
self._set_rows(y0, y1)
282+
self._write(RAMWR)
283283

284284
def clear(self):
285285
"""

drivers/st7789_buf.mpy

15 Bytes
Binary file not shown.

drivers/st7789_buf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,10 @@ def set_window(self, x0, y0, x1, y1):
353353
x1 (int): column end address
354354
y1 (int): row end address
355355
"""
356-
self._set_columns(x0, x1)
357-
self._set_rows(y0, y1)
358-
self._write(ST7789_RAMWR)
356+
if x0 < self.width and y0 < self.height:
357+
self._set_columns(x0, x1)
358+
self._set_rows(y0, y1)
359+
self._write(ST7789_RAMWR)
359360

360361
def clear(self):
361362
"""

drivers/st7789_spi.mpy

15 Bytes
Binary file not shown.

drivers/st7789_spi.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,10 @@ def set_window(self, x0, y0, x1, y1):
348348
x1 (int): column end address
349349
y1 (int): row end address
350350
"""
351-
self._set_columns(x0, x1)
352-
self._set_rows(y0, y1)
353-
self._write(ST7789_RAMWR)
351+
if x0 < self.width and y0 < self.height:
352+
self._set_columns(x0, x1)
353+
self._set_rows(y0, y1)
354+
self._write(ST7789_RAMWR)
354355

355356
def clear(self):
356357
"""

libs/easydisplay.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def text(self, s: str, x: int, y: int,
377377
FrameBuffer(data, font_size, font_size,
378378
RGB565), x, y, key)
379379
else:
380-
dp.set_window(x, y, x + font_size - 1, y + font_size + 1)
380+
dp.set_window(x, y, x + font_size - 1, y + font_size)
381381
dp.write_data(data)
382382
else:
383383
data = self._RGB565_font_size(byte_data, font_size, palette, self._size)
@@ -386,7 +386,7 @@ def text(self, s: str, x: int, y: int,
386386
FrameBuffer(data,
387387
font_size, font_size, RGB565), x, y, key)
388388
else:
389-
dp.set_window(x, y, x + font_size - 1, y + font_size + 1)
389+
dp.set_window(x, y, x + font_size - 1, y + font_size)
390390
dp.write_data(data)
391391
# 英文字符半格显示
392392
if ord(char) < 128 and half_char:
@@ -450,7 +450,7 @@ def pbm(self, file: str, x, y, key: int = -1, show: bool = None, clear: bool = N
450450
if reversion: # New
451451
color, bg_color = bg_color, color
452452
palette = self._calculate_palette(color, bg_color) # 计算调色板
453-
dp.set_window(x, y, x + _width - 1, y + _height + 1) # 设置窗口
453+
dp.set_window(x, y, x + _width - 1, y + _height) # 设置窗口
454454
data = f_read(buffer_size)
455455
write_data = dp.write_data
456456
while data:
@@ -522,7 +522,7 @@ def pbm(self, file: str, x, y, key: int = -1, show: bool = None, clear: bool = N
522522
except AttributeError:
523523
pass
524524
else: # 直接驱动
525-
dp.set_window(x, y, x + _width - 1, y + _height + 1) # 设置窗口
525+
dp.set_window(x, y, x + _width - 1, y + _height) # 设置窗口
526526
buffer = bytearray(_width * 2)
527527
for _y in r_height: # 逐行显示图片
528528
for _x in r_width:
@@ -622,7 +622,7 @@ def bmp(self, file: str, x, y, key: int = -1, show: bool = None, clear: bool = N
622622
buffer = bytearray(_width * 2)
623623
self_buf = self._buffer
624624
if not self_buf:
625-
dp.set_window(x, y, x + _width - 1, y + _height + 1) # 设置窗口
625+
dp.set_window(x, y, x + _width - 1, y + _height) # 设置窗口
626626
r_width = range(_width)
627627
r_height = range(_height)
628628
for _y in r_height:
@@ -716,7 +716,7 @@ def dat(self, file, x, y, key=-1):
716716
size = self.BUFFER_SIZE * 10
717717
data = f_read(size)
718718
dp_write = self.display.write_data
719-
self.display.set_window(x, y, x + _width - 1, y + _height + 1)
719+
self.display.set_window(x, y, x + _width - 1, y + _height)
720720
while data:
721721
dp_write(data)
722722
data = f_read(size)

0 commit comments

Comments
 (0)