6 Commits
Author SHA1 Message Date
linyimin 5bde549d91 update: version 2026-09-04 11:11:41 +08:00
linyimin d96ca4d031 fix: 调整气压值 2026-09-02 14:19:04 +08:00
linyimin ced66682ed fix: 去除3秒内只能射箭一次的限制 2026-09-02 14:10:46 +08:00
linyimin a09b45738a fix: camera flip 2026-09-02 13:43:16 +08:00
linyimin e4d8454947 fix: update version 2026-09-02 11:26:44 +08:00
linyimin c09189332d fix: 摄像头翻转 2026-09-02 11:25:33 +08:00
5 changed files with 33 additions and 19 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
id: t11 id: t11
name: t11 name: t11
version: 2.15.35 version: 3.0.5
author: t11 author: t11
icon: '' icon: ''
desc: t11 desc: t11
+17 -1
View File
@@ -8,6 +8,15 @@ import threading
import config import config
from logger_manager import logger_manager from logger_manager import logger_manager
_USE_CV = False
try:
import cv2
import numpy as np
from maix import image as _maix_image
_USE_CV = True
except ImportError:
pass
class CameraManager: class CameraManager:
"""相机管理器(单例)""" """相机管理器(单例)"""
@@ -57,6 +66,12 @@ class CameraManager:
with self._camera_lock: with self._camera_lock:
if self._camera is None: if self._camera is None:
self._camera = camera.Camera(width, height) self._camera = camera.Camera(width, height)
v_flip = getattr(config, 'CAMERA_V_FLIP', False)
h_mirror = getattr(config, 'CAMERA_H_MIRROR', False)
if v_flip:
self._camera.vflip(1)
if h_mirror:
self._camera.hmirror(1)
return self._camera return self._camera
@@ -101,7 +116,8 @@ class CameraManager:
with self._camera_lock: with self._camera_lock:
if self._camera is None: if self._camera is None:
self.init_camera() self.init_camera()
return self._camera.read() frame = self._camera.read()
return frame
def show(self, image): def show(self, image):
""" """
+2
View File
@@ -15,6 +15,8 @@ LOCAL_FILENAME = APP_DIR + "/main_tmp.py"
# 相机初始化分辨率(CameraManager / main.py 使用) # 相机初始化分辨率(CameraManager / main.py 使用)
CAMERA_WIDTH = 640 CAMERA_WIDTH = 640
CAMERA_HEIGHT = 480 CAMERA_HEIGHT = 480
CAMERA_V_FLIP = True # 摄像头垂直翻转(上下颠倒时设为 True)
CAMERA_H_MIRROR = True # 摄像头水平镜像(左右反了时设为 True)
# 三角形检测缩图比例:默认按相机最长边缩到 1/2(性能更稳;可按需调整) # 三角形检测缩图比例:默认按相机最长边缩到 1/2(性能更稳;可按需调整)
# 取值范围建议 (0.25 ~ 1.0]1.0 表示不缩图 # 取值范围建议 (0.25 ~ 1.0]1.0 表示不缩图
+12 -16
View File
@@ -136,6 +136,7 @@ def cmd_str():
sync_system_time_from_4g() sync_system_time_from_4g()
# 2.1 WiFi 热点配网兜底:仅当 STA 与 4G 均不可用时起 AP + HTTP;提交后删 /boot/wifi.ap、建 wifi.sta 并 reboot # 2.1 WiFi 热点配网兜底:仅当 STA 与 4G 均不可用时起 AP + HTTP;提交后删 /boot/wifi.ap、建 wifi.sta 并 reboot
_ota_pending_path = f"{config.APP_DIR}/ota_pending.json"
try: try:
from wifi_config_httpd import maybe_start_wifi_ap_fallback from wifi_config_httpd import maybe_start_wifi_ap_fallback
@@ -286,12 +287,13 @@ def cmd_str():
logger.info("系统准备完成...") logger.info("系统准备完成...")
last_adc_trigger = 0 last_adc_trigger = 0
trigger_adc_val = 0 # 触发时的气压值,气压需降回此值以下才能再次触发
# 读取一次ADC初始值,防止开机时传感器已有压力导致误触发 # 读取一次ADC初始值,防止开机时传感器已有压力导致误触发
enable_check = True
try: try:
last_adc_val = hardware_manager.adc_obj.read() last_adc_val = hardware_manager.adc_obj.read()
except Exception: except Exception:
last_adc_val = 0 last_adc_val = 0
peak_adc_val = 0 # 当前周期内的压力峰值
# 气压采样:减少日志频率(每 N 个点输出一条),避免 logger.debug 拖慢采样 # 气压采样:减少日志频率(每 N 个点输出一条),避免 logger.debug 拖慢采样
PRESSURE_BATCH_SIZE = 100 PRESSURE_BATCH_SIZE = 100
@@ -381,22 +383,16 @@ def cmd_str():
pressure_max = adc_val pressure_max = adc_val
if len(pressure_buf) >= PRESSURE_BATCH_SIZE: if len(pressure_buf) >= PRESSURE_BATCH_SIZE:
_flush_pressure_buf("batch") _flush_pressure_buf("batch")
# 峰值检测:压力从峰值下降时触发,确保捕获到最大冲击时刻 # 突变增量检测:压力增量大于300时触发
if adc_val > peak_adc_val: # 触发后需等气压降到触发值以下才重新检测增量
peak_adc_val = adc_val # 更新峰值 if adc_val < trigger_adc_val :
if (peak_adc_val >= config.ADC_TRIGGER_THRESHOLD enable_check = True
and adc_val < peak_adc_val if (adc_val - last_adc_val) > 250 and enable_check:
and last_adc_val >= peak_adc_val):
# 封顶后下降沿触发:peak是最大值,当前值开始下降,且上次值还在peak位置
hardware_manager.start_idle_timer() # 重新计时 hardware_manager.start_idle_timer() # 重新计时
diff_ms = current_time - last_adc_trigger
if diff_ms < 3000:
peak_adc_val = 0 # 去抖期间重置峰值
time.sleep_ms(5)
continue
last_adc_trigger = current_time last_adc_trigger = current_time
peak_adc_val = 0 # 触发后重置峰 trigger_adc_val = adc_val # 记录触发时的气压
# 触发前先把缓存刷出来,避免波形被长耗时处理截断 last_adc_val = adc_val # 更新基准值,防止连续增量误触发
enable_check = False
_flush_pressure_buf("before_trigger") _flush_pressure_buf("before_trigger")
try: try:
@@ -415,7 +411,7 @@ def cmd_str():
camera_manager.show(camera_manager.read_frame()) camera_manager.show(camera_manager.read_frame())
except Exception as e: except Exception as e:
pass pass
time.sleep_ms(5) time.sleep_ms(1)
last_adc_val = adc_val last_adc_val = adc_val
except Exception as e: except Exception as e:
+1 -1
View File
@@ -4,6 +4,6 @@
应用版本号 应用版本号
每次 OTA 更新时,只需要更新这个文件中的版本号 每次 OTA 更新时,只需要更新这个文件中的版本号
""" """
VERSION = '2.18.0' VERSION = '3.0.5'