💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# touchscreen_范例 ***** * [ ] **## 图画板** > 黑底白画笔画图板, 使用`boot`按键可以清除内容 ``` import touchscreen as ts from machine import I2C import lcd, image from board import board_info from fpioa_manager import fm fm.register(board_info.BOOT_KEY, fm.fpioa.GPIO1) btn_clear = GPIO(GPIO.GPIO1, GPIO.IN) lcd.init() i2c = I2C(I2C.I2C0, freq=400000, scl=30, sda=31) ts.init(i2c) #ts.calibrate() lcd.clear() img = image.Image() status_last = ts.STATUS_IDLE x_last = 0 y_last = 0 draw = False while True: (status,x,y) = ts.read() print(status, x, y) if draw: img.draw_line((x_last, y_last, x, y)) if status_last!=status: if (status==ts.STATUS_PRESS or status == ts.STATUS_MOVE): draw = True else: draw = False status_last = status lcd.display(img) x_last = x y_last = y if btn_clear.value() == 0: img.clear() ```