解决OpenMV非官方LCD显示

 以下代码可以解决花屏,就是屏幕被分割的情况,但是并不能够解决完全能解决,屏幕起码能看,额,最好的方式就是改变驱动。之后再说。感谢一位友的分享。

# SPI 控制
#
# 这个例子展示了,如何使用OpenMV的SPI总线
# LCD 扩展板没有使用内置的lcd驱动。而是使用了SPI。
# 需要插入LCD扩展板来运行这个例子

import sensor, image, time
from pyb import Pin, SPI

cs  = Pin("P3", Pin.OUT_OD)
rst = Pin("P7", Pin.OUT_PP)
rs  = Pin("P8", Pin.OUT_PP)
# # OpenMV上的硬件SPI总线都是2

# 注意:SPI时钟频率将不总是所请求的频率。
# 硬件仅支持总线频率除以预分频器的频率(可以是2、4、8、16、32、64、128或256)。
spi = SPI(2, SPI.MASTER, baudrate=int(1000000000), polarity=0, phase=0)

def write_command_byte(c):
    cs.low()
    rs.low()
    spi.send(c)
    cs.high()

def write_data_byte(c):
    cs.low()
    rs.high()
    spi.send(c)
    cs.high()

def write_command(c, *data):
    write_command_byte(c)
    if data:
        for d in data: write_data_byte(d)

def write_image(img):
    cs.low()
    rs.high()
    spi.send(img)
    cs.high()

def lcd2():
    write_command(0x2a)
    write_data_byte(0x00)
    write_data_byte(0x02)
    write_data_byte(0x00)
    write_data_byte(0x81)
    write_command(0x2b)
    write_data_byte(0x00)
    write_data_byte(0x01)
    write_data_byte(0x00)
    write_data_byte(0xa0)
    write_command(0x2c)

# 重启
rst.low()
rst.high()

write_command(0x11) # Sleep Exit 退出休眠

# 存储器数据存取控制
# 写0xC8设置为BGR模式
write_command(0x36, 0xC0)

# 设置 Pixel Format 接口
write_command(0x3A, 0x05)

# 开启显示
write_command(0x29)

sensor.reset() # 初始化摄像头感光元件
sensor.set_pixformat(sensor.RGB565) # 必须这样写
sensor.set_framesize(sensor.QQVGA2) # must be this
sensor.skip_frames(time = 2000) # 让新设置生效
clock = time.clock() # 跟踪FPS帧率

while(True):
    clock.tick() # 跟踪snapshots()之间经过的毫秒数
    img = sensor.snapshot() # 拍一张照片并返回图像

    write_command(0x2C) # 编写图像命令
    lcd2()
    write_image(img)

    print(clock.fps())

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值