Compare commits
14 Commits
b9f984d573
...
49b2e193de
Author | SHA1 | Date |
---|---|---|
Ryan | 49b2e193de | |
thirdr | 662df5a8b1 | |
thirdr | eb841fbe53 | |
thirdr | 14877b1793 | |
thirdr | 233896ac81 | |
thirdr | badc679c2b | |
thirdr | fc67c0db86 | |
thirdr | 3b56bc1781 | |
thirdr | d74279dbdf | |
thirdr | 4a7f552f8a | |
thirdr | a4e8fda4d8 | |
thirdr | 111e00de64 | |
thirdr | 9cce6a7474 | |
thirdr | dc63b215cd |
|
@ -1,8 +1,11 @@
|
|||
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY, PEN_P8
|
||||
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY_2, PEN_P8
|
||||
import pngdec
|
||||
|
||||
# Create a PicoGraphics instance
|
||||
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_P8, rotate=270)
|
||||
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY_2, pen_type=PEN_P8, rotate=270)
|
||||
|
||||
# Get the display width/height so we can position the PNGs
|
||||
width, height = display.get_bounds()
|
||||
|
||||
# Set the backlight so we can see it!
|
||||
display.set_backlight(1.0)
|
||||
|
@ -33,15 +36,24 @@ for i in range(3):
|
|||
display.set_pen(BG)
|
||||
display.clear()
|
||||
|
||||
|
||||
try:
|
||||
# Open our PNG File from flash. In this example we're using an image of a cartoon pencil.
|
||||
# You can use Thonny to transfer PNG Images to your Pico.
|
||||
png.open_file("pencil_gray.png")
|
||||
|
||||
# Horizontally/vertically center the three PNG Images.
|
||||
png_w = png.get_width()
|
||||
png_h = png.get_height()
|
||||
|
||||
offset_x = (width - png_w * 2) // 2
|
||||
height_y = (height // 3)
|
||||
offset_y = (height_y - png_h * 2) // 2
|
||||
|
||||
# Decode our PNG file and set the X and Y
|
||||
png.decode(35, 10, scale=2, mode=pngdec.PNG_COPY, palette_offset=0)
|
||||
png.decode(35, 90, scale=2, mode=pngdec.PNG_COPY, palette_offset=16)
|
||||
png.decode(35, 170, scale=2, mode=pngdec.PNG_COPY, palette_offset=32)
|
||||
png.decode(offset_x, offset_y, scale=2, mode=pngdec.PNG_COPY, palette_offset=0)
|
||||
png.decode(offset_x, offset_y + height_y, scale=2, mode=pngdec.PNG_COPY, palette_offset=16)
|
||||
png.decode(offset_x, offset_y + (height_y * 2), scale=2, mode=pngdec.PNG_COPY, palette_offset=32)
|
||||
|
||||
# Handle the error if the image doesn't exist on the flash.
|
||||
except OSError:
|
||||
|
|
Loading…
Reference in New Issue