kopia lustrzana https://github.com/pimoroni/pimoroni-pico
correct layout on pico display 1 & 2
rodzic
d790d3d344
commit
b5a040f6cc
|
@ -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
|
import pngdec
|
||||||
|
|
||||||
# Create a PicoGraphics instance
|
# 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!
|
# Set the backlight so we can see it!
|
||||||
display.set_backlight(1.0)
|
display.set_backlight(1.0)
|
||||||
|
@ -33,15 +36,24 @@ for i in range(3):
|
||||||
display.set_pen(BG)
|
display.set_pen(BG)
|
||||||
display.clear()
|
display.clear()
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Open our PNG File from flash. In this example we're using an image of a cartoon pencil.
|
# 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.
|
# You can use Thonny to transfer PNG Images to your Pico.
|
||||||
png.open_file("pencil_gray.png")
|
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
|
# 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(offset_x, offset_y, scale=2, mode=pngdec.PNG_COPY, palette_offset=0)
|
||||||
png.decode(35, 90, scale=2, mode=pngdec.PNG_COPY, palette_offset=16)
|
png.decode(offset_x, offset_y + height_y, 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 + (height_y * 2), scale=2, mode=pngdec.PNG_COPY, palette_offset=32)
|
||||||
|
|
||||||
# Handle the error if the image doesn't exist on the flash.
|
# Handle the error if the image doesn't exist on the flash.
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
Ładowanie…
Reference in New Issue