diff --git a/fafo_green.png b/fafo_green.png new file mode 100644 index 0000000..41ae7ee Binary files /dev/null and b/fafo_green.png differ diff --git a/src/fafogreen.bmp b/src/fafogreen.bmp new file mode 100644 index 0000000..89bfc9f Binary files /dev/null and b/src/fafogreen.bmp differ diff --git a/src/main.py b/src/main.py index 8ed1382..f70a30d 100644 --- a/src/main.py +++ b/src/main.py @@ -2,7 +2,7 @@ # MIT License; Copyright (c) 2017 Jeffrey N. Magee from ili934xnew import ILI9341, color565 from machine import Pin, SPI,Timer -from ST7735 import TFT +from ST7735 import TFT,TFTColor import m5stack import tt14 import glcdfont @@ -44,7 +44,43 @@ def splash(): display.print("Spincoater",size=3,nowrap=True) # #display.show() +def fafo(): + with open('fafogreen.bmp','rb') as f: + if f.read(2) == b'BM': #header + print("BMP@") + dummy = f.read(8) #file size(4), creator bytes(4) + offset = int.from_bytes(f.read(4), 'little') + hdrsize = int.from_bytes(f.read(4), 'little') + width = int.from_bytes(f.read(4), 'little') + height = int.from_bytes(f.read(4), 'little') + print("Image size:", width, "x", height) + if int.from_bytes(f.read(2), 'little') == 1: #planes must be 1 + depth = int.from_bytes(f.read(2), 'little') + print("DEPTH",depth) + if depth == 24 and int.from_bytes(f.read(4), 'little') == 0:#compress method == uncompressed + print("Image size:", width, "x", height) + rowsize = (width * 3 + 3) & ~3 + if height < 0: + height = -height + flip = False + else: + flip = True + w, h = width, height + if w > 128: w = 128 + if h > 160: h = 160 + tft._setwindowloc((0,0),(w - 1,h - 1)) + for row in range(h): + if flip: + pos = offset + (height - 1 - row) * rowsize + else: + pos = offset + row * rowsize + if f.tell() != pos: + dummy = f.seek(pos) + for col in range(w): + bgr = f.read(3) + tft._pushcolor(TFTColor(bgr[2],bgr[1],bgr[0])) + time.sleep(10) def tftprinttest(): tft.fill(TFT.BLACK) v = 30 @@ -373,7 +409,8 @@ with open("config.json", "r") as f: #display.set_font(tt32) tft.fill(TFT.BLACK) -splash() +# splash() +fafo() # for ff in fonts: # display.set_font(ff) # display.print(text)