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.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):
|
while (True):
|
||||||
image = sensor.snapshot()
|
clock.tick()
|
||||||
lcd.write_image(image)
|
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):
|
while (vcp_is_connected()==False):
|
||||||
led.on(led.BLUE)
|
led.on()
|
||||||
time.sleep(150)
|
time.sleep(150)
|
||||||
led.off(led.BLUE)
|
led.off()
|
||||||
time.sleep(100)
|
time.sleep(100)
|
||||||
led.on(led.BLUE)
|
led.on()
|
||||||
time.sleep(150)
|
time.sleep(150)
|
||||||
led.off(led.BLUE)
|
led.off()
|
||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import spi, gpio
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from pyb import Pin, SPI
|
||||||
|
|
||||||
rst = gpio.GPIO(gpio.PA1)
|
rst = Pin('PD12', Pin.OUT_PP, Pin.PULL_UP)
|
||||||
rs = gpio.GPIO(gpio.PA2)
|
rs = Pin('PD13', Pin.OUT_PP, Pin.PULL_UP)
|
||||||
cs = gpio.GPIO(gpio.PA7)
|
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():
|
def reset():
|
||||||
rst.low()
|
rst.low()
|
||||||
@ -14,18 +16,18 @@ def reset():
|
|||||||
def write_command(c):
|
def write_command(c):
|
||||||
cs.low()
|
cs.low()
|
||||||
rs.low()
|
rs.low()
|
||||||
spi.write(c)
|
spi.send(c)
|
||||||
cs.high()
|
cs.high()
|
||||||
|
|
||||||
def write_data(c):
|
def write_data(c):
|
||||||
cs.low()
|
cs.low()
|
||||||
rs.high()
|
rs.high()
|
||||||
spi.write(c)
|
spi.send(c)
|
||||||
cs.high()
|
cs.high()
|
||||||
|
|
||||||
def clear(c=0x00):
|
def clear(c=0x00):
|
||||||
write_command(0x2C)
|
write_command(0x2C)
|
||||||
for i in range(120*160):
|
for i in range(128*160):
|
||||||
write_data(c)
|
write_data(c)
|
||||||
write_data(c)
|
write_data(c)
|
||||||
|
|
||||||
@ -33,10 +35,16 @@ def write_image(image):
|
|||||||
write_command(0x2C)
|
write_command(0x2C)
|
||||||
cs.low()
|
cs.low()
|
||||||
rs.high()
|
rs.high()
|
||||||
spi.write(image)
|
spi.send(image)
|
||||||
cs.high()
|
cs.high()
|
||||||
|
|
||||||
def init():
|
def set_backlight(on):
|
||||||
|
if (on):
|
||||||
|
bl.high()
|
||||||
|
else:
|
||||||
|
bl.low()
|
||||||
|
|
||||||
|
def init(madctl=0xC0):
|
||||||
#HW reset
|
#HW reset
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
@ -94,7 +102,7 @@ def init():
|
|||||||
|
|
||||||
#MX, MY, MV, RGB mode
|
#MX, MY, MV, RGB mode
|
||||||
write_command(0x36)
|
write_command(0x36)
|
||||||
write_data(0x60)
|
write_data(madctl)
|
||||||
|
|
||||||
#ST7735R Gamma Sequence
|
#ST7735R Gamma Sequence
|
||||||
write_command(0xe0)
|
write_command(0xe0)
|
||||||
@ -138,14 +146,14 @@ def init():
|
|||||||
write_data(0x00)
|
write_data(0x00)
|
||||||
write_data(0x00)
|
write_data(0x00)
|
||||||
write_data(0x00)
|
write_data(0x00)
|
||||||
write_data(0x9F)
|
write_data(128-1)
|
||||||
|
|
||||||
# set row address
|
# set row address
|
||||||
write_command(0x2b)
|
write_command(0x2b)
|
||||||
write_data(0x00)
|
write_data(0x00)
|
||||||
write_data(0x00)
|
write_data(0x00)
|
||||||
write_data(0x00)
|
write_data(0x00)
|
||||||
write_data(0x77)
|
write_data(160-1)
|
||||||
|
|
||||||
#Enable test command
|
#Enable test command
|
||||||
write_command(0xF0)
|
write_command(0xF0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user