Skip to content

Commit b6765c5

Browse files
committed
Add draw image
1 parent fc02e2b commit b6765c5

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

ports/esp32/boards/IPST-WiFi/modules/display.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
2828
buffer = bytearray(pages * 128)
29-
framebuf = framebuf.FrameBuffer(buffer, 128, 64, framebuf.MONO_VLSB)
29+
fbuff = framebuf.FrameBuffer(buffer, 128, 64, framebuf.MONO_VLSB)
3030

3131
def write_cmd(cmd):
3232
i2c.writeto(ADDR, bytes([ 0x80, cmd ]))
@@ -59,34 +59,39 @@ def invert(invert):
5959
write_cmd(SET_NORM_INV | (invert & 1))
6060

6161
def fill(c):
62-
framebuf.fill(c)
62+
fbuff.fill(c)
6363

6464
def pixel(x, y, c):
65-
framebuf.pixel(x, y, c)
65+
fbuff.pixel(x, y, c)
6666

6767
def scroll(dx, dy):
68-
framebuf.scroll(dx, dy)
68+
fbuff.scroll(dx, dy)
6969

7070
def text(string, x, y, c=1):
71-
framebuf.text(string, x, y, c)
71+
fbuff.text(string, x, y, c)
7272

7373
def hline(x, y, w, c):
74-
framebuf.hline(x, y, w, c)
74+
fbuff.hline(x, y, w, c)
7575

7676
def vline(x, y, h, c):
77-
framebuf.vline(x, y, h, c)
77+
fbuff.vline(x, y, h, c)
7878

7979
def line(x1, y1, x2, y2, c):
80-
framebuf.line(x1, y1, x2, y2, c)
80+
fbuff.line(x1, y1, x2, y2, c)
8181

8282
def rect(x, y, w, h, c):
83-
framebuf.rect(x, y, w, h, c)
83+
fbuff.rect(x, y, w, h, c)
8484

8585
def fill_rect(x, y, w, h, c):
86-
framebuf.fill_rect(x, y, w, h, c)
86+
fbuff.fill_rect(x, y, w, h, c)
8787

8888
def blit(fbuf, x, y):
89-
framebuf.blit(fbuf, x, y)
89+
fbuff.blit(fbuf, x, y)
90+
91+
def image(imageData, x, y):
92+
buffer = bytearray(imageData[2:])
93+
fbuff.blit(framebuf.FrameBuffer(buffer, int(imageData[0]), int(imageData[1]), framebuf.MONO_HLSB), x, y)
94+
buffer = None
9095

9196
setupCMD = (
9297
SET_DISP | 0x00, # off

0 commit comments

Comments
 (0)