v1.4实现机器人一起踢乒乓球功能,使用maixcam,离线运行。

This commit is contained in:
myperworld committed 2026-01-01 20:56:41 +08:00
1 parent 650797fe28
commit 9d3aa2684b
13 files changed
+19044 -1041

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
# ------------------------------
# LED配置
# ------------------------------
from maix import camera, display, image, nn, app, sys
from maix import uart, pinmap, time, err, gpio
import traceback
LED_PIN_NAME = "A14"
LED_GPIO_NAME = "GPIOA14"
BLINK_INTERVAL = 500 # LED闪烁间隔(ms)
# ------------------------------
# 全局业务状态变量
# ------------------------------
led = None # LED实例
serial_dev = None # 舵机串口全局变量
previous_millis = 0 # LED闪烁计时
# ------------------------------
# LED控制
# ------------------------------
def init_led():
"""初始化LED引脚"""
global led
try:
err.check_raise(
pinmap.set_pin_function(LED_PIN_NAME, LED_GPIO_NAME),
f"设置LED引脚{LED_PIN_NAME}功能失败"
)
led = gpio.GPIO(LED_GPIO_NAME, gpio.Mode.OUT)
led.value(0) # 初始熄灭
print(f"LED初始化完成:引脚{LED_PIN_NAME}({LED_GPIO_NAME})")
except Exception as e:
print(f"LED初始化失败: {e}")
led = None
def update_led():
"""更新LED状态:改为固定闪烁模式"""
global previous_millis
if led is None:
return
current_millis = time.time_ms()
if current_millis - previous_millis >= BLINK_INTERVAL:
previous_millis = current_millis
led.toggle()