Different display "modes" with e-paper or eink

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
greenleaf
 
Posts: 21
Joined: Sat Jun 25, 2011 10:18 pm

Different display "modes" with e-paper or eink

Post by greenleaf »

Maybe someone has some prior art or a library that does this.

I want to have the buttons on my Pimoroni Badger 2040 change the modes of the display. The challenge is gracefully removing the current contents of the display before rendering the selected mode.

Right now my kludgy solution is a try/except that takes the sledgehammer approach and tries to remove all the text groups that could be on the screen.

Code: Select all

        try:
            g.remove(q_group)
            g.remove(a_group)
        except:
            print('Groups not attached.')
Is there a more graceful way to do this?

User avatar
greenleaf
 
Posts: 21
Joined: Sat Jun 25, 2011 10:18 pm

Re: Different display "modes" with e-paper or eink

Post by greenleaf »

It looks like I can zero out the text labels by setting them to empty strings.

How do you handle this scenario? Perhaps a cleanup function that empties out the strings and removes all images from their group?

User avatar
greenleaf
 
Posts: 21
Joined: Sat Jun 25, 2011 10:18 pm

Re: Different display "modes" with e-paper or eink

Post by greenleaf »

Here's what I came up with, a basic function to wipe any artifacts from the previous mode that remain on screen. The device has three modes - conference badge, dad jokes, and cat facts:

Code: Select all

def clear_ui(display_group):
    try:
        display_group.remove(badge_group)
    except:
        print("Badge group not attached.")
    dadjoke_q_area.text = ''
    dadjoke_a_area.text = ''
    catfact_area.text = ''
    name_area.text = ''
    title_area.text = ''

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”