Skip to content

Instantly share code, notes, and snippets.

@rsbohn
Created November 29, 2021 12:05
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 rsbohn/55c40ef594fc7093c398c60da4e42456 to your computer and use it in GitHub Desktop.
Save rsbohn/55c40ef594fc7093c398c60da4e42456 to your computer and use it in GitHub Desktop.
Color Bitmaps on Displayio
# 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