from adafruit_displayio_layout.widgets.switch_round import SwitchRound as Switch from adafruit_displayio_layout.widgets.annotation import Annotation display = board.DISPLAY ts = adafruit_touchscreen.Touchscreen( board.TOUCH_XL, board.TOUCH_XR, board.TOUCH_YD, board.TOUCH_YU, calibration=((5200, 59000), (5800, 57000)), size=(display.width, display.height), ) # Create the switch widget my_switch = Switch(190, 50) # Create several annotations # This annotation is positioned relative to the switch widget, with default values. switch_annotation = Annotation( widget=my_switch, # positions are relative to the switch text="Widget Annotation: Switch", ) # This annotation is positioned relative to the switch widget, with the line # going in the downard direction and anchored at the middle bottom of the switch. # The position is "nudged" downward using ``position_offset`` to create a 1 pixel # gap between the end of the line and the switch. # The text is positioned under the line by setting ``text_under`` to True. switch_annotation_under = Annotation(
display = board.DISPLAY # setup the touch screen ts = adafruit_touchscreen.Touchscreen( board.TOUCH_XL, board.TOUCH_XR, board.TOUCH_YD, board.TOUCH_YU, calibration=((5200, 59000), (5800, 57000)), size=(display.width, display.height), ) # Create the switches my_switch = Switch(20, 30) my_switch2 = Switch( x=120, y=35, height=30, # Set height to 30 pixels. If you do not specify width, # it is automatically set to a default aspect ratio touch_padding=10, # add extra boundary for touch response value=True, ) # initial value is set to True my_switch3 = Switch( x=20, y=85, height=40, fill_color_off=(255, 0, 0), # Set off colorred, can use hex code (0xFF0000)