Skip to content

Instantly share code, notes, and snippets.

@Gadgetoid
Last active June 2, 2023 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gadgetoid/0b8e352e377135d743338c9483178c01 to your computer and use it in GitHub Desktop.
Save Gadgetoid/0b8e352e377135d743338c9483178c01 to your computer and use it in GitHub Desktop.
Display a 4K jpeg from the microSD card
import os
import machine
import jpegdec
import sdcard
from picographics import PicoGraphics, DISPLAY_INKY_FRAME_7 as DISPLAY
# Initialise PicoGraphics
graphics = PicoGraphics(DISPLAY)
# Mount the SD card
sd_spi = machine.SPI(0, sck=machine.Pin(18, machine.Pin.OUT), mosi=machine.Pin(19, machine.Pin.OUT), miso=machine.Pin(16, machine.Pin.OUT))
sd = sdcard.SDCard(sd_spi, machine.Pin(22))
os.mount(sd, "/sd")
# Render the JPEG
jpeg = jpegdec.JPEG(graphics)
jpeg.open_file("/sd/placekitten-3840-2160.jpg")
jpeg.decode(dither=True, scale=jpegdec.JPEG_SCALE_QUARTER)
# Update the display
graphics.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment