Inky Frame: make image_gallery work with all sizes
This commit is contained in:
parent
a8a8321405
commit
3d597e7d03
|
@ -1,12 +1,17 @@
|
||||||
# An offline image gallery that switches between five jpg images
|
# An offline image gallery that switches between five jpg images
|
||||||
# Copy them into your Pico's flash using Thonny.
|
# Copy them into the root of your Pico's flash using Thonny.
|
||||||
# If you want to use your own images they must be 600 x 448 pixels or smaller
|
|
||||||
# and saved as *non-progressive* jpgs
|
|
||||||
|
|
||||||
from pimoroni import ShiftRegister
|
# If you want to use your own images they must be the screen dimensions (or smaller)
|
||||||
from picographics import PicoGraphics, DISPLAY_INKY_FRAME
|
# and saved as *non-progressive* jpgs.
|
||||||
|
|
||||||
|
# Make sure to uncomment the correct size for your display!
|
||||||
|
|
||||||
|
from picographics import PicoGraphics, DISPLAY_INKY_FRAME as DISPLAY # 5.7"
|
||||||
|
# from picographics import PicoGraphics, DISPLAY_INKY_FRAME_4 as DISPLAY # 4.0"
|
||||||
|
# from picographics import PicoGraphics, DISPLAY_INKY_FRAME_7 as DISPLAY # 7.3"
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
import jpegdec
|
import jpegdec
|
||||||
|
from pimoroni import ShiftRegister
|
||||||
|
|
||||||
# you can change your file names here
|
# you can change your file names here
|
||||||
IMAGE_A = "jwst1.jpg"
|
IMAGE_A = "jwst1.jpg"
|
||||||
|
@ -16,7 +21,7 @@ IMAGE_D = "jwst4.jpg"
|
||||||
IMAGE_E = "jwst5.jpg"
|
IMAGE_E = "jwst5.jpg"
|
||||||
|
|
||||||
# set up the display
|
# set up the display
|
||||||
display = PicoGraphics(display=DISPLAY_INKY_FRAME)
|
graphics = PicoGraphics(DISPLAY)
|
||||||
|
|
||||||
# Inky Frame uses a shift register to read the buttons
|
# Inky Frame uses a shift register to read the buttons
|
||||||
SR_CLOCK = 8
|
SR_CLOCK = 8
|
||||||
|
@ -42,14 +47,7 @@ hold_vsys_en_pin = Pin(HOLD_VSYS_EN_PIN, Pin.OUT)
|
||||||
hold_vsys_en_pin.value(True)
|
hold_vsys_en_pin.value(True)
|
||||||
|
|
||||||
# Create a new JPEG decoder for our PicoGraphics
|
# Create a new JPEG decoder for our PicoGraphics
|
||||||
j = jpegdec.JPEG(display)
|
j = jpegdec.JPEG(graphics)
|
||||||
|
|
||||||
# setup
|
|
||||||
activity_led.on()
|
|
||||||
# update the image on Inky every time it's powered up
|
|
||||||
# comment these lines out if running on battery power
|
|
||||||
# button_a_led.on()
|
|
||||||
# display_image(IMAGE_A)
|
|
||||||
|
|
||||||
|
|
||||||
def display_image(filename):
|
def display_image(filename):
|
||||||
|
@ -61,9 +59,16 @@ def display_image(filename):
|
||||||
j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)
|
j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)
|
||||||
|
|
||||||
# Display the result
|
# Display the result
|
||||||
display.update()
|
graphics.update()
|
||||||
|
|
||||||
|
|
||||||
|
# setup
|
||||||
|
activity_led.on()
|
||||||
|
# update the image on Inky every time it's powered up
|
||||||
|
# comment these lines out if running on battery power
|
||||||
|
# button_a_led.on()
|
||||||
|
# display_image(IMAGE_A)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
button_a_led.off()
|
button_a_led.off()
|
||||||
button_b_led.off()
|
button_b_led.off()
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
# An offline image gallery that switches between five jpg images
|
# An offline image gallery that switches between five jpg images
|
||||||
# on your SD card (copy them across by plugging your SD into a computer).
|
# on your SD card (copy them across by plugging your SD into a computer).
|
||||||
# If you want to use your own images they must be 600 x 448 pixels or smaller
|
|
||||||
|
# If you want to use your own images they must be the screen dimensions (or smaller)
|
||||||
# and saved as *non-progressive* jpgs
|
# and saved as *non-progressive* jpgs
|
||||||
|
|
||||||
|
# Make sure to uncomment the correct size for your display!
|
||||||
|
|
||||||
|
from picographics import PicoGraphics, DISPLAY_INKY_FRAME as DISPLAY # 5.7"
|
||||||
|
# from picographics import PicoGraphics, DISPLAY_INKY_FRAME_4 as DISPLAY # 4.0"
|
||||||
|
# from picographics import PicoGraphics, DISPLAY_INKY_FRAME_7 as DISPLAY # 7.3"
|
||||||
from pimoroni import ShiftRegister
|
from pimoroni import ShiftRegister
|
||||||
from picographics import PicoGraphics, DISPLAY_INKY_FRAME
|
|
||||||
from machine import Pin, SPI
|
from machine import Pin, SPI
|
||||||
import jpegdec
|
import jpegdec
|
||||||
import sdcard
|
import sdcard
|
||||||
import uos
|
import uos
|
||||||
|
|
||||||
|
|
||||||
# you can change your file names here
|
# you can change your file names here
|
||||||
IMAGE_A = "sd/jwst1.jpg"
|
IMAGE_A = "sd/jwst1.jpg"
|
||||||
IMAGE_B = "sd/jwst2.jpg"
|
IMAGE_B = "sd/jwst2.jpg"
|
||||||
|
@ -18,7 +24,7 @@ IMAGE_D = "sd/jwst4.jpg"
|
||||||
IMAGE_E = "sd/jwst5.jpg"
|
IMAGE_E = "sd/jwst5.jpg"
|
||||||
|
|
||||||
# set up the display
|
# set up the display
|
||||||
display = PicoGraphics(display=DISPLAY_INKY_FRAME)
|
graphics = PicoGraphics(DISPLAY)
|
||||||
|
|
||||||
# Inky Frame uses a shift register to read the buttons
|
# Inky Frame uses a shift register to read the buttons
|
||||||
SR_CLOCK = 8
|
SR_CLOCK = 8
|
||||||
|
@ -49,14 +55,7 @@ hold_vsys_en_pin = Pin(HOLD_VSYS_EN_PIN, Pin.OUT)
|
||||||
hold_vsys_en_pin.value(True)
|
hold_vsys_en_pin.value(True)
|
||||||
|
|
||||||
# Create a new JPEG decoder for our PicoGraphics
|
# Create a new JPEG decoder for our PicoGraphics
|
||||||
j = jpegdec.JPEG(display)
|
j = jpegdec.JPEG(graphics)
|
||||||
|
|
||||||
# setup
|
|
||||||
activity_led.on()
|
|
||||||
# update the image on Inky every time it's powered up
|
|
||||||
# comment these lines out if running on battery power
|
|
||||||
# button_a_led.on()
|
|
||||||
# display_image(IMAGE_A)
|
|
||||||
|
|
||||||
|
|
||||||
def display_image(filename):
|
def display_image(filename):
|
||||||
|
@ -68,9 +67,16 @@ def display_image(filename):
|
||||||
j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)
|
j.decode(0, 0, jpegdec.JPEG_SCALE_FULL)
|
||||||
|
|
||||||
# Display the result
|
# Display the result
|
||||||
display.update()
|
graphics.update()
|
||||||
|
|
||||||
|
|
||||||
|
# setup
|
||||||
|
activity_led.on()
|
||||||
|
# update the image on Inky every time it's powered up
|
||||||
|
# comment these lines out if running on battery power
|
||||||
|
# button_a_led.on()
|
||||||
|
# display_image(IMAGE_A)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
button_a_led.off()
|
button_a_led.off()
|
||||||
button_b_led.off()
|
button_b_led.off()
|
||||||
|
|
Loading…
Reference in New Issue