# Line Drawing
#
# This example shows off drawing lines on the OpenMV Cam.
import sensor, image, time, pyb
gainceiling=16
constrast=0
brightness=0
saturation=0
gainceiling_flag=1
constrast_flag=1
brightness_flag=1
saturation_flag=1
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # or GRAYSCALE...
sensor.set_framesize(sensor.QVGA) # or QQVGA...
sensor.skip_frames(time = 2000)
clock = time.clock()
p0_in = Pin('P0', Pin.IN, Pin.PULL_UP)
p1_in = Pin('P1', Pin.IN, Pin.PULL_UP)
p2_in = Pin('P2', Pin.IN, Pin.PULL_UP)
p3_in = Pin('P3', Pin.IN, Pin.PULL_UP)
def Key_Scan():
gainceiling_flag=p0_in.value() # get value, 0 or 1
constrast_flag=p1_in.value() # get value, 0 or 1
brightness_flag=p2_in.value() # get value, 0 or 1
saturation_flag=p3_in.value() # get value, 0 or 1
if(gainceiling_flag==0)
time.sleep(0.02) #延时20ms,防抖动
if (gainceiling_flag==0): #再次判断是否被按下
while (gainceiling_flag==0): #等待松手
pass
gainceiling=gainceiling*2
if(gainceiling>128)
gainceiling=2
if(constrast_flag==0)
time.sleep(0.02) #延时20ms,防抖动
if (constrast_flag==0): #再次判断是否被按下
while (constrast_flag==0): #等待松手
pass
constrast=constrast+1
if(constrast>3)
constrast=-3
if(brightness_flag==0)
time.sleep(0.02) #延时20ms,防抖动
if (brightness_flag==0): #再次判断是否被按下
while (brightness_flag==0): #等待松手
pass
brightness=brightness+1
if(brightness>3)
brightness=-3
if(saturation_flag==0)
time.sleep(0.02) #延时20ms,防抖动
if (saturation_flag==0): #再次判断是否被按下
while (saturation_flag==0): #等待松手
pass
saturation=saturation+1
if(saturation>3)
saturation=-3
sensor.set_gainceiling(gainceiling)
sensor.set_contrast(constrast)
sensor.set_brightness(brightness)
sensor.set_saturation(saturation)
while(True):
clock.tick()
Key_Scan()
img = sensor.snapshot()
请在这里粘贴代码