It appears that, any time I want to change a number on the display, I have to call refresh().
Every time I call refresh(), the entire screen blinks black and white for 10 seconds before settling into the new values. This is aesthetically unacceptable (to the intended audience) for a display that changes every 3 minutes.
Is this just the nature of the beast, or am I doing something to cause this? I wanted to use the eInk to recreate the "retro" vibe of the thermometer device I am gutting and replacing, but I might need to rethink.
Code: Select all
import gc
import time
import board
import displayio
import adafruit_il91874
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text import bitmap_label
from adafruit_display_shapes.circle import Circle
from adafruit_display_shapes.line import Line
from adafruit_display_shapes.rect import Rect
# Set based on your display
FLEXIBLE = False
TRICOLOR = True
ROTATION = 180
RED = 0xFF0000
# Define the pins needed for display use
spi = board.SPI() # Uses SCK and MOSI
ecs = board.A2
dc = board.A1
rst = board.A0 # set to None for FeatherWing/Shield
busy = board.A3 # set to None for FeatherWing/Shield
my_scale = 1
# Load some fonts
fractionFontFile = "fonts/Roboto-Regular-40.bdf"
fractionFont = bitmap_font.load_font(fractionFontFile)
if TRICOLOR:
highlight = 0xFF0000 # third color is red (0xff0000)
else:
highlight = 0x000000
if ROTATION == 0 or ROTATION == 180:
width = 176
height = 264
else:
width = 264
height = 176
# Used to ensure the display is free in CircuitPython
displayio.release_displays()
# Create the displayio connection to the display pins
display_bus = displayio.FourWire(
spi, command=dc, chip_select=ecs, reset=rst, baudrate=1000000
)
time.sleep(1) # Wait a bit
# Create the display object
display = adafruit_il91874.IL91874(
display_bus,
width=width,
height=height,
busy_pin=busy,
rotation=ROTATION,
highlight_color=highlight,
)
main_group = displayio.Group()
display.show(main_group)
glyphs = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-_,.:?!'\n "
fractionFont.load_glyphs(glyphs)
print("bitmap_label used: {} memory".format(bitmap_label_start - bitmap_label_end))
outside= bitmap_label.Label(
font=fractionFont,
text="888.8",
color=0x000000,
background_color=0xFFFFFF,
padding_bottom=0,
padding_left=0,
padding_right=0,
padding_top=0,
background_tight=True,
base_alignment=True,
line_spacing=1.25,
scale=my_scale,
anchor_point=(0.0, 1.0),
anchored_position=(10, 60),
)
bmap_group = displayio.Group() # Create a group for displaying
bmap_group.append(outside)
# Create a display group for our screen objects
# Creates a group of sprites & pixels at 0,0, scale=1 (no scaling).
background_color_rect = Rect(0, 0, width, height, fill=0xFFFFFF)
main_group = displayio.Group()
main_group.append(background_color_rect)
main_group.append(bmap_group)
# Place the display group on the screen
display.show(main_group)
# Refresh the display to have it actually show the image
# NOTE: Do not refresh eInk displays sooner than 180 seconds
display.refresh()
print("refreshed")
while True:
time.sleep(180)
outside.text = "111.1"
print('ok')
display.refresh()
time.sleep(180)
outside.text = "888.8"
print('ok')
display.refresh()