lcd连接数据线的时候能正常显示,外接电源之后中间有一半白屏是怎么回事
-
lcd连接数据线的时候能正常显示,外接电源之后中间有一半白屏是怎么回事
-
需要提供代码,和照片。
-
THRESHOLD = (51, 100, 0, 21, 12, 33) #线路阈值
import sensor, image, time,lcd
from pyb import Servo
from pid import PID
rho_pid = PID(p=0.4, i=0) #截距
theta_pid = PID(p=0.001, i=0) #斜率s1 = Servo(3) # P9
def run(_angle,_range,_sleep): #角度,幅度,间隔延时
s1.angle(_angle+_range) #角度,转到该角度的时间
time.sleep(_sleep)
s1.angle(_angle-_range)
time.sleep(_sleep)sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000.
#sensor.set_windowing([0,20,80,40])
sensor.skip_frames(time = 2000) # WARNING: If you use QQVGA it may take seconds
clock = time.clock() # to process a frame sometimes.lcd.init()
while(True):
clock.tick()
#img = sensor.snapshot()
img = sensor.snapshot()
line = img.get_regression([(100,100,0,0,0,0)], robust = True)
if (line):
rho_err = abs(line.rho())-img.width()/2
if line.theta()>90:
theta_err = line.theta()-180
else:
theta_err = line.theta()
img.draw_line(line.line(), color = 127)
print(rho_err,line.magnitude(),theta_err)#lcd.display(sensor.snapshot()) lcd.display(img.draw_line(line.line(),color=127)) if line.magnitude()>0: #if -40<b_err<40 and -30<t_err<30: rho_output = rho_pid.get_pid(rho_err,1) theta_output = theta_pid.get_pid(theta_err,1) output = rho_output+theta_output #output=output*3 if theta_err>70: #限制摆动角度 theta_err=70 if theta_err<-70: theta_err=-70 run(theta_err,15,180) #角度,幅度,间隔延时 pass![0_1572269044774_852B78E315A605550E330DB196766244.jpg](https://fcdn.singtown.com/0c8ae143-f07e-48e3-99e2-85338bb96b25.jpg)
-
-
https://singtown.com/learn/49601/
用例子进行测试。