forked from openmv/qt-creator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: huangziyi <[email protected]>
- Loading branch information
Showing
46 changed files
with
2,379 additions
and
1,251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Camera Example | ||
# | ||
# Note: You will need an SD card to run this example. | ||
# | ||
# You can start 2 camera preview. | ||
|
||
from media.camera import * | ||
from media.display import * | ||
from media.media import * | ||
import time, os | ||
import sys | ||
|
||
def camera_test(): | ||
print("camera_test") | ||
# use hdmi for display | ||
display.init(LT9611_1920X1080_30FPS) | ||
camera.sensor_init(CAM_DEV_ID_0, CAM_DEFAULT_SENSOR) | ||
out_width = 640 | ||
out_height = 480 | ||
# set camera out width align up with 16Bytes | ||
out_width = ALIGN_UP(out_width, 16) | ||
# set chn0 output size | ||
camera.set_outsize(CAM_DEV_ID_0, CAM_CHN_ID_0, out_width, out_height) | ||
# set chn0 out format | ||
camera.set_outfmt(CAM_DEV_ID_0, CAM_CHN_ID_0, PIXEL_FORMAT_YUV_SEMIPLANAR_420) | ||
# create meida source device | ||
meida_source = media_device(CAMERA_MOD_ID, CAM_DEV_ID_0, CAM_CHN_ID_0) | ||
# create meida sink device | ||
meida_sink = media_device(DISPLAY_MOD_ID, DISPLAY_DEV_ID, DISPLAY_CHN_VIDEO1) | ||
# create meida link | ||
media.create_link(meida_source, meida_sink) | ||
# set display plane with video channel | ||
display.set_plane(160, 160, out_width, out_height, PIXEL_FORMAT_YVU_PLANAR_420, DISPLAY_MIRROR_NONE, DISPLAY_CHN_VIDEO1) | ||
|
||
|
||
camera.sensor_init(CAM_DEV_ID_1, CAM_OV5647_1920X1080_CSI1_30FPS_10BIT_USEMCLK_LINEAR) | ||
out_width = 640 | ||
out_height = 480 | ||
# set camera out width align up with 16Bytes | ||
out_width = ALIGN_UP(out_width, 16) | ||
# set chn0 output size | ||
camera.set_outsize(CAM_DEV_ID_1, CAM_CHN_ID_0, out_width, out_height) | ||
# set chn0 out format | ||
camera.set_outfmt(CAM_DEV_ID_1, CAM_CHN_ID_0, PIXEL_FORMAT_YUV_SEMIPLANAR_420) | ||
# create meida source device | ||
meida_source1 = media_device(CAMERA_MOD_ID, CAM_DEV_ID_1, CAM_CHN_ID_0) | ||
# create meida sink device | ||
meida_sink1 = media_device(DISPLAY_MOD_ID, DISPLAY_DEV_ID, DISPLAY_CHN_VIDEO2) | ||
# create meida link | ||
media.create_link(meida_source1, meida_sink1) | ||
# set display plane with video channel | ||
display.set_plane(960, 480, out_width, out_height, PIXEL_FORMAT_YVU_PLANAR_420, DISPLAY_MIRROR_NONE, DISPLAY_CHN_VIDEO2) | ||
|
||
# init meida buffer | ||
media.buffer_init() | ||
# start stream for camera device0 | ||
camera.start_mcm_stream() | ||
|
||
try: | ||
while True: | ||
os.exitpoint() | ||
time.sleep(5) | ||
except KeyboardInterrupt as e: | ||
print("user stop: ", e) | ||
except BaseException as e: | ||
sys.print_exception(e) | ||
# stop stream for camera device0 | ||
camera.stop_mcm_stream() | ||
|
||
# deinit display | ||
display.deinit() | ||
# destroy media link | ||
media.destroy_link(meida_source, meida_sink) | ||
media.destroy_link(meida_source1, meida_sink1) | ||
|
||
os.exitpoint(os.EXITPOINT_ENABLE_SLEEP) | ||
time.sleep_ms(100) | ||
# deinit media buffer | ||
media.buffer_deinit() | ||
|
||
if __name__ == "__main__": | ||
os.exitpoint(os.EXITPOINT_ENABLE) | ||
camera_test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Camera Example | ||
# | ||
# Note: You will need an SD card to run this example. | ||
# | ||
# You can start 3 camera preview. | ||
|
||
from media.camera import * | ||
from media.display import * | ||
from media.media import * | ||
import time, os | ||
import sys | ||
|
||
def camera_test(): | ||
print("camera_test") | ||
# use hdmi for display | ||
display.init(LT9611_1920X1080_30FPS) | ||
camera.sensor_init(CAM_DEV_ID_0, CAM_DEFAULT_SENSOR) | ||
out_width = 640 | ||
out_height = 480 | ||
# set camera out width align up with 16Bytes | ||
out_width = ALIGN_UP(out_width, 16) | ||
# set chn0 output size | ||
camera.set_outsize(CAM_DEV_ID_0, CAM_CHN_ID_0, out_width, out_height) | ||
# set chn0 out format | ||
camera.set_outfmt(CAM_DEV_ID_0, CAM_CHN_ID_0, PIXEL_FORMAT_YUV_SEMIPLANAR_420) | ||
# create meida source device | ||
meida_source = media_device(CAMERA_MOD_ID, CAM_DEV_ID_0, CAM_CHN_ID_0) | ||
# create meida sink device | ||
meida_sink = media_device(DISPLAY_MOD_ID, DISPLAY_DEV_ID, DISPLAY_CHN_VIDEO1) | ||
# create meida link | ||
media.create_link(meida_source, meida_sink) | ||
# set display plane with video channel | ||
display.set_plane(0, 0, out_width, out_height, PIXEL_FORMAT_YVU_PLANAR_420, DISPLAY_MIRROR_NONE, DISPLAY_CHN_VIDEO1) | ||
|
||
|
||
camera.sensor_init(CAM_DEV_ID_1, CAM_OV5647_1920X1080_CSI1_30FPS_10BIT_USEMCLK_LINEAR) | ||
out_width = 640 | ||
out_height = 480 | ||
# set camera out width align up with 16Bytes | ||
out_width = ALIGN_UP(out_width, 16) | ||
# set chn0 output size | ||
camera.set_outsize(CAM_DEV_ID_1, CAM_CHN_ID_0, out_width, out_height) | ||
# set chn0 out format | ||
camera.set_outfmt(CAM_DEV_ID_1, CAM_CHN_ID_0, PIXEL_FORMAT_YUV_SEMIPLANAR_420) | ||
# create meida source device | ||
meida_source1 = media_device(CAMERA_MOD_ID, CAM_DEV_ID_1, CAM_CHN_ID_0) | ||
# create meida sink device | ||
meida_sink1 = media_device(DISPLAY_MOD_ID, DISPLAY_DEV_ID, DISPLAY_CHN_VIDEO2) | ||
# create meida link | ||
media.create_link(meida_source1, meida_sink1) | ||
# set display plane with video channel | ||
display.set_plane(640, 320, out_width, out_height, PIXEL_FORMAT_YVU_PLANAR_420, DISPLAY_MIRROR_NONE, DISPLAY_CHN_VIDEO2) | ||
|
||
|
||
camera.sensor_init(CAM_DEV_ID_2, CAM_OV5647_1920X1080_CSI2_30FPS_10BIT_USEMCLK_LINEAR) | ||
out_width = 640 | ||
out_height = 480 | ||
# set camera out width align up with 16Bytes | ||
out_width = ALIGN_UP(out_width, 16) | ||
# set chn0 output size | ||
camera.set_outsize(CAM_DEV_ID_2, CAM_CHN_ID_0, out_width, out_height) | ||
# set chn0 out format | ||
camera.set_outfmt(CAM_DEV_ID_2, CAM_CHN_ID_0, PIXEL_FORMAT_RGB_888) | ||
# create meida source device | ||
meida_source2 = media_device(CAMERA_MOD_ID, CAM_DEV_ID_2, CAM_CHN_ID_0) | ||
# create meida sink device | ||
meida_sink2 = media_device(DISPLAY_MOD_ID, DISPLAY_DEV_ID, DISPLAY_CHN_OSD0) | ||
# create meida link1 | ||
media.create_link(meida_source2, meida_sink2) | ||
# set display plane with video channel | ||
display.set_plane(1280, 600, out_width, out_height, PIXEL_FORMAT_RGB_888, DISPLAY_MIRROR_NONE, DISPLAY_CHN_OSD0) | ||
|
||
|
||
# init meida buffer | ||
media.buffer_init() | ||
# start stream for camera device0 | ||
camera.start_mcm_stream() | ||
|
||
try: | ||
while True: | ||
os.exitpoint() | ||
time.sleep(5) | ||
except KeyboardInterrupt as e: | ||
print("user stop: ", e) | ||
except BaseException as e: | ||
sys.print_exception(e) | ||
# stop stream for camera device0 | ||
camera.stop_mcm_stream() | ||
|
||
# deinit display | ||
display.deinit() | ||
# destroy media link | ||
media.destroy_link(meida_source, meida_sink) | ||
media.destroy_link(meida_source1, meida_sink1) | ||
media.destroy_link(meida_source2, meida_sink2) | ||
os.exitpoint(os.EXITPOINT_ENABLE_SLEEP) | ||
time.sleep_ms(100) | ||
# deinit media buffer | ||
media.buffer_deinit() | ||
|
||
if __name__ == "__main__": | ||
os.exitpoint(os.EXITPOINT_ENABLE) | ||
camera_test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
# 基础示例 | ||
# | ||
# 欢迎使用CanMV IDE, 点击IDE左下角的绿色按钮开始执行脚本 | ||
|
||
from machine import ADC | ||
|
||
adc = ADC(0,enable=True) #构造adc对象,通道0默认开启 | ||
value = adc.value() #获取通道0的数值 | ||
print("value = %d" % value) | ||
adc.deinit() #注销adc对象 | ||
# 实例化ADC通道0 | ||
adc = ADC(0) | ||
# 获取ADC通道0采样值 | ||
print(adc.read_u16()) | ||
# 获取ADC通道0电压值 | ||
print(adc.read_uv(), "uV") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,18 @@ | ||
from machine import FPIOA | ||
a = FPIOA() | ||
|
||
|
||
a.help() | ||
for i in range(63): | ||
a.help(i) | ||
|
||
for i in range(221): | ||
a.get_Pin_num(i) | ||
|
||
a.help(60) | ||
a.set_function(60,a.GPIO60) | ||
a.help(60) | ||
|
||
a.set_function(60,set_sl=1,set_ie=0,set_oe=0,set_pd=1,set_pu=0,set_ds=6,set_st=0,set_di=1) | ||
a.help(60) | ||
try : | ||
print(a.set_function(60,set_msc=0)) | ||
|
||
except Exception as e: | ||
print("set error ", e) | ||
|
||
a.help(60) | ||
|
||
|
||
|
||
# 实例化FPIOA | ||
fpioa = FPIOA() | ||
# 打印所有引脚配置 | ||
fpioa.help() | ||
# 打印指定引脚详细配置 | ||
fpioa.help(0) | ||
# 打印指定功能所有可用的配置引脚 | ||
fpioa.help(FPIOA.IIC0_SDA, func=True) | ||
# 设置Pin0为GPIO0 | ||
fpioa.set_function(0, FPIOA.GPIO0) | ||
# 设置Pin2为GPIO2, 同时配置其它项 | ||
fpioa.set_function(2, FPIOA.GPIO2, ie=1, oe=1, pu=0, pd=0, st=1, sl=0, ds=7) | ||
# 获取指定功能当前所在的引脚 | ||
fpioa.get_pin_num(FPIOA.UART0_TXD) | ||
# 获取指定引脚当前功能 | ||
fpioa.get_pin_func(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from machine import Pin | ||
from machine import FPIOA | ||
|
||
# 实例化FPIOA | ||
fpioa = FPIOA() | ||
# 设置Pin2为GPIO2 | ||
fpioa.set_function(2, FPIOA.GPIO2) | ||
|
||
# 实例化Pin2为输出 | ||
pin = Pin(2, Pin.OUT, pull=Pin.PULL_NONE, drive=7) | ||
# 设置输出为高 | ||
pin.value(1) | ||
# pin.on() | ||
# pin.high() | ||
# 设置输出为低 | ||
pin.value(0) | ||
# pin.off() | ||
# pin.low() | ||
# 初始化Pin2为输入 | ||
pin.init(Pin.IN, pull=Pin.PULL_UP, drive=7) | ||
# 获取输入 | ||
print(pin.value()) | ||
# 设置模式 | ||
pin.mode(Pin.IN) | ||
# 获取模式 | ||
print(pin.mode()) | ||
# 设置上下拉 | ||
pin.pull(Pin.PULL_NONE) | ||
# 获取上下拉 | ||
print(pin.pull()) | ||
# 设置驱动能力 | ||
pin.drive(7) | ||
# 获取驱动能力 | ||
print(pin.drive()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from machine import RTC | ||
|
||
# 实例化RTC | ||
rtc = RTC() | ||
# 获取当前时间 | ||
print(rtc.datetime()) | ||
# 设置当前时间 | ||
rtc.init((2024,2,28,2,23,59,0,0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
# 基础示例 | ||
# | ||
# 欢迎使用CanMV IDE, 点击IDE左下角的绿色按钮开始执行脚本 | ||
|
||
from machine import Timer | ||
def on_timer(arg): #定义定时器回调函数 | ||
print("time up: %d" % arg) | ||
|
||
tim = Timer(mode=Timer.MODE_ONE_SHOT,period=3, unit=Timer.UNIT_S, callback=on_timer, arg=1, start=True) #构造定时器对象,时间为3s,默认开启定时器 | ||
import time | ||
|
||
# 实例化一个软定时器 | ||
tim = Timer(-1) | ||
# 初始化定时器为单次模式,周期100ms | ||
tim.init(period=100, mode=Timer.ONE_SHOT, callback=lambda t:print(1)) | ||
time.sleep(0.2) | ||
# 初始化定时器为周期模式,频率为1Hz | ||
tim.init(freq=1, mode=Timer.PERIODIC, callback=lambda t:print(2)) | ||
time.sleep(2) | ||
# 释放定时器资源 | ||
tim.deinit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.