• Skip to content

Main Menu

  • Home
  • Paintings
  • Interactive Work
  • About
  • Posts
  • Back
  • NM Women Series
  • Hollyhocks Series
  • Daily Paintings
  • Small Works
  • Back
  • Games and Toys
  • Ribbons
  • ORBS
Enrico Trujillo

Main Menu

  • Home
  • Paintings
    • NM Women Series
    • Hollyhocks Series
    • Daily Paintings
    • Small Works
  • Interactive Work
    • Games and Toys
    • Ribbons
    • ORBS
  • About
  • Posts
  • Search

Pico Display Pack

 Posted on on March 15, 2023

Here is a little code that will hopefully pull images from the internet and display on the screen every 10 minutes.

import time
import busio
import digitalio
import adafruit_requests as requests
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
import adafruit_esp32spi
import adafruit_imageload
import adafruit_display_text.label
import adafruit_fancyled.adafruit_fancyled as fancy
import adafruit_ili9341

# Set up the ESP32SPI interface and pins
esp32_cs = digitalio.DigitalInOut(board.GP17)
esp32_ready = digitalio.DigitalInOut(board.GP16)
esp32_reset = digitalio.DigitalInOut(board.GP20)
spi = busio.SPI(board.GP18, board.GP19, board.GP16)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

# Set up the socket for HTTP requests
socket.set_interface(esp)
requests.set_socket(socket, esp)

# Set up the Pico Display Pack
display_bus = busio.SPI(board.GP10, MOSI=board.GP11, SCK=board.GP12)
display_cs = board.GP13
display_dc = board.GP14
display_reset = board.GP15
display = adafruit_ili9341.ILI9341(display_bus, cs=display_cs, dc=display_dc, rst=display_reset)

# Set up the font for the label
font = bitmap_font.load_font("/fonts/Arial-12.bdf")
font.load_glyphs(b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890- ()')

# Set up the timer to pull a new image every 10 minutes
last_update = time.monotonic()

while True:
    # Pull a new image every 10 minutes
    if time.monotonic() - last_update >= 600:
        try:
            # Get the image from picsum.photos
            image_url = "https://picsum.photos/240/135"
            response = requests.get(image_url)
            image_file = response.content
            image = adafruit_imageload.load(image_file, bitmap=displayio.Bitmap, palette=displayio.Palette)
            
            # Display the image on the Pico Display Pack
            display.show(image)
            
            # Create a label with the time the image was pulled and display it on the Pico Display Pack
            label = adafruit_display_text.label.Label(font, text="Updated at {}".format(time.strftime("%H:%M:%S")))
            label.x = 20
            label.y = 20
            display.show(label)
            
            # Reset the timer
            last_update = time.monotonic()
        except Exception as e:
            print("Error: ", e)
    
    # Wait for button press to exit
    if not button.value:
        break

Posted in Uncategorized

Comments are closed.

Post navigation

Previous
Next

Primary

Recent Posts

  • Building an Art Store with WooCommerce: A Guide for Solo Artists
  • Egon Schiele⁣⁣ Portrait of the Painter Anton Peschka⁣⁣ 1909
  • Learning to Stretch My Paintings a Little Further
  • Growing Your Artist Footprint Online—Simple Steps I’m Taking (and You Can Too)
  • Choosing My Canvas: Why Format Matters When Painting People and Places

Archives

  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • August 2024
  • July 2024
  • April 2024
  • March 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • July 2022
  • March 2022
  • February 2022
  • December 2021
  • October 2021
  • August 2021

Categories

  • Advice
  • Agriculture
  • Art
  • Article
  • Business
  • Community
  • Culture
  • Daily
  • Drawing
  • Galleries
  • Home
  • Illustration
  • Land
  • News
  • Painting
  • Photography
  • Planning
  • Tech
  • Uncategorized

Follow us

Follow us on TwitterLike us on FacebookSubscribe to our Channel on YouTubeFollow us on GithubFollow us on InstagramFollow us on CodepenFollow us on SoundCloud

© Enrico Trujillo 2025MINIMAL

x