# This is a freeform annotation that is positioned using (x,y) values at the bottom, right # corner of the display (display.width, display.height). # The line direction is freeform_annotation = Annotation( x=display.width, # uses freeform (x,y) position y=display.height, text="Freeform annotation (display.width, height)", ) my_group = displayio.Group() my_group.append(my_switch) my_group.append(switch_annotation) my_group.append(switch_annotation_under) my_group.append(freeform_annotation) # Add my_group to the display display.show(my_group) # Start the main loop while True: p = ts.touch_point # get any touches on the screen if p: # Check each switch if the touch point is within the switch touch area # If touched, then flip the switch with .selected if my_switch.contains(p): my_switch.selected(p) time.sleep( 0.05) # touch response on PyPortal is more accurate with a small delay
my_group.append(my_switch6) my_group.append(my_switch7) my_group.append(my_switch8) # Add my_group to the display display.show(my_group) # Start the main loop while True: p = ts.touch_point # get any touches on the screen if p: # Check each switch if the touch point is within the switch touch area # If touched, then flip the switch with .selected if my_switch.contains(p): my_switch.selected(p) elif my_switch2.contains(p): my_switch2.selected(p) elif my_switch3.contains(p): my_switch3.selected(p) elif my_switch4.contains(p): my_switch4.selected(p) elif my_switch5.contains(p): my_switch5.selected(p) elif my_switch6.contains(p):