From a34b55bc7acb2b61101a075337096dac7673d6c1 Mon Sep 17 00:00:00 2001 From: Snarr Date: Tue, 5 Mar 2024 06:20:58 +0000 Subject: [PATCH] Add example program (janky, look at next sprint) --- .../PygameZero_GPIOZero_Button_Example.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/PygameZero_GPIOZero_Button_Example.py diff --git a/examples/PygameZero_GPIOZero_Button_Example.py b/examples/PygameZero_GPIOZero_Button_Example.py new file mode 100644 index 00000000..c2a97c3a --- /dev/null +++ b/examples/PygameZero_GPIOZero_Button_Example.py @@ -0,0 +1,23 @@ +from gpiozero import Button +import pgzrun + +WIDTH = 300 +HEIGHT = 300 + +button = Button(2) + +screen_text = "" + +def update(): + if button.is_pressed: + screen_text = "Pressed" + +def draw(): + if button.is_pressed: + screen_text = "Pressed" + else: + screen_text = "Not Pressed" + screen.clear() + screen.fill((255, 255, 255)) + screen.draw.text(screen_text, fontsize=40, center=(150, 150), color=(0,0,0)) +pgzrun.go()