From: azao <821478748@qq.com> Date: Tue, 17 Mar 2026 01:30:37 +0000 (+0800) Subject: 双按键无屏代码移植到单按键上 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fheads%2FJSWM_single;p=mirrors%2FASR1603_G5.git 双按键无屏代码移植到单按键上 --- diff --git a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py index c1d8fed1..4c8ec9fd 100644 --- a/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py +++ b/2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py @@ -1052,9 +1052,9 @@ class AI_dev(Abstract): else: # self.pwk_key = ExtInt(ExtInt.GPIO41, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb) self.pwk_key = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.pwk_extint_cb) - self.extint_AI = ExtInt(ExtInt.GPIO22,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb) + # self.extint_AI = ExtInt(ExtInt.GPIO26,ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.keyAI_extint_cb) - self.extint_AI.enable() + # self.extint_AI.enable() self.pwk_key_status = 0 self.pwk_key_timer_count = 0 self.pwk_key_long_press = 0 @@ -1063,6 +1063,7 @@ class AI_dev(Abstract): self.pwk_is_double_timer = osTimer() self.double_click_threshold = 1000#双击间隔时间 self.pwk_press_count = 0#按下次数 + self.pwk_timer_running = False # 定时器是否有效 self.last_key_time = 0 # 上一次有效触发时间 self.key_debounce_interval = 20 # 防抖窗口20ms,标准值 #self.pwk_key = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb) @@ -1357,6 +1358,7 @@ class AI_dev(Abstract): # 停止旧定时器,启动长按/单击判定定时器(100ms单次触发,循环靠回调自启) self.pwk_key_timer.stop() + self.pwk_timer_running = True#定时器开始运行 self.pwk_key_timer.start(100, 1, self.pwk_key_timer_cb) print("第一次按下,等待第二次按下") @@ -1368,7 +1370,8 @@ class AI_dev(Abstract): #符合双击阈值:执行双击逻辑 if interval <= self.double_click_threshold: self.pwk_key_timer.stop() # 停止长按定时器(关键:避免触发长按) - self.pwk_key_double_press() # 执行双击业务 + EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_release}) + # self.pwk_key_double_press() # 执行双击业务 print("双击生效") # 重置所有状态 self.pwk_press_count = 0 @@ -1404,6 +1407,8 @@ class AI_dev(Abstract): def pwk_key_timer_cb(self, *args, **kwargs): + if not self.pwk_timer_running: + return EventMesh.publish("set_wait_first_flag",0) EventMesh.publish("set_history_board_flag",0) EventMesh.publish("set_play_new_voice_state",0) @@ -1435,14 +1440,18 @@ class AI_dev(Abstract): key_count = 5 if dev_type == "7PIN_BK" or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze": key_count = 3 - if self.pwk_key_timer_count >= key_count: #防抖200ms + if self.pwk_key_timer_count >= key_count: #防抖 #EventMesh.publish("AI_key_release") - EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_release}) + print("触发单击+1") + self.AI_key_press()#执行单击业务 + self.pwk_key_timer.stop() + print("self.pwk_key_timer.stop状态:{}".format(self.pwk_key_timer.stop())) + self.pwk_timer_running = False self.pwk_key.enable() self.pwk_key_timer_count = 0 self.pwk_key_press = 0 self.pwk_press_count = 0#按下次数 - self.pwk_key_timer.stop() + except Exception as e: usys.print_exception(e)