Badger2040: Image file overlay toggle
@@ -58,6 +58,7 @@ button_down = machine.Pin(badger2040.BUTTON_DOWN, machine.Pin.IN, machine.Pin.PU
image = bytearray(int(296 * 128 / 8))
current_image = 0
+show_info = True
# Draw an overlay box with a given message within it
@@ -97,6 +98,8 @@ def show_image(n):
name = file.split(".")[0]
open("images/{}".format(file), "r").readinto(image)
display.image(image)
+
+ if show_info:
name_length = display.measure_text(name, 0.5)
display.pen(0)
display.rectangle(0, HEIGHT - 21, name_length + 11, 21)
@@ -137,7 +140,10 @@ while True:
if current_image < TOTAL_IMAGES - 1:
current_image += 1
show_image(current_image)
- if button_a.value() or button_b.value() or button_c.value():
+ if button_a.value():
+ show_info = not show_info
+ show_image(current_image)
+ if button_b.value() or button_c.value():
display.pen(15)
display.clear()
draw_overlay("To add images connect Badger2040 to a PC, load up Thonny, and see readme.txt in images/", WIDTH - OVERLAY_BORDER, HEIGHT - OVERLAY_BORDER, OVERLAY_SPACING, 0.5)
