Last active
November 16, 2022 15:45
-
-
Save joeycastillo/aaa79ba24349696ca8faf242c6ff207a to your computer and use it in GitHub Desktop.
Show a 300x400 bitmap on the Open Book's display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | |
# SPDX-License-Identifier: MIT | |
"""Simple test script for 4.2" 400x300 black and white displays. | |
*** REQUIRES adafruit_il0398 *** | |
Supported products: | |
* WaveShare 4.2" Black and White | |
* https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper.htm | |
* https://www.waveshare.com/product/modules/oleds-lcds/e-paper/4.2inch-e-paper-module.htm | |
""" | |
import time | |
import board | |
import busio | |
import displayio | |
import digitalio | |
import adafruit_il0398 | |
# Open Book peripheral enable pin (active low) | |
en = digitalio.DigitalInOut(board.GP0) | |
en.switch_to_output() | |
en.value = False | |
displayio.release_displays() | |
spi = busio.SPI(board.GP10, MOSI=board.GP11) | |
epd_cs = board.GP9 | |
epd_dc = board.GP8 | |
epd_reset = board.GP7 | |
epd_busy = board.GP6 | |
display_bus = displayio.FourWire( | |
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000 | |
) | |
time.sleep(1) | |
display = adafruit_il0398.IL0398( | |
display_bus, width=300, height=400, busy_pin=epd_busy, rotation=270 | |
) | |
display.show(None) | |
g = displayio.Group() | |
with open("/macos.bmp", "rb") as f: | |
pic = displayio.OnDiskBitmap(f) | |
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader) | |
g.append(t) | |
display.show(g) | |
display.refresh() | |
while True: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment