MicroPython-ST7735 icon indicating copy to clipboard operation
MicroPython-ST7735 copied to clipboard

placing a small image somewhere on the screen

Open 404invalid-user opened this issue 3 years ago • 6 comments

hello im trying to make a little wether and notifications display but cant figure out how to place a small bmp image say for clouds or the sun i haven noticed there is an image() function but cant get it to work

404invalid-user avatar Sep 11 '22 14:09 404invalid-user

Please refer to tftbmp.py. It is an example of showing a small bitmap file on the screen.

boochow avatar Sep 13 '22 23:09 boochow

Hi! I'm trying to put another bmp file, it's 128x160 px like yours but it seems not working. Can you help me?

synth-04 avatar Jun 11 '23 15:06 synth-04

Please refer to tftbmp.py. It is an example of showing a small bitmap file on the screen.

cool, and it works for me, but I want to show 32x32px app icon on my display and want to make them in 3x3 grid. What do I need to modify in tftbmp.py?

tomekyeet avatar Jun 23 '23 21:06 tomekyeet

@boochow

tomekyeet avatar Jul 07 '23 16:07 tomekyeet

@tANDyeet to draw rectangular images, (1) use _setwindowloc((x0,y0), (x1,y1)) to define the area to be drawn, then (2) call _pushcolor(16-bit int) for the number of pixels in the area to draw each pixel. Example (for RPi pico):

from machine import SPI,Pin
from ST7735 import TFT
spi = SPI(0, baudrate=20000000, polarity=0, phase=0, sck=Pin(2), mosi=Pin(3), miso=Pin(0))
tft=TFT(spi,4,5,1)
tft.initr()
tft.rgb(True)
for x in range(3):
    for y in range(3):
        tft._setwindowloc((x * 32, y * 32), (x * 32 + 31, y * 32 + 31))
        for c in range(1024):
            tft._pushcolor(TFT.color((c >> 5) << 3, (c & 0x1f) << 3, (-c & 0x1f) << 3))

boochow avatar Jul 08 '23 04:07 boochow

Thanks a lot! Now I can resume my project :)

tomekyeet avatar Jul 08 '23 18:07 tomekyeet