Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

placing a small image somewhere on the screen #6

Open
404invalid-user opened this issue Sep 11, 2022 · 7 comments
Open

placing a small image somewhere on the screen #6

404invalid-user opened this issue Sep 11, 2022 · 7 comments

Comments

@404invalid-user
Copy link

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

@boochow
Copy link
Owner

boochow commented Sep 13, 2022

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

@synth-04
Copy link

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

@ahenyao
Copy link

ahenyao commented Jun 23, 2023

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?

@ahenyao
Copy link

ahenyao commented Jul 7, 2023

@boochow

@boochow
Copy link
Owner

boochow commented Jul 8, 2023

@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))

@ahenyao
Copy link

ahenyao commented Jul 8, 2023

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

@StuMunsonMcGee
Copy link

Thanks for the driver and support! However, I'm confused by your answer on Jul 7, 2023 to tANDyeet. I don't see in your code where the icon images are loaded and how they are changed as you loop through the 9 images. Can you clarify? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants