mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update examples
This commit is contained in:
parent
a674b99474
commit
b8273fec98
@ -1,6 +1,17 @@
|
||||
import lcd, sensor
|
||||
import lcd, sensor, time
|
||||
lcd.init()
|
||||
lcd.clear(0xFF)
|
||||
lcd.clear(0x00)
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_contrast(2)
|
||||
sensor.set_brightness(0)
|
||||
sensor.set_saturation(2)
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.QQVGA2)
|
||||
|
||||
clock = time.clock()
|
||||
while (True):
|
||||
image = sensor.snapshot()
|
||||
lcd.write_image(image)
|
||||
clock.tick()
|
||||
image = sensor.snapshot()
|
||||
lcd.write_image(image)
|
||||
print(clock.fps())
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
import led, time
|
||||
import pyb, time
|
||||
|
||||
led = pyb.LED(3)
|
||||
|
||||
while (vcp_is_connected()==False):
|
||||
led.on(led.BLUE)
|
||||
led.on()
|
||||
time.sleep(150)
|
||||
led.off(led.BLUE)
|
||||
led.off()
|
||||
time.sleep(100)
|
||||
led.on(led.BLUE)
|
||||
led.on()
|
||||
time.sleep(150)
|
||||
led.off(led.BLUE)
|
||||
led.off()
|
||||
time.sleep(600)
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import spi, gpio
|
||||
from time import sleep
|
||||
from pyb import Pin, SPI
|
||||
|
||||
rst = gpio.GPIO(gpio.PA1)
|
||||
rs = gpio.GPIO(gpio.PA2)
|
||||
cs = gpio.GPIO(gpio.PA7)
|
||||
rst = Pin('PD12', Pin.OUT_PP, Pin.PULL_UP)
|
||||
rs = Pin('PD13', Pin.OUT_PP, Pin.PULL_UP)
|
||||
cs = Pin('PB12', Pin.OUT_PP, Pin.PULL_UP)
|
||||
bl = Pin('PA5', Pin.OUT_PP, Pin.PULL_UP)
|
||||
spi = SPI(2, SPI.MASTER, baudrate=22500000, polarity=0, phase=0)
|
||||
|
||||
def reset():
|
||||
rst.low()
|
||||
@ -14,18 +16,18 @@ def reset():
|
||||
def write_command(c):
|
||||
cs.low()
|
||||
rs.low()
|
||||
spi.write(c)
|
||||
spi.send(c)
|
||||
cs.high()
|
||||
|
||||
def write_data(c):
|
||||
cs.low()
|
||||
rs.high()
|
||||
spi.write(c)
|
||||
spi.send(c)
|
||||
cs.high()
|
||||
|
||||
def clear(c=0x00):
|
||||
write_command(0x2C)
|
||||
for i in range(120*160):
|
||||
for i in range(128*160):
|
||||
write_data(c)
|
||||
write_data(c)
|
||||
|
||||
@ -33,10 +35,16 @@ def write_image(image):
|
||||
write_command(0x2C)
|
||||
cs.low()
|
||||
rs.high()
|
||||
spi.write(image)
|
||||
spi.send(image)
|
||||
cs.high()
|
||||
|
||||
def init():
|
||||
def set_backlight(on):
|
||||
if (on):
|
||||
bl.high()
|
||||
else:
|
||||
bl.low()
|
||||
|
||||
def init(madctl=0xC0):
|
||||
#HW reset
|
||||
reset()
|
||||
|
||||
@ -94,7 +102,7 @@ def init():
|
||||
|
||||
#MX, MY, MV, RGB mode
|
||||
write_command(0x36)
|
||||
write_data(0x60)
|
||||
write_data(madctl)
|
||||
|
||||
#ST7735R Gamma Sequence
|
||||
write_command(0xe0)
|
||||
@ -138,14 +146,14 @@ def init():
|
||||
write_data(0x00)
|
||||
write_data(0x00)
|
||||
write_data(0x00)
|
||||
write_data(0x9F)
|
||||
write_data(128-1)
|
||||
|
||||
# set row address
|
||||
write_command(0x2b)
|
||||
write_data(0x00)
|
||||
write_data(0x00)
|
||||
write_data(0x00)
|
||||
write_data(0x77)
|
||||
write_data(160-1)
|
||||
|
||||
#Enable test command
|
||||
write_command(0xF0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user