马达io修改提交
authordxy <1731678236qq.com>
Wed, 27 Aug 2025 09:18:21 +0000 (17:18 +0800)
committerdxy <1731678236qq.com>
Wed, 27 Aug 2025 09:18:21 +0000 (17:18 +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/ai_alarm.py

index cd31639..b0c9bf8 100644 (file)
@@ -9,7 +9,7 @@ import _thread
 import usys
 
 
-motor_pin = Pin(Pin.GPIO20, Pin.OUT, Pin.PULL_PD, 0)
+motor_pin = Pin(Pin.GPIO36, Pin.OUT, Pin.PULL_PD, 0)
 def open_motor():#开马达
     motor_pin.write(1)
 
@@ -55,10 +55,6 @@ class motorEventManager(Abstract):#马达事件
 
     # msg 0马达使能 1 马达振动时间100ms单位 2 震动次数 3 间隔时间振动 4 是否需要长振 5 长振时间  6间隔时间长振 7长振次数1一次 要为200ms的倍数
     def set_motor_time(self,event,msg):
-        open_power = EventMesh.publish("get_power_on_state")#获取开机标识
-        if open_power != None:
-            if open_power == 0:
-                return
         if msg != None:
             self.motor_enable = msg[0]
             if self.motor_enable == 1: #马达使能
@@ -77,7 +73,7 @@ class motorEventManager(Abstract):#马达事件
             close_motor()
             EventMesh.publish("close_motor_infor")#关闭马达和定时器
             return
-        if self.motor_mode == 1:#
+        if self.motor_mode == 1:# 持续振动时间100单位 长振
             if self.motor_total_time > 0:
                 self.motor_total_time-=1
                 if self.motor_total_time > 0:
@@ -86,7 +82,7 @@ class motorEventManager(Abstract):#马达事件
                     close_motor()
                     EventMesh.publish("close_motor_infor")#关闭马达和定时器
                     return
-        elif self.motor_mode == 2:#
+        elif self.motor_mode == 2:# 间隔振动
             # print("self.motor_count",self.motor_count,self.motor_open_time,self.motor_close_time,self.motor_total_time)
             if self.motor_count % (self.motor_open_time) < self.motor_close_time: # 4 4 2 1%4 = 1 2%4 = 2 3%4 = 3
                 open_motor()
index 7e24851..28cb2b6 100644 (file)
@@ -2474,8 +2474,7 @@ class AI_VC(Abstract):
                                                 "bot_name": "柒先生",
                                                 "voice": "x2_xiaowang",
                                                 "lang": "zh-cn"
-                                                }
-                                                ,
+                                                },
                                             "内蒙古话": {
                                                 "bot_name": "柒先生",
                                                 "voice": "x2_xiaobao",
@@ -4227,7 +4226,11 @@ class AI_VC(Abstract):
                         return 0
                     if text.find("版本") != -1 :
                         sourceVersion = versions.Build_Time
-                        self.AI_TTS_str ="Mr-Seven-"+sourceVersion
+                        bt_versions = EventMesh.publish("get_bt_versions")
+                        if bt_versions ==None:
+                            bt_versions = "BT_NONE"
+                        self.AI_TTS_str ="Mr-Seven-"+sourceVersion+bt_versions
+
                         return 0
                     if text.find("服务器地址") != -1 :
                         self.AI_TTS_str ="服务器地址"+self.server_ip
index c703bfb..81c9683 100644 (file)
@@ -121,7 +121,7 @@ class AI_alarm(Abstract):
             self.minute_now_old = minute_now
             # print("AI_alarm_poll222")
             if self.all_states_zero(self.alarm_array) == True:
-                print("_alarm:errror!!!!!!")
+                print("闹钟state字段参数全为0不再检查闹钟列表")
                 return
             try:
                 now_time = utime.localtime()
@@ -321,7 +321,7 @@ class AI_alarm(Abstract):
                             EventMesh.publish("set_motor_time",[1,1,5,8,4])#设置马达参数
                             pass
                         elif shakeType == "long":
-                            EventMesh.publish("set_motor_time",[1,1,5*2*2,8,4])#设置马达参数
+                            EventMesh.publish("set_motor_time",[1,1,5*2,8,4])#设置马达参数
                             pass 
                         base_sentence = "{}".format(name)
                         if AringTimes == 0:
@@ -339,7 +339,7 @@ class AI_alarm(Abstract):
                             EventMesh.publish("set_motor_time",[1,1,5,8,4])#设置马达参数
                             pass
                         elif shakeType == "long":
-                            EventMesh.publish("set_motor_time",[1,1,5*2*2,8,4])#设置马达参数
+                            EventMesh.publish("set_motor_time",[1,1,5*2,8,4])#设置马达参数
                         
                         if ringUrl == None:
                             base_sentence = "{}".format(name)
@@ -829,8 +829,13 @@ class schedule(Abstract):
         print("日程个数 ={}".format(self.schedule_count))
         self.is_schedule = 0
         self.old_minute = 0
+        self.schedule_play_count = 0
+        self.schedule_play_count_tmp=0
         EventMesh.subscribe("AI_schedule_open",self.AI_schedule_open)#
         EventMesh.subscribe("set_schedule_info",self.set_schedule_info)#
+        self.schedule_play_timer = osTimer()
+        self.base_sentence = ""
+        self.schedul_timer_default = 60*5 #默认5分钟提醒一次日程
 
     def set_schedule_info(self,event=None,msg=None):
         print("msg:{}".format(msg))
@@ -888,24 +893,64 @@ class schedule(Abstract):
                 day_now = time_tuple[2]
                 hour_now = time_tuple[3]
                 minute_now = time_tuple[4]
+                # print("当前{}年{}月{}日,设置{}年{}月{}日".format(year_now,month_now,day_now,date_year,date_month,date_day))
+                if year_now != date_year or (year_now == date_year and month_now > date_month) or (year_now == date_year and month_now == date_month and day_now  >date_day): #当前年份大于设置的年份清除这个
+                    print("当前年份大于设置的年份")
+                    self.schedule_array.pop(i)
+                    EventMesh.publish("set_storage_config",["schedule",self.schedule_array])#读取闹钟数组
+                    continue
+                
+                if (year_now == date_year and month_now == date_month and date_day == day_now):
+                    if hour_now*60 + minute_now > set_hour*60 +set_min: #年月日相等 时间分钟大于设置分钟数不再检查当前index了
+                        print("时间过了")
+                        self.schedule_array.pop(i)
+                        EventMesh.publish("set_storage_config",["schedule",self.schedule_array])#读取闹钟数组
+                        continue
+
                 if year_now == date_year and month_now == date_month and date_day == day_now and set_hour == hour_now and set_min == minute_now: #该提醒了
                     alarm_tts_info = alarm
                     self.is_schedule = 1
                     current_index = i
                     break
+
             if self.is_schedule == 1: #需要执行闹钟响铃声
                 self.schedule_array.pop(current_index)
                 alarm_TTS_str = alarm_tts_info["description"]
                 AringTimes  = alarm_tts_info["repeat"]
-                base_sentence = "{}".format(alarm_TTS_str)
+                self.base_sentence = ""
+                self.base_sentence = "{}".format(alarm_TTS_str)
                 if AringTimes == 0:
                     AringTimes = 1
-                repeat_sentence = (base_sentence + ",") * AringTimes  # 重复5次并加逗号分隔
+                repeat_sentence = (self.base_sentence + ",") * AringTimes  # 重复5次并加逗号分隔
                 final_sentence = repeat_sentence.rstrip(",")
-                
+                self.schedule_play_timer.stop()
+                self.schedule_play_count = AringTimes
+                self.schedule_play_count_tmp=1
                 EventMesh.publish("play_tts",[final_sentence,1])  #播放tts闹钟文本内容
                 EventMesh.publish("set_storage_config",["schedule",self.schedule_array])#读取闹钟数组
+                if AringTimes > 1: #只有次数大于2才开定时器播放重复的内容
+                    self.schedule_play_timer.start(self.schedul_timer_default*1000,0,self.shchedu_play_repeat_timer)
+
+                
                 print("日程:{} self.schedule_array :{}".format(final_sentence,self.schedule_array))
+    #循环播放定时器
+    def shchedu_play_repeat_timer(self,*argc):
+        print("播放日程提醒定时器{} {} self.base_sentence:{}".format(self.schedule_play_count,self.schedule_play_count_tmp,self.base_sentence))
+        if self.schedule_play_count <= 1:
+            self.schedule_play_count=0
+            self.schedule_play_count_tmp=0
+            return
+        if len(self.base_sentence) != 0:
+            repeat_sentence = (self.base_sentence + ",") * self.schedule_play_count  # 重复5次并加逗号分隔
+            final_sentence = repeat_sentence.rstrip(",") #截掉最后一个逗号
+            EventMesh.publish("play_tts",[final_sentence,1])  #播放tts闹钟文本内容
+        self.schedule_play_count_tmp+=1
+        if self.schedule_play_count_tmp >= self.schedule_play_count:
+            self.schedule_play_count=0
+            self.schedule_play_count_tmp=0
+            return
+        self.schedule_play_timer.start(self.schedul_timer_default*1000,0,self.shchedu_play_repeat_timer)
+        
 
 
         
\ No newline at end of file