音量同步
authordxy <1731678236qq.com>
Fri, 29 Aug 2025 08:01:30 +0000 (16:01 +0800)
committerdxy <1731678236qq.com>
Fri, 29 Aug 2025 08:01:30 +0000 (16:01 +0800)
2.sdk/Helios_SDK/services/microPython/ports/quectel/core/motor.py
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/protocol.py

index b0c9bf8..c5c29f6 100644 (file)
@@ -31,6 +31,8 @@ class motorEventManager(Abstract):#马达事件
         self.motor_mode = 0#模式
         _thread.start_new_thread(self.motorInfo_queue_thread, ())
         EventMesh.subscribe("publish_message_event_motorInfo",self.publish_message_event_motorInfo)
+        EventMesh.subscribe("set_motor_time", self.set_motor_time)#设置参数
+        EventMesh.subscribe("close_motor_infor", self.close_motor_infor)#关闭马达和定时器
         pass
 
     def motorInfo_queue_thread(self):
@@ -50,8 +52,7 @@ class motorEventManager(Abstract):#马达事件
         EventMesh.publish("publish_message_event_motorInfo",{"func":self.motor_fun_cb,"data":0})  
         
     def post_processor_after_instantiation(self):
-        EventMesh.subscribe("set_motor_time", self.set_motor_time)#设置参数
-        EventMesh.subscribe("close_motor_infor", self.close_motor_infor)#关闭马达和定时器
+        pass
 
     # msg 0马达使能 1 马达振动时间100ms单位 2 震动次数 3 间隔时间振动 4 是否需要长振 5 长振时间  6间隔时间长振 7长振次数1一次 要为200ms的倍数
     def set_motor_time(self,event,msg):
index 4970621..548633e 100644 (file)
@@ -230,6 +230,7 @@ class AI_UART():
         EventMesh.subscribe("recv_bt_connect_rest",self.recv_bt_connect_rest)
         EventMesh.subscribe("AI_send_bt_ble_switch_toble",self.AI_send_bt_ble_switch_toble)
         EventMesh.subscribe("get_bt_versions",self.get_bt_versions)
+        EventMesh.subscribe("adjust_volume_toBle",self.adjust_volume_toBle)
         EventMesh.subscribe("clear_earphone_record",self.clear_earphone_record)
         self.bt_switch = 0
         self.ble_switch = 0
@@ -411,6 +412,16 @@ class AI_UART():
         json_str  =ujson.dumps(json_data)
         print("clear_earphone_record{}".format(json_str))
         self.send_data(json_str)
+    def adjust_volume_toBle(self,event,msg): #
+
+        json_data = \
+        {
+            "event": "adjust_volume",
+            "data":str(msg)
+        }
+        json_str  =ujson.dumps(json_data)
+        print("adjust_volume_toBle{}".format(json_str))
+        self.send_data(json_str)
 
     def AI_send_bt_ble_switch_toble(self,event,msg):
         # // {
@@ -916,6 +927,11 @@ class AI_dev(Abstract):
         if ble_switch_flag == None:
             ble_switch_flag = "1"
         EventMesh.publish("send_ble_switch_toble",str(ble_switch_flag))
+        vc_tts_volume = EventMesh.publish("get_storage_config","VC_TTS_volume")
+        if vc_tts_volume == None:
+            vc_tts_volume=100
+        EventMesh.publish("adjust_volume_toBle",str(vc_tts_volume))
+
         pass
         print("ble_switch_flag_time_cb!!!!!!!")
     def ntptime_cb(self):
@@ -1964,7 +1980,7 @@ class OTA():
                 if data:
                     try:
                         if data["code"] == 20007:#有新版本
-                            if data["data"]["targetVersion"]  != bt_versions and "fileList"in data["data"] and bt_versions != "":
+                            if data["data"]["targetVersion"]  != bt_versions and "fileList"in data["data"]:
                                 #if len(data["data"]["fileList"]) == 2:
                                     for fileList in data["data"]["fileList"]:
                                         
@@ -2690,8 +2706,11 @@ class AI_VC(Abstract):
         return self.AI_audio_queue
     def get_VC_satrt_flag(self, event, msg):
         return self.VC_satrt_flag
-
-
+    #检查有没有意外打开ai部分功能
+    def chack_vc_start(self):
+        if self.VC_satrt_flag == 0:
+            if self.VC_record_state_flag == 1 or self.AI_client_VC_isconnect == 1 or  self.VC_Play_flag == 1:
+                self.Close()
     def VC_30S_timer_cb(self, *args): #
         EventMesh.publish("publish_AI_btnInfo",{"func":self.VC_30S_timer_cb_}) 
 
@@ -2704,6 +2723,7 @@ class AI_VC(Abstract):
                     self.http_get_config()#获取/更新配置参数
                 except Exception as e:
                     usys.print_exception(e)
+        self.chack_vc_start()#30秒检查一下有没有关闭
     #提交错误id           
     def ud_error(self,error_data):
         response = None
@@ -3885,6 +3905,7 @@ class AI_VC(Abstract):
                             EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
                             self.AI_TTS_str = "了解,音量已经调整,当前音量是{}".format(self.VC_TTS_volume)
                             EventMesh.publish("post_device_state")
+                            EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume)
                         return 0
                 if text.find("音量增大") != -1:
                         print("self.VC_TTS_volume add:{}".format(self.VC_TTS_volume))
@@ -3897,6 +3918,7 @@ class AI_VC(Abstract):
                             self.aud.setVolume(self.VC_TTS_volume //10)
                             EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
                             EventMesh.publish("post_device_state")
+                            EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume)
                             self.AI_TTS_str = "了解,音量已经调大了,当前音量是{}".format(self.VC_TTS_volume)
                             
                         return 0
@@ -3912,6 +3934,7 @@ class AI_VC(Abstract):
                         self.aud.setVolume(self.VC_TTS_volume //10)
                         EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
                         EventMesh.publish("post_device_state")
+                        EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume)
                         self.AI_TTS_str = "好嘞,音量已经调小了,当前音量是{}".format(self.VC_TTS_volume)
                     return 0
                 
@@ -4169,6 +4192,7 @@ class AI_VC(Abstract):
                             self.aud.setVolume(self.VC_TTS_volume //10)
                             EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
                             EventMesh.publish("post_device_state")
+                            EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume)
                             #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
                             #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
                             self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
@@ -4185,6 +4209,7 @@ class AI_VC(Abstract):
                             self.aud.setVolume(self.VC_TTS_volume //10)
                             EventMesh.publish("set_storage_config",["VC_TTS_volume",self.VC_TTS_volume])
                             EventMesh.publish("post_device_state")
+                            EventMesh.publish("adjust_volume_toBle",self.VC_TTS_volume)
                             #EventMesh.publish("audio_montage_play",["peizhichenggong.mp3"])
                             #self.aud.play(1,0,'U:/static/peizhichenggong.mp3')#配置成功
                             self.AI_TTS_str = "配置成功,当前音量 {}".format(self.VC_TTS_volume)
index 6abde46..9bb0fa8 100644 (file)
@@ -2475,6 +2475,7 @@ class IOTWeb_volumeProtoCol(ProtoCol):
             r_volume = msg["data"]
             print("recv volume{} type:{}".format(r_volume,type(msg)))
             EventMesh.publish("SET_TTS_VOLUME",int(r_volume))
+            EventMesh.publish("adjust_volume_toBle",r_volume)
         EventMesh.publish(WEB_CMD_ENUM.VOLUME_S_CMD)
 #下发SOS配置
 class IOTWeb_sos_configProtoCol(ProtoCol):