设置关机不关的问题
authord15521469561 <d155214695615@qq.com>
Thu, 27 Apr 2023 01:14:29 +0000 (09:14 +0800)
committerd15521469561 <d155214695615@qq.com>
Thu, 27 Apr 2023 01:14:29 +0000 (09:14 +0800)
增加协议

3.code/1.watch/2.code/appWechat.py
3.code/1.watch/2.code/constants.py
3.code/1.watch/2.code/main_1.py
3.code/1.watch/2.code/mgr.py
3.code/1.watch/2.code/protocol.py
3.code/1.watch/2.code/ui.py
3.code/1.watch/2.code/ui_setting.py

index 6a09acc..6ce5c1d 100644 (file)
@@ -487,7 +487,6 @@ wechat_popup_title.set_text("你有新的微聊消息")
 wechat_popup_title.set_long_mode(lv.label.LONG.WRAP)
 wechat_popup_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
 wechat_popup_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-#信息弹窗
 class NewWechatPopupScreen(Screen):
     NAME = "wechat_popup"
     def __init__(self):
@@ -683,57 +682,6 @@ class MESSAGE_ProtoCol(ProtoCol):
         EventMesh.publish("wechat_updata_list_show")
             
       
-#微聊弹窗
-
-wechat_popup_screen = lv.obj()
-wechat_popup = lv.obj(wechat_popup_screen)
-wechat_popup.center()
-wechat_popup.set_size(240, 320)
-wechat_popup.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-wechat_popup_title = lv.label(wechat_popup)
-wechat_popup_title.set_pos(0, 150)
-wechat_popup_title.set_size(240, 40)
-wechat_popup_title.set_text("你有新的微聊消息")
-wechat_popup_title.set_long_mode(lv.label.LONG.WRAP)
-wechat_popup_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-wechat_popup_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-#信息弹窗
-class NewWechatPopupScreen(Screen):
-    NAME = "wechat_popup"
-    def __init__(self):
-        super().__init__()
-        self.meta = wechat_popup_screen
-
-    def done_left_to_right(self):
-        EventMesh.publish("wechat_updata_list_show")
-        EventMesh.publish("load_screen", {"screen": "wechat"})
-
-    def done_right_to_left(self):
-        EventMesh.publish("wechat_updata_list_show")
-        EventMesh.publish("load_screen", {"screen": "wechat"})
-
-    def done_bottom_to_top(self):
-        EventMesh.publish("wechat_updata_list_show")
-        EventMesh.publish("load_screen", {"screen": "wechat"})
-
-    def done_top_to_bottom(self):
-        EventMesh.publish("wechat_updata_list_show")
-        EventMesh.publish("load_screen", {"screen": "wechat"})
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def done_click(self):
-        EventMesh.publish("wechat_updata_list_show")
-        EventMesh.publish("load_screen", {"screen": "wechat"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
 
 
     
index 480e1cf..c2f04ac 100644 (file)
@@ -56,6 +56,12 @@ class PROTOCOL:
     UPLOAD_SEND = "UPLOAD_SEND"
     UPLOAD_RECV = "UPLOAD_RECV"
 
+    CENTER_SEND = "CENTER_SEND"
+    CENTER_RECV = "CENTER_RECV"
+
+    MONITOR_SEND = "MONITOR_SEND"
+    MONITOR_RECV = "MONITOR_RECV"
+
 class EVENT:
     CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND"
     START_LOCATION = "START_LOCATION" 
index 25b174d..b0c4d15 100644 (file)
@@ -51,7 +51,7 @@ if __name__ == '__main__':
     print("init3:{}".format(utime.localtime()))
     from ext.btn_device_ec800m import BtnDevice
     from ext.protocol import LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,UPLOAD_ProtoCol,TEMP_ProtoCol,DLT_ProtoCol,\
-        WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol
+        WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol
     import ext.mgr as mgr
     print("init1:{}".format(utime.localtime()))
     import ext.ui as _ui
@@ -192,6 +192,7 @@ if __name__ == '__main__':
     pcr.add_support(TEMP_ProtoCol())
     pcr.add_support(DLT_ProtoCol())
     pcr.add_support(UPLOAD_ProtoCol())
+    pcr.add_support(MONITOR_ProtoCol())
     sm = SockManager()
     sm.add_support_resolver(pcr)
     app.append_manager(sm)
index 9afa67b..307b888 100644 (file)
@@ -440,8 +440,9 @@ def voice_callback(args):
         tmp = []
         tmp = args[6]
         find_num = tmp[0]
-        b = tmp.isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了
-        if find_num != 0 and size_len > 11:
+        b = tmp[0].isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了 判断号码是否大于11位数,如果大于11位数 并且第一个字符是数字就按照最后11位做存储
+
+        if b == True and size_len > 11:
             tmp = tmp[size_len-11:]
         EventMesh.publish("load_screen", {"screen": "incoming_call","meta":str(tmp)})
 
@@ -451,8 +452,8 @@ def voice_callback(args):
         tmp = []
         tmp = args[6]
         find_num = tmp[0]
-        b = tmp.isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了
-        if find_num != 0 and size_len > 11:
+        b = tmp[0].isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了
+        if b == True and size_len > 11:
             tmp = tmp[size_len-11:]
         EventMesh.publish("load_screen", {"screen": "on_call","meta":str(tmp)})
 
@@ -826,10 +827,11 @@ class DeviceInfoManager(Abstract):
                             self.HR_Onestate = 1
                       
                         elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
-                           
+                            print("stop_heart Onec ")
                             if self.Hr_Need_Open == 1:#需要关闭心率测量
                                 EventMesh.publish(constants.EVENT.STOP_HEART)
                                 heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                                print("stop_heart heart_value:{}".format(heart_value))
                                 if heart_value > 50 and heart_value != None:
                                     EventMesh.publish("set_old_hr_data",heart_value)
                                     EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
@@ -1576,24 +1578,24 @@ class getOldHrDataManager(Abstract):
         self.oldHr = 0
         self.oldspo2 = 0
         self.read_data = {}
-        # check_json= ql_fs.path_exists("/ext/static/storage_file/config.json")
-        # if check_json == True :
-        #     with open("/ext/static/storage_file/config.json","r") as fd:#音频文件编号
-        #         self.read_data = ujson.load(fd)
-        #         if self.read_data != {}:
-        #             b = str("old_hr") in self.read_data.keys()
-        #             if b == True:
-        #                 self.oldHr = self.read_data["old_hr"]  
-        #             else:
-        #                 self.oldHr = 0
-        #             old_spo2 = str("old_spo2") in self.read_data.keys()
-        #             if old_spo2 == True:
-        #                 self.oldspo2 = self.read_data["old_spo2"]  
-        #             else:
-        #                 self.oldspo2 = 0
-        #         else:
-        #             self.oldHr = 0
-        #             self.oldspo2 = 0
+        check_json= ql_fs.path_exists("/ext/static/storage_file/config.json")
+        if check_json == True :
+            with open("/ext/static/storage_file/config.json","r") as fd:#音频文件编号
+                self.read_data = ujson.load(fd)
+                if self.read_data != {}:
+                    b = str("old_hr") in self.read_data.keys()
+                    if b == True:
+                        self.oldHr = self.read_data["old_hr"]  
+                    else:
+                        self.oldHr = 0
+                    old_spo2 = str("old_spo2") in self.read_data.keys()
+                    if old_spo2 == True:
+                        self.oldspo2 = self.read_data["old_spo2"]  
+                    else:
+                        self.oldspo2 = 0
+                else:
+                    self.oldHr = 0
+                    self.oldspo2 = 0
 
     def post_processor_after_instantiation(self):
         EventMesh.subscribe("set_old_hr_data", self.save_hr_value)
index 88c9352..2108ffd 100644 (file)
@@ -786,7 +786,71 @@ class UPLOAD_ProtoCol(ProtoCol):
         with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
             ujson.dump(storage_tmp,fd)
         EventMesh.publish(constants.PROTOCOL.UPLOAD_SEND)
-        
+
+#设置快捷号码
+class UPLOAD_ProtoCol(ProtoCol):
+    """设置快捷号码"""
+    TYPE = "CENTER"
+    def send(self, event, msg):
+        # [XT*334588000000156*0004*temp]
+        send_data = "SZKW*%s*0006*CENTER"%(self.imei)
+        MD5_SIGN = self.pack_MD5_head(send_data)
+        data = "[%s%s]"%(str(MD5_SIGN),send_data)
+        print("UPLOAD:data:%s"%(data))
+        # 通过socket发送到服务器端
+        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+    def recv(self, event, msg):
+        """
+        @param event:
+        @param msg: 接收到的下行数据
+        """
+        # b'[SZKW*867387060319166*000A*UPLOAD,600]'
+        # print("DLT_ProtoCol RECV msg:".format(msg))
+        msg = msg[1:-1]
+        msg_tmp = msg.decode('ascii')
+        msg_tmp = msg_tmp.split(',')
+        msg_tmp = msg_tmp[1]
+        print("UPLOAD_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
+        center_dial = str(msg_tmp)
+        storage_tmp = EventMesh.publish("get_storage_data")
+        storage_tmp["center_dial"] = center_dial
+        EventMesh.publish("set_storage_data", storage_tmp)
+        with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
+            ujson.dump(storage_tmp,fd)
+        EventMesh.publish(constants.PROTOCOL.CENTER_SEND)  
+
+#呼叫快捷电话号码
+import voiceCall
+class MONITOR_ProtoCol(ProtoCol):
+    """呼叫快捷号码"""
+    TYPE = "MONITOR"
+    def send(self, event, msg):
+        # [XT*334588000000156*0004*MONITOR]
+        send_data = "SZKW*%s*0007*MONITOR"%(self.imei)
+        MD5_SIGN = self.pack_MD5_head(send_data)
+        data = "[%s%s]"%(str(MD5_SIGN),send_data)
+        print("MONITOR:data:%s"%(data))
+        # 通过socket发送到服务器端
+        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+    def recv(self, event, msg):
+        """
+        @param event:
+        @param msg: 接收到的下行数据
+        """
+        # b'[SZKW*867387060319166*000A*MONITOR]'
+        self.read_data = {}
+        self.read_data = EventMesh.publish("get_storage_data")
+        if self.read_data != {}:
+            b = str("center_dial") in self.read_data.keys()
+            if b == True:
+                contact = self.read_data["center_dial"]
+                if len(contact) > 0:
+                    print("MONITOR RECV msg:{} {}".format(contact,type(contact)))
+                    EventMesh.publish("save_phonenum", contact)  
+                    voiceCall.callStart(contact)
+        EventMesh.publish(constants.PROTOCOL.MONITOR_SEND)  
   
 class ProtoColResolver(object):
     def __init__(self):
index 52a48df..c984738 100644 (file)
@@ -928,10 +928,10 @@ class PhoneScreen(Screen):
         
     def show_num(self):
         len_t = len(self.phone_list)*40
-        if len_t > 235:
-            len_t = 235
+        if len_t > 230:
+            len_t = 230
         phone_label.set_size(len_t,45)
-        phone_label.set_pos(235-len_t,60)
+        phone_label.set_pos(230-len_t,60)
         phone_label.set_text(self.phone_num)
 
     def done_return(self):
@@ -1112,7 +1112,7 @@ class CallLogScreen(Screen):
                 j = 0
                 if b == True:
                     for i in range(len(self.phonebook)): #字典 key value
-                        #'001:邓雪英':15521469561
+                        #'001:':15521469561
                         name = self.phonebook[phonebook_keys[j]]
                         name_value = phonebook_keys[j]
                         number_tmp = str(phonnum)
@@ -1185,7 +1185,7 @@ class DialingScreen(Screen):
         super().__init__()
         self.meta = dialing_screen
         hangup_imgbtn.add_event_cb(lambda e: self.hangup(e),
-                                     lv.EVENT.CLICKED, None)
+                                    lv.EVENT.CLICKED, None)
         self.call_log = {}
         self.call_log_value = {}
         self.read_call_log = {}
@@ -1307,7 +1307,7 @@ msg_list_t_done_img.set_src("E:/static/IMAGE_NOTICE_NONE.jpg")
 msg_list_t_done_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 no_msg_text = lv.label(msg_list_t)
-no_msg_text.set_pos(0, 200)
+no_msg_text.set_pos(0, 210)
 no_msg_text.set_size(240, 40)
 no_msg_text.set_text("暂无信息")
 no_msg_text.set_long_mode(lv.label.LONG.WRAP)
@@ -1388,7 +1388,7 @@ message_full.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
 message_full_label = lv.label(message_full)
 message_full_label.set_pos(0, 100)
 message_full_label.set_size(240, 40)
-message_full_label.set_text("消息已满,是否清除所有?")
+message_full_label.set_text("信息已满,是否清除所有?")
 message_full_label.set_long_mode(lv.label.LONG.WRAP)
 message_full_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
 message_full_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
@@ -1707,12 +1707,12 @@ class HeartrateScreen(Screen):
         if self.point > 60: #测20s
             self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
             if self.heart_value > 50:
+                EventMesh.publish("set_old_hr_data",self.heart_value)
                 EventMesh.publish(constants.PROTOCOL.HEART_SEND,self.heart_value)
             if self.heart_value != 0:
                 heartrate_start_label.set_text(" ")
-                heartrate_bpm_label.set_text("{}  bpm".format(self.heart_value))
+                heartrate_bpm_label.set_text("{}bpm".format(self.heart_value))
                 heartrate_done_label.set_text("测量完成")
-                EventMesh.publish("set_old_hr_data",self.heart_value)
             else:
                 heartrate_start_label.set_text("退出,请重新测量")
 
@@ -1924,10 +1924,10 @@ class IncomingCallScreen(Screen):
         EventMesh.publish("call_log_update_show_list")
 
         self.call_timer.start(6000, 1, self.call_timer_cb)
-        self.aud.play(1, 0, 'E:/static/R_CALL_mp3.mp3')  #播放来电铃声
+        self.aud.play(1, 1, 'E:/static/R_CALL_mp3.mp3')  #播放来电铃声
 
     def call_timer_cb(self,e):
-       self.aud.play(1, 0, 'E:/static/R_CALL_mp3.mp3')  #播放来电铃声
+       self.aud.play(1, 1, 'E:/static/R_CALL_mp3.mp3')  #播放来电铃声
 
     def answer(self,e):
         self.call_timer.stop()
@@ -2558,6 +2558,7 @@ class Spo2Screen(Screen):
             self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
             # print("ui self.spo2_value :{}".format(self.spo2_value))
             if self.spo2_value > 85 and self.spo2_value != None:
+                EventMesh.publish("set_old_spo2_data",self.spo2_value)
                 EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,self.spo2_value)
             spo2_label.set_text("{} %".format(self.spo2_value))
             if self.spo2_value == 0:
@@ -2572,10 +2573,10 @@ class Spo2Screen(Screen):
                 time = EventMesh.publish("screen_get_time")
                 time_year = time[4]
                 time_month = time[2]
-                time_time ="   {}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通话时间
+                time_time ="  {}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通话时间
                 spo2_last_time.set_text(str(time_year)+str(time_month)+str(time_time))
             
-            EventMesh.publish("set_old_spo2_data",self.spo2_value)
+            
 
             self.timer.stop()
             self.point = 0
@@ -3257,14 +3258,14 @@ class UIFINDScreen(Screen):
 
     def initialization(self):
         self.FIND_timer.start(3000, 1, self.FIND_timer_cb)
-        self.aud.play(1, 0, 'E:/static/audio_audio_haixiu.mp3')  #播放声音
+        self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3')  #播放声音
         
     def post_processor_after_instantiation(self):
         pass
     def post_processor_after_initialization(self):
         pass
     def FIND_timer_cb(self, *args):
-        self.aud.play(1, 0, 'E:/static/audio_audio_haixiu.mp3') 
+        self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3') 
         self.FIND_timer_count += 1
         if self.FIND_timer_count > 40: #120秒
             self.stop_FIND()
index 317d14c..c908405 100644 (file)
@@ -833,6 +833,7 @@ class RestoreScreen(Screen):
         restore_confirm.add_event_cb(lambda e: self.confirm(e),lv.EVENT.CLICKED, None)
         restore_cancel.add_event_cb(lambda e: self.concel(e),lv.EVENT.CLICKED, None)
         
+
     def confirm(self, e):
         ret = 0
         ret = ql_fs.path_exists("/ext/static/storage_file")#电话本
@@ -841,9 +842,7 @@ class RestoreScreen(Screen):
             ql_fs.mkdirs("/ext/static/storage_file")
         # [XT*334588000000156*0003*DLT]
         EventMesh.publish(constants.PROTOCOL.DLT_SEND)
-        dlt_flag = EventMesh.publish("get_dlt_flag")
-        if dlt_flag == 1:
-            Power.powerRestart()
+        
         
         # EventMesh.publish("load_screen", {"screen": "setting"})
 
@@ -934,15 +933,14 @@ poweroff_label.set_size(240, 20)
 poweroff_label.set_pos(0,120)
 poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
 
-poweroff_confirm = lv.img(poweroff)
-poweroff_confirm.set_size(176, 46)
-poweroff_confirm.set_pos(32, 150)
-poweroff_confirm.set_src("E:/static/off_icon.png")
-poweroff_confirm.add_flag(lv.obj.FLAG.CLICKABLE)
-poweroff_confirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-poweroff_confirm.set_ext_click_area(20)
+poweroff_confirm_img = lv.img(poweroff)
+poweroff_confirm_img.set_size(176, 46)
+poweroff_confirm_img.set_pos(32, 150)
+poweroff_confirm_img.set_src("E:/static/off_icon.png")
+poweroff_confirm_img.add_flag(lv.obj.FLAG.CLICKABLE)
+poweroff_confirm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
-poweroff_confirm_label = lv.label(poweroff_confirm)
+poweroff_confirm_label = lv.label(poweroff_confirm_img)
 poweroff_confirm_label.set_text("关机")
 poweroff_confirm_label.align(lv.ALIGN.CENTER, 0, 0)
 poweroff_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
@@ -968,7 +966,7 @@ class PoweroffScreen(Screen):
         self.meta = poweroff_screen
         self.timer = osTimer()
         self.button_flag = 0
-        poweroff_confirm.add_event_cb(lambda e: self.confirm(e),lv.EVENT.CLICKED, None)
+        poweroff_confirm_img.add_event_cb(lambda e: self.confirm(e),lv.EVENT.CLICKED, None)
         poweroff_return.add_event_cb(lambda e: self.concel(e),lv.EVENT.CLICKED, None)
 
     def initialization(self):