AI按键短按一次长按3s进入sos
authordxy <1731678236qq.com>
Wed, 27 Aug 2025 05:58:29 +0000 (13:58 +0800)
committerdxy <1731678236qq.com>
Wed, 27 Aug 2025 05:58:29 +0000 (13:58 +0800)
闹钟铃声播放增加

2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_VC.py
2.sdk/project/7PIN_1_5/sdk/services/microPython/ports/quectel/core/ai_alarm.py

index 0a2bc21..7e24851 100644 (file)
@@ -796,6 +796,7 @@ class AI_dev(Abstract):
         self.KeyAI_status = 0
         self.KeyAI_timer_count = 0
         self.KeyAI_long_press = 0
+        self.KeySos_long_press = 0
         self.KeyAI_press = 0
         if self.is_wdt == 1:
             self.wdt = WDT(30) #开启看门狗
@@ -1097,6 +1098,8 @@ class AI_dev(Abstract):
         except Exception as e: 
             usys.print_exception(e)
     def pwk_key_timer_cb(self, *args, **kwargs):
+        if EventMesh.publish("get_play_new_voice_state") == 1:
+            EventMesh.publish("set_play_new_voice_state",0)
     #     EventMesh.publish("publish_AI_btnInfo",{"func":self.pwk_key_timer_cb_})
     # def pwk_key_timer_cb_(self) :
         try:
@@ -1145,6 +1148,8 @@ class AI_dev(Abstract):
             
             if self.KeyAI_status == 0:#按下
                 if self.KeyAI_press == 0 :
+                    if EventMesh.publish("get_play_new_voice_state") == 1:
+                        EventMesh.publish("set_play_new_voice_state",0)
                     EventMesh.publish(constants.EVENT.SYSTEM_UP)#唤醒休眠
                     self.extint_AI.disable()
                     self.KeyAI_press = 1
@@ -1164,10 +1169,23 @@ class AI_dev(Abstract):
             self.KeyAI_status = self.extint_AI.read_level()
             self.KeyAI_timer_count +=1
             if self.KeyAI_timer_count >= 10*1 : #长按1s 
+               
                 if self.KeyAI_long_press == 0:
                     self.KeyAI_long_press = 1
                     #EventMesh.publish("AI_key_long_press")
                     EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_long_press})  
+            if self.KeyAI_timer_count >= 10*3 : #长按1s 
+                print("long sos phone:{}".format(self.KeySOS_timer_flag))
+                
+                if self.KeySOS_timer_flag == 1:
+                    self.KeySOS_timer_flag=0
+                    self.KeySos_long_press = 1
+                    self.KeySOS_timer.stop()
+                    get_sos_flag = EventMesh.publish("get_sos_flag")
+                    if get_sos_flag == 0:
+                        EventMesh.publish("set_sos_info_call")
+                    pass
+
             elif self.KeyAI_timer_count >= 10*8:#关机
                 if dev_type == 'jswm' or dev_type == 'jswm_BOX':
                     EventMesh.publish("audio_montage_play",["zhengzaiguanji.mp3"])
@@ -1183,12 +1201,23 @@ class AI_dev(Abstract):
                 if dev_type == "7PIN_BK"or dev_type == "7PIN_BK_EU"or dev_type == "7PIN_BK_coze":
                     key_count = 3
                 if self.KeyAI_timer_count >= key_count: #防抖200ms
+                    if self.KeyAI_long_press == 0:
+                        if self.KeySOS_timer_flag == 0:
+                            self.KeySOS_timer_flag = 1
+                            self.KeySos_long_press = 0
+                            self.KeySOS_timer.start(5000, 0, self.KeySos_timer_cb)
+                    else:
+                        self.KeySOS_timer_flag = 0
+                        self.KeySos_long_press = 0
+                        self.KeySOS_timer.stop()
+                        
                     #EventMesh.publish("AI_key_release")
                     EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_key_release})  
                     self.extint_AI.enable()
                     self.KeyAI_timer.stop()
                     self.KeyAI_timer_count = 0
                     self.KeyAI_press = 0
+                    self.KeyAI_long_press=0
             
         except Exception as e: 
             usys.print_exception(e) 
@@ -1199,6 +1228,17 @@ class AI_dev(Abstract):
         print("AI_key_press")
         EventMesh.publish("AI_key_press")
     def KeySos_timer_cb(self,*argc):
+        print("KeySos_timer_cb!!!!!!!!!!{} {}".format(self.KeySos_long_press,self.KeySOS_timer_flag))
+        
+        if self.KeySos_long_press == 1 and self.KeySOS_timer_flag == 1:
+            self.KeySos_long_press=0
+            self.KeySOS_timer_flag=0
+            get_sos_flag = EventMesh.publish("get_sos_flag")
+            if get_sos_flag == 0:
+                EventMesh.publish("set_sos_info_call")
+        self.KeySos_long_press=0
+        self.KeySOS_timer_flag = 0
+        return
         self.KeySOS_timer_flag = 0
         if self.KeySOS_timer_count >= 3:
             self.KeySOS_timer_count = 0
@@ -1215,11 +1255,11 @@ class AI_dev(Abstract):
         
     def AI_key_release(self):
         print("AI_key_release")
-        self.KeySOS_timer_count +=1
-        print("self.KeySOS_timer_count:{} {}".format(self.KeySOS_timer_count,self.KeySOS_timer_flag))
-        if self.KeySOS_timer_flag == 0:
-            self.KeySOS_timer_flag = 1
-            self.KeySOS_timer.start(5000, 0, self.KeySos_timer_cb)
+        # self.KeySOS_timer_count +=1
+        # print("self.KeySOS_timer_count:{} {}".format(self.KeySOS_timer_count,self.KeySOS_timer_flag))
+        # if self.KeySOS_timer_flag == 0:
+        #     self.KeySOS_timer_flag = 1
+        #     self.KeySOS_timer.start(5000, 0, self.KeySos_timer_cb)
         
         EventMesh.publish("AI_key_release")
         
@@ -3749,7 +3789,7 @@ class AI_VC(Abstract):
             # EventMesh.publish("publish_AI_btnInfo",{"func":self.websocket_deconnect_VC}) 
             # EventMesh.publish("publish_AI_btnInfo",{"func":self.AI_VC_start}) 
         except Exception as e:
-                usys.print_exception(e)   
+            usys.print_exception(e)
         pass
     def check_text_server(self,cmd):
         return -1
index d373f66..c703bfb 100644 (file)
@@ -268,6 +268,7 @@ class AI_alarm(Abstract):
                             self.alarm_array[i]["state"] = "0"
                             print("单次闹钟时间过了{}".format(self.alarm_array))
                             EventMesh.publish("set_storage_config",["alarm_list",self.alarm_array])
+                            EventMesh.publish("GET_NEED_ALARM_REPORT_INFO")
                             continue
                     if (week_now in week_list) or all(c == '0' for c in loop) == 1:
                         if set_hour *60 + set_min == hour_now*60+ minute_now and self.alarm_min_repeat_tmp != minute_now:
@@ -305,14 +306,8 @@ class AI_alarm(Abstract):
                     ringUrl = alarm_TTS_str["ringUrl"]
                     print("{} {} {}".format(AringTimes,alarmMode,shakeType))
                     if alarmMode == "ring": #只响铃
-                        tts_audio = "chenggong.mp3"
-                        if AringTimes == 0:
-                            AringTimes = 1
-                        tts_str = [tts_audio] * AringTimes
-                        print(tts_str)
                         if ringUrl != None:
-                            pass
-                            # EventMesh.publish("play_new_voice",[ringUrl,1])
+                            EventMesh.publish("play_new_voice",[ringUrl,1])
                         if ringUrl == None:
                             base_sentence = "{}".format(name)
                             if AringTimes == 0:
@@ -337,12 +332,8 @@ class AI_alarm(Abstract):
                         EventMesh.publish("play_tts",[final_sentence,1])  #播放tts闹钟文本内容
 
                     elif alarmMode == "both": #响铃加振动
-                        tts_audio = "chenggong.mp3"
-                        if AringTimes == 0:
-                            AringTimes = 1
-                        tts_str = [tts_audio] * AringTimes
                         if ringUrl != None:
-                            # EventMesh.publish("play_new_voice",[ringUrl,1])
+                            EventMesh.publish("play_new_voice",[ringUrl,1])
                             pass
                         if shakeType == "short":
                             EventMesh.publish("set_motor_time",[1,1,5,8,4])#设置马达参数