So I thought to try out the Miniscreen buttons and here is what i got
And this is the code
from pitop.miniscreen import Miniscreen
from time import sleep
from PIL import Image, ImageDraw, ImageFont
ms = Miniscreen()
image = Image.new(ms.mode, ms.size,)
canvas = ImageDraw.Draw(image)
up = ms.up_button
down = ms.down_button
page = 1
def display_page():
global page
canvas.rectangle(ms.bounding_box, fill=0)
if page == 1:
canvas.text((23, 23),f"Page : {page}",font=ImageFont.load_default(),fill=1)
elif page == 2:
canvas.text((60, 43),f"Page : {page}",font=ImageFont.load_default(),fill=1)
elif page == 3:
canvas.text((13, 36),f"Page : {page}",font=ImageFont.load_default(),fill=1)
ms.display_image(image)
def do_up_thing():
global page
if page == 3:
page = 1
else:
page += 1
def do_down_thing():
global page
if page == 1:
page = 3
else:
page -= 1
up.when_pressed = do_up_thing
down.when_pressed = do_down_thing
while True:
display_page()