from fpioa_manager import*from Maix import GPIO
fm.register(board_info.LED_R, fm.fpioa.GPIO0)
led_r=GPIO(GPIO.GPIO0,GPIO.OUT)
led_r.value(0)
攝像頭例程
import sensor, image, time, lcd
lcd.init(freq=15000000)
sensor.reset()# Reset and initialize the sensor. It will# run automatically, call sensor.run(0) to stop
sensor.set_pixformat(sensor.RGB565)# Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA)# Set frame size to QVGA (320x240)
sensor.skip_frames(time =2000)# Wait for settings take effect.
clock = time.clock()# Create a clock object to track the FPS.while(True):
clock.tick()# Update the FPS clock.
img = sensor.snapshot()# Take a picture and return the image.
lcd.display(img)# Display on LCDprint(clock.fps())# Note: MaixPy's Cam runs about half as fast when connected# to the IDE. The FPS should increase once disconnected.
觸摸屏畫圖例程
import touchscreen as ts
from Maix import GPIO
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, force=True)
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 =FalsewhileTrue:(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 =Trueelse:
draw =False
status_last = status
lcd.display(img)
x_last = x
y_last = y
if btn_clear.value()==0:
img.clear()