Created
November 29, 2021 12:05
-
-
Save rsbohn/55c40ef594fc7093c398c60da4e42456 to your computer and use it in GitHub Desktop.
Color Bitmaps on Displayio
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: Copyright (c) 2021 Randall Bohn (dexter) | |
# | |
# SPDX-License-Identifier: MIT | |
"""A first look at DisplayIO""" | |
import time | |
import board | |
import displayio | |
import vectorio | |
display = board.DISPLAY | |
splash = displayio.Group() | |
background_palette = displayio.Palette(3) | |
background_palette[0] = 0x336699 | |
background_palette[1] = 0x990000 | |
background = displayio.Bitmap(display.width, display.height, 3) | |
background_tg = displayio.TileGrid(background, pixel_shader=background_palette) | |
splash.append(background_tg) | |
display.show(splash) | |
print("bitmap fill") | |
sleeptime = 2 | |
for _ in range(2): | |
background.fill(0) | |
time.sleep(sleeptime) | |
background.fill(1) | |
time.sleep(sleeptime) | |
print("palette update") | |
background.fill(2) | |
for _ in range(2): | |
background_palette[2]=0x339933 | |
time.sleep(sleeptime) | |
background_palette[2]=0x993333 | |
time.sleep(sleeptime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment