S6:
authordxy15521469561 <1731678236@qq.com>
Wed, 27 Sep 2023 08:11:42 +0000 (16:11 +0800)
committerdxy15521469561 <1731678236@qq.com>
Wed, 27 Sep 2023 08:11:42 +0000 (16:11 +0800)
优化

2.sdk/project/S6/audio/R_ALARM_3.mp3 [deleted file]
2.sdk/project/S6/audio/R_ALARM_NEW.mp3 [new file with mode: 0644]
2.sdk/project/S6/audio/R_WECHAT_RECV.mp3 [new file with mode: 0644]
2.sdk/project/S6/sdk/services/microPython/ports/quectel/core/btn_device_ec800m.py
2.sdk/project/S6/sdk/services/microPython/ports/quectel/core/led.py
2.sdk/project/S6/sdk/services/microPython/ports/quectel/core/main_init.py
2.sdk/project/S6/sdk/services/microPython/ports/quectel/core/mgr.py
2.sdk/project/S6/sdk/services/microPython/ports/quectel/core/protocol.py
2.sdk/project/S6/sdk/services/microPython/ports/quectel/core/ui.py
2.sdk/project/S6/usr/static/R_POWER_OFF_1.mp3 [new file with mode: 0644]
2.sdk/project/S6/usr/static/audio.bin

diff --git a/2.sdk/project/S6/audio/R_ALARM_3.mp3 b/2.sdk/project/S6/audio/R_ALARM_3.mp3
deleted file mode 100644 (file)
index 8c0938f..0000000
Binary files a/2.sdk/project/S6/audio/R_ALARM_3.mp3 and /dev/null differ
diff --git a/2.sdk/project/S6/audio/R_ALARM_NEW.mp3 b/2.sdk/project/S6/audio/R_ALARM_NEW.mp3
new file mode 100644 (file)
index 0000000..3fd8ed2
Binary files /dev/null and b/2.sdk/project/S6/audio/R_ALARM_NEW.mp3 differ
diff --git a/2.sdk/project/S6/audio/R_WECHAT_RECV.mp3 b/2.sdk/project/S6/audio/R_WECHAT_RECV.mp3
new file mode 100644 (file)
index 0000000..3d263db
Binary files /dev/null and b/2.sdk/project/S6/audio/R_WECHAT_RECV.mp3 differ
index 3b5678e..98dbfaa 100644 (file)
@@ -19,7 +19,8 @@ import _thread
 import usys
 
 
-audio_buf =['audio_audio_haixiu', 'R_ALARM_3', 'R_CALL_mp3', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_HSENSOR_RESULT_FAILE', 'R_HSENSOR_RESULT_HR_TITLE', 'R_HSENSOR_RESULT_OK', 'R_HSENSOR_SPO2_TITLE', 'R_HSENSOR_TEMP_TITLE', 'R_NO_SET_SOS_DIAL', 'R_NO_SIM', 'R_POWER_OFF_1', 'R_READ_STEP_0', 'R_READ_STEP_1', 'R_READ_STEP_2', 'R_READ_STEP_3', 'R_READ_STEP_4', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_MIN', 'R_READ_TIME_ZHENG', 'R_SIM_CONNECT', 'R_SIM_FAILE', 'R_SOS_ALERT', 'R_TSENSOR_RESULT_VALUE_DOT', 'R_UNREAD_WECHAT']
+audio_buf = ['audio_audio_haixiu', 'R_ALARM_NEW', 'R_CALL_mp3', 'R_CHARGE_FULL', 'R_CHARGE_IN', 'R_CHARGE_OUT', 'R_HSENSOR_RESULT_FAILE', 'R_HSENSOR_RESULT_HR_TITLE', 'R_HSENSOR_RESULT_OK', 'R_HSENSOR_SPO2_TITLE', 'R_HSENSOR_TEMP_TITLE', 'R_NO_SET_SOS_DIAL', 'R_NO_SIM', 'R_POWER_OFF_1', 'R_READ_STEP_0', 'R_READ_STEP_1', 'R_READ_STEP_2', 'R_READ_STEP_3', 'R_READ_STEP_4', 'R_READ_TIME_0', 'R_READ_TIME_1', 'R_READ_TIME_2', 'R_READ_TIME_3', 'R_READ_TIME_4', 'R_READ_TIME_5', 'R_READ_TIME_6', 'R_READ_TIME_7', 'R_READ_TIME_8', 'R_READ_TIME_9', 'R_READ_TIME_MIN', 'R_READ_TIME_ZHENG', 'R_SIM_CONNECT', 'R_SIM_FAILE', 'R_SOS_ALERT', 'R_TSENSOR_RESULT_VALUE_DOT', 'R_UNREAD_WECHAT', 'R_WECHAT_RECV']
+
 class call:
     CALL_OUT = 1
     CALL_IN = 2
@@ -29,8 +30,12 @@ class call:
 class intervManager(Abstract):
     def __init__(self):
         self.timer = osTimer()
-
+        self.timer1 = osTimer()
         self.pwk_timer = osTimer()
+        self.sos_timer1 = osTimer()
+        self.timer1_sos = osTimer()
+        self.pwk_timer1 = osTimer()
+        self.pwk_timer2 = osTimer()
         self.aud = audio.Audio(0)
         self.aud.set_pa(Pin.GPIO29)
         self.aud.setVolume(11)
@@ -77,12 +82,15 @@ class intervManager(Abstract):
         self.updateTime = 0
         
         self.power_on_flag = 0
+        self.alarm_state = 1
+        self.alarm_timer_count = 0
 
-        self.MXA_MSG = 3
+        self.MXA_MSG = 1
         self.wechat_recode_list = {}
         self.wechat_num = 0
         self.read_data = {}
         self.volum_size = 8 
+        self.phone_num = ''
         self.msg_tmp = ""
         check_txt = ql_fs.path_exists("/usr/static/storage_file/wechat_record.json")
         if check_txt == True :
@@ -126,8 +134,8 @@ class intervManager(Abstract):
         EventMesh.subscribe("play_temp_value", self.play_temp_value)#播放体温数值
 
 
-        EventMesh.subscribe("set_usb_state", self.set_usb_state)#
-        EventMesh.subscribe("get_usb_state", self.get_usb_state)#
+        EventMesh.subscribe("set_usb", self.set_usb_state)#
+        EventMesh.subscribe("get_usb", self.get_usb_state)#
 
         EventMesh.subscribe("play_cur_step_event", self.play_cur_step_event)#
 
@@ -140,6 +148,8 @@ class intervManager(Abstract):
         EventMesh.subscribe("call_test_event", self.call_test_event)#电话拨进响铃测试
 
         EventMesh.subscribe("dial_out_call_center_cb", self.dial_out_call_center_cb)#电话拨出去
+        EventMesh.subscribe("sos_out_call_center_cb", self.sos_out_call_center_cb)#sos拨打
+
 
         EventMesh.subscribe("close_audio_play", self.close_audio_play)#关闭音频
 
@@ -157,9 +167,36 @@ class intervManager(Abstract):
 
 
         EventMesh.subscribe("get_power_on_state", self.get_power_on_state)#获取开机标识
+        EventMesh.subscribe("get_power_off_state", self.get_power_off_state)#获取关机标识
+
 
         EventMesh.subscribe("play_audio_file", self.play_audio_file)#获取播放音频文件
 
+        EventMesh.subscribe("OPEN_ALARM_RING", self.send_alarm_ring)#闹钟到点响铃
+        EventMesh.subscribe("STOP_ALARM_RING", self.stop_alarm_ring)#是否需要关闭闹钟
+
+        EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件
+
+        EventMesh.subscribe("close_led_and_motor", self.close_led_and_motor)#关闭马达和灯按按键的时候
+
+    def close_led_and_motor(self,args,msg):
+        EventMesh.publish("stop_led_timer")#设置参数
+        flag = EventMesh.publish("get_call_state") 
+        if flag != 2:
+            EventMesh.publish("close_motor_infor")#关闭马达和定时器
+
+
+
+    def sos_short_press(self,args,msg):
+        
+        EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话
+        EventMesh.publish("close_audio_play")#强制关闭音频文件播放
+        EventMesh.publish("STOP_FIND_WATCH")#停止查找设备
+        EventMesh.publish("STOP_ALARM_RING")#停止闹钟响铃
+        # EventMesh.publish("play_cur_time_event")#播报当前时间
+            #播报当前时间
+
+
     def play_audio_file(self,event,str_data):#msg 拼接的路径文件
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
         if open_power != None:
@@ -197,13 +234,16 @@ class intervManager(Abstract):
     def publish_find_watch_event_cb(self, *args, **kwargs):#查找设备
         EventMesh.publish("publish_message_event_interInfo",{"func":self.FIND_timer_cb,"data":0})  
 
+    def publish_alarm_ring_event_cb(self, *args, **kwargs):#闹钟响铃
+        EventMesh.publish("publish_message_event_interInfo",{"func":self.Alarm_timer_cb,"data":0})  
+
     def powe_resatrt_down_fun(self, *args):
-        EventMesh.publish("close_motor_infor")#关闭马达和定时器
+        EventMesh.publish("close_led_and_motor")#关闭马达和定时器
         self.aud.stopPlayStream()
         Power.powerRestart()
 
     def power_down_fun(self, *args):
-        EventMesh.publish("close_motor_infor")#关闭马达和定时器
+        EventMesh.publish("close_led_and_motor")#关闭马达和定时器
         self.aud.stopPlayStream()
         Power.powerDown()
         
@@ -223,7 +263,6 @@ class intervManager(Abstract):
 
 
     def close_timer_all(self, event, msg): 
-        EventMesh.publish("stop_led_timer")#设置参数
         self.timer.stop()
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
         power_off = EventMesh.publish("get_power_off_state")#获取开机标识
@@ -255,9 +294,9 @@ class intervManager(Abstract):
         if power_off != None:
             if power_off == 1:
                 return
+        EventMesh.publish("close_led_and_motor")#设置参数
         EventMesh.publish("close_timer_all")#
-        EventMesh.publish("close_wechat_btn_timer")#
-        EventMesh.publish("close_motor_infor")#关闭马达和定时器
+        # EventMesh.publish("close_wechat_btn_timer")#
         EventMesh.publish("set_motor_time",[1,2,200,40,10])#设置马达参数
         self.timer.start(6000, 1, self.publish_call_event_cb)
         str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CALL_mp3"))
@@ -291,16 +330,55 @@ class intervManager(Abstract):
                 return
         print("dial_out_call_center_cb",msg,type(msg))
         if self.call_state == 0:
+            self.phone_num = ''
             EventMesh.publish("close_timer_all")#
-            EventMesh.publish("close_motor_infor")#关闭马达和定时器
+            
             if msg == None:
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
                 # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
             else:
+                self.phone_num = str(msg)
+                self.timer1.start(2000, 0, self.time_out_phone)
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-                voiceCall.callStart(str(msg))
+
+                # voiceCall.callStart(str(msg))
+    def time_out_phone(self, msg):#电话拨出去
+        voiceCall.callStart(self.phone_num)
+
+    def sos_out_call_center_cb(self, event, msg):#sos电话呼叫中
+        open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+        if open_power != None:
+            if open_power == 0:
+                return
+        power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+        if power_off != None:
+            if power_off == 1:
+                return
+        self.sos_phone_num = ''
+        print("sos_out_call_center_cb",msg)
+        if self.call_state == 0:
+            EventMesh.publish("close_timer_all")#
+            if msg == None:
+                str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+                EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+                # EventMesh.publish("play_audio_file",str_data)#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+            else:
+                self.sos_phone_num = msg
+                self.sos_timer1.start(2000, 0, self.sos_call_out_phone)
+                self.timer1_sos.start(30000, 0, self.sos_time_out_phone)
+                str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
+                EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
+                
+    def sos_time_out_phone(self, msg):#30s超时未打通或者信号不好则重新拨打
+        sos_flag = EventMesh.publish("get_sos_flag")
+        if sos_flag == 1:
+            if self.call_state == 0:
+                EventMesh.publish("set_sos_info_call") 
+                
+    def sos_call_out_phone(self, msg):#电话拨出去
+        voiceCall.callStart(self.sos_phone_num)
 
     def call_test_event(self, event, msg):
         voiceCall.callStart(str("10086"))
@@ -312,18 +390,17 @@ class intervManager(Abstract):
         flag = EventMesh.publish("get_call_state") 
         if flag == 2 or flag == 3:#电话通话中 或者呼叫中挂断中断
             if flag == 2:
-                EventMesh.publish("close_motor_infor")#关闭马达和定时器
+                EventMesh.publish("close_motor_infor")#
                 EventMesh.publish("close_timer_all")#
                 voiceCall.callAnswer()
             elif flag == 3:
                 EventMesh.publish("close_motor_infor")#关闭马达和定时器
+                EventMesh.publish("close_timer_all")#
                 voiceCall.callEnd()
     
     def dialing_out_event(self, event, msg):#侧边金属按键挂断电话呼叫中
         flag = EventMesh.publish("get_call_state") 
-       
         if flag == 1:#电话呼叫中
-            EventMesh.publish("close_motor_infor")#关闭马达和定时器
             voiceCall.callEnd()
        
 
@@ -570,40 +647,44 @@ class intervManager(Abstract):
         if open_power != None:
             if open_power == 0:
                 return
+        power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+        if power_off != None:
+            if power_off == 1:
+                return
         flag = EventMesh.publish("get_call_state") 
         
         if msg == 1:
             self.usbState = msg
-            
+            str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE]
+            EventMesh.publish("set_led_time_arg",str_buf)#
             if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断
                 EventMesh.publish("close_timer_all")#
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_IN"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-
-            EventMesh.publish("set_led_time_arg",None)#
             print("charge R_CHARGE_IN")
             
             
         elif msg == 2:
             self.usbState = msg
+            EventMesh.publish("stop_led_timer")#设置参数
+            # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功
+            EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功
             print("charge R_CHARGE_OUT")
             if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断
                 EventMesh.publish("close_timer_all")#
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_OUT"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-            EventMesh.publish("stop_led_timer")#设置参数
-            # EventMesh.publish("set_led_time_arg",[0,1000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.CHARGE_OUT_MODE])#測量成功
-            EventMesh.publish("set_led_time_arg",[1,1,0,led_mode.FLASH_LIGHT_GREEN,4,4,led_mode.CHARGE_OUT_MODE])#測量成功
-
+            
         elif msg == 3:
             self.usbState = msg
             print("charge full")
-            
+            str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE]
+            EventMesh.publish("set_led_time_arg",str_buf)#
             if flag == 3 or flag == 1 or flag == 0:#电话通话中 或者呼叫中挂断中断
                 EventMesh.publish("close_timer_all")#
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_CHARGE_FULL"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-            EventMesh.publish("set_led_time_arg",None)#
+            
 
 
     def get_usb_state(self, event, msg):
@@ -612,21 +693,12 @@ class intervManager(Abstract):
     def open_power_on(self, event, msg): #msg 1 开机 2 关机 3 重启 
         EventMesh.publish("close_timer_all")#
         if msg == 1:
-            self.power_on_flag = 1
-            str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
-            EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-            EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
-            # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
-             # msg 0马达使能 1 马达振动时间100ms单位 2 震动次数 3 间隔时间振动 4 是否需要长振 5 长振时间 6长振次数1一次
-            EventMesh.publish("set_motor_time",[1,2,4,4,2])#设置马达参数
-            self.power_on_flag = 0
-            self.pwk_timer.start(5000,0,self.power_on_cb)
+            self.pwk_timer1.start(3000,0,self.power_on_audio_cb)
+        
         elif msg == 2:
             flag = EventMesh.publish("get_call_state") 
             if flag != 0:#电话呼叫中
                 voiceCall.callEnd()
-            str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
-            EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
             step = EventMesh.publish("get_old_step_value")
             self.read_data = EventMesh.publish("get_storage_data")
             if step != 0:
@@ -635,26 +707,23 @@ class intervManager(Abstract):
             time_tmp = utime.mktime(date_tmp)
             EventMesh.publish("set_storage_config",["old_time",time_tmp])#关机保存一个是时间
             
-            EventMesh.publish("set_motor_time",[1,2,4,4,2])#设置马达参数
-            EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_RED,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
-            self.power_off = 1
-            # EventMesh.publish("set_led_time_arg",[1000,200,10,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#
-            self.timer.start(10000,0,self.publish_power_down_event_cb)
+            self.pwk_timer1.start(3000,0,self.power_off_audio_cb)
         elif msg == 3:
             flag = EventMesh.publish("get_call_state") 
             if flag != 0:#电话呼叫中
                 voiceCall.callEnd()
-            str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
-            EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+            self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
+            # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_POWER_OFF_1"))
+            # EventMesh.publish("play_audio_file",[str_data,0])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
             EventMesh.publish("stop_led_timer")#设置参数
             self.power_off = 1
-            self.timer.start(10000,0,self.publish_resatrt_down_event_cb)
-           
-            #EventMesh.publish("set_led_time_arg",[3000,4000,1,led_mode.LONG_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE])#
+            self.timer.start(8000,0,self.publish_resatrt_down_event_cb)
+
         elif msg == 4:
             flag = EventMesh.publish("get_call_state") 
             if flag != 0:#电话呼叫中
                 voiceCall.callEnd()
+            EventMesh.publish("stop_led_timer")#设置参数
             self.power_off = 1
             ret = 0
             ret = ql_fs.path_exists("/usr/static/storage_file")#
@@ -665,13 +734,38 @@ class intervManager(Abstract):
                 EventMesh.publish(constants.PROTOCOL.DLT_SEND)
             self.aud.stopPlayStream()
             self.timer.start(6*1000,0,self.fun)
+
     def fun(self,*argc):
             self.aud.stopPlayStream()
             Power.powerRestart()
 
     def power_on_cb(self, msg): #msg 开机标识
         self.power_on_flag = 1
-        self.pwk_timer.stop()
+    def clear_power_on_cb(self, msg): #msg 开机标识
+        self.power_on_flag = 0
+
+    def power_on_audio_cb(self,msg):
+        self.power_on_flag = 1
+        print("power_on_audio_cb")
+        self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
+        EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
+        EventMesh.publish("set_motor_time",[1,2,4,4,2])#设置马达参数
+        self.pwk_timer1.start(2000,0,self.clear_power_on_cb)
+        self.pwk_timer2.start(6000,0,self.power_on_cb)
+
+    def power_off_audio_cb(self, msg):
+        print("power_off_audio_cb")
+        self.aud.play(1,0,'U:/static/R_POWER_OFF_1.mp3')
+        EventMesh.publish("set_led_time_arg",[1,2,4*8,led_mode.FLASH_LIGHT_RED,4,2,led_mode.POWER_OFF_MODE])#
+        EventMesh.publish("set_motor_time",[1,2,4,4,2])#设置马达参数
+        self.pwk_timer1.start(2000,0,self.set_power_off_cb)
+        self.pwk_timer2.start(7000,0,self.publish_power_down_event_cb)
+
+    def set_power_off_cb(self, msg):
+        self.power_off = 1
+
+    def get_power_off_state(self, event, msg):
+        return self.power_off
     
     def get_power_on_state(self, event, msg):
         return self.power_on_flag
@@ -680,7 +774,8 @@ class intervManager(Abstract):
     def close_hr_sop2(self, event, msg): #msg 关闭心率血氧测试
         get_hr_state = EventMesh.publish("get_hr_state")
         get_spo2_state = EventMesh.publish("get_spo2_state")
-        if get_hr_state != None and get_spo2_state != None:
+        get_temp_state = EventMesh.publish("get_temp_state")
+        if get_hr_state != None or get_spo2_state != None or get_temp_state != None:
             if get_hr_state != 0:
                 EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 
                 print("sstop hr")
@@ -689,17 +784,24 @@ class intervManager(Abstract):
                 print("stop spo2")
                 EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
                 EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+            if get_temp_state != 0:
+                print("stop temp")
+                EventMesh.publish("set_temp_state",0)
+                EventMesh.publish(constants.EVENT.STOP_TEMP)#手动体温测试
+
 
     def set_manual_measure_mode(self, event, msg): #手动测试 1心率 2 血氧 3 体温
+        get_hr_state = EventMesh.publish("get_hr_state")
+        get_spo2_state = EventMesh.publish("get_spo2_state")
+        get_temp_state = EventMesh.publish("get_temp_state")
         if msg == 1:
-            get_hr_state = EventMesh.publish("get_hr_state")
             if get_hr_state != 1:#不是手动测试直接打断
                 print("set_manual_measure_mode",msg)
                 EventMesh.publish("set_hr_state",1)
                 EventMesh.publish("set_start_measure_time")#设置开始测量的时间戳时间
+                EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN) #停止测试血氧
                 EventMesh.publish(constants.EVENT.START_HEART) #手动心率测试
         elif msg == 2:
-            get_spo2_state = EventMesh.publish("get_spo2_state")
             if get_hr_state == 0:
                 if get_spo2_state != 1:
                     print("set_manual_measure_mode",msg)
@@ -707,7 +809,6 @@ class intervManager(Abstract):
                     EventMesh.publish("set_start_measure_time")#设置开始测量的时间戳时间
                     EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN) #手动血氧测试
         elif msg == 3:
-            get_temp_state = EventMesh.publish("get_temp_state")
             if get_temp_state != 1:
                 print("set_manual_measure_mode",msg)
                 EventMesh.publish("set_temp_state",1)
@@ -757,11 +858,11 @@ class intervManager(Abstract):
             if msg != None:
                 EventMesh.publish("close_timer_all")#
                 if msg > 0:
-                    str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
-                    EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+                    # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+                    # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
                     EventMesh.publish("set_hr_blood_led",2)#测量成功
                     self.temp_value = msg
-                    self.timer.start(2*1000,1,self.play_temp_fun)
+                    self.play_temp_fun(0)
                 else:
                     str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
                     EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
@@ -816,11 +917,11 @@ class intervManager(Abstract):
             if msg != None:
                 EventMesh.publish("close_timer_all")#
                 if msg >= 50:
-                    str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
-                    EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+                    # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+                    # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
                     self.hr_value = msg
                     EventMesh.publish("set_hr_blood_led",2)#测量成功
-                    self.timer.start(2*1000,1,self.play_hr_fun)
+                    self.play_hr_fun(0)
                     
                     
                 else:
@@ -834,11 +935,11 @@ class intervManager(Abstract):
             if msg != None:
                 EventMesh.publish("close_timer_all")#
                 if msg >= 85:
-                    str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
-                    EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+                    # str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_OK"))
+                    # EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
                     EventMesh.publish("set_hr_blood_led",2)#测量成功
                     self.spo2_value = msg
-                    self.timer.start(2*1000,1,self.play_spo2_fun)
+                    self.play_spo2_fun(0)
                 else:
                     str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_HSENSOR_RESULT_FAILE"))
                     EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
@@ -907,7 +1008,6 @@ class intervManager(Abstract):
         flag = EventMesh.publish("get_call_state") 
         if flag != 2:#电话通话中 或者呼叫中挂断中断
             EventMesh.publish("close_timer_all")#
-            EventMesh.publish("stop_led_timer")#设置参数
             mode = 0
             signal = EventMesh.publish("screen_get_sig")
             if signal != None:
@@ -918,26 +1018,22 @@ class intervManager(Abstract):
                         mode = 1
                 else:#未插卡
                     mode = 3
-            if mode == 1:#蓝灯色灯
-                
+            if mode == 1:#白色灯
+                EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_WHITE,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
                 # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_WHITE,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-                EventMesh.publish("set_led_time_arg",[1,1,6,led_mode.FLASH_LIGHT_WHITE,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
                 pass
-            elif mode == 2:#绿色灯
-                
+            elif mode == 2:#蓝灯色灯
+                EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_GREEN,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
                 # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_CONNECT"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-                EventMesh.publish("set_led_time_arg",[1,1,6,led_mode.FLASH_LIGHT_GREEN,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
                 pass
             elif mode == 3:#红灯闪烁
+                EventMesh.publish("set_led_time_arg",[1,2,10,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
                 str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
                 EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-                EventMesh.publish("set_led_time_arg",[1,1,6,led_mode.FLASH_LIGHT_RED,4,2,led_mode.OTHER_MEASURE_MODE])#測量成功
-                # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
-                pass
             pass
     def sim_falied_cb(self, event, msg):#识别卡未联网
         # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_WHITE,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
@@ -958,40 +1054,41 @@ class intervManager(Abstract):
         
     def dial_sos_phone(self, event, msg): #拨打紧急求助电话
         flag = EventMesh.publish("get_call_state")
-        
-        print("dial_sos_phone111")
         if flag == 0:
-            EventMesh.publish("close_timer_all")#
-            EventMesh.publish("close_motor_infor")#关闭马达和定时器
-            if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
-                sos_number = EventMesh.publish("get_dial_sos_number")
-                print("sos_number!!!!!!!",sos_number)
-                if sos_number != None:
-                    if len(sos_number) != 0:
-                        
-                        EventMesh.publish("save_phonename",sos_number[0])
-                        EventMesh.publish("save_phonenum",sos_number[0])
-                        EventMesh.publish("set_sos_num",0)
-                        EventMesh.publish("set_sos_flag",1)
-                        
-                        str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SOS_ALERT"))
-                        EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件
-                        voiceCall.callStart(sos_number[0])
-
-                    else:#未设置sos紧急求助号码
-                        str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+            signal = EventMesh.publish("screen_get_sig")
+            if signal != None:
+                if signal >= 0 and signal <= 31:#有卡 
+                    if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网提示关机
+                        sos_number = EventMesh.publish("get_dial_sos_number")
+                        if sos_number != None:
+                            if len(sos_number) != 0:
+                                    EventMesh.publish("close_timer_all")#
+                                    EventMesh.publish("set_sos_flag",1)
+                            else:#未设置sos紧急求助号码
+                                EventMesh.publish("close_timer_all")#
+                                str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SET_SOS_DIAL"))
+                                EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+                                pass
+                    else:
+                        EventMesh.publish("close_timer_all")#
+                        str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
                         EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-                        pass
-            else:
-                str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_SIM_FAILE"))
-                EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
-        print("dial_sos_phone2222")
+                else:#未插卡
+                    EventMesh.publish("close_timer_all")#
+                    str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_NO_SIM"))
+                    EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+    
+
            
     def send_find_watch(self, event, msg): #发送查找设备指令
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
         if open_power != None:
             if open_power == 0:
                 return
+        power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+        if power_off != None:
+            if power_off == 1:
+                return
         flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
         wechat_state = EventMesh.publish("get_wechat_state")
         if flag == 0 and wechat_state == 0:
@@ -1003,14 +1100,13 @@ class intervManager(Abstract):
             # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
             str_data = 'mp3files={}.mp3'.format(audio_buf.index("audio_audio_haixiu"))
             EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+
     
     def stop_find_watch(self, event, msg): 
         if self.find_state == 1:
             self.find_state = 0
             self.FIND_timer_count = 0
-            EventMesh.publish("stop_led_timer")#设置参数
             self.aud.stopPlayStream()
-            # self.aud.stop()  #播放声音 
             self.timer.stop()
 
     def FIND_timer_cb(self, data):
@@ -1025,6 +1121,44 @@ class intervManager(Abstract):
     def stop_FIND(self) :
         self.timer.stop()
 
+    def send_alarm_ring(self, event, msg): #发送查找设备指令
+        open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+        if open_power != None:
+            if open_power == 0:
+                return
+        power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+        if power_off != None:
+            if power_off == 1:
+                return
+        flag = EventMesh.publish("get_call_state")#在通话或者电话拨进 或者拨出不允许寻找设备
+        wechat_state = EventMesh.publish("get_wechat_state")
+        if flag == 0 and wechat_state == 0:
+            EventMesh.publish("close_timer_all")#
+            self.alarm_state = 1
+            self.alarm_timer_count = 0
+            self.timer.start(3000,1,self.publish_alarm_ring_event_cb)
+            # EventMesh.publish("set_led_time_arg",[1,1,330,led_mode.LONG_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+            # EventMesh.publish("set_led_time_arg",[1000,33000,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
+            str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
+            EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+    
+    def stop_alarm_ring(self, event, msg): #停止闹钟响铃
+        if self.alarm_state == 1:
+            self.alarm_state = 0
+            self.alarm_timer_count = 0
+            # EventMesh.publish("stop_led_timer")#设置参数
+            self.aud.stopPlayStream()  #停止播放
+            self.timer.stop()
+
+    def Alarm_timer_cb(self, data):
+        if self.alarm_state == 1:
+            print("self.alarm_timer_count:{}".format(self.alarm_timer_count))
+            str_data = 'mp3files={}.mp3'.format(audio_buf.index("R_ALARM_NEW"))
+            EventMesh.publish("play_audio_file",[str_data,1])#获取播放音频文件('U:/static/audio.bin',1,1,str_data)
+            self.alarm_timer_count += 1
+            if self.alarm_timer_count > 15: #120秒30s
+                EventMesh.publish("STOP_ALARM_RING")
+    
 
     def play_cur_time_event(self, event, msg): #播放当前时间
         flag = EventMesh.publish("get_call_state") 
@@ -1308,10 +1442,12 @@ class intervManager(Abstract):
                 #录音时间太短
                 return
             else:
-                self.wechat_recode_list["%02d"%(self.wechat_show)] = "read:1"
+                self.wechat_recode_list["%02d"%(self.wechat_show)] = "read:0"
                 self.wechat_recode_list["num"] = self.wechat_show
                 print("self.wechat_recode_list :{}".format(self.wechat_recode_list))
 
+
+
                 with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
                     ujson.dump(self.wechat_recode_list,fd)
                 print("send wechat data!!!!!!!!!!!!!!!!!!!!!")
@@ -1349,7 +1485,7 @@ class intervManager(Abstract):
                 num = 0
                 play_state = 0
                 if len(self.wechat_recode_list) > 1:
-                    num = self.wechat_recode_list["num"]
+                    num = int(self.wechat_recode_list["num"])
                     #print("self.wechat_recode_list1:{}".format(self.wechat_recode_list))
                     if num != 0:
                         last_num = str("%02d"%(num))
@@ -1377,7 +1513,7 @@ class intervManager(Abstract):
                                             self.wechat_recode_list[key] = "read:0"
                                             self.wechat_recode_list["num"] = num 
                                             print("self.wechat_recode_list2:{} num_id:{} num:{}".format(self.wechat_recode_list,num_id,num))
-                                            self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num_id))  #文件名前面要加上路径
+                                            # self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num))  #文件名前面要加上路径
                                             play_state = 1
                                             with open("/usr/static/storage_file/wechat_record.json","w+",encoding="utf-8") as fd:
                                                 ujson.dump(self.wechat_recode_list,fd)
@@ -1389,17 +1525,17 @@ class intervManager(Abstract):
                                 else:
                                     continue
                         #print("play_state:{}".format(play_state))
-                        if play_state == 0:
-                            check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num))#还要检测这个文件是否存在
-                            if check_amr == True:
-                                self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num))  #文件名前面要加上路径
+                        # if play_state == 0:#
+                        check_amr = ql_fs.path_exists("/usr/static/storage_file/{}.amr".format(num))#还要检测这个文件是否存在
+                        if check_amr == True:
+                            self.aud.play(1, 1, '/usr/static/storage_file/{}.amr'.format(num))  #文件名前面要加上路径
 
     def play_unread_wechat_infor(self,event,msg):#未读微聊语音
         if self.wechat_recode_list != None:
             num = 0
             play_state = 0
             if len(self.wechat_recode_list) > 1:
-                num = self.wechat_recode_list["num"]
+                num = int(self.wechat_recode_list["num"])
                 if num != 0:
                     for i in range(len(self.wechat_recode_list)-1):#1 01 02 
                         key = "%02d"%(i+1)
@@ -1424,7 +1560,7 @@ class intervManager(Abstract):
         time_tmp = utime.mktime(date_tmp)
         if state != None:
             if state == 1:
-                EventMesh.publish("set_led_time_arg",[1,1,4,led_mode.FLASH_LIGHT_GREEN,2,1,led_mode.OTHER_MEASURE_MODE])#測量成功
+                EventMesh.publish("set_led_time_arg",[1,2,8,led_mode.FLASH_LIGHT_GREEN,8,4,led_mode.OTHER_MEASURE_MODE])#測量成功
                 # EventMesh.publish("set_led_time_arg",[1000,400,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
                 if self.updateTime == 0:
                     self.updateTime = time_tmp
@@ -1443,33 +1579,8 @@ class intervManager(Abstract):
 
 
 
-
 class resetFactoryUnbindManager(Abstract):#按键按下恢复出厂设置解绑app
-    def __init__(self):
-        self.timer = osTimer()
-        self.aud = audio.Audio(0)
-        self.aud.set_pa(Pin.GPIO29)
-        self.aud.setVolume(11)
-        pass
-        
-    
-    def post_processor_after_instantiation(self):
-        EventMesh.subscribe("reset_factor_setiing", self.reset_factor_setiing)#恢复出厂设置
-    
-    def reset_factor_setiing(self, event, msg):
-        ret = 0
-        ret = ql_fs.path_exists("/usr/static/storage_file")#
-        if ret == True:
-            ql_fs.rmdirs("/usr/static/storage_file")
-            ql_fs.mkdirs("/usr/static/storage_file")
-        if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
-            EventMesh.publish(constants.PROTOCOL.DLT_SEND)
-        self.timer.start(5*1000,0,self.fun)
-
-    def fun(self,*argc):
-        EventMesh.publish("close_motor_infor")#关闭马达和定时器
-        self.aud.stopPlayStream()
-        Power.powerRestart()
+    pass
 
 
 
@@ -1553,7 +1664,7 @@ class BtnDevice(Abstract):
     def post_processor_after_instantiation(self):
         # self.keypad.init()
         # self.keypad.set_callback(self.key_callback)
-        EventMesh.subscribe("sos_short_press", self.sos_short_press)#sos短按事件
+        
         EventMesh.subscribe("close_wechat_btn_timer", self.close_wechat_btn_timer)#来电强制关闭微聊语音
         self.pk.powerKeyEventRegister(self.powerKey_callback)
         
@@ -1568,21 +1679,25 @@ class BtnDevice(Abstract):
 
         key19 = Pin(Pin.GPIO19, Pin.OUT, Pin.PULL_PU, 0)
 
-    def sos_short_press(self,args,msg):
-        EventMesh.publish("interup_call_event")#如果在电话中强制挂断电话
-        EventMesh.publish("close_audio_play")#强制关闭音频文件播放
-        EventMesh.publish("stop_led_timer")#设置参数关闭定时器 同时也关闭所有的灯再开相对应的灯
-        EventMesh.publish("STOP_FIND_WATCH")#停止查找设备
-        # EventMesh.publish("play_cur_time_event")#播报当前时间
-        #播报当前时间
-
 
     def pwk_extint_cb(self,args):#侧边按键
         self.GPIO26_status = self.extint.read_level()
         print('### key20_extint_cb  {} self.GPIO26_status :{}'.format(args,self.GPIO26_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
+        power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+        if power_off != None:
+            if power_off == 1:
+                return
         if self.sosKey_status != 0 and self.WeChatKey_status != 0:
             if self.GPIO26_status == 0:#按下
                 if self.pwkey_press == 0 :
+                    self.wechatKey_timer.stop()
+                    self.pwkey_timer.stop()
+                    self.sosKey_timer.stop()
+                    self.wechatKey_press_count = 0
+                    self.sosKey_press_count = 0
+                    self.sosKey_press = 0
+                    self.wechatKey_press = 0
+                
                     self.pwkey_press = 1
                     self.pwkey_count = 0
                     self.led_state = 0
@@ -1606,43 +1721,25 @@ class BtnDevice(Abstract):
                     self.pwKey_press_count = 0
                     self.led_state = 0
                     return
-                else:
-                    if self.GPIO26_status == 1:#松开
-                        pass
-                        # EventMesh.publish("stop_led_timer")#设置参数
-                
-                    
-                
-
-            
             if self.GPIO26_status == 1:#松开
-                if self.pwkey_count >= 1 and self.pwkey_count <= 5: #防抖100ms
+                if self.pwkey_count >= 1: #防抖100ms
                     self.pwkey_timer.stop()
                     self.pwkey_count = 0
                     self.pwkey_press = 0
                     self.led_state = 0
                     self.pwKey_press_count+=1
                     self.pwkey_timer.start(500, 0, self.pwKey_timeout_cb)#松手超时1s判断
-                else:
-                    self.pwkey_timer.stop()
-                    self.pwkey_count = 0
-                    self.pwkey_press = 0
-                    self.led_state = 0
-                    self.pwKey_press_count = 0
-                    
-                    print("self.pwKey_status!!!!!!!!!!!!!!")
 
     def pwKey_timeout_cb(self, *args):#侧边按键
         if self.pwKey_press_count >= 1:
             self.pwKey_press_count = 0
-            # EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位
-            # open_motor()
-            # self.motor.start(50,0,self.motor_cb)
+            EventMesh.publish("close_led_and_motor")#设置参数
             sos_flag = EventMesh.publish("get_sos_flag")
             if sos_flag == 1:
                 EventMesh.publish("set_sos_flag",0)
                 EventMesh.publish("set_sos_num",0)
                 EventMesh.publish("set_hangup_mode",0)
+
             EventMesh.publish("dialing_out_event")#电话呼叫中
             EventMesh.publish("close_hr_sop2")#
             flag = EventMesh.publish("get_call_state") 
@@ -1650,26 +1747,31 @@ class BtnDevice(Abstract):
                 EventMesh.publish("set_sim_mode")#播報imei号
 
     def sosKey_extint_cb(self,args):
+        
+        power_off = EventMesh.publish("get_power_off_state")#获取关机标识
+        if power_off != None:
+            if power_off == 1:
+                return
         self.sosKey_status = self.sosKey.read_level()
         # print('### key22_extint_cb  {} self.GPIO22_status:{}'.format(args,self.sosKey_status)) # args[0]:gpio号 args[1]:上升沿或下降沿
         if self.WeChatKey_status != 0 and self.GPIO26_status != 0:
             if self.sosKey_status == 0:#按下
                 if self.sosKey_press == 0 :
+                    self.wechatKey_timer.stop()
+                    self.pwkey_timer.stop()
+                    self.sosKey_timer.stop()
+                    self.wechatKey_press_count = 0
                     self.sosKey_press = 1
+                    self.pwkey_press = 0
+                    self.wechatKey_press = 0
                     self.sosKey_long_press = 0
                     self.sosKey_count = 0
                     self.sosKey_timer.start(100, 1, self.publish_soskey_btn_event_cb)
-                    print("key22_extint_cb:self.key22_timer.start!!!!\n")
+                    # print("key22_extint_cb:self.key22_timer.start!!!!\n")
 
     def sosKey_press_cb(self, data):
         '''KEY2:联动屏幕右下角或返回键长按关机'''
         if self.sosKey_press == 1 :
-            # print("self.sosKey_count",self.sosKey_count)
-            # if self.sosKey_count <= 2:
-                # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#未联网不需要录音
-                #     EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
-                # else:
-                #     EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
             self.sosKey_count += 1
             if self.sosKey_count >= 10*3: #长按3s sos拨号
                
@@ -1682,53 +1784,46 @@ class BtnDevice(Abstract):
 
             # print("self.sosKey_count {}",self.sosKey_count)
             if self.sosKey_status == 1:#松开
-                if self.sosKey_count >= 1 and self.sosKey_count <= 5: #防抖100ms
+                if self.sosKey_count >= 1: #防抖100ms
                     self.sosKey_timer.stop()
                     self.sosKey_count = 0
                     self.sosKey_press = 0
                     self.sosKey_press_count+=1
                     self.sosKey_timer.start(500, 0, self.sosKey_timeout_cb)#松手超时1s判断
-                else:
-                    self.sosKey_timer.stop()
-                    self.sosKey_count = 0
-                    self.sosKey_press = 0
-                    self.sosKey_press_count=0
-                    
-                    print("self.sosKey_status!!!!!!!!!!!!!!")
-        # import audio
-        # aud.montage_play('U:/mp3.bin',2,1,'mp3files=1.mp3+2.mp3+3.mp3')
 
     def sosKey_timeout_cb(self, *args):#微聊键
         print("sosKey_press_count!!!!!!!!!!!!!! ",self.sosKey_press_count)
-        if self.sosKey_press_count >= 10:#
+        if self.sosKey_press_count == 10:#
             self.sosKey_press_count = 0
+            EventMesh.publish("close_led_and_motor")#设置参数
             EventMesh.publish("open_power_on", 4)#恢复出厂
             pass
-        elif self.sosKey_press_count >= 6:#
+        elif self.sosKey_press_count == 6:#
             self.sosKey_press_count = 0
-            # EventMesh.publish("set_manual_measure_mode",2)#测量血氧
+            EventMesh.publish("close_led_and_motor")#设置参数
             EventMesh.publish("play_imei_event")#播報imei号
             pass
-        elif self.sosKey_press_count >= 5:
+        elif self.sosKey_press_count == 5:
             self.sosKey_press_count = 0
             # EventMesh.publish("set_manual_measure_mode",3)#测量体温
             pass
-        elif self.sosKey_press_count >= 4:#拨打app快捷号码
+        elif self.sosKey_press_count == 4:#拨打app快捷号码
             self.sosKey_press_count = 0
             # EventMesh.publish("play_center_phone")#拨打快捷号码
             # EventMesh.publish("call_phonebook_three_call")
             pass
-        elif self.sosKey_press_count >= 3:#测试心率
+        elif self.sosKey_press_count == 3:#测试心率
             self.sosKey_press_count = 0
             # EventMesh.publish("set_manual_measure_mode",1)#
             pass
-        elif self.sosKey_press_count >= 2:#播报当前步数
+        elif self.sosKey_press_count == 2:#播报当前步数
             self.sosKey_press_count = 0
+            EventMesh.publish("close_led_and_motor")#
             EventMesh.publish("play_cur_step_event")#
             pass
-        elif self.sosKey_press_count >= 1:#挂断来电 短语音播报
+        elif self.sosKey_press_count == 1:#挂断来电 短语音播报
             self.sosKey_press_count = 0
-            
+            EventMesh.publish("close_led_and_motor")#设置参数
             # EventMesh.publish("call_test_event")
             EventMesh.publish("sos_short_press")#sos短按事件
             pass
@@ -1857,28 +1952,28 @@ class BtnDevice(Abstract):
 
     def wechatKey_timeout_cb(self, *args):#微聊键
         print("wechatKey_timeout_cb!!!!!!!!!!!!!! ",self.wechatKey_press_count)
-        if self.wechatKey_press_count >= 10:#短按十次解绑app
+        if self.wechatKey_press_count == 10:#短按十次解绑app
             self.wechatKey_press_count = 0
             EventMesh.publish("reset_factor_setiing")#恢复出厂设置
             pass
-        elif self.wechatKey_press_count >= 6:#短按六次播报imei号
+        elif self.wechatKey_press_count == 6:#短按六次播报imei号
             self.wechatKey_press_count = 0
             EventMesh.publish("play_imei_event")#播報imei号
             pass
-        elif self.wechatKey_press_count >= 4:#拨打通讯录号码三
+        elif self.wechatKey_press_count == 4:#拨打通讯录号码三
             self.wechatKey_press_count = 0
             EventMesh.publish("call_phonebook_three_call")
             pass
-        elif self.wechatKey_press_count >= 3:#拨打通讯录号码二
+        elif self.wechatKey_press_count == 3:#拨打通讯录号码二
             self.wechatKey_press_count = 0
             EventMesh.publish("call_phonebook_two_call")
             pass
-        elif self.wechatKey_press_count >= 2:#拨打通讯录号码一
+        elif self.wechatKey_press_count == 2:#拨打通讯录号码一
             self.wechatKey_press_count = 0
             EventMesh.publish("call_phonebook_one_call")
            # EventMesh.publish("interup_call_event")#
             pass
-        elif self.wechatKey_press_count >= 1:#播放最后收到的语音
+        elif self.wechatKey_press_count == 1:#播放最后收到的语音
             self.wechatKey_press_count = 0
             call_state = EventMesh.publish("get_call_state") 
             if call_state == 2:#电话拨进需要接听
index 66be3cb..6cedc0c 100644 (file)
@@ -73,35 +73,6 @@ def close_motor():#关闭马达
     motor_pin.write(0)
 
 
-LED_TIMER_OUT = 100 
-class led_mode:
-    LONG_LIGHT_RED = 1
-    LONG_LIGHT_GREEN = 2
-    LONG_LIGHT_WHITE = 3
-    FLASH_LIGHT_RED = 4
-    FLASH_LIGHT_GREEN = 5
-    FLASH_LIGHT_WHITE = 6
-    FLASH_LIGHT_RED_GREEN = 7
-    FLASH_LIGHT_RED_WHITE = 8
-    FLASH_LIGHT_GREEN_WHITE = 9
-    LIGHT_NONE = FLASH_LIGHT_GREEN_WHITE+1
-
-    DEFAULT_LONG_LIGHT_MODE = 0+LIGHT_NONE #默认是关闭
-    OPEN_LONG_LIGHT_MODE = 1+LIGHT_NONE#开启
-    CLOSE_LONG_LIGHT_MODE = 2+LIGHT_NONE#需要关闭
-    INTERVAL_LIGHT_RED  = 3+LIGHT_NONE
-    INTERVAL_LIGHT_GREEN  = 4+LIGHT_NONE
-    INTERVAL_LIGHT_WHITE  = 5+LIGHT_NONE
-
-    OTHER_MEASURE_MODE = 200
-
-    HEALTH_LED_MODE = 201 #健康测试模式
-    WECHAT_LED_MODE = 202 #微聊模式
-    CHARGE_IN_MODE = 203 #充电模式
-    CHARGE_OUT_MODE = 204 #充电已移出
-    CHARGE_FULL_MODE = 205 #充电已满
-
-
 
 MOTOR_TIME = 100
 class motorEventManager(Abstract):#马达事件
@@ -117,7 +88,22 @@ class motorEventManager(Abstract):#马达事件
         _thread.start_new_thread(self.motorInfo_queue_thread, ())
         EventMesh.subscribe("publish_message_event_motorInfo",self.publish_message_event_motorInfo)
         pass
-        
+
+    def motorInfo_queue_thread(self):
+        while True:
+            data = self.motorInfo_queue.get()
+            #print("ledInfo_queue:data = {}".format(data))
+            if data != None:
+                try:
+                    data["func"](data["data"])
+                except Exception as e:
+                    print("ledInfo_queue:ERROR:{}".format(e))
+                    usys.print_exception(e)
+    def publish_message_event_motorInfo(self,event,msg):
+        self.motorInfo_queue.put(msg)
+
+    def publish_motor_event_cb(self, *args, **kwargs):
+        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)#设置参数
@@ -138,11 +124,12 @@ class motorEventManager(Abstract):#马达事件
                 self.motor_close_time = msg[4]#关马达事件100ms
                 self.motor_count = 0
                 self.motor_timer.stop()
+                # print("motor msg",msg)
+                close_motor()
                 self.motor_timer.start(MOTOR_TIME,1,self.publish_motor_event_cb)
 
     def motor_fun_cb(self, data):
         if self.motor_mode == 0 or self.motor_enable == 0:
-            self.motor_timer.stop()
             return
         if self.motor_mode == 1:#
             if self.motor_total_time > 0:
@@ -152,16 +139,20 @@ class motorEventManager(Abstract):#马达事件
                 else:
                     close_motor()
                     EventMesh.publish("close_motor_infor")#关闭马达和定时器
+                    return
         elif self.motor_mode == 2:#
-            self.motor_count+1
+            # 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()
             else:
                 close_motor()
-            if self.motor_count >= self.motor_total_time:
+            if self.motor_count >= self.motor_total_time-1:
                 EventMesh.publish("close_motor_infor")#关闭马达和定时器
+                return
+            self.motor_count+=1
 
     def close_motor_infor(self,event,msg):
+        print("close_motor_infor!!!")
         close_motor()
         self.motor_enable = 0#马达使能
         self.motor_total_time = 0#总的时间
@@ -170,25 +161,42 @@ class motorEventManager(Abstract):#马达事件
         self.motor_count = 0
         self.motor_mode = 0#模式
         self.motor_timer.stop()
-        
-        pass
 
 
-    def motorInfo_queue_thread(self):
-        while True:
-            data = self.motorInfo_queue.get()
-            #print("ledInfo_queue:data = {}".format(data))
-            if data != None:
-                try:
-                    data["func"](data["data"])
-                except Exception as e:
-                    print("ledInfo_queue:ERROR:{}".format(e))
-                    usys.print_exception(e)
-    def publish_message_event_motorInfo(self,event,msg):
-        self.motorInfo_queue.put(msg)
 
-    def publish_motor_event_cb(self, *args, **kwargs):
-        EventMesh.publish("publish_message_event_motorInfo",{"func":self.motor_fun_cb,"data":0})  
+
+LED_TIMER_OUT = 100 
+class led_mode:
+    LONG_LIGHT_RED = 1
+    LONG_LIGHT_GREEN = 2
+    LONG_LIGHT_WHITE = 3
+    FLASH_LIGHT_RED = 4
+    FLASH_LIGHT_GREEN = 5
+    FLASH_LIGHT_WHITE = 6
+    FLASH_LIGHT_RED_GREEN = 7
+    FLASH_LIGHT_RED_WHITE = 8
+    FLASH_LIGHT_GREEN_WHITE = 9
+    LIGHT_NONE = FLASH_LIGHT_GREEN_WHITE+1
+
+    DEFAULT_LONG_LIGHT_MODE = 0+LIGHT_NONE #默认是关闭
+    OPEN_LONG_LIGHT_MODE = 1+LIGHT_NONE#开启
+    CLOSE_LONG_LIGHT_MODE = 2+LIGHT_NONE#需要关闭
+    INTERVAL_LIGHT_RED  = 3+LIGHT_NONE
+    INTERVAL_LIGHT_GREEN  = 4+LIGHT_NONE
+    INTERVAL_LIGHT_WHITE  = 5+LIGHT_NONE
+
+    OTHER_MEASURE_MODE = 200
+
+    HEALTH_LED_MODE = 201 #健康测试模式
+    WECHAT_LED_MODE = 202 #微聊模式
+    CHARGE_IN_MODE = 203 #充电模式
+    CHARGE_OUT_MODE = 204 #充电已移出
+    CHARGE_FULL_MODE = 205 #充电已满
+    POWER_OFF_MODE = 206 #关机模式
+
+
+
+
 
 class ledEventManager(Abstract):#灯事件
     def __init__(self):
@@ -210,6 +218,7 @@ class ledEventManager(Abstract):#灯事件
         self.led_close_time = 0
         self.led_total_time = 0#闪的总时间
         self.led_enable = 0
+        self.led_mode = 0
         self.working_led_mode = None
         self.ledInfo_queue = Queue()
         _thread.start_new_thread(self.ledInfo_queue_thread, ())
@@ -237,6 +246,7 @@ class ledEventManager(Abstract):#灯事件
 
         EventMesh.subscribe("close_led_pin", self.close_led_pin)#读取白灯的电平状态def close_led_pin(self, event, msg):
 
+
     def ledInfo_queue_thread(self):
         while True:
             data = self.ledInfo_queue.get()
@@ -250,8 +260,6 @@ class ledEventManager(Abstract):#灯事件
     def publish_message_event_ledInfo(self,event,msg):
         self.ledInfo_queue.put(msg)
 
-
-
     def publish_led_event_cb(self, *args, **kwargs):
         EventMesh.publish("publish_message_event_ledInfo",{"func":self.led_fun_cb,"data":0})  
 
@@ -271,28 +279,32 @@ class ledEventManager(Abstract):#灯事件
         print("set_hr_blood_led :{}".format(msg))
         if msg != None:
             if msg == 1:
-                EventMesh.publish("set_led_time_arg",[1,2,10*70,led_mode.FLASH_LIGHT_RED_GREEN,10,5,led_mode.HEALTH_LED_MODE])#測量成功
+                EventMesh.publish("set_led_time_arg",[1,2,10*70*2,led_mode.FLASH_LIGHT_RED_GREEN,10,5,led_mode.HEALTH_LED_MODE])#測量成功
                 # EventMesh.publish("set_led_time_arg",[1000,200,300,led_mode.FLASH_LIGHT_RED_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.HEALTH_LED_MODE])#開始測量
             elif msg == 2:
-                EventMesh.publish("set_led_time_arg",[1,1,300,led_mode.FLASH_LIGHT_GREEN,31,10*3,led_mode.OTHER_MEASURE_MODE])#測量成功
+                EventMesh.publish("set_led_time_arg",[1,2,60,led_mode.FLASH_LIGHT_GREEN,60,30,led_mode.OTHER_MEASURE_MODE])#測量成功
                 # EventMesh.publish("set_led_time_arg",[3000,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#測量成功
-            elif msg == 3:
-                EventMesh.publish("set_led_time_arg",[1,1,300,led_mode.FLASH_LIGHT_RED,31,10*3,led_mode.OTHER_MEASURE_MODE])#測量成功
-                # EventMesh.publish("set_led_time_arg",[3000,1000,1,led_mode.LONG_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#測量失敗
+            elif msg == 3:#测量失败
+                EventMesh.publish("stop_led_timer")
+                # EventMesh.publish("set_led_time_arg",[1,1,1,led_mode.FLASH_LIGHT_RED,31,10*3,led_mode.OTHER_MEASURE_MODE])#測量成功
+                pass
+                # EventMesh.publish("set_led_time_arg",[1,1,30,led_mode.FLASH_LIGHT_RED,31,10*3,led_mode.OTHER_MEASURE_MODE])#测量失败
                 #加音频文件
 
     def set_find_watch_led(self, event, msg): #查找设备
         EventMesh.publish("OPEN_FIND_WATCH")#
+       
         # EventMesh.publish("set_led_time_arg",[37000,1000,1,led_mode.LONG_LIGHT_GREEN,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#查找设备绿灯长亮37s
 
     def get_led_state(self, event, msg): #
         return self.timer_state
-    def open_timer(self,msg):
+    def open_timer(self,msg): #msg 0 使能 1总的时间 2 灯模式 3 开启时间 4 关闭时间 
         if msg != None:
             if len(msg) != 0:
                 self.led_total_time = msg[2]#
                 print("open_timer:{}".format(msg))
                 if self.led_total_time != None:
+
                     if self.led_total_time > 0:
                         self.led_enable=msg[0]
                         if self.led_enable != 0:
@@ -306,85 +318,91 @@ class ledEventManager(Abstract):#灯事件
                             if self.timer_state == 0:
                                 self.timer_state = 1
                                 self.timer.stop()
-                                EventMesh.publish("close_led_pin")
+                                # self.timer.start(LED_TIMER_OUT,1,self.led_fun_cb)
                                 self.timer.start(LED_TIMER_OUT,1,self.publish_led_event_cb)
+                
+        
+
 
     def set_led_time_arg(self, event, msg): #msg 
-        print("set_led_time_arg",msg)
+        
         open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+        power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+        print("set_led_time_arg",msg,open_power,power_off)
         if open_power != None:
             if open_power == 0:
                 return
-        usb_in = EventMesh.publish("get_usb_state")#
-        # print("usb_in",usb_in)
-        if usb_in != None:
-            if usb_in == 1 or usb_in == 3:#正在充电或者充电已满都不要被打断
-                if self.timer_state == 1:
-                    self.timer_state = 0
-                    self.timer.stop()
-                if usb_in == 1:
-                    if self.working_led_mode != led_mode.CHARGE_IN_MODE:
-                        str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE]
-                        self.open_timer(str_buf)
-                    self.working_led_mode = led_mode.CHARGE_IN_MODE
-
-                elif usb_in == 3:
-                    if self.working_led_mode != led_mode.CHARGE_FULL_MODE:
-                        str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE]
-                        self.open_timer(str_buf)
-                    self.working_led_mode = led_mode.CHARGE_FULL_MODE
-                
+        if power_off != None:
+            if power_off == 1:
                 return
-            else:
-                if msg[5] != led_mode.HEALTH_LED_MODE:
-                    self.working_led_mode = led_mode.OTHER_MEASURE_MODE
-
-                get_hr_state = EventMesh.publish("get_hr_state")
-                get_spo2_state = EventMesh.publish("get_spo2_state")
-                
-                wechat_state = EventMesh.publish("get_wechat_state")
-                print("get_hr_state",get_hr_state,get_spo2_state,wechat_state,self.working_led_mode)
-                if wechat_state != None: #获取微聊状态
-                    if wechat_state == 1:
-                        if self.working_led_mode != led_mode.WECHAT_LED_MODE:#如果不在亮微聊模式需要亮微聊模式
+        usb_in = EventMesh.publish("get_usb")#
+        if msg != None:
+            if msg[6] != led_mode.POWER_OFF_MODE:#插入usb关机以防不亮红绿灯
+                # print("usb_in",usb_in)
+                if usb_in != None:
+                    if usb_in == 1 or usb_in == 3:#正在充电或者充电已满都不要被打断
+                        if self.timer_state == 1:
                             self.timer_state = 0
                             self.timer.stop()
-                            str_buf = [1,1,1,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.WECHAT_LED_MODE]
-                            self.open_timer(str_buf)
-                            self.working_led_mode = led_mode.WECHAT_LED_MODE
-                            return
-                        else:
-                           return
-                            
-                    else:
-                        self.wechat_btn = 0
-                        if get_hr_state != 0 or get_spo2_state != 0 :#心率血氧优先级高
-                            if self.working_led_mode != led_mode.HEALTH_LED_MODE:#如果不在亮微聊模式需要亮微聊模式
-                                print("set_hr_blood_led!!!!!!!!!!")
-                                str_buf = [1,2,10*70,led_mode.FLASH_LIGHT_RED_GREEN,10,5,led_mode.HEALTH_LED_MODE]#測量成功
-                                self.timer_state = 0
-                                self.timer.stop()
+                        if usb_in == 1:
+                            if self.working_led_mode != led_mode.CHARGE_IN_MODE:
+                                str_buf = [1,1,10,led_mode.LONG_LIGHT_RED,4,2,led_mode.CHARGE_IN_MODE]
                                 self.open_timer(str_buf)
-                                self.working_led_mode = led_mode.HEALTH_LED_MODE
-                                return
-                            else:
-                                print("set_hr_blood_led stop!!!!!!!!!!")
-                                return
-                        if  get_hr_state == 0 and get_spo2_state == 0:
+                            self.working_led_mode = led_mode.CHARGE_IN_MODE
+
+                        elif usb_in == 3:
+                            if self.working_led_mode != led_mode.CHARGE_FULL_MODE:
+                                str_buf = [1,1,10,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.CHARGE_FULL_MODE]
+                                self.open_timer(str_buf)
+                            self.working_led_mode = led_mode.CHARGE_FULL_MODE
+                        
+                        return
+                    else:
+                        if msg[5] != led_mode.HEALTH_LED_MODE:
                             self.working_led_mode = led_mode.OTHER_MEASURE_MODE
-                
+
+                        get_hr_state = EventMesh.publish("get_hr_state")
+                        get_spo2_state = EventMesh.publish("get_spo2_state")
+                        
+                        wechat_state = EventMesh.publish("get_wechat_state")
+                        temp_state = EventMesh.publish("get_temp_state")
+                        print("get_hr_state",get_hr_state,get_spo2_state,temp_state,wechat_state,self.working_led_mode)
+                        if wechat_state != None: #获取微聊状态
+                            if wechat_state == 1:
+                                if self.working_led_mode != led_mode.WECHAT_LED_MODE:#如果不在亮微聊模式需要亮微聊模式
+                                    self.timer_state = 0
+                                    self.timer.stop()
+                                    str_buf = [1,1,1,led_mode.LONG_LIGHT_GREEN,4,2,led_mode.WECHAT_LED_MODE]
+                                    self.open_timer(str_buf)
+                                    self.working_led_mode = led_mode.WECHAT_LED_MODE
+                                    return
+                                else:
+                                    return
+                                    
+                            else:
+                                self.wechat_btn = 0
+                                if get_hr_state != 0 or get_spo2_state != 0 or temp_state != 0 :#心率血氧优先级高
+                                    if self.working_led_mode != led_mode.HEALTH_LED_MODE:#如果不在亮微聊模式需要亮微聊模式
+                                        print("set_hr_blood_led!!!!!!!!!!")
+                                        str_buf = [1,2,10*70*2,led_mode.FLASH_LIGHT_RED_GREEN,10,5,led_mode.HEALTH_LED_MODE]#測量成功
+                                        self.timer_state = 0
+                                        self.timer.stop()
+                                        self.open_timer(str_buf)
+                                        self.working_led_mode = led_mode.HEALTH_LED_MODE
+                                        return
+                                    else:
+                                        print("set_hr_blood_led stop!!!!!!!!!!")
+                                        return
+                                if  get_hr_state == 0 and get_spo2_state == 0 and temp_state == 0:
+                                    self.working_led_mode = led_mode.OTHER_MEASURE_MODE
+                        
         self.open_timer(msg)
 
 
-    def stop_led_timer(self, event, msg):
-        open_power = EventMesh.publish("get_power_on_state")#获取开机标识
-        if open_power != None:
-            if open_power == 0:
-                return
-        EventMesh.publish("close_all_led")#关闭所有的灯
+   
     # EventMesh.publish("set_led_time_arg",[1,2,2*300,led_mode.FLASH_LIGHT_RED_GREEN,2,1,led_mode.HEALTH_LED_MODE])#測量成功
     def led_fun_cb(self, data):#
-        if self.led_enable ==0 and self.led_total_time == 0:
+        if self.led_enable == 0 or self.led_total_time == 0:
             return
         # print("self.long_count",self.long_count)
         if self.led_total_time != 0:
@@ -400,20 +418,20 @@ class ledEventManager(Abstract):#灯事件
                         else:
                             EventMesh.publish("stop_led_timer")#关闭所有的灯
                 elif self.led_mode == 2:
-                    self.long_count+=1
-                    if self.long_count % (self.led_open_time) <  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
+                    # print("led red!!!!!!!")
+                    
+                    if self.long_count % (self.led_open_time) <=  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
                         close_led_green()
                         close_led_white()
                         open_led_red()
-                        pass
                     else:
                         close_led_green()
                         close_led_white()
                         close_led_red()
-                        pass
-                    if self.long_count >= self.led_total_time:#大于总的时间 4
+                    if self.long_count >= self.led_total_time-1:#大于总的时间 4
                         EventMesh.publish("stop_led_timer")#设置参数
-                        pass
+                        return
+                    self.long_count+=1
             #绿灯闪烁
             elif self.long_light_mode == led_mode.FLASH_LIGHT_GREEN:#
                 if self.led_mode == 1:#长亮时间限制
@@ -429,8 +447,8 @@ class ledEventManager(Abstract):#灯事件
                         
 
                 elif self.led_mode == 2:
-                    self.long_count+=1
-                    if self.long_count % (self.led_open_time) <  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
+                    
+                    if self.long_count % (self.led_open_time) <=  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
                         close_led_red()
                         close_led_white()
                         open_led_green()
@@ -440,9 +458,11 @@ class ledEventManager(Abstract):#灯事件
                         close_led_white()
                         close_led_red()
                         pass
-                    if self.long_count >= self.led_total_time:#大于总的时间 4
+                    
+                    if self.long_count >= self.led_total_time-1:#大于总的时间 4
                         EventMesh.publish("stop_led_timer")#设置参数
-                        pass
+                        return
+                    self.long_count+=1
             #蓝灯闪烁 暂时是白色灯
             elif self.long_light_mode == led_mode.FLASH_LIGHT_WHITE:#
                 if self.led_mode == 1:#长亮时间限制
@@ -455,8 +475,7 @@ class ledEventManager(Abstract):#灯事件
                         else:
                             EventMesh.publish("stop_led_timer")#关闭所有的灯
                 elif self.led_mode == 2:
-                    self.long_count+=1
-                    if self.long_count % (self.led_open_time) <  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
+                    if self.long_count % (self.led_open_time) <=  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
                         close_led_red()
                         close_led_green()
                         open_led_white()
@@ -466,14 +485,15 @@ class ledEventManager(Abstract):#灯事件
                         close_led_white()
                         close_led_red()
                         pass
-                    if self.long_count >= self.led_total_time:#大于总的时间 4
+                    if self.long_count >= self.led_total_time-1:#大于总的时间 4
                         EventMesh.publish("stop_led_timer")#设置参数
-                        pass
+                        return
+                    self.long_count+=1
             #红绿灯闪烁
             elif self.long_light_mode == led_mode.FLASH_LIGHT_RED_GREEN:#
-                self.long_count+=1
                 
-                if self.long_count % (self.led_open_time) <  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
+                
+                if self.long_count % (self.led_open_time) <=  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
                     close_led_white()#白色灯
                     close_led_green()
                     open_led_red()
@@ -483,13 +503,13 @@ class ledEventManager(Abstract):#灯事件
                     close_led_red()
                     open_led_green()
                     pass
-                if self.long_count >= self.led_total_time:#大于总的时间 4
+                if self.long_count >= self.led_total_time-1:#大于总的时间 4
                     EventMesh.publish("stop_led_timer")#设置参数
-                    pass
+                    return
+                self.long_count+=1
             #红蓝灯闪烁 蓝变成白色灯
             elif self.long_light_mode == led_mode.FLASH_LIGHT_RED_WHITE:#
-                self.long_count+=1
-                if self.long_count % (self.led_open_time) <  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
+                if self.long_count % (self.led_open_time) <=  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
                     close_led_white()#白色灯
                     close_led_green()
                     open_led_red()
@@ -499,14 +519,15 @@ class ledEventManager(Abstract):#灯事件
                     close_led_red()
                     open_led_white()
                     pass
-                if self.long_count >= self.led_total_time:#大于总的时间 4
+                if self.long_count >= self.led_total_time-1:#大于总的时间 4
                     EventMesh.publish("stop_led_timer")#设置参数
-                    pass
+                    return
+                self.long_count+=1
             #蓝绿灯闪烁
             elif self.long_light_mode == led_mode.FLASH_LIGHT_GREEN_WHITE:#
 
-                self.long_count+=1
-                if self.long_count % (self.led_open_time) <  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
+                
+                if self.long_count % (self.led_open_time) <=  self.led_close_time: # 4*cnt cnt 多少次 4 开启时间保护关闭时间 2 关闭时间 100ms 4-2关闭时间为200ms 开启时间也为200ms 
                     close_led_white()#白色灯
                     close_led_red()
                     open_led_green()
@@ -516,49 +537,101 @@ class ledEventManager(Abstract):#灯事件
                     close_led_red()
                     open_led_white()
                     pass
-                if self.long_count >= self.led_total_time:#大于总的时间 4
+                if self.long_count >= self.led_total_time-1:#大于总的时间 4
                     EventMesh.publish("stop_led_timer")#设置参数
-                    pass
+                    return
+                self.long_count+=1
             #红灯长亮
             elif self.long_light_mode == led_mode.LONG_LIGHT_RED:#
                 close_led_white()#白色灯
                 close_led_green()
                 open_led_red()
+                self.timer.stop()
+                self.timer_state = 0
+                self.led_total_time = 0
+                self.led_enable = 0
+                self.led_mode = 0
+                self.long_light_mode = 0
+                self.led_open_time = 0
+                self.led_close_time = 0
+                self.working_led_mode = 0
+                self.long_count = 0
+
             #绿灯长亮
             elif self.long_light_mode == led_mode.LONG_LIGHT_GREEN:#
                 close_led_white()#白色灯
                 close_led_red()
                 open_led_green()
+                self.timer.stop()
+                self.timer_state = 0
+                self.led_total_time = 0
+                self.led_enable = 0
+                self.led_mode = 0
+                self.long_light_mode = 0
+                self.led_open_time = 0
+                self.led_close_time = 0
+                self.working_led_mode = 0
+                self.long_count = 0
             #蓝灯长亮
             elif self.long_light_mode == led_mode.LONG_LIGHT_WHITE:#
                 close_led_green()#白色灯
                 close_led_red()
                 open_led_white()
+                self.timer.stop()
+                self.timer_state = 0
+                self.led_total_time = 0
+                self.led_enable = 0
+                self.led_mode = 0
+                self.long_light_mode = 0
+                self.led_open_time = 0
+                self.led_close_time = 0
+                self.working_led_mode = 0
+                self.long_count = 0
     
     def close_led_pin(self, event, msg):
+        print("close_led_pin!!!")
+        if self.timer_state == 1:
+            self.timer_state = 0
+            self.timer.stop()
         close_led_red()
         close_led_green()
         close_led_white()
 
+    def stop_led_timer(self, event, msg):
+        EventMesh.publish("close_all_led")#关闭所有的灯
+    
     def close_all_led(self, event, msg):
-        print("close_all_led!!!!")
-        usb_in = EventMesh.publish("get_usb_state")#
-        if usb_in != None:
-            if usb_in == 1 or usb_in == 3:#正在充电或者充电已满都不要被打断
-                self.timer_state = 0
-                self.timer.stop()
+        # self.close_all_led_do(0)
+        # print("close_all_led!!2222222!!")
+        EventMesh.publish("publish_message_event_ledInfo",{"func":self.close_all_led_do,"data":0})  
+    def close_all_led_do(self,data):   
+        open_power = EventMesh.publish("get_power_on_state")#获取开机标识
+        if open_power != None:
+            if open_power == 0:
                 return
-            else:
-                get_hr_state = EventMesh.publish("get_hr_state")
-                get_spo2_state = EventMesh.publish("get_spo2_state")
-                
-                wechat_state = EventMesh.publish("get_wechat_state")
-                print("get_hr_state",get_hr_state,get_spo2_state,wechat_state,self.working_led_mode)
-                if wechat_state != None: #获取微聊状态
-                    if wechat_state == 1 or get_spo2_state != 0 or get_hr_state != 0:
+        usb_in = EventMesh.publish("get_usb")#
+        open_power_off = EventMesh.publish("get_power_off_state")#获取开机标识
+        if open_power_off != None:
+            if open_power_off != 1:
+                if usb_in != None:
+                    if usb_in == 1 or usb_in == 3:#正在充电或者充电已满都不要被打断
+                        if self.timer_state == 1:
+                            self.timer_state = 0
+                            self.timer.stop()
                         return
+                    else:
+                        get_hr_state = EventMesh.publish("get_hr_state")
+                        get_spo2_state = EventMesh.publish("get_spo2_state")
+                        
+                        wechat_state = EventMesh.publish("get_wechat_state")
+                        temp_state = EventMesh.publish("get_temp_state")
+                        print("get_hr_state",get_hr_state,get_spo2_state,wechat_state,self.working_led_mode)
+                        if wechat_state != None: #获取微聊状态
+                            if wechat_state == 1 or get_spo2_state != 0 or get_hr_state != 0 or temp_state != 0:
+                                return
+        if self.timer_state == 1:
+            self.timer.stop()
         self.timer_state = 0
-        self.timer.stop()
         self.led_total_time = 0
         self.led_enable = 0
         self.led_mode = 0
@@ -572,286 +645,9 @@ class ledEventManager(Abstract):#灯事件
         close_led_white()
         print("close led!!!")
 
-
     def led_test_fun_cb(self, data):
         return
-        if 0:
-            # print("self.freq_time :{} self.freq_num:{} self.flash_light:{}".format(self.freq_time,self.freq_num,self.flash_light))
-            if self.freq_time != 0 and self.freq_num != 0 and self.flash_light != 0:
-                if self.flash_light == led_mode.LONG_LIGHT_RED:
-                    if self.total_time != 0:
-                        if self.long_light_mode == led_mode.DEFAULT_LONG_LIGHT_MODE:#不是长亮模式 只需要长亮3 5 7 s这样就关闭长亮
-                            count = self.total_time//LED_TIMER_OUT#100ms单位
-                            self.long_count+=1
-                            if self.long_count == 1:
-                                close_led_green()
-                                close_led_white()
-                                open_led_red()#亮红灯 高电平
-                        
-                            elif self.long_count >= count :#不开长亮 只亮3 5 s这样就直接关闭
-                                close_led_red()#亮红灯 低电平
-                                EventMesh.publish("stop_led_timer")#设置参数
-
-                        elif self.long_light_mode == led_mode.OPEN_LONG_LIGHT_MODE:#开启长亮,需要手动发指令关闭长亮模式
-                            EventMesh.publish("stop_led_timer")#设置参数
-                            close_led_green()
-                            close_led_white()
-                            open_led_red()#亮红灯 高电平
-                            
-
-                        elif self.long_light_mode == led_mode.CLOSE_LONG_LIGHT_MODE:#关闭长亮模式
-                            close_led_red()#亮红灯 低电平
-                            EventMesh.publish("stop_led_timer")#设置参数
-                    else:
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.LONG_LIGHT_GREEN:
-                    if self.total_time != 0:
-                        if self.long_light_mode == led_mode.DEFAULT_LONG_LIGHT_MODE:#不是长亮模式 只需要长亮3 5 7 s这样就关闭长亮
-                            count = self.total_time//LED_TIMER_OUT#100ms单位
-                            self.long_count+=1
-                            if self.long_count == 1:
-                                close_led_red()
-                                close_led_white()
-                                open_led_green()#亮绿灯 高电平
-                        
-                            elif self.long_count >= count :#不开长亮 只亮3 5 s这样就直接关闭
-                                close_led_green()#亮绿灯 低电平
-                                EventMesh.publish("stop_led_timer")#设置参数
-
-                        elif self.long_light_mode == led_mode.OPEN_LONG_LIGHT_MODE:#开启长亮,需要手动发指令关闭长亮模式
-                            EventMesh.publish("stop_led_timer")#设置参数
-                            close_led_red()
-                            close_led_white()
-                            open_led_green()#亮绿灯 高电平
-                            
-
-                        elif self.long_light_mode == led_mode.CLOSE_LONG_LIGHT_MODE:#关闭长亮模式
-                            close_led_green()#亮绿灯 低电平
-                            EventMesh.publish("stop_led_timer")#设置参数
-                        
-                    else:
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.LONG_LIGHT_WHITE:
-                    if self.total_time != 0:
-                        if self.long_light_mode == led_mode.DEFAULT_LONG_LIGHT_MODE:#不是长亮模式 只需要长亮3 5 7 s这样就关闭长亮
-                            count = self.total_time//LED_TIMER_OUT#100ms单位
-                            self.long_count+=1
-                            if self.long_count == 1:
-                                close_led_green()
-                                close_led_red()
-                                open_led_white()#亮绿灯 高电平
-                            elif self.long_count >= count:
-                                close_led_white()#亮绿灯 低电平
-                                EventMesh.publish("stop_led_timer")#设置参数
-
-                        elif self.long_light_mode == led_mode.OPEN_LONG_LIGHT_MODE:#开启长亮,需要手动发指令关闭长亮模式
-                            EventMesh.publish("stop_led_timer")#设置参数
-                            close_led_green()
-                            close_led_red()
-                            open_led_white()#亮绿灯 高电平
-                        
-                        elif self.long_light_mode == led_mode.CLOSE_LONG_LIGHT_MODE:#开启长亮,需要手动发指令关闭长亮模式
-                            close_led_white()#亮绿灯 低电平
-                            EventMesh.publish("stop_led_timer")#设置参数
-
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.FLASH_LIGHT_RED:#红灯快速闪烁 灭灯时间和闪烁时间一致
-                    if self.total_time != 0:
-                        count = self.freq_num
-                        self.freq = self.freq_time // LED_TIMER_OUT#
-                        self.long_count+=1
-                        # print("self.freq : {} FLASH_LIGHT_RED count :{} self.long_count:{} self.total_count:{}".format(self.freq,count,self.long_count,self.total_count))
-                        if self.long_count == 1:#间隔多久闪一次 100ms单位
-                            close_led_green()
-                            close_led_white()
-                            open_led_red()#亮白灯 高电平
-                        elif self.long_count == self.freq+1:
-                            self.total_count+=1
-                            close_led_red()#亮白灯 低电平
-                        if self.long_count >= self.freq*2:
-                            self.long_count = 0
-                        
-                        # print("self.total_count:{}".format(self.total_count))
-                        if self.total_count >= count:
-                            close_led_red()#亮白灯 低电平
-                            self.total_count = 0
-                            self.long_count = 0
-                            EventMesh.publish("stop_led_timer")#设置参数
-
-
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-                elif self.flash_light == led_mode.FLASH_LIGHT_GREEN:#绿灯快速闪烁
-                    if self.total_time != 0:
-                        count = self.freq_num
-                        self.freq = self.freq_time // LED_TIMER_OUT#
-                        self.long_count+=1
-                        # print("self.freq : {} FLASH_LIGHT_GREEN count :{} self.long_count:{} self.total_count:{}".format(self.freq,count,self.long_count,self.total_count))
-                        if self.long_count == 1:#间隔多久闪一次 100ms单位
-                            close_led_red()
-                            close_led_white()
-                            open_led_green()#亮白灯 高电平
-                        elif self.long_count == self.freq+1:
-                            self.total_count+=1
-                            close_led_green()#亮白灯 低电平
-                        if self.long_count >= self.freq*2:
-                            self.long_count = 0
-                        
-                        # print("self.total_count:{}".format(self.total_count))
-                        if self.total_count >= count:
-                            close_led_green()#亮白灯 低电平
-                            self.total_count = 0
-                            self.long_count = 0
-                            EventMesh.publish("stop_led_timer")#设置参数
-
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.FLASH_LIGHT_WHITE:#白灯灯快速闪烁
-                    if self.total_time != 0:
-                        count = self.freq_num
-                        self.freq = self.freq_time // LED_TIMER_OUT#
-                        self.long_count+=1
-                        # print("self.freq : {} FLASH_LIGHT_WHITE count :{} self.long_count:{} self.total_count:{}".format(self.freq,count,self.long_count,self.total_count))
-                        if self.long_count == 1:#间隔多久闪一次 100ms单位
-                            close_led_green()
-                            close_led_red()
-                            open_led_white()#亮白灯 高电平
-                        elif self.long_count == self.freq+1:
-                            self.total_count+=1
-                            close_led_white()#亮白灯 低电平
-                        if self.long_count >= self.freq*2:
-                            self.long_count = 0
-                        
-                        # print("self.total_count:{}".format(self.total_count))
-                        if self.total_count >= count:
-                            close_led_white()#亮白灯 低电平
-                            self.total_count = 0
-                            self.long_count = 0
-                            EventMesh.publish("stop_led_timer")#设置参数
-
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.INTERVAL_LIGHT_RED:#间隔闪烁
-                    if self.total_time != 0:
-                        count = self.freq_num
-                        self.freq = self.freq_time // LED_TIMER_OUT#
-                        self.long_count+=1
-                        # print("self.freq : {} FLASH_LIGHT_RED count :{} self.long_count:{} self.total_count:{}".format(self.freq,count,self.long_count,self.total_count))
-                        if self.long_count == 1:#间隔多久闪一次 100ms单位
-                            close_led_green()
-                            close_led_white()
-                            open_led_red()#亮白灯 高电平
-                        elif self.long_count == self.freq+1:
-                            self.total_count+=1
-                            close_led_red()#亮白灯 低电平                                  
-                        if self.long_count >= self.freq*2:
-                            self.long_count = 0
-                        
-                        # print("self.total_count:{}".format(self.total_count))
-                        if self.total_count >= count:
-                            close_led_red()#亮白灯 低电平
-                            self.total_count = 0
-                            self.long_count = 0
-                            EventMesh.publish("stop_led_timer")#设置参数
-
+   
 
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.INTERVAL_LIGHT_GREEN:#绿灯快速闪烁
-                    if self.total_time != 0:
-                        count = self.freq_num
-                        self.freq = self.freq_time // LED_TIMER_OUT#
-                        self.long_count+=1
-                        # print("self.freq : {} FLASH_LIGHT_GREEN count :{} self.long_count:{} self.total_count:{}".format(self.freq,count,self.long_count,self.total_count))
-                        if self.long_count == 1:#间隔多久闪一次 100ms单位
-                            close_led_red()
-                            close_led_white()
-                            open_led_green()#亮白灯 高电平
-                        elif self.long_count == self.freq+1:
-                            self.total_count+=1
-                            close_led_green()#亮白灯 低电平
-                        if self.long_count >= self.freq*2:
-                            self.long_count = 0
-                        
-                        # print("self.total_count:{}".format(self.total_count))
-                        if self.total_count >= count:
-                            close_led_green()#亮白灯 低电平
-                            self.total_count = 0
-                            self.long_count = 0
-                            EventMesh.publish("stop_led_timer")#设置参数
-
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.INTERVAL_LIGHT_WHITE:#白灯灯快速闪烁
-                    if self.total_time != 0:
-                        count = self.freq_num
-                        self.freq = self.freq_time // LED_TIMER_OUT#
-                        self.long_count+=1
-                        # print("self.freq : {} FLASH_LIGHT_WHITE count :{} self.long_count:{} self.total_count:{}".format(self.freq,count,self.long_count,self.total_count))
-                        if self.long_count == 1:#间隔多久闪一次 100ms单位
-                            close_led_green()
-                            close_led_red()
-                            open_led_white()#亮白灯 高电平
-                        elif self.long_count == self.freq+1:
-                            self.total_count+=1
-                            close_led_white()#亮白灯 低电平
-                        if self.long_count >= self.freq*2:
-                            self.long_count = 0
-                        
-                        # print("self.total_count:{}".format(self.total_count))
-                        if self.total_count >= count:
-                            close_led_white()#亮白灯 低电平
-                            self.total_count = 0
-                            self.long_count = 0
-                            EventMesh.publish("stop_led_timer")#设置参数
-
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-
-                elif self.flash_light == led_mode.FLASH_LIGHT_RED_GREEN:#红绿灯灯快速闪烁
-                    if self.total_time != 0:
-                        count = self.freq_num
-                        self.freq = self.freq_time // LED_TIMER_OUT#
-                        self.long_count+=1
-                        if self.long_count == 1:#间隔多久闪一次 100ms单位
-                            close_led_white()
-                            close_led_green()#亮白灯 低电平
-                            open_led_red()#紅
-                        elif self.long_count == 1*self.freq+1:#5 6 7 8 
-                            close_led_red()#亮白灯 低电平
-                            close_led_green()#亮白灯 低电平
-                            
-                        elif self.long_count == 2*self.freq+1:#5 6 7 8 
-                            open_led_green()#綠
-                        
-                        elif self.long_count == 3*self.freq+1:#5 6 7 8 
-                            close_led_red()#亮白灯 低电平
-                            close_led_green()#亮白灯 低电平
-                            self.total_count += 1
-
-                        if self.long_count >= 4*self.freq:
-                            self.long_count = 0
-                        # print("self.total_count:{}".format(self.total_count))
-                        if self.total_count >= count:
-                            close_led_green()#亮白灯 低电平
-                            close_led_red()#亮白灯 低电平
-                            self.long_count = 0
-                            EventMesh.publish("stop_led_timer")#设置参数
-                        
-                    else:#防止长亮时未设置长亮总时长 未设置不开灯
-                        EventMesh.publish("stop_led_timer")#设置参数
-                elif self.flash_light >= led_mode.LIGHT_NONE:#未知
-                    EventMesh.publish("stop_led_timer")#设置参数
-                
-            else:
-                EventMesh.publish("stop_led_timer")#关闭定时器和关闭所有的led灯
 
 
index 49c03d1..68aced1 100644 (file)
@@ -55,7 +55,7 @@ def main_init():
     
     print("init2:{}".format(utime.localtime()))
     print("init3:{}".format(utime.localtime()))
-    from btn_device_ec800m import BtnDevice,intervManager,wechatInforManager,resetFactoryUnbindManager
+    from btn_device_ec800m import BtnDevice,intervManager,wechatInforManager
 
     btn_device = BtnDevice()
     btn_device.start()
@@ -79,11 +79,10 @@ def main_init():
     import mgr as mgr
     print("init7:{}".format(utime.localtime()))
     
-    from mgr import testSmsSetIPManager,ConfigStoreManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
+    from mgr import ClockManager,deleteSmsManager,testSmsSetIPManager,ConfigStoreManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
     AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
     print("init8:{}".format(utime.localtime()))
     
-    
     # from appWechat import TK_ProtoCol,MESSAGE_ProtoCol
     
     
@@ -104,8 +103,7 @@ def main_init():
         .append_manager(intervManager())\
         .append_manager(ledEventManager())\
         .append_manager(wechatInforManager())\
-        .append_manager(resetFactoryUnbindManager())\
-        .append_manager(motorEventManager())
+        .append_manager(motorEventManager())\
         # .append_manager(playImeiManager())\
         # .append_manager(playCurStepManager())\
         # .append_manager(usbStateManager())\
@@ -143,6 +141,8 @@ def main_init():
     app.append_manager(CountdownManager())
     app.append_manager(sosInfoCallManager())
     app.append_manager(testSmsSetIPManager())
+    app.append_manager(deleteSmsManager())
+    app.append_manager(ClockManager())
 
     print("init21:{}".format(utime.localtime()))    
     
@@ -194,6 +194,7 @@ def main_init():
         if timeSecond != 0:
             next_alarm_time = utime.localtime(timeSecond)
             machine.RTC().datetime((next_alarm_time[0],next_alarm_time[1],next_alarm_time[2],next_alarm_time[6],next_alarm_time[3],next_alarm_time[4],next_alarm_time[5],0))
+    
     EventMesh.publish("open_power_on", 1)#
     
     # EventMesh.publish("load_screen", {"screen": "main_menu"})
index faf4086..48e9580 100644 (file)
@@ -22,11 +22,16 @@ import usys
 import audio
 from machine import I2C
 from Gsensor import SC7A20
+import pm
 try :
     from Hsensor import GH3018
 except Exception as e:
     print("Hsensor none GH3018:{}".format(e))   
-# 
+#
+try :
+    from Hsensor import HX3918
+except Exception as e:
+    print("Hsensor none HX3918:{}".format(e))    
 from machine import RTC
 import quecgnss
 import wifiScan
@@ -514,6 +519,22 @@ class sosInfoCallManager(Abstract):
                         num_len = len(number)+2  
                     # print("number:{} number_len :{} num:{} num_len:{}".format(number,len(number),num,num_len))
                     if num > num_len :
+                        if len(number) == 1:
+                            number1 = str(number[0])
+                            sms.sendPduMsg(number1, '我需要你的帮助', 'UCS2')
+                        elif len(number) == 2:
+                            number1 = str(number[0])
+                            sms.sendPduMsg(number1, '我需要你的帮助', 'UCS2')
+
+                            number2 = str(number[1])
+                            sms.sendPduMsg(number2, '我需要你的帮助', 'UCS2')
+                        elif len(number) == 3:
+                            number1 = str(number[0])
+                            sms.sendPduMsg(number1, '我需要你的帮助', 'UCS2')
+                            number2 = str(number[1])
+                            sms.sendPduMsg(number2, '我需要你的帮助', 'UCS2')
+                            number3 = str(number[2])
+                            sms.sendPduMsg(number3, '我需要你的帮助', 'UCS2')
                         EventMesh.publish("set_sos_flag",0)
                         EventMesh.publish("set_sos_num",0)
                     else:
@@ -593,10 +614,8 @@ def voice_callback(args):
         EventMesh.publish("set_sos_info_call")  
         flag = EventMesh.publish("get_call_state") 
         if flag == 2:
-            EventMesh.publish("close_motor_infor")#关闭马达和定时器
             EventMesh.publish("close_timer_all")#
         EventMesh.publish("set_call_state",0) 
-
         print('voicecall disconnect end')
         
 
@@ -612,6 +631,7 @@ def voice_callback(args):
         
    elif args[0] == 15:
         print('voicecall alerting, PhoneNO.: ', args[6])
+        EventMesh.publish("set_call_state",1) 
         
    elif args[0] == 16:
         print('voicecall holding, PhoneNO.: ', args[6])
@@ -657,7 +677,7 @@ class DeviceInfoManager(Abstract):
         self.Hr_Need_Open = 0
         self.Spo2_Need_Open = 0
         self.bat_time = 0
-        self.sms_full_flag = 0
+        self.vbat_full_flag = 0
         self.clear_step = 0
         self.test = 0
         self.old_time = 0
@@ -697,7 +717,11 @@ class DeviceInfoManager(Abstract):
         self.gsensor.init()
         print("DeviceInfoManager:2")
         self.gsensor.set_callback(self.gsensor_cb)
-        
+        try :
+            self.hsensor = HX3918()
+            
+        except Exception as e:
+            print("Hsensor none HX3918:{}".format(e))   
         try :
             self.hsensor = GH3018()
         except Exception as e:
@@ -833,11 +857,13 @@ class DeviceInfoManager(Abstract):
 
         EventMesh.publish("countdown_end_cb")
         """定时检查是否关闭gps失败"""
-        gnss_state = quecgnss.get_state()
-        get_location_flag = EventMesh.publish("get_location_flag")
-        if get_location_flag != None:
-            if gnss_state == 2 and get_location_flag == 0:
-                EventMesh.publish(constants.EVENT.GPSCLOSE)
+        # gnss_state = quecgnss.get_state()
+        # get_location_flag = EventMesh.publish("get_location_flag")
+        # if get_location_flag != None:
+        #     # if gnss_state == 2 and get_location_flag == 0:
+        #     #     EventMesh.publish(constants.EVENT.GPSCLOSE)
+        #     if(get_location_flag == 0):
+        #         EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始UD定位
 
         """7分钟一次心跳"""
         if  math.fabs(time_tmp - self.KA_time) > 7*60: #7分钟一次心跳
@@ -845,16 +871,22 @@ class DeviceInfoManager(Abstract):
             EventMesh.publish(constants.PROTOCOL.KA_SEND)
 
         """定时定位"""
+        #EventMesh.publish("set_upload_data",3*60)
         self.upload_time = EventMesh.publish("get_upload_data")
         #print("self.upload_time:{} math.fabs(time_tmp - self.UD_time):{}".format(self.upload_time,math.fabs(time_tmp - self.UD_time)))
         if self.upload_time != None :
             if  math.fabs(time_tmp - self.UD_time) > self.upload_time: #30分钟一次定位
                 self.UD_time = time_tmp
                 status_tmp = self.gsensor.get_status()#获取运动次数
+                #status_tmp = 4
                 #EventMesh.txt_log("status_count:{}".format(status_tmp))
                 if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and status_tmp > 3 :
                     EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始UD定位
                     self.gsensor.clean_status()#清除运动次数
+                else : #关闭定位
+                    #EventMesh.txt_log("NO status")
+                    print("NO status")
+                    EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位 
         EventMesh.publish(constants.EVENT.PUSH_STEP, self.get_step_count())
 
         """电池平均值"""
@@ -890,11 +922,12 @@ class DeviceInfoManager(Abstract):
         hour = date_tmp[3]
         min = date_tmp[4]
         old_Timesec = EventMesh.publish("get_old_time_data")
+        # print("old_Timesec",old_Timesec)
         if old_Timesec != None:
             data = RTC().datetime()
             hour = data[4]
             min = data[5]
-            next_alarm_time = utime.localtime(old_Timesec)
+            next_alarm_time = utime.localtime(int(old_Timesec))
             # print("data[5]:{} {} next_alarm_time:{} old_Timesec:{}".format(data[1],data[2],next_alarm_time,old_Timesec))
             month = next_alarm_time[1]
             day = next_alarm_time[2]
@@ -943,7 +976,6 @@ class DeviceInfoManager(Abstract):
             if get_low_btn == 1:
                 self.bat_time+=10
                 # print("date_tmp:{} self.bat_time:{}".format(date_tmp,self.bat_time))
-
                 if self.bat_time > 5*60:
                     self.bat_time = 0
                     if battery[1] <= 20 and battery[1] > 0:
@@ -954,72 +986,44 @@ class DeviceInfoManager(Abstract):
         
         """未联网提示关机"""
         ble=EventMesh.publish(constants.EVENT.GET_CONNECT)
-        print("ble",ble)
+        # print("ble",ble)
         if ble == 0:#未联网提示关机
-
-            # usb_state = EventMesh.publish("get_usb_state")#
-            # print("usb_state",usb_state)
-            # if usb_state != None:
-            #     if usb_state == 0 or usb_state == 2:
-            self.no_smi_count+=10
-            print("self.no_smi_count",self.no_smi_count)
-            if self.no_smi_count >= (15*60):
-                self.no_smi_count = 0
-                EventMesh.publish("open_power_on", 2)#  #未检测到sim卡15分钟后关机
-            #     else:
-            #         self.no_smi_count = 0
-            
-            if self.no_smi_state < 6:
-                self.no_smi_state+=1
-                if self.no_smi_state >= 6:#开机一分钟后提示未检测到sim卡
-                    EventMesh.publish("sim_no_cb")#未插卡
+            if battery[0] != '1':
+                self.no_smi_count+=10
+                # print("self.no_smi_count",self.no_smi_count)
+                if self.no_smi_count >= (15*60):
+                    self.no_smi_count = 0
+                    EventMesh.publish("open_power_on", 2)#  #未检测到sim卡15分钟后关机
+                
+                if self.no_smi_state < 6:
+                    self.no_smi_state+=1
+                    if self.no_smi_state >= 6:#开机一分钟后提示未检测到sim卡
+                        EventMesh.publish("sim_no_cb")#未插卡
                   
         else:
             self.no_smi_count = 0
-        # if battery[0] == "1":
-        #     if battery[1] >= 100:
-        #         if self.charge_full_count > 60 and self.charge_full_count % (60*10) == 0:#每十分钟提醒一次
-        #             pass
-        #             # EventMesh.publish("load_screen", {"screen": "charge_full"})  
-        #         self.charge_full_count+=10
-        # else:
-        #     self.charge_full_count = 0
-
-        """检测短信已满,提示是否清掉"""
-        msg_nums = sms.getMsgNums() #获取短信条数
-        if(msg_nums != -1):
-            sms_data = sms.getSaveLoc()
-            sms_max = sms_data[0][2]
-            if msg_nums >= sms_max-1:
-                self.sms_full_flag+=10
-                if self.sms_full_flag >= 120:
-                    self.sms_full_flag=0
-                    # EventMesh.publish("load_screen", {"screen": "message_full"})
-            else:
-                self.sms_full_flag = 0
 
         """定时测量心率,血氧,体温"""
-        # WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+        WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
         self.get_hr_state = EventMesh.publish("get_hr_state")
         self.get_spo2_state = EventMesh.publish("get_spo2_state")
         get_temp_time  = EventMesh.publish("get_temp_time")
         get_temp_state  = EventMesh.publish("get_temp_state")
         hr_time = {}
         hr_time = EventMesh.publish("get_time_hr_spo2")#获取时间是否大于0
-        # if get_temp_state != None : #突然脱腕
-        #     if get_temp_state > 1 and WEAR != 1:
-        #         EventMesh.publish(constants.EVENT.STOP_TEMP)
-        #         EventMesh.publish("set_temp_state",0)       
-        #     if (self.get_hr_state > 1 or self.get_spo2_state > 1) and WEAR != 1:
-        #         if self.get_hr_state > 1 :
-        #             EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 
-        #             EventMesh.publish(constants.EVENT.STOP_HEART) 
-        #         elif self.get_spo2_state > 1:
-        #             EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
-        #             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-
-        #if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1": #:
-        if 0:
+        if get_temp_state != None : #突然脱腕
+            if get_temp_state > 1 and WEAR != 1:
+                EventMesh.publish(constants.EVENT.STOP_TEMP)
+                EventMesh.publish("set_temp_state",0)       
+            if (self.get_hr_state > 1 or self.get_spo2_state > 1) and WEAR != 1:
+                if self.get_hr_state > 1 :
+                    EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 
+                    EventMesh.publish(constants.EVENT.STOP_HEART) 
+                elif self.get_spo2_state > 1:
+                    EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+                    EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+        if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1" and WEAR == 1:
+
             # print("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state))
             if get_temp_time != None:#定时测量体温
                 if get_temp_time > 0:
@@ -1525,105 +1529,101 @@ class DeviceInfoManager(Abstract):
             self.old_time = 0    
             self.set_hsenor_crt = 0
 
-        if 0:
-            hr_state = EventMesh.publish("get_hr_state")
-            spo2_state = EventMesh.publish("get_spo2_state")
-            temp_state  = EventMesh.publish("get_temp_state")
-            if hr_state != None or spo2_state != None or temp_state != None:#手动测试
-                if hr_state == 1:
-                    time_s = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
-                    if time_s != None:
-                        if time_s != 0:
-                            if (time_tmp - time_s) >= 60:#大于60s关闭测试
-                                EventMesh.publish("set_hr_state",0)#0代表g关闭测试
-                                print("stop debug7")
-                                EventMesh.publish(constants.EVENT.STOP_HEART)
-                                heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                                if heart_value > 50 and heart_value != None:
-                                    EventMesh.publish("play_hr_value",heart_value)
-                                    EventMesh.publish("set_history_hr_value",heart_value)
-                                    EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
-                                else:
-                                    EventMesh.publish("play_hr_value",0) 
-
-                    pass
-                if spo2_state == 1:#手动测试血氧
-                    time_s = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
-                    if time_s != None:
-                        if time_s != 0:
-                            if (time_tmp - time_s) >= 60:#大于60s关闭测试
-                                EventMesh.publish("set_spo2_state",0)#0代表g关闭测试
-                                print("stop spo2 debug7")
-                                EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-                                spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-                                if spo2_value > 85 and spo2_value != None:
-                                    EventMesh.publish("play_spo2_value",spo2_value)
-                                    EventMesh.publish("set_old_spo2_data",spo2_value)
-                                    EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-                                else:
-                                    EventMesh.publish("play_spo2_value",0)
-                    pass
 
-                if temp_state == 1:#手动测试体温
-                    time_s = EventMesh.publish("get_start_temp_measure_time")#设置开始测量的时间戳时间
-                    if time_s != None:
-                        if time_s != 0:
-                            if (time_tmp - time_s) >= 60:#大于60s关闭测试
-                                print("体温测量结束")
-                                temp = EventMesh.publish(constants.EVENT.GET_TEMP)       
-                                temp += 0.5      
-                                if temp < 25 or temp > 42:
-                                    temp = 0
-                                print("temp",temp)
-                                EventMesh.publish("set_temp_state",0)
-                                if temp > 0:
-                                    tmp_f = str(temp).split('.')[0] 
-                                    tmp_f_tmp = int(tmp_f)
-                                    
-                                    tmp_d = str(temp).split('.')[1][:1]
-                                    tmp_d_tmp = int(tmp_d)
-                                    
-                                    if temp != None:
-                                        if temp != 0:
-                                            EventMesh.publish("set_history_temp_value",temp)
-                                            EventMesh.publish("play_temp_value",temp)#播放体温数值
-                                            EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
-                                else:
-                                    EventMesh.publish("set_history_temp_value",0)
-                                    EventMesh.publish("play_temp_value",0)#播放体温数值
+        hr_state = EventMesh.publish("get_hr_state")
+        spo2_state = EventMesh.publish("get_spo2_state")
+        temp_state  = EventMesh.publish("get_temp_state")
+        if hr_state != None or spo2_state != None or temp_state != None:#手动测试
+            if hr_state == 1:
+                time_s = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
+                if time_s != None:
+                    if time_s != 0:
+                        if (time_tmp - time_s) >= 60:#大于60s关闭测试
+                            EventMesh.publish("set_hr_state",0)#0代表g关闭测试
+                            print("stop debug7")
+                            EventMesh.publish(constants.EVENT.STOP_HEART)
+                            heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                            if heart_value > 50 and heart_value != None:
+                                EventMesh.publish("play_hr_value",heart_value)
+                                EventMesh.publish("set_history_hr_value",heart_value)
+                                EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+                            else:
+                                EventMesh.publish("play_hr_value",0) 
+
+                pass
+            if spo2_state == 1:#手动测试血氧
+                time_s = EventMesh.publish("get_start_measure_time")#设置开始测量的时间戳时间
+                if time_s != None:
+                    if time_s != 0:
+                        if (time_tmp - time_s) >= 60:#大于60s关闭测试
+                            EventMesh.publish("set_spo2_state",0)#0代表g关闭测试
+                            print("stop spo2 debug7")
+                            EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+                            spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+                            if spo2_value > 85 and spo2_value != None:
+                                EventMesh.publish("play_spo2_value",spo2_value)
+                                EventMesh.publish("set_old_spo2_data",spo2_value)
+                                EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+                            else:
+                                EventMesh.publish("play_spo2_value",0)
+                pass
+
+            if temp_state == 1:#手动测试体温
+                time_s = EventMesh.publish("get_start_temp_measure_time")#设置开始测量的时间戳时间
+                if time_s != None:
+                    if time_s != 0:
+                        if (time_tmp - time_s) >= 60:#大于60s关闭测试
+                            print("体温测量结束")
+                            temp = EventMesh.publish(constants.EVENT.GET_TEMP)       
+                            temp += 0.5      
+                            if temp < 25 or temp > 42:
+                                temp = 0
+                            print("temp",temp)
+                            EventMesh.publish("set_temp_state",0)
+                            if temp > 0:
+                                tmp_f = str(temp).split('.')[0] 
+                                tmp_f_tmp = int(tmp_f)
                                 
-                                EventMesh.publish(constants.EVENT.STOP_TEMP)
-                    pass 
-            
+                                tmp_d = str(temp).split('.')[1][:1]
+                                tmp_d_tmp = int(tmp_d)
+                                
+                                if temp != None:
+                                    if temp != 0:
+                                        EventMesh.publish("set_history_temp_value",temp)
+                                        EventMesh.publish("play_temp_value",temp)#播放体温数值
+                                        EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+                            else:
+                                EventMesh.publish("set_history_temp_value",0)
+                                EventMesh.publish("play_temp_value",0)#播放体温数值
+                            
+                            EventMesh.publish(constants.EVENT.STOP_TEMP)
+                pass 
+        
         # EventMesh.publish("play_unread_wechat_infor")#每10s检测是否有未读语音数据
 
-        usb_state = EventMesh.publish("get_usb_state")#
-        if usb_state != None:
-            if usb_state == 1 or usb_state == 3:
-                if battery[1] >= 100:#充电已满
-                    if self.charge_full_count == 0:
-                        EventMesh.publish("set_usb_state",3)#
+        usb_state = EventMesh.publish("get_usb")#
+        
+
+        if battery[0] == '1':
+            # print("battery[1]",battery[1])
+            if self.vbat_full_flag <= 120:
+                self.vbat_full_flag+=10
+                if self.vbat_full_flag == 80:#开机检测一次如果是充电标识为1就不再提示
+                    if usb_state != 1:
+                        EventMesh.publish("set_usb",1)#
+            else:
+                if battery[1] >= 100:
+                    if self.charge_full_count == 0:#充电已满
+                        EventMesh.publish("set_usb",3)#
                         print("charge R_CHARGE_full")
                         self.charge_full_count = 1
-                else:
-                    self.charge_full_count = 0
-            else:
-                self.charge_full_count = 0
-                low_power = battery[1]
-                if low_power <= 5:#小于5%红色灯慢闪
-                    EventMesh.publish("set_led_time_arg",[1,2,10*11,led_mode.FLASH_LIGHT_RED,10,5,led_mode.OTHER_MEASURE_MODE])#測量成功
-                    # EventMesh.publish("set_led_time_arg",[1000,400,52,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#開始測量
-
-
-        # self.charge_full_count+=1
-        # print("self.charge_full_count",self.charge_full_count)
-        # if self.charge_full_count == 6:
-        #     EventMesh.publish("set_usb_state", 1)#
-        # elif self.charge_full_count == 7:
-        #     EventMesh.publish("set_usb_state", 2)#
-        # elif self.charge_full_count >= 8:
-        #     self.charge_full_count = 0
-        # EventMesh.publish("set_usb_state", 2)#
+                
+        else:
+            self.charge_full_count = 0
+            low_power = battery[1]
+            if low_power <= 5:#小于5%红色灯慢闪
+                EventMesh.publish("set_led_time_arg",[1,2,20*11,led_mode.FLASH_LIGHT_RED,20,10,led_mode.OTHER_MEASURE_MODE])#測量成功
+                # EventMesh.publish("set_led_time_arg",[1000,400,52,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#開始測量
 
       
     def get_sim_Status(self, event, msg):
@@ -1869,8 +1869,7 @@ class DeviceInfoManager(Abstract):
         return data[0]
     
     def get_wear(self, topic, msg):
-        pass
-        # return self.hsensor.get_wear()
+        return self.hsensor.get_wear()
     
     def get_Hsensor(self, topic, msg):
         return self.hsensor
@@ -1927,10 +1926,10 @@ class DeviceInfoManager(Abstract):
 
         if status == 1:#插入USB
             print("charge R_CHARGE_in")
-            EventMesh.publish("set_usb_state", 1)#
+            EventMesh.publish("set_usb", 1)#
             pass
         elif status == 0:#拨出usbs
-            EventMesh.publish("set_usb_state", 2)#
+            EventMesh.publish("set_usb", 2)#
             print("charge R_CHARGE_out")
             
             
@@ -2219,7 +2218,7 @@ class LocationManager(Abstract):
                         #gnss_r_data = [0,1]
                         gnss_r_data = quecgnss.read(4096)
                         #EventMesh.txt_log("gps Datalen:{}".format(gnss_r_data[0]))
-                        print("location gnss_r_data:len{}\n{}".format(gnss_r_data[0],gnss_r_data[1].decode()))
+                        # print("location gnss_r_data:len{}\n{}".format(gnss_r_data[0],gnss_r_data[1].decode()))
                         #print("gnss_r_data len:{}".format(gnss_r_data[0]))
                         if gnss_r_data[0] > 0 : #有数据
                             tmp_ok_count = 0
@@ -2446,7 +2445,7 @@ class AddrBookManager(Abstract):
                 EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
         else:
             EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
-            print("call_phonebook_one_call name:{} key_tmp:{} len:{}".format(name,key_tmp,len(self.read_phonebook)))
+        print("call_phonebook_one_call name:{} key_tmp:{} len:{}".format(name,key_tmp,len(self.read_phonebook)))
 
     def call_phonebook_two_call(self, event, msg):
         name = ''
@@ -2474,21 +2473,23 @@ class AddrBookManager(Abstract):
         name = ''
         key_tmp = ''
         if self.read_phonebook != {}:
-            if len(self.read_phonebook) >= 3:
+            if len(self.read_phonebook) >= 2:
                 phonebook_keys = sorted(self.read_phonebook.keys())
                 name = self.read_phonebook[phonebook_keys[2]]
                 key_tmp = phonebook_keys[2]
                 if len(name) != 0:
+                    #voiceCall.callStart(str(name))
                     EventMesh.publish("save_phonename",str(name))
                     EventMesh.publish("save_phonenum",str(name))
                     EventMesh.publish("dial_out_call_center_cb",str(name))#电话拨出去
-                    # voiceCall.callStart(str(name))
                 else:
                     EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
                 
             else:
                 EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
-            print("call_phonebook_three_call name:{} key_tmp:{}".format(name,key_tmp))
+        else:
+            EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
+        print("call_phonebook_three_call name:{} key_tmp:{}".format(name,key_tmp))
 
     def set(self, event, msg):
         self.check_json = msg[0]
@@ -2917,6 +2918,8 @@ class getTempTimeManager(Abstract):
     
     def set_temp_state(self, event, msg): 
         self.get_temp = msg
+        if msg != 0:
+            EventMesh.publish("set_hr_blood_led",1)#红绿灯交替闪烁
 
     def get_temp_state(self, event, msg): 
         return self.get_temp
@@ -3126,32 +3129,30 @@ class getSosFlagManager(Abstract):#设置sos
     def set_sos_flag(self, event, msg): 
         self.sos_flag = msg
        
-        # if self.sos_flag == 1:
-        #     number = EventMesh.publish("get_dial_sos_number")
-        #     print("set_sos_flag")
-        #     if number != None:
-        #         if len(number) > 0:
-        #             EventMesh.publish("save_phonename",number[0])
-        #             EventMesh.publish("save_phonenum",number[0])
-        #             EventMesh.publish("set_sos_num",0)
-        #             phone_num = EventMesh.publish("get_phonenum")  
-        #             EventMesh.publish("dial_out_call_center_cb",phone_num)#电话拨出去
-        #         else:
-        #             EventMesh.publish("dial_out_call_center_cb",None)#电话拨出去
+        if self.sos_flag == 1:
+            number = EventMesh.publish("get_dial_sos_number")
+           
+            if number != None:
+                if len(number) > 0:
+                    EventMesh.publish("save_phonename",number[0])
+                    EventMesh.publish("save_phonenum",number[0])
+                    EventMesh.publish("set_sos_num",0)
+                    phone_num = EventMesh.publish("get_phonenum")  
+                    EventMesh.publish("sos_out_call_center_cb",phone_num)#电话拨出去
+                else:
+                    EventMesh.publish("sos_out_call_center_cb",None)#电话拨出去
 
     def set_callnumer_cb(self, event, msg):
         self.callnumer = msg
-        self.call_timer.start(10000, 0, self.call_timer_cb)#延迟10S 继续拨打
+        self.call_timer.start(5000, 0, self.call_timer_cb)#延迟10S 继续拨打
 
     def call_timer_cb(self, *args, **kwargs):
-        # print("call_timer_cb:{}".format(self.callnumer))
-        EventMesh.publish("save_phonename",str(self.callnumer))
-        EventMesh.publish("save_phonenum",str(self.callnumer))
-        phone_num = EventMesh.publish("get_phonenum")  
-        EventMesh.publish("dial_out_call_center_cb",phone_num)#电话拨出去
-        # phone_num = EventMesh.publish("get_phonenum")  
-        # voiceCall.callStart(phone_num)
-        # self.aud.play(1, 1, 'U:/static/R_SOS_ALERT.mp3')  #电话呼叫启动中 
+        if self.sos_flag == 1:
+            EventMesh.publish("save_phonename",str(self.callnumer))
+            EventMesh.publish("save_phonenum",str(self.callnumer))
+            phone_num = EventMesh.publish("get_phonenum")  
+            EventMesh.publish("sos_out_call_center_cb",phone_num)#电话拨出去
+       
 
     def get_sos_flag(self, event, msg): 
         return self.sos_flag
@@ -3307,6 +3308,345 @@ class testSmsSetIPManager(Abstract):#
         # return [self.newip,self.newcom,self.newmd5]
         if(tmp_data != None):
             return [self.newip,self.newcom]
+        
+
+class deleteSmsManager(Abstract):#删除信息
+    def __init__(self):
+        pass
+
+    def post_processor_after_instantiation(self):
+        EventMesh.subscribe("delete_sms_event", self.delete_sms_event)#删除短信
+        EventMesh.subscribe("delete_sms_thread", self.delete_sms_thread)#
 
+    def delete_sms_event(self, event, msg): 
+        EventMesh.publish_async("remove_all_sms_cb","",1*1024)
+
+    def delete_sms_thread(self, event, msg):
+        sms.deleteMsg(1,4)
+
+#闹钟信息
+alarm_list = [{'hour': 16, 'repeart': 10, 'idx': 0, 'enabled': 0, 'days': [], 'minute': 39},
+               {'hour': 16, 'repeart': 10, 'idx': 1, 'enabled': 0, 'days': [], 'minute': 39}]
+#用于显示闹钟列表不包含开关机信息
+
+class ClockManager(Abstract):
+    def __init__(self):
+        super().__init__()
+        self.rtc = RTC()
+        self.days = 0
+        self.idx = 0
+
+        IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json") 
+        self.check_alarm_list = []     
+        if IFEXIST == True:
+            with open("/usr/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd:
+                self.check_alarm_list = ujson.load(fd)
+        
+        EventMesh.subscribe("push_clock_info", self.set)
+        EventMesh.subscribe("read_alarminjson", self.read_alarminjson)
+        EventMesh.subscribe("add_alarm", self.add_alarm)
+        EventMesh.subscribe("remove_alarm", self.remove_alarm)
+        EventMesh.subscribe("set_rtc_alarm", self.set_rtc_alarm)
+        EventMesh.subscribe("get_alarm_indx", self.get_alarm_indx)
+        EventMesh.subscribe("get_check_alarm_list", self.get_check_alarm_list)
+        EventMesh.subscribe("push_update_alarm_show", self.update_show_info)
+
+    def post_processor_after_instantiation(self):
+        
+
+        EventMesh.publish("read_alarminjson")
+        EventMesh.publish("set_rtc_alarm")
+       
+    def update_show_info(self,event,msg):
+        EventMesh.publish("read_alarminjson")
+        EventMesh.publish("set_rtc_alarm")
+
+    def get_check_alarm_list(self, event, msg):
+        alarm_len = 0
+        global alarm_list
+        EventMesh.publish("read_alarminjson")
+        alarm_len = len(alarm_list)
+        return alarm_len
+
+
+    def set(self, event, msg):
+        global alarm_list
+        print("msg = {}".format(msg))
+        idx = msg.get("idx")
+        print("修改第{}个闹钟信息{}".format(idx,alarm_list[idx]))
+        alarm_list[idx]["hour"] = msg["hour"]
+        alarm_list[idx]["minute"] = msg["minute"]
+        alarm_list[idx]["days"] = msg["days"]
+        alarm_list[idx]["enabled"] = msg["enabled"]
+        alarm_list[idx]["repeart"] = msg["repeart"]
+        with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+            ujson.dump(alarm_list,fd)
+
+    def read_alarminjson(self, event, msg):
+        IFEXIST = ql_fs.path_exists("/usr/static/storage_file/alarm_msg.json") 
+        global alarm_list     
+        print("IFEXIST:{}".format(IFEXIST))
+        if IFEXIST == True:
+            with open("/usr/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd:
+                alarm_list = ujson.load(fd)
+        return alarm_list
+
+    def add_alarm(self, event, msg):
+
+        global alarm_list
+        EventMesh.publish("read_alarminjson")
+        idx = len(alarm_list)
+        
+        # msg = ['1','06:90','23:59']
+        count = 1
+        new = 0
+        num = 0
+        print("msg:{}".format(msg))
+        # if msg[0] == 1:
+        # msg_new = msg[1]
+        for i in range(0,2):#开关机固定是 idx 0 1
+            off_msg1 = msg[i+1]
+            msg_tmp1 = off_msg1.split(':')
+            start_hour = int(msg_tmp1[0])
+            start_min = int(msg_tmp1[1])
+            enable = int(msg[0])
+            EventMesh.publish("set_boot_off_time",[msg[0],msg[1],msg[2]])
+            if alarm_list and new == 0 :
+                for x in range(0,5):
+                    # print("count :{} self.alarm_list:111111{} len(self.alarm_list):{}".format(count,alarm_list,len(alarm_list)))
+                    if new == 1 and count > len(alarm_list):
+                        break
+                    tmp = alarm_list[count-1]['idx']
+                    if tmp == 0 or tmp == 1:#覆盖旧的
+                        alarm_list[count-1] = {"idx": tmp, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10}
+                        count+=1
+                        if count > len(alarm_list):
+                            new = 1
+                        # print("self.alarm_list:5555 {}".format(alarm_list))
+                        break
+                    else:#添加最新的
+                        count+=1
+                        if tmp == 2 or tmp == 3 or tmp == 4:#添加最新的
+                            msg_tmp = EventMesh.publish("get_boot_off_time")
+                            # print("msg_tmp all_data {}".format(msg_tmp))
+                            if msg_tmp != None: 
+                                if len(msg_tmp[0]) > 0:#只有关机时间长度为0时才添加新元素 不是就覆盖原来旧的数据
+                                    # print("self.alarm_list:444444 {}".format(alarm_list))
+                                    if count > len(alarm_list):
+                                        new = 1
+                                    continue
+                                else:
+                                    alarm_list.append({"idx": num, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10}) 
+                                    # print("self.alarm_list:7777777 {}".format(alarm_list))
+                                    if count > len(alarm_list):
+                                        new = 1
+                                    break
+                    count+=1
+                    # print("self.alarm_list:111111 {}".format(alarm_list))
+                    
+            else:#添加最新的
+                alarm_list.append({"idx": num, "hour": start_hour, "minute": start_min, "days":[0,1,2,3,4,5,6], "enabled": enable,"repeart":10})
+                new = 1
+            num+=1
+            # print("add_here-----idx:{} msg:{} alarm_list:{}".format(idx,msg,alarm_list))
+
+        
+        print("alarm_list----len- :{}".format(len(alarm_list)))
+        with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+            ujson.dump(alarm_list,fd)
+        EventMesh.publish("push_update_alarm_show")
+        
+       
+            
+        
+
+
+    def remove_alarm(self, event, msg):
+        global alarm_list
+        print("ddddddddddddddddddd:",msg)
+        idx = msg.get("idx")
+        print("delete_here1-----{},{}:".format(idx,msg))
+
+        for i, alarm in enumerate(alarm_list):
+            print("delete_here2-----{},{}:".format(i,alarm))
+
+            if alarm["idx"] == idx:
+                del alarm_list[i]
+                print("delete_here3-----",alarm_list)
+
+                #删除闹钟后,对idx重新排序
+                if alarm_list:
+                    for j in range(i,len(alarm_list)):
+                        alarm_list[j]["idx"] -= 1
+                        print("delete_here4-----",alarm_list)
+
+        with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+            ujson.dump(alarm_list,fd)
+
+
+    def get_alarm_indx(self,event,msg):
+        return self.idx
+
+    def _rtc_callback(self,args):
+        print("---!!!!!!alarm_ring!!!!!!!---,idx:",args)
+        global alarm_list
+        EventMesh.publish("read_alarminjson")
+        idx = self.idx
+        print("单次闹钟关闭:{} alarm_list:{}".format(idx,alarm_list))
+        #判断是否是单次闹钟,如果是,则将开关状态设置为关闭
+        # for i in range(len(alarm_list)):
+        #     if alarm_list[i]["idx"] == self.idx:
+        #         idx = i
+        if not alarm_list[idx]["days"] :
+            print("关闭1:",alarm_list[idx]["days"])
+            print("关闭2:",alarm_list [idx]["days"])
+            alarm_list[idx]["enabled"] = False
+            with open("/usr/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+                ujson.dump(alarm_list,fd)
+        EventMesh.publish("set_rtc_alarm")
+        #设置下一个闹钟,定时开关机功能
+        if 0 :
+            msg_data = EventMesh.publish("get_boot_off_time")
+            print("msg_tmp:{}".format(msg_data))
+            
+            msg_tmp = msg_data[0]
+            off_tmp2  = msg_tmp[2]
+            msg_tmp2 = off_tmp2.split(':')
+            end_min = int(msg_tmp2[0])*60+int(msg_tmp2[1])
+
+            rtc_now_time = self.rtc.datetime()
+            current = rtc_now_time[4]*60+rtc_now_time[5]
+            
+            print("end_min:{} current:{} off_tmp2:{}".format(end_min,current,off_tmp2))
+            if end_min == current:#结束的时间分钟等于关机时间分钟数则关机
+                # EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
+                return
+        
+
+        
+        # get_hr_state = EventMesh.publish("get_hr_state")
+        # get_spo2_state = EventMesh.publish("get_spo2_state")
+        # if get_hr_state != None or get_spo2_state != None:
+        #     if get_hr_state != 1 and get_spo2_state != 1:
+        EventMesh.publish("OPEN_ALARM_RING")#闹钟到点响铃
+                # EventMesh.publish("load_screen", {"screen": "popup_alarm"})
+    # def _reset_rtc_alarm_time(self, args):
+    #     print("---alarm_ring---")
+
+    def set_rtc_alarm(self,event,msg):
+        global alarm_list
+        EventMesh.publish("read_alarminjson")
+        rtc_now_time = self.rtc.datetime()
+
+       # print("00获取所有闹钟信息:{}".format(alarm_list))
+        new_alarm_list = [(alarm['hour'], alarm['minute'], alarm['days'],alarm["idx"]) for alarm in alarm_list if alarm['enabled']]
+
+        print("01获取开启的闹钟:{}".format(new_alarm_list))
+        start_day = 0 # 周日
+        start_minute = 0 # 0点
+        end_minute = 60*24*7
+        minute_list = []
+
+        if not new_alarm_list:
+            print("02当前并没有开启的闹钟,退出闹钟设置程序:{}".format(new_alarm_list))
+            self.rtc.enable_alarm(0)
+            return
+        
+        for alarm in new_alarm_list:
+            hour, minute, days,idx = alarm
+            #如果没有选择day,则表示是单次闹钟
+            if days:
+                for day in days:
+                    minute_list.append(hour*60 + minute + (day-start_day)*24*60)
+                   
+            else:
+                #如果当前时间没超过闹钟设置时间,则设置为今天,否则设置为明天
+                if (hour*60 + minute) > (rtc_now_time[4]*60 + rtc_now_time[5]):
+                    minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day)*24*60)
+                    print("设置单次闹钟:{}".format(new_alarm_list))
+
+                else:
+                    minute_list.append(hour*60 + minute + (rtc_now_time[3]-start_day+1)*24*60)
+        
+        total_minutes = sorted(minute_list)
+        print("02以周日00:00为起点,计算所有开启闹钟的total_min并排序:{}".format(total_minutes))
+
+        #获取当前时间  (2020, 9, 11, 5, 15, 43, 23, 0)
+        # rtc_now_time = (2020, 9, 11, 6, 11, 43, 23, 0)
+        # rtc_now_time = self.rtc.datetime()
+
+        print("03当前的rtc时间:{}".format(rtc_now_time))  
+
+        current_minute = rtc_now_time[4]*60 + rtc_now_time[5] + (rtc_now_time[3]-start_day)*24*60
+        print("04当前的rtc_total_minutes:{}".format(current_minute))  
+
+        if current_minute in minute_list:
+            print("当前时间和闹钟列表时间重复,删除重复的时间")
+            minute_list.remove(current_minute)
+
+        minute_list.append(current_minute)
+
+        # 对分钟数列表进行排序,并获取当前时间分钟数所在的位置
+        minute_list = sorted(minute_list)
+        current_index = minute_list.index(current_minute)
+
+        print("05将当前时间插入min_list后的min_list:{}".format(minute_list))  
+        print("06当前时间所在位置:{}".format(current_index))  
+
+        next_index = current_index + 1
+        if next_index >= len(minute_list):
+            next_minute = minute_list[0]
+            print("07下一个闹钟的分钟数:", next_minute)
+        else:
+            next_minute = minute_list[next_index]
+            print("07下一个闹钟的分钟数:", next_minute)
+
+        if next_minute >= current_minute:
+            interval_minute = next_minute - current_minute
+            print("08距离下一次响铃的的分钟数:", interval_minute)
+        else:
+            interval_minute = end_minute - current_minute + next_minute
+            print("08距离下一次响铃的的分钟数:", interval_minute)
+
+        #反向获取时间戳
+        time = utime.localtime()
+        print("09获取utime的时间戳:", time)
+        rtc_mktime = utime.mktime(time)
+        print("10反向获取utime的mktime:", rtc_mktime)
+
+        #加上下一次响铃需要的时间
+        next_alarm_mktime = rtc_mktime + interval_minute*60
+        print("11下一次响铃的mktime:", next_alarm_mktime)
+
+        #格式化时间戳,得到下一次闹钟的时间
+        next_alarm_time = utime.localtime(next_alarm_mktime)
+        print("12下一次响铃的准确时间:", next_alarm_time)
+        #将时间转换为rtc的格式
+        data_l = [2021, 7, 9, 5, 12, 30, 0, 0]
+        #给rtc时间赋值
+        data_l[0] = next_alarm_time[0] #year
+        data_l[1] = next_alarm_time[1] #month                    
+        data_l[2] = next_alarm_time[2] #day                     
+        data_l[4] = next_alarm_time[3] #hour               
+        data_l[5] = next_alarm_time[4] #minute               
+        #转换为元组       
+        data_e=tuple(data_l)
+        print("13将该时间转换为RTC元组:", data_e)
+       
+        for alarm in alarm_list:
+            if not alarm["days"] and alarm["enabled"]:
+                print("关闭666:",alarm["idx"])
+                if alarm["hour"] == data_l[4] and alarm["minute"]==data_l[5]:
+                    self.idx = alarm["idx"]
+        #设置rtc闹钟时间
+        self.rtc.register_callback(self._rtc_callback)
+
+        FLAG = self.rtc.set_alarm(data_e)
+        if FLAG == 0:
+            print("14成功设置rtc的到期时间:", data_e)
+        else:
+            print("14设置rtc的到期时间失败:", data_e)
+        
+        self.rtc.enable_alarm(1)
+         
 
-    
\ No newline at end of file
index 5ebd0fa..ab55adc 100644 (file)
@@ -23,7 +23,7 @@ import usys
 
 
 def server_init(server_type = None):
-    #服务器选择1,防走丢,2大锤,3三基同创,4童信
+    #服务器选择1,防走丢,2大锤,3三基同创,4童信,5云米,6荣为
     if server_type == None:
         server_type = 1
     #print("server_init:server_type:{}".format(server_type))
@@ -56,6 +56,11 @@ def server_init(server_type = None):
         d_server_port = 8505
         d_md5_key = ""
         d_PID = "3G"
+    elif server_type == 6:
+        d_server_addr = "120.26.104.21"
+        d_server_port = 9968
+        d_md5_key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
+        d_PID = "SZKW"
     return [d_server_addr,d_server_port,d_md5_key,d_PID]
 from queue import Queue
 def unicode_to_utf8(src):
@@ -157,7 +162,7 @@ class SockManager(Abstract):
 
     def connect(self):
         print("connect1{}:{}".format(self.server_addr, self.server_port))
-        if EventMesh.publish("network_state") == 0: #没注网
+        if EventMesh.publish("get_sim_Status") != 1: #没sim
             return
         try:
             if(self.sock != None) :
@@ -203,7 +208,7 @@ class SockManager(Abstract):
             data = self.socket_send_queue.get()
             print("TCP:send data1 len:{}".format(len(data)))
 
-            # print("ui_queue_thread:data = {}".format(data))
+            #print("ui_queue_thread:data = {}".format(data))
             socketsta = self.sock.getsocketsta() 
             if(socketsta == -1): #给释放了或者出错了
                 continue
@@ -215,8 +220,8 @@ class SockManager(Abstract):
                     except Exception as e:
                         self.reconnect()
                         self.socket_send_queue.put(data)#重新把数据加回队列
-                        print("socket_send_queue_thread1:ERROR:")
-                        usys.print_exception(e)
+                        #print("socket_send_queue_thread1:ERROR:")
+                        #usys.print_exception(e)
             elif socketsta < 4:#正在连接,等待连接成功重新发送
                 count = 0
                 while True:
@@ -230,8 +235,8 @@ class SockManager(Abstract):
                         except Exception as e:
                             self.reconnect()
                             self.socket_send_queue.put(data)#重新把数据加回队列
-                            print("socket_send_queue_thread2:ERROR:")
-                            usys.print_exception(e)
+                            #print("socket_send_queue_thread2:ERROR:")
+                            #usys.print_exception(e)
                         break
             else :#连接错误
                 print("socket_send_queue_thread:ERROR:reconnect")
@@ -240,7 +245,7 @@ class SockManager(Abstract):
 
     def send(self, topic, msg):
        # print("TCP:send data:{}".format(msg))
-        if EventMesh.publish("network_state") == 0: #没注网,则不发送
+        if EventMesh.publish("get_sim_Status") != 1: #没sim,则不发送
             EventMesh.publish(constants.EVENT.SET_CONNECT, 0)#标记断网
             print("dataCall not connect")
             return
@@ -266,7 +271,7 @@ class SockManager(Abstract):
                 data = data + r
                 print("TCP recv: data:len:{}".format(len(data)))
                 
-                # print("TCP recv: data:{}".format(data))
+                print("TCP recv: data:{}".format(data))
                 if data[-1] != 0x5d and len(data)<20*1024: #']':
                     continue
                 self.connect_tmp = 1 #有数据,就认为是连接状态
@@ -282,8 +287,8 @@ class SockManager(Abstract):
                 
                 data = b''
             except Exception as e:
-                print("TCP:ERROR:recv:")
-                usys.print_exception(e)
+                #print("TCP:ERROR:recv:")
+                #usys.print_exception(e)
                 self.run_flag = False
                 self.reconnect()
                 
@@ -547,7 +552,7 @@ class UD_ProtoCol(ProtoCol):
         
         MD5_SIGN = self.pack_MD5_head(MD5_head_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("UD:data:{}".format(data))
+        #EventMesh.txt_log("{}".format(data))
         # wt_data = EventMesh.publish("get_weather_data")
         # # #如果没有天气数据,则获取天气数据
         # if wt_data != None or wt_data[0] == None :
@@ -776,39 +781,72 @@ class REMIND_ProtoCol(ProtoCol):
 
         alarm_new  = EventMesh.publish("read_alarminjson")
         # print("alarm_list:{} msg_tmp:{}",alarm_new,msg_tmp)
-
-        k=0
-        if len(alarm_new) < 5 :
-            alarm_new = []
-            for i in range(5):
-                alarm_new.append({'hour': 16, 'repeart': 1, 'idx': i, 'enabled': 0, 'days': [], 'minute': 39}) 
-        for j in range(2,5):#0 1是开关机,234是闹钟
+        k=1
+        count = 0
+        
+        for i in range(len(str(msg_tmp))):#寻找有多少个,号
+            if msg_tmp[i] == ',':#, , ,
+                k+=1
+        # if len(alarm_new) < 5 :
+        #     alarm_new = []
+        #     for i in range(5):
+        #         alarm_new.append({'hour': 8, 'repeart': 10, 'idx': i, 'enabled': 0, 'days': [], 'minute': 39}) 
+        # print("len",len(alarm_new),alarm_new)
+        if len(alarm_new) > 2:
+            for i in range(0,len(alarm_new)-2):
+                # print("alarm_new_tmp",alarm_new)
+                del alarm_new[2]
+        # print("alarm_new:{}",alarm_new)
+        for j in range(2,2+k):#0 1是开关机,234是闹钟
             alarm_day = []
             alarm_week = []
             alarm_total_data = []
-            alarm_total_data = msg_tmp.split(',')[k]
-            k+=1
-            b = alarm_total_data.find('-')
-            if b != -1:
-                alarm_data = alarm_total_data.split('-')#-作为分隔符
-                alarm_switch = int(alarm_data[1])#开关
-                alarm_day_num = int(alarm_data[2])#天
-                alarm_time = alarm_data[0]#时间
-                alarm_time_tmp = alarm_time.split(':')#冒号分隔时间 时 分
-                alarm_time_hour = int(alarm_time_tmp[0])
-                alarm_time_min = int(alarm_time_tmp[1])
-                if alarm_day_num == 3:
-                    alarm_week = alarm_data[3]#星期
-
-                if alarm_day_num == 2:#每一天
-                    alarm_day = [1,2,3,4,5,6,0]
-                elif alarm_day_num == 3:#自定义
-                    for i in range(0,7):
-                        if alarm_week[i] != '0':
-                           alarm_day.append(i)
-                alarm_new[j] = {"idx": j, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num}
-                
-        # print("self.alarm_list: {}".format(alarm_new))
+            # print("j!!!!!!!!!!",j)
+            if k == 1:
+                if len(msg_tmp) != 0:
+                    alarm_data = msg_tmp.split('-')#-作为分隔符
+                    alarm_switch = int(alarm_data[1])#开关
+                    alarm_day_num = int(alarm_data[2])#天
+                    alarm_time = alarm_data[0]#时间
+                    alarm_time_tmp = alarm_time.split(':')#冒号分隔时间 时 分
+                    alarm_time_hour = int(alarm_time_tmp[0])
+                    alarm_time_min = int(alarm_time_tmp[1])
+                    if alarm_day_num == 3:
+                        alarm_week = alarm_data[3]#星期
+
+                    if alarm_day_num == 2:#每一天
+                        alarm_day = [1,2,3,4,5,6,0]
+                    elif alarm_day_num == 3:#自定义
+                        for i in range(0,7):
+                            if alarm_week[i] != '0':
+                                alarm_day.append(i)
+                    alarm_new.append({"idx": j, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num})
+            else:
+                if len(msg_tmp) != 0:
+                    alarm_total_data = msg_tmp.split(',')[count]
+                    count+=1
+                    b = alarm_total_data.find('-')
+                    if b != -1:
+                        alarm_data = alarm_total_data.split('-')#-作为分隔符
+                        alarm_switch = int(alarm_data[1])#开关
+                        alarm_day_num = int(alarm_data[2])#天
+                        alarm_time = alarm_data[0]#时间
+                        alarm_time_tmp = alarm_time.split(':')#冒号分隔时间 时 分
+                        alarm_time_hour = int(alarm_time_tmp[0])
+                        alarm_time_min = int(alarm_time_tmp[1])
+                        if alarm_day_num == 3:
+                            alarm_week = alarm_data[3]#星期
+
+                        if alarm_day_num == 2:#每一天
+                            alarm_day = [1,2,3,4,5,6,0]
+                        elif alarm_day_num == 3:#自定义
+                            for i in range(0,7):
+                                if alarm_week[i] != '0':
+                                    alarm_day.append(i)
+                        alarm_new.append({"idx": j, "hour": alarm_time_hour, "minute": alarm_time_min, "days":alarm_day, "enabled": alarm_switch,"repeart":alarm_day_num})
+                        
+        # print("alarm_new end:{}",alarm_new)
+        
         with open("/usr/static/storage_file/alarm_msg.json", 'w',encoding='utf-8') as fd:
             ujson.dump(alarm_new,fd)
         EventMesh.publish("push_update_alarm_show")
@@ -816,6 +854,9 @@ class REMIND_ProtoCol(ProtoCol):
         # EventMesh.publish("add_alarm",[0,msg_tmp])
         EventMesh.publish(constants.PROTOCOL.REMIND_SEND)
 
+
+
+
 class HRSTART_ProtoCol(ProtoCol):
     """心率频率数据"""
     TYPE = "hrtstart"
@@ -1127,15 +1168,25 @@ class MONITOR_ProtoCol(ProtoCol):
         @param msg: 接收到的下行数据
         """
         # b'[SZKW*867387060319166*000A*MONITOR]'
-        read_data = EventMesh.publish("get_storage_config","center_dial")
-        print("MONITOR:data:%s"%(read_data))
-        if read_data != None: 
-            contact = read_data
-            if len(contact) > 0:
-                print("MONITOR RECV msg:{} {}".format(contact,type(contact)))
-                EventMesh.publish("save_phonename", contact)  
-                EventMesh.publish("save_phonenum", contact)  
-                EventMesh.publish("dial_out_call_center_cb",contact)#电话拨出去
+        msg = msg[1:-1]
+        msg_tmp = msg.decode('ascii')
+        msg_tmp = msg_tmp.split('MONITOR')
+        msg_tmp = msg_tmp[1]
+        print("MONITOR_ProtoCol RECV msg:{} msg_:{}".format(msg,len(msg_tmp)))
+        if len(msg_tmp) != 0:
+            EventMesh.publish("save_phonename", contact)
+            EventMesh.publish("save_phonenum", contact)
+            EventMesh.publish("dial_out_call_center_cb",contact)#电话拨出去
+        else:
+            read_data = EventMesh.publish("get_storage_config","center_dial")
+            print("MONITOR:data:%s"%(read_data))
+            if read_data != None: 
+                contact = read_data
+                if len(contact) > 0:
+                    print("MONITOR RECV msg:{} {}".format(contact,type(contact)))
+                    EventMesh.publish("save_phonename", contact)
+                    EventMesh.publish("save_phonenum", contact)
+                    EventMesh.publish("dial_out_call_center_cb",contact)#电话拨出去
         EventMesh.publish(constants.PROTOCOL.MONITOR_SEND)  
 
 #定时开关机
@@ -1418,7 +1469,7 @@ class TK_ProtoCol(ProtoCol):
             get_wechat_data = EventMesh.publish("get_wechat_data")
             MXA_MSG = get_wechat_data[0]
             wechat_recode_list = get_wechat_data[1]
-            wechat_num = wechat_recode_list["num"]
+            wechat_num = int(wechat_recode_list["num"])
             # Wechat_log("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
             
             if wechat_num >= MXA_MSG:
@@ -1463,6 +1514,7 @@ class TK_ProtoCol(ProtoCol):
                         break
                 fd.write(arm)
             EventMesh.publish(constants.PROTOCOL.TK_SEND,1)
+            EventMesh.publish("recv_wechat_audio")#
 
             
             
@@ -1527,6 +1579,7 @@ class MESSAGE_ProtoCol(ProtoCol):
         # else:
         #     EventMesh.publish("wechat_updata_list_show")
         EventMesh.publish(constants.PROTOCOL.MESSAGE_SEND)
+        # EventMesh.publish("recv_wechat_audio")#
 
 
 class ProtoColResolver(object):
index f6395b3..c31b85b 100644 (file)
@@ -1,6 +1,5 @@
 import utime
 import osTimer
-import lvgl as lv
 import EventMesh
 from machine import Timer
 import voiceCall
@@ -31,5904 +30,36 @@ def audio_cb(event):
 CALL_LOG_MAX = 50
 aud = audio.Audio(0)
 aud.setCallback(audio_cb)
-# -----------------------------------------style create--------------------------------------
-style_screen = lv.style_t()
-style_screen.init()
-style_screen.set_radius(0)
-style_screen.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
-style_screen.set_bg_opa(255)
-style_screen.set_border_width(0)
-style_screen.set_pad_left(0)
-style_screen.set_pad_right(0)
-style_screen.set_pad_top(0)
-style_screen.set_pad_bottom(0)
 
-style_bar = lv.style_t() 
-style_bar.init()
-style_bar.set_radius(10)
-style_bar.set_bg_color(lv.color_make(0xA0, 0xA0, 0xA0))
-style_bar.set_bg_grad_color(lv.color_make(0xA0, 0xA0, 0xA0))
-style_bar.set_bg_grad_dir(lv.GRAD_DIR.VER)
-style_bar.set_bg_opa(60)
-style_bar.set_pad_left(0)
-style_bar.set_pad_right(0)
-style_bar.set_pad_top(0)
-style_bar.set_pad_bottom(0)
-
-
-style_bar_indic = lv.style_t()
-style_bar_indic.init()
-style_bar_indic.set_radius(10)
-style_bar_indic.set_bg_color(lv.color_make(0xff, 0x61, 0x3a))
-style_bar_indic.set_bg_grad_color(lv.color_make(0xff, 0x61, 0x3a))
-style_bar_indic.set_bg_grad_dir(lv.GRAD_DIR.VER)
-style_bar_indic.set_bg_opa(255)
-# 默认白色
-
-style_font_youyuan_20 = lv.style_t()
-style_font_youyuan_20.init()
-style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff))
-style_font_youyuan_20.set_text_font_v2("font_28.bin",28,0)
-
-style_font_youyuan_40 = lv.style_t()
-style_font_youyuan_40.init()
-style_font_youyuan_40.set_text_color(lv.color_make(0xff, 0xff, 0xff))
-style_font_youyuan_40.set_text_font_v2("font_40.bin",40,0)
-#黑色
-style_font_youyuan_20_black = lv.style_t()
-style_font_youyuan_20_black.init()
-style_font_youyuan_20_black.set_text_color(lv.color_make(0x00, 0x00, 0x00))
-style_font_youyuan_20_black.set_text_font_v2("font_28.bin",28,0)
-
-
-style_font_youyuan_20_red = lv.style_t()
-style_font_youyuan_20_red.init()
-style_font_youyuan_20_red.set_text_color(lv.color_make(0xff, 0x00, 0x00))
-style_font_youyuan_20_red.set_text_font_v2("font_28.bin",28,0)
-
-style_img = lv.style_t()
-style_img.init()
-style_img.set_img_opa(255)
-
-style_line = lv.style_t()
-style_line.init()
-style_line.set_line_width(2)
-style_line.set_line_color(lv.color_make(0xff, 0xff, 0xff))
-
-
-style_list = lv.style_t()
-style_list.init()
-style_list.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
-style_list.set_radius(0)
-style_list.set_bg_opa(255)
-style_list.set_border_width(0)
-style_list.set_pad_left(0)
-style_list.set_pad_right(0)
-style_list.set_pad_top(0)
-
-style_list_scro = lv.style_t()
-style_list_scro.init()
-style_list_scro.set_bg_opa(0)
-
-# create style style_btn
-style_btn = lv.style_t()
-style_btn.init()
-style_btn.set_bg_opa(0)
-style_btn.set_shadow_opa(0)
-style_btn.set_border_width(0)
-
-style_wechat_btn =  lv.style_t()
-style_wechat_btn.init()
-style_wechat_btn.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
-style_wechat_btn.set_border_width(0)
-style_wechat_btn.set_shadow_opa(0)
-
-style_contact_btn =  lv.style_t()
-style_contact_btn.init()
-style_contact_btn.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
-style_contact_btn.set_border_width(0)
-style_contact_btn.set_shadow_opa(0)
-
-style_common_bg_rect_btn_pressed =  lv.style_t()
-style_common_bg_rect_btn_pressed.init()
-style_common_bg_rect_btn_pressed.set_bg_color(lv.color_make(0x1E, 0x26, 0xff))
-style_common_bg_rect_btn_pressed.set_bg_opa(100)
-style_common_bg_rect_btn_pressed.set_border_width(0)
-style_common_bg_rect_btn_pressed.set_shadow_opa(0)
-
-style_contact_btn_pressed = lv.style_t()
-style_contact_btn_pressed.init()
-style_contact_btn_pressed.set_radius(5)
-style_contact_btn_pressed.set_bg_color(lv.color_make(0xff,0xff,0xff))
-style_contact_btn_pressed.set_bg_grad_color(lv.color_make(0x21,0x95,0xf6))
-style_contact_btn_pressed.set_bg_grad_dir(lv.GRAD_DIR.HOR)
-style_contact_btn_pressed.set_bg_opa(217)
-style_contact_btn_pressed.set_border_color(lv.color_make(0x21,0x95,0xf6))
-style_contact_btn_pressed.set_border_width(0)
-style_contact_btn_pressed.set_border_opa(255)
-style_contact_btn_pressed.set_text_color(lv.color_make(0x00,0x00,0x00))
-
-
-style_alipay_btn = lv.style_t()
-style_alipay_btn.init()
-style_alipay_btn.set_bg_color(lv.color_make(0xFF, 0xFF, 0xff))
-style_alipay_btn.set_bg_opa(20)
-style_alipay_btn.set_border_width(0)
-style_alipay_btn.set_shadow_opa(0)
-
-
-
-style_circle = lv.style_t()
-style_circle.init()
-style_circle.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
-style_circle.set_radius(0x7FFF)
-
-
-
-from common import Abstract
-
-class Screen(Abstract):
-    meta_type = "UI"
-    def __init__(self):
-        self.meta = None
-        self.meta_info = None
-        
-    #     self.bg_img = None
-
-    # def set_bg_img(self, _fp):
-    #     print("bg _fp = {} NAME = {} bg_img = {}".format(_fp, self.NAME, self.bg_img))
-    #     if self.bg_img:
-    #         self.bg_img.set_src(_fp)
-  
-    def load_screen(self, e, msg):
-        print("msg = {}".format(msg))
-        EventMesh.publish("load_screen", msg)
-    
-
-
-    def load(self):
-        pass
-
-    def get_meta(self):
-        return self.meta
-
-    def Close(self):
-        pass
-    def lcd_on(self):
-        pass
-    def lcd_off(self):
-        pass
-    def done_left_to_right(self):
-        pass
-
-    def done_right_to_left(self):
-        pass
-
-    def done_bottom_to_top(self):
-        pass
-
-    def done_top_to_bottom(self):
-        pass
-
-    def done_return(self):
-        pass
-
-    def done_click(self):
-        pass
-
-    def done_error(self):
-        pass
-    def handle_message_event(self,data):
-        pass
-    def publish_message_event(self,data):
-        EventMesh.publish("publish_message_event_ui", data)
-
-PHONE_CALL_MAX_DATA = 22
-
-phone_line_points = [{"x":0,"y":0},{"x":0,"y":40}]
-phone_screen = None
-phone_line = None
-phone_label = None
-phone_one = None
-phone_two = None
-phone_three = None
-phone_four = None
-phone_five = None
-phone_six = None
-phone_seven = None
-phone_eight = None
-phone_nine = None
-phone_start = None
-phone_zero = None
-phone_hash = None
-phone_call = None
-phone_call_btn = None
-phone_contact = None
-phone_contact_btn = None
-phone_delete = None
-phone_delete_btn = None
-
-class PhoneScreen(Screen):
-    NAME = "Phone"
-
-    def __init__(self):
-
-        super().__init__()
-        self.meta = None
-        self.phone_num = ''
-        self.phone_list = []
-        self.button = 0
-        self.timer = osTimer()
-        self.timer_cb = 0
-        self.count = 0
-        
-    
-
-    def initialization(self):
-        self.phone_num=''
-        self.phone_list = []
-        global phone_screen ,phone_line,phone_label,phone_one,phone_two,phone_three,phone_four,phone_five,phone_six,phone_seven,phone_eight,phone_nine,phone_start,\
-        phone_zero,phone_hash,phone_call,phone_call_btn,phone_contact,phone_contact_btn,phone_delete,phone_delete_btn
-
-
-        if phone_screen == None:
-            phone_screen = lv.obj()
-            print("phone_screen")
-            phone_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            phone_line = lv.line(phone_screen)
-            phone_line.set_points(phone_line_points,2)
-            phone_line.set_pos(235,8)
-            phone_line.set_size(2,40)
-            phone_line.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            phone_line.add_style(style_line,0)
-
-            phone_label = lv.label(phone_screen)
-            phone_label.set_pos(0, 14)
-            phone_label.set_size(0, 48)
-            phone_label.set_text(" ")
-            phone_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_label.set_long_mode(lv.label.LONG.CLIP)
-            phone_label.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0)
-
-            phone_one = lv.img(phone_screen)
-            phone_one.set_src("U:/static/IMAGE_NUMBER_KEY1_ICON.png")
-            phone_one.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_one.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_one.set_pos(3, 60)
-            phone_one.set_size(76, 50)
-
-            phone_two = lv.img(phone_screen)
-            phone_two.set_size(76, 50)
-            phone_two.set_src("U:/static/IMAGE_NUMBER_KEY2_ICON.png")
-            phone_two.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_two.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_two.set_pos(82, 60)
-
-            phone_three = lv.img(phone_screen)
-            phone_three.set_size(76, 50)
-            phone_three.set_src("U:/static/IMAGE_NUMBER_KEY3_ICON.png")
-            phone_three.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_three.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_three.set_pos(161, 60)
-
-            phone_four = lv.img(phone_screen)
-            phone_four.set_size(76, 50)
-            phone_four.set_src("U:/static/IMAGE_NUMBER_KEY4_ICON.png")
-            phone_four.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_four.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_four.set_pos(3, 112)
-
-            phone_five = lv.img(phone_screen)
-            phone_five.set_size(76, 50)
-            phone_five.set_src("U:/static/IMAGE_NUMBER_KEY5_ICON.png")
-            phone_five.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_five.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_five.set_pos(82, 112)
-
-            phone_six = lv.img(phone_screen)
-            phone_six.set_size(76, 50)
-            phone_six.set_src("U:/static/IMAGE_NUMBER_KEY6_ICON.png")
-            phone_six.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_six.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_six.set_pos(161, 112)
-
-            phone_seven = lv.img(phone_screen)
-            phone_seven.set_size(76, 50)
-            phone_seven.set_src("U:/static/IMAGE_NUMBER_KEY7_ICON.png")
-            phone_seven.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_seven.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_seven.set_pos(3, 164)
-
-            phone_eight = lv.img(phone_screen)
-            phone_eight.set_size(76, 50)
-            phone_eight.set_src("U:/static/IMAGE_NUMBER_KEY8_ICON.png")
-            phone_eight.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_eight.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_eight.set_pos(82, 164)
-
-            phone_nine = lv.img(phone_screen)
-            phone_nine.set_size(76, 50)
-            phone_nine.set_src("U:/static/IMAGE_NUMBER_KEY9_ICON.png")
-            phone_nine.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_nine.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_nine.set_pos(161, 164)
-
-            phone_start = lv.img(phone_screen)
-            phone_start.set_size(76, 50)
-            phone_start.set_src("U:/static/IMAGE_NUMBER_KEYSTAR_ICON.png")
-            phone_start.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_start.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_start.set_pos(3, 216)
-
-            phone_zero = lv.img(phone_screen)
-            phone_zero.set_size(76, 50)
-            phone_zero.set_src("U:/static/IMAGE_NUMBER_KEY0_ICON.png")
-            phone_zero.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_zero.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_zero.set_pos(82, 216)
-
-            phone_hash = lv.img(phone_screen)
-            phone_hash.set_size(76, 50)
-            phone_hash.set_src("U:/static/IMAGE_NUMBER_KEYHASH_ICON.png")
-            phone_hash.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_hash.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_hash.set_pos(161, 216)
-
-            phone_call = lv.img(phone_screen)
-            phone_call.set_size(76, 50)
-            phone_call.set_src("U:/static/IMAGE_BUTTON_DIAL.png")
-            phone_call.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_call.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_call.set_pos(3, 270)
-
-            phone_call_btn = lv.img(phone_screen)
-            phone_call_btn.set_size(76, 52)
-            phone_call_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_call_btn.set_pos(3, 268)
-
-            phone_contact = lv.img(phone_screen)
-            phone_contact.set_size(64, 50)
-            phone_contact.set_src("U:/static/IMAGE_BUTTON_DIAL_CONTACT.png")
-            phone_contact.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_contact.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_contact.set_pos(87, 270)
-
-            phone_contact_btn = lv.img(phone_screen)
-            phone_contact_btn.set_size(76, 52)
-            phone_contact_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_contact_btn.set_pos(87, 268)
-
-            phone_delete = lv.img(phone_screen)
-            phone_delete.set_size(76, 50)
-            phone_delete.set_src("U:/static/IMAGE_BUTTON_DELKEY.png")
-            phone_delete.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_delete.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            phone_delete.set_pos(161, 270)
-
-            phone_delete_btn = lv.img(phone_screen)
-            phone_delete_btn.set_size(76, 52)
-            phone_delete_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-            phone_delete_btn.set_pos(161, 268)
-
-            self.meta = phone_screen
-
-            phone_one.add_event_cb(lambda e: EventMesh.callback_wrapper(self.one(e)),
-                                     lv.EVENT.CLICKED, None)
-            phone_two.add_event_cb(lambda e: EventMesh.callback_wrapper(self.two(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_three.add_event_cb(lambda e: EventMesh.callback_wrapper(self.three(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_four.add_event_cb(lambda e: EventMesh.callback_wrapper(self.four(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_five.add_event_cb(lambda e: EventMesh.callback_wrapper(self.five(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_six.add_event_cb(lambda e: EventMesh.callback_wrapper(self.six(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_eight.add_event_cb(lambda e: EventMesh.callback_wrapper(self.eight(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero(e)),
-                                        lv.EVENT.CLICKED, None)
-
-            phone_call_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.call(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_contact_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.contact(e)),
-                                        lv.EVENT.CLICKED, None)
-            phone_delete_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.delete(e)),
-                                        lv.EVENT.CLICKED, None)
-            
-            phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
-                                        lv.EVENT.CLICKED, None)#短按显示* 
-            
-            phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.pressed_start(e)),
-                                        lv.EVENT.LONG_PRESSED, None)#长按显示+
-            
-            phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.endpressed_start(e)),
-                                        lv.EVENT.RELEASED, None)#释放按键
-            
-
-            phone_hash.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hash(e)),
-                                        lv.EVENT.CLICKED, None)
-            
-
-        self.phone_num=''
-        self.phone_list = []
-        self.count = 0
-        if phone_label != None:
-            phone_label.set_pos(0, 14)
-            phone_label.set_size(0, 0)
-            phone_label.set_text(" ")
-        #phone_label.set_text(" ")
-        # print("self.phone_list :{} self.phone_num:{}".format(self.phone_list,self.phone_num))
-        if self.timer_cb == 0:
-            self.timer_cb = 1
-            self.timer.start(1000,1,self.refresh_line) 
-          
-
-    def refresh_line(self,e):
-        if self.count > 2 :
-            self.count = 1
-        if self.count%2 == 0:
-            phone_line.clear_flag(lv.obj.FLAG.HIDDEN)
-        else:
-            phone_line.add_flag(lv.obj.FLAG.HIDDEN)
-        self.count+=1
-    def one(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("1")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-    
-    def two(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("2")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def three(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("3")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def four(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("4")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def five(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("5")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def six(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("6")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def seven(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("7")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def eight(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("8")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def nine(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("9")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def zero(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:#限制拨号数量20个数字
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("0")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-    
-    def start(self,e):
-        self.button = 0
-
-    def pressed_start(self,e):
-        self.button = 1
-    def Close(self):
-        self.timer_cb = 0
-        self.timer.stop()
-
-    def endpressed_start(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:#限制拨号数量20个数字
-            #self.phone_list.pop(0)
-            return
-  
-        if self.button == 1:#长按
-            self.phone_list.append("+")  
-        else:#短按
-            self.phone_list.append("*")  
-                      
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-    
-    def hash(self,e):
-        if len(self.phone_list) >= PHONE_CALL_MAX_DATA:#限制拨号数量20个数字
-            #self.phone_list.pop(0)
-            return
-        self.phone_list.append("#")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-
-    def delete(self,e):
-        if len(self.phone_list) != 0:
-            self.phone_list.pop()
-            self.phone_num = ''.join(self.phone_list)
-            self.show_num()
-
-    def contact(self,e):
-        EventMesh.publish("load_screen", {"screen": "contacts"})
-
-    def call(self,e):
-        if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
-            self.name = None
-            self.phonebook = {}
-            self.number_tmp = {}
-            if len(self.phone_list) != 0:
-                data = EventMesh.publish("get_phonebook_list")
-                if data != None:
-                    check = data[0]
-                    self.phonebook = data[1]
-                    # print("check :{}".format(check))
-                    if check == 1:#检查通讯录
-                        phonebook_keys = sorted(self.phonebook.keys())
-                        b = str(self.phone_num) in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
-                        j = 0
-                        if b == True:
-                            for i in range(len(self.phonebook)): #字典 key value
-                                #'001:张三':15521469561
-                                name = self.phonebook[phonebook_keys[j]]
-                                name_value = phonebook_keys[j]
-                                number_tmp = str(self.phone_num)
-                                # print("name :{} number_tmp:{}".format(name,number_tmp))
-                                if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
-                                    number_f= name_value
-                                    name_s = number_f.split(':')
-                                    name_s = name_s[1]
-                                    self.name = name_s
-                                    break
-                                j+=1
-                        else:
-                            self.name = self.phone_num
-                    else:
-                        self.name = self.phone_num
-
-                    EventMesh.publish("save_phonenum",self.phone_num)
-                    EventMesh.publish("save_phonename",self.name)#
-                    EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
-            else:
-                EventMesh.publish("load_screen", {"screen": "no_valied_num_screen"})
-        else:#未插卡
-            EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
-            
-
-    def show_num(self):
-        #print("self.phone_num ",self.phone_num,self.phone_list)
-        len_t = len(self.phone_list)*40
-        if len_t > 230:
-            len_t = 230
-        phone_label.set_size(len_t,48)
-        phone_label.set_pos(230-len_t,14)
-        phone_label.set_text(self.phone_num)
-    
-    def lcd_on(self):
-        if self.timer_cb != 0:
-            self.timer_cb = 0
-            self.timer.start(1000,1,self.refresh_line) 
-    
-    def lcd_off(self):
-        self.timer_cb = 1
-        self.timer.stop() 
-
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-call_log_screen  = None
-contacts_cont_list  = None
-call_log_title  = None
-none_call_log_title  = None
-call_log_cont_list_screen = None
-CALLLOG_FLAG = 0
-class CallLogScreen(Screen):
-    NAME = "call_log"
-
-    def __init__(self):
-        super().__init__()
-        self.CALL_LOG_MAX = CALL_LOG_MAX
-        self.meta = None
-        self.log_list = []
-        self.read_call_log = {}
-        self.check_json = 0
-        self.call_log_detail_list = None
-        self.call_log_detail_list_dict = []
-        self.timer = osTimer()
-        EventMesh.subscribe("call_log_update_show_list", self.call_log_update_show_list)
-
-    def post_processor_before_initialization(self):
-        read_call_log = EventMesh.publish("get_call_log_list")
-        if read_call_log != None:
-            self.check_json = read_call_log[0]
-            self.read_call_log = read_call_log[1]
-    
-    
-
-    def call_log_update_show_list(self, event, msg): 
-        read_call_log = EventMesh.publish("get_call_log_list")
-        if read_call_log != None:
-            # print("read_call_log:{}".format(read_call_log))
-            self.check_json = read_call_log[0] #文件是否存在
-            self.read_call_log = read_call_log[1]#通话记录数据
-            self.timer.start(500,0,self.reciving)
-
-    def reciving(self,e):
-       self.btn_create()
-
-    def initialization(self):
-        global call_log_screen,contacts_cont_list ,call_log_title ,none_call_log_title ,call_log_cont_list_screen
-        if call_log_screen  == None:
-            call_log_screen = lv.obj()
-            print("call_log_screen")
-            call_log_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            call_log_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            call_log_cont_list_screen = lv.obj(call_log_screen)
-            call_log_cont_list_screen.set_pos(0, 50)
-            call_log_cont_list_screen.set_size(240, 270)
-            call_log_cont_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            call_log_cont_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            call_log_title = lv.label(call_log_screen)
-            call_log_title.set_pos(0, 10)
-            call_log_title.set_size(240, 40)
-            call_log_title.set_long_mode(lv.label.LONG.WRAP)
-            call_log_title.set_text("通话记录")
-            call_log_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            call_log_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            none_call_log_title = lv.label(call_log_cont_list_screen)
-            none_call_log_title.set_pos(0, 120)
-            none_call_log_title.set_size(240, 40)
-            none_call_log_title.set_long_mode(lv.label.LONG.WRAP)
-            none_call_log_title.set_text(" ")
-            none_call_log_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            none_call_log_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            #self.call_log_detail_list = lv.obj(call_log_screen)
-            self.call_log_detail_list = lv.obj(call_log_cont_list_screen)
-            self.call_log_detail_list.set_pos(0, 0)
-            self.call_log_detail_list.set_size(240, 271)
-            self.call_log_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            self.call_log_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            for i in range(self.CALL_LOG_MAX):
-                _btn = lv.btn(self.call_log_detail_list)
-                _btn.add_flag(lv.obj.FLAG.CLICKABLE)
-                _btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling(e)),
-                                        lv.EVENT.CLICKED, None)
-                _btn.add_flag(lv.obj.FLAG.HIDDEN)
-                _btn_label2 = lv.label(_btn)
-                _btn_label3 = lv.label(_btn)
-                _btn_label4 = lv.label(_btn)
-                _btn_label5 = lv.label(_btn)
-                _btn_label6 = lv.label(_btn)
-                self.call_log_detail_list_dict.append({"_btn":_btn,"_btn_label2":_btn_label2,"_btn_label3":_btn_label3,
-                                              "_btn_label4":_btn_label4,"_btn_label5":_btn_label5,"_btn_label6":_btn_label6})
-            self.meta = call_log_screen
-
-        
-        read_call_log = EventMesh.publish("get_call_log_list")
-        # print("read_call_log:{}".format(read_call_log))
-        if read_call_log != None:
-            self.check_json = read_call_log[0] #文件是否存在
-            self.read_call_log = read_call_log[1]#通话记录数据
-        if self.check_json == True and self.read_call_log != {}:
-            none_call_log_title.set_text(" ")
-        else:
-            none_call_log_title.set_text("暂无记录")
-        self.btn_create()
-    
-    def btn_create(self):
-        EventMesh.publish("publish_message_event_ui",{"func":self.btn_create_screen,"data":0})
-
-    def btn_create_screen(self,data):    
-        global call_log_screen,contacts_cont_list ,call_log_title ,none_call_log_title ,call_log_cont_list_screen
-        h = 0
-        if call_log_screen != None:
-            if self.check_json == True and len(self.read_call_log) != 0:
-                
-                none_call_log_title.set_text(" ")
-
-                # self.call_log_detail_list.delete()#先删除一次控件
-                # self.call_log_detail_list = lv.obj(call_log_cont_list_screen)
-                # self.call_log_detail_list.set_pos(0, 0)
-                # self.call_log_detail_list.set_size(240, 271)
-                # self.call_log_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-                # self.call_log_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-                sort_tmp = self.read_call_log.values()
-                sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
-                # print("self.call_log :{} \r\n sort_new:{}\r\n".format(self.read_call_log,sort_new))
- 
-                for sort_new_tmp in sort_new: #字典 key value
-                    num_count = sort_new_tmp["count"]#获取通话次数
-                    num_name = sort_new_tmp["name"]#获取名称
-                    num_phonnum = sort_new_tmp["number"]#获取电话号码
-                    num_time = sort_new_tmp["time"]#获取电话号码
-
-                    # print("num_count :{} num_name:{} num_time:{}".format(num_count,num_name,num_time))
-                    #_btn = lv.btn(self.call_log_detail_list)
-                    self.call_log_detail_list_dict[h]["_btn"].set_size(240,80)
-                    self.call_log_detail_list_dict[h]["_btn"].set_pos(0,82*h)
-                    self.call_log_detail_list_dict[h]["_btn"].add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
-                    self.call_log_detail_list_dict[h]["_btn"].add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling(e)),
-                                            lv.EVENT.CLICKED, None)
-
-
-                    #_btn_label2 = lv.label(_btn)
-                    self.call_log_detail_list_dict[h]["_btn_label2"].set_pos(0, 5)
-                    self.call_log_detail_list_dict[h]["_btn_label2"].set_size(0, 25)
-                    self.call_log_detail_list_dict[h]["_btn_label2"].set_text(num_phonnum)
-                    #_btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-                    #
-                    #_btn_label3 = lv.label(_btn)
-                    self.call_log_detail_list_dict[h]["_btn_label3"].set_pos(0, 0)
-                    self.call_log_detail_list_dict[h]["_btn_label3"].set_size(0, 0)
-                    self.call_log_detail_list_dict[h]["_btn_label3"].set_text("(" + str(num_count) + ")")
-                    # _btn_label3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-                    #_btn_label4 = lv.label(_btn)
-                    self.call_log_detail_list_dict[h]["_btn_label4"].set_pos(0, 38)
-                    self.call_log_detail_list_dict[h]["_btn_label4"].set_size(230, 30)
-                    self.call_log_detail_list_dict[h]["_btn_label4"].set_text(num_phonnum)
-                    self.call_log_detail_list_dict[h]["_btn_label4"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-                    #_btn_label5 = lv.label(_btn)
-                    self.call_log_detail_list_dict[h]["_btn_label5"].set_pos(0, 5)
-                    self.call_log_detail_list_dict[h]["_btn_label5"].set_size(0, 0)
-                    self.call_log_detail_list_dict[h]["_btn_label5"].set_text(num_name)
-                    # _btn_label5.set_long_mode(lv.obj.LONG.DOT)
-                    # _btn_label5.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-                    #_btn_label6 = lv.label(_btn)
-                    self.call_log_detail_list_dict[h]["_btn_label6"].set_pos(0, 5)
-                    self.call_log_detail_list_dict[h]["_btn_label6"].set_size(230, 28)
-                    self.call_log_detail_list_dict[h]["_btn_label6"].set_text(num_name)
-                    self.call_log_detail_list_dict[h]["_btn_label6"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-                    
-                    self.call_log_detail_list_dict[h]["_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
-                    #self.call_log_detail_list_dict[h]["_btn"].scroll_to_view(lv.ANIM.OFF)
-                    h = h + 1
-                for i in range(self.CALL_LOG_MAX):
-                    if i >= h :
-                        self.call_log_detail_list_dict[i]["_btn"].add_flag(lv.obj.FLAG.HIDDEN)#隐藏多余
-            else:
-                if call_log_cont_list_screen != None:
-                    none_call_log_title.set_text("暂无记录")
-                self.call_log_detail_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
-        
-    def calling(self,e):
-        code = e.get_code()
-        if code == lv.EVENT.CLICKED:
-            global call_log_screen,contacts_cont_list ,call_log_title ,none_call_log_title 
-            # print("e.get_text():{} {}".format(e.get_target().get_child(0).get_text(),e.get_target().get_child(3).get_text()))
-            phonnum = str(e.get_target().get_child(0).get_text())
-            phnoname = e.get_target().get_child(3).get_text()
-            # print("phonnum :{} _msg:{}".format(phonnum,phnoname))
-            
-           
-            self.name = None
-            self.phonebook = {}
-
-            self.call_log = {}
-            self.call_log_value = {}
-            self.read_call_log = {}
-            self.number_tmp = {}
-
-            data = EventMesh.publish("get_phonebook_list")
-            if data != None:
-                check = data[0]
-                self.phonebook = data[1]
-                # print("check :{}".format(check))
-                if check == 1:#检查通讯录
-                    phonebook_keys = sorted(self.phonebook.keys())
-                    b = str(phonnum) in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
-                    j = 0
-                    if b == True:
-                        for i in range(len(self.phonebook)): #字典 key value
-                            #'001:':15521469561
-                            name = self.phonebook[phonebook_keys[j]]
-                            name_value = phonebook_keys[j]
-                            number_tmp = str(phonnum)
-                            # print("name :{} number_tmp:{}".format(name,number_tmp))
-                            if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
-                                number_f= name_value
-                                name_s = number_f.split(':')
-                                name_s = name_s[1]
-                                self.name = name_s
-                                break
-                            j+=1
-                    else:
-                        self.name = phnoname
-                else:
-                    self.name = phnoname
-
-            if self.name == None:
-                self.name = phnoname
-            if len(phonnum) > 0:
-                EventMesh.publish("save_phonename",self.name)#
-                EventMesh.publish("save_phonenum",phonnum)#保存电话号码用于界面显示获取
-                #voiceCall.callStart(str(phonnum))
-                EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
-            else:
-                EventMesh.publish("load_screen", {"screen": "no_valied_num_screen"})#无效的号码 请重新输入
-
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-# ------------------------------拨打电话-------------dialing screen----------------------------------------------------------
-
-dialing_screen = None
-dialing_img = None
-dialing_name = None
-dialing_call_label = None
-hangup_imgbtn = None
-class DialingScreen(Screen):
-    NAME = "dialing"
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        
-        self.call_log = {}
-        self.call_log_value = {}
-        self.read_call_log = {}
-        self.number_tmp = {}
-        self.CALL_LOG_MAX = CALL_LOG_MAX
-    def initialization(self):
-        EventMesh.publish("set_UI_high_priority", 1)
-        global dialing_screen,dialing_img,dialing_name ,hangup_imgbtn 
-        if dialing_screen == None:
-            dialing_screen = lv.obj()
-            print("dialing_screen")
-            dialing_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_img = lv.img(dialing_screen)
-            dialing_img.set_pos(80, 20)
-            dialing_img.set_size(64, 64)
-            dialing_img.set_src("U:/static/IMAGE_NOTICE_CALL.png")
-            dialing_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_name = lv.label(dialing_screen)
-            dialing_name.set_pos(0, 120)
-            dialing_name.set_size(240, 50)
-            dialing_name.set_text(" ")
-            dialing_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            dialing_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_call_label = lv.label(dialing_screen)
-            dialing_call_label.set_pos(0, 174)
-            dialing_call_label.set_size(240, 50)
-            dialing_call_label.set_text("正在等待对方接\n听电话")
-            dialing_call_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            dialing_call_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            hangup_imgbtn = lv.img(dialing_screen)
-            hangup_imgbtn.set_size(64, 64)
-            hangup_imgbtn.set_src("U:/static/hang_up.png")
-            hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-            hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            hangup_imgbtn.set_pos(80, 250)
-            hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
-                                    lv.EVENT.CLICKED, None)
-            self.meta = dialing_screen
-        if dialing_name != None:
-            name = EventMesh.publish("get_phonename")#获取拨打电话名称
-            dialing_name.set_text(name)#名称
-    def post_processor_after_initialization(self):
-       # print("创建通话记录 post_processor_before_initialization\n")
-        utime.sleep_ms(200)#不加延时会切屏
-        #获取字符串
-        name = EventMesh.publish("get_phonename")#获取拨打电话名称
-        content = EventMesh.publish("get_phonenum")#获取电话号码
-        time = EventMesh.publish("screen_get_time")#获取系统时间
-
-        # ["15692025051","2","12:59","哥gdh符合双方和开发商开发好看的思考"],
-        # 格式:{"电话号码":{"timesec":'时间戳',"number":'电话号码',"name":'名字',"time":'时间',"count":'通话次数'}}
-        # dialing_content.set_text(content)#电话号码
-        num = 0
-   
-        date_tmp = utime.localtime()
-        time_tmp = utime.mktime(date_tmp)
-        # print("time_tmp:{}".format(time_tmp))
-        read_call_log = EventMesh.publish("get_call_log_list")
-        check_json = read_call_log[0]
-
-        if check_json == True:
-            self.read_call_log = read_call_log[1]
-            b = content in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
-            if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
-                number_tmp = {}
-                number_tmp = self.read_call_log[content] #通话次数加一
-                num_tmp_t = number_tmp["count"]
-                # print("number_tmp:{} self.read_call_log.value:{}".format(number_tmp,self.read_call_log.values()))
-            else :
-                num_tmp_t = 0
-            num = num_tmp_t 
-        else:
-            num = 0 #通话次数
-
-        sort_tmp = {}
-        sort_tmp = self.read_call_log.values()
-        sort_new = {}
-        sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
-
-        i = 0
-        # 49 50 
-        if len(self.read_call_log) >= self.CALL_LOG_MAX:
-            for sort_new_tmp in sort_new: #字典 key value
-                i+=1 # 1 
-                if i >= self.CALL_LOG_MAX:#大于50条把最后一条删除掉只保留前面50调最新的数据
-                    key_tmp = sort_new_tmp["number"]
-                    del self.read_call_log[key_tmp]
-        tmp = {}
-        tmp["count"]= num+1 #通话次数
-        tmp["time"]= "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通湖时间
-        tmp["name"]= name #名称
-        tmp["timesec"]= time_tmp #时间戳
-        tmp["number"] = content
-
-        self.read_call_log[content] = tmp
-        with open("/usr/static/storage_file/Call_log.json","w",encoding="utf-8") as fd:
-            ujson.dump(self.read_call_log,fd)
-        print("创建通话记录")
-        EventMesh.publish("set_call_log_list", [1,self.read_call_log])
-        EventMesh.publish("call_log_update_show_list")
-        
-    def hangup(self,e):
-        EventMesh.publish("set_UI_high_priority", 0)
-        EventMesh.publish("set_hangup_mode", 1)
-        voiceCall.callEnd()
-
-    def done_return(self):
-        pass
-        #EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn1_release(self):
-        pass
-        #EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        flag = EventMesh.publish("get_lcd_state")
-        if flag == 1:
-            EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
-        else:
-            EventMesh.publish(constants.EVENT.SYSTEM_UP)
-
-
-
-no_sim_popup_screen = None
-no_sim_popup_screen_title1 = None
-no_sim_popup_screen_title2 = None
-#未插卡
-class NoSimScreen(Screen):#
-    NAME = "no_sim_popup_screen"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-
-    def initialization(self):
-        global no_sim_popup_screen,no_sim_popup_screen_title1,no_sim_popup_screen_title2 
-        if no_sim_popup_screen == None :
-            no_sim_popup_screen = lv.obj()
-            print("no_sim_popup_screen")
-            no_sim_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_sim_popup_screen_title1 = lv.label(no_sim_popup_screen)
-            no_sim_popup_screen_title1.set_pos(0, 140)
-            no_sim_popup_screen_title1.set_size(240, 40)
-            no_sim_popup_screen_title1.set_text("无SIM卡或")
-            no_sim_popup_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_sim_popup_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_sim_popup_screen_title2 = lv.label(no_sim_popup_screen)
-            no_sim_popup_screen_title2.set_pos(0, 190)
-            no_sim_popup_screen_title2.set_size(240, 40)
-            no_sim_popup_screen_title2.set_text("无网络")
-            no_sim_popup_screen_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_sim_popup_screen_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            self.meta = no_sim_popup_screen
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-    def done_click(self):
-        EventMesh.publish("return_prev_screen")
-
-    def btn1_release(self):
-        EventMesh.publish("return_prev_screen")
-
-    def btn8_press(self):
-        EventMesh.publish("return_prev_screen")
-
-
-no_valied_num_screen = None
-no_valied_num_screen_title1 = None
-no_valied_num_screen_title2 = None
-#=无效的号码 请重新输入
-class NovaliedNumScreen(Screen):#
-    NAME = "no_valied_num_screen"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-        self.timer_count = 0
-        self.timer=osTimer()
-
-    def initialization(self):
-        global no_valied_num_screen,no_valied_num_screen_title1,no_valied_num_screen_title2 
-        if no_valied_num_screen == None :
-            no_valied_num_screen = lv.obj()
-            print("no_valied_num_screen")
-            no_valied_num_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_valied_num_screen_title1 = lv.label(no_valied_num_screen)
-            no_valied_num_screen_title1.set_pos(0, 140)
-            no_valied_num_screen_title1.set_size(240, 40)
-            no_valied_num_screen_title1.set_text("无效的号码,")
-            no_valied_num_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_valied_num_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            no_valied_num_screen_title2 = lv.label(no_valied_num_screen)
-            no_valied_num_screen_title2.set_pos(0, 190)
-            no_valied_num_screen_title2.set_size(240, 40)
-            no_valied_num_screen_title2.set_text("请重新输入")
-            no_valied_num_screen_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_valied_num_screen_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            self.meta = no_valied_num_screen
-    def post_processor_after_initialization(self):
-        self.timer_count = 0
-        self.timer.start(5000,1,self.timeout_exit)
-
-    def timeout_exit(self,e):
-        self.timer_count+=1
-        if self.timer_count >= 2:
-            self.timer_count = 0
-            EventMesh.publish("return_prev_screen")
-    
-    def Close(self):
-        self.timer.stop()
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-    def done_click(self):
-        EventMesh.publish("return_prev_screen")
-
-    def btn1_release(self):
-        EventMesh.publish("return_prev_screen")
-
-    def btn8_press(self):
-        EventMesh.publish("return_prev_screen")
-
-
-
-no_sim_power_screen = None
-no_sim_power_screen_title = None
-no_sim_power_screen_label =None
-no_sim_power_screen_comfirm =None
-no_sim_power_screen_cancel = None
-no_sim_power_screen_img = None
-
-#未插卡,长按关机
-class NoSimPowerScreen(Screen):#
-    NAME = "no_sim_power_screen"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-
-    def initialization(self):
-        global no_sim_power_screen,no_sim_power_screen_img,no_sim_power_screen_title,no_sim_power_screen_comfirm,no_sim_power_screen_cancel,no_sim_power_screen_label
-        if no_sim_power_screen == None :
-            no_sim_power_screen = lv.obj()
-            print("no_sim_power_screen")
-            no_sim_power_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_sim_power_screen_title = lv.label(no_sim_power_screen)
-            no_sim_power_screen_title.set_pos(0, 20)
-            no_sim_power_screen_title.set_size(240, 40)
-            no_sim_power_screen_title.set_text("无SIM卡,无法拨打")
-            no_sim_power_screen_title.set_long_mode(lv.label.LONG.WRAP)
-            no_sim_power_screen_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_sim_power_screen_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_sim_power_screen_img = lv.img(no_sim_power_screen)
-            no_sim_power_screen_img.set_pos(100, 70)
-            no_sim_power_screen_img.set_size(61, 61)
-            no_sim_power_screen_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            no_sim_power_screen_img.set_src("U:/static/poweroff_icon.png")
-
-
-            no_sim_power_screen_label = lv.label(no_sim_power_screen)
-            no_sim_power_screen_label.set_pos(0, 150)
-            no_sim_power_screen_label.set_size(240, 40)
-            no_sim_power_screen_label.set_text("是否关机?")
-            no_sim_power_screen_label.set_long_mode(lv.label.LONG.WRAP)
-            no_sim_power_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_sim_power_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            no_sim_power_screen_comfirm = lv.img(no_sim_power_screen)
-            no_sim_power_screen_comfirm.set_size(176, 46)
-            no_sim_power_screen_comfirm.set_pos(32, 190)
-            no_sim_power_screen_comfirm.set_src("U:/static/off_icon.png")
-            no_sim_power_screen_comfirm.add_flag(lv.obj.FLAG.CLICKABLE)
-            no_sim_power_screen_comfirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            poweroff_confirm_label = lv.label(no_sim_power_screen_comfirm)
-            poweroff_confirm_label.set_text("确定")
-            poweroff_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
-            poweroff_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_sim_power_screen_cancel = lv.img(no_sim_power_screen)
-            no_sim_power_screen_cancel.set_size(176, 46)
-            no_sim_power_screen_cancel.set_pos(32, 250)
-            no_sim_power_screen_cancel.set_src("U:/static/cancel_icon.png")
-            no_sim_power_screen_cancel.add_flag(lv.obj.FLAG.CLICKABLE)
-            no_sim_power_screen_cancel.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            poweroff_return_label = lv.label(no_sim_power_screen_cancel)
-            poweroff_return_label.set_text("取消")
-            poweroff_return_label.align(lv.ALIGN.CENTER, 0, 5)
-            poweroff_return_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            no_sim_power_screen_cancel.set_ext_click_area(20)
-
-            self.meta = no_sim_power_screen
-            no_sim_power_screen_comfirm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)),
-                                     lv.EVENT.CLICKED, None)
-        
-            no_sim_power_screen_cancel.add_event_cb(lambda e: EventMesh.callback_wrapper(self.cancel(e)),
-                                     lv.EVENT.CLICKED, None)
-
-    def confirm(self,e):
-        EventMesh.publish("load_screen", {"screen": "poweroff_comfirm"})
-
-    def cancel(self,e):
-        EventMesh.publish("return_prev_screen")
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-    def done_click(self):
-        pass
-        #EventMesh.publish("return_prev_screen")
-
-    def btn1_release(self):
-        #EventMesh.publish("return_prev_screen")
-        pass
-
-    def btn8_press(self):
-        EventMesh.publish("return_prev_screen")
-
-dialing_popup_screen = None
-dialing_popup_img = None
-dialing_popup_name = None
-dialing_popup_hangup_imgbtn = None
-class DialingNoPlayPopupScreen(Screen):#正在拨号中...未打出
-    NAME = "dialing_noplay_popup"
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-        self.timer1 = osTimer()
-        self.time_count = 0
-        self.timer2 = osTimer()
-       
-    def initialization(self):
-        EventMesh.publish("set_UI_high_priority", 1)
-        global dialing_popup_screen,dialing_popup_img,dialing_popup_name ,dialing_popup_call,dialing_popup_hangup_imgbtn 
-        if dialing_popup_screen == None:
-            dialing_popup_screen = lv.obj()
-            print("dialing_popup_screen")
-            dialing_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_popup_img = lv.img(dialing_popup_screen)
-            dialing_popup_img.set_pos(80, 20)
-            dialing_popup_img.set_size(64, 64)
-            dialing_popup_img.set_src("U:/static/IMAGE_NOTICE_CALL.png")
-            dialing_popup_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_popup_name = lv.label(dialing_popup_screen)
-            dialing_popup_name.set_pos(0, 120)
-            dialing_popup_name.set_size(240, 50)
-            dialing_popup_name.set_text(" ")
-            dialing_popup_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            dialing_popup_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_popup_call = lv.label(dialing_popup_screen)
-            dialing_popup_call.set_pos(0, 180)
-            dialing_popup_call.set_size(240, 50)
-            dialing_popup_call.set_text("正在拨号中")
-            dialing_popup_call.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            dialing_popup_call.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_popup_hangup_imgbtn = lv.img(dialing_popup_screen)
-            dialing_popup_hangup_imgbtn.set_size(64, 64)
-            dialing_popup_hangup_imgbtn.set_src("U:/static/hang_up.png")
-            dialing_popup_hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-            dialing_popup_hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            dialing_popup_hangup_imgbtn.set_pos(80, 250)
-            dialing_popup_hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
-                                    lv.EVENT.CLICKED, None)
-            self.meta = dialing_popup_screen
-        if dialing_popup_name != None:
-            name = EventMesh.publish("get_phonename")#获取拨打电话名称
-            dialing_popup_name.set_text(name)#名称
-
-    def post_processor_after_initialization(self):
-        self.time_count = 0
-        self.timer1.start(1000, 1, self.timeout_hangup)
-        self.timer2.start(2000, 0, self.timeout_call)
-
-    def timeout_call(self,e):
-        phone_num = EventMesh.publish("get_phonenum")  
-        EventMesh.publish("set_call_state", 1)#
-        voiceCall.callStart(phone_num)
-        
-    def timeout_hangup(self,e):
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.time_count+=1
-        if self.time_count >= 5:#5s内没有打通则不在继续拨打关闭
-            self.time_count = 0
-            EventMesh.publish("set_UI_high_priority", 0)
-            sos_flag = EventMesh.publish("get_sos_flag")
-            if sos_flag == 1:
-                EventMesh.publish("set_sos_flag",0)
-                EventMesh.publish("set_sos_num",0)
-                EventMesh.publish("set_hangup_mode",0)
-
-            EventMesh.publish("load_screen", {"screen": "dial_no_connect_popup"})
-
-    def hangup(self,e):
-        EventMesh.publish("set_UI_high_priority", 0)
-        voiceCall.callEnd()
-        sos_flag = EventMesh.publish("get_sos_flag")
-        if sos_flag == 1:
-            EventMesh.publish("set_sos_flag",0)
-            EventMesh.publish("set_sos_num",0)
-            EventMesh.publish("set_hangup_mode",0)
-        EventMesh.publish("return_prev_screen") #返回上一级
-
-    def Close(self):
-        self.timer1.stop()
-        self.timer2.stop()
-
-    def done_return(self):
-        pass
-        #EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn1_release(self):
-        pass
-        #EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        flag = EventMesh.publish("get_lcd_state")
-        if flag == 1:
-            EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
-        else:
-            EventMesh.publish(constants.EVENT.SYSTEM_UP)
-
-dial_no_connect_popup = None
-dialing_connect_call = None
-class DialNoconnectPopupScreen(Screen):#你所拨打的电话暂时无法接通
-    NAME = "dial_no_connect_popup"
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-        self.timer = osTimer()
-        self.time_count = 0
-       
-    def initialization(self):
-        global dial_no_connect_popup,dialing_connect_call
-        if dial_no_connect_popup == None:
-            dial_no_connect_popup = lv.obj()
-            print("dial_no_connect_popup")
-            dial_no_connect_popup.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            dialing_connect_call = lv.label(dial_no_connect_popup)
-            dialing_connect_call.set_pos(0, 110)
-            dialing_connect_call.set_size(240, 150)
-            dialing_connect_call.set_text("你好,你所拨打的\n电话暂时无法接\n通,请稍后再拨")
-            dialing_connect_call.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            dialing_connect_call.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            self.meta = dial_no_connect_popup
-
-    def post_processor_after_initialization(self):
-        self.time_count = 0
-        self.timer.start(1000, 1, self.timeout_hangup)
-        
-    def timeout_hangup(self,e):
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.time_count+=1
-        if self.time_count >= 10:
-            self.time_count = 0
-            EventMesh.publish("return_prev_screen")
-
-    def Close(self):
-        self.timer.stop()
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-    def done_click(self):
-        EventMesh.publish("return_prev_screen")
-
-    def btn1_release(self):
-        EventMesh.publish("return_prev_screen")
-
-    def btn8_press(self):
-        EventMesh.publish("return_prev_screen")
-
-message_popup_screen = None
-message_popup_title = None
-#信息弹窗
-class NewMessageScreen(Screen):
-    NAME = "message_popup"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-
-    def initialization(self):
-        global message_popup_screen,message_popup_title 
-        if message_popup_screen == None :
-            message_popup_screen = lv.obj()
-            print("message_popup_screen")
-            message_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            message_popup_title = lv.label(message_popup_screen)
-            message_popup_title.set_pos(0, 150)
-            message_popup_title.set_size(240, 40)
-            message_popup_title.set_text("你有新的消息")
-            message_popup_title.set_long_mode(lv.label.LONG.WRAP)
-            message_popup_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            message_popup_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            self.meta = message_popup_screen
-        EventMesh.publish("set_sms_clear_all_data",10)
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-    def done_click(self):
-        EventMesh.publish("load_screen", {"screen": "popup"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-message_full_screen = None 
-message_full_label = None 
-message_full_confirm = None 
-message_full_cancel = None 
-#信息弹窗
-class MessageFullScreen(Screen):
-    NAME = "message_full"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-    def initialization(self):
-        global message_full_screen,message_full_label,message_full_confirm,message_full_cancel
-        if message_full_screen == None :
-            message_full_screen = lv.obj()
-            print("message_full_screen")
-            message_full_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            message_full_label = lv.label(message_full_screen)
-            message_full_label.set_pos(0, 100)
-            message_full_label.set_size(240, 40)
-            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)
-
-            message_full_confirm = lv.label(message_full_screen)
-            message_full_confirm.set_text("确认")
-            message_full_confirm.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            message_full_confirm.set_size(120, 60)
-            message_full_confirm.set_pos(0,180)
-            message_full_confirm.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            message_full_confirm.add_flag(lv.obj.FLAG.CLICKABLE)
-            message_full_confirm.set_ext_click_area(20)
-
-            message_full_cancel = lv.label(message_full_screen)
-            message_full_cancel.set_text("取消")
-            message_full_cancel.set_size(120, 60)
-            message_full_cancel.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            message_full_cancel.set_pos(120,180)
-            message_full_cancel.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            message_full_cancel.add_flag(lv.obj.FLAG.CLICKABLE)
-            message_full_cancel.set_ext_click_area(20)
-            self.meta = message_full_screen
-            
-            message_full_confirm.add_event_cb(lambda e: EventMesh.callback_wrapper(self.confirm(e)),lv.EVENT.CLICKED, None)
-            message_full_cancel.add_event_cb(lambda e: EventMesh.callback_wrapper(self.concel(e)),lv.EVENT.CLICKED, None)
-
-
-    def confirm(self, e):
-        # self.timer.start(2*1000,0,self.clear_data)
-        sms.deleteMsg(1,4)
-        EventMesh.publish("load_screen", {"screen": "popup"})
-
-    def concel(self, e):
-        EventMesh.publish("return_prev_screen")
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-    def done_click(self):
-        EventMesh.publish("load_screen", {"screen": "popup"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-############短信###############################
-MSG_FLAG = 0
-MSG_MAX = 5 #最大显示短信内容条数
-def msg_cb(args):
-    index = args[1]
-    storage = args[2]
-    print("index:{}".format(index))
-    sms_data = sms.getSaveLoc()
-    sms_max = sms_data[0][2]
-    if index != -1:
-        tmp = sms.searchTextMsg(index)
-        detail = tmp[1]#内容
-        print("msg_cb:detail {}".format,detail)
-        if  detail.find("SETIP:") != -1:#寻找是否有这个字符串
-            tmp_test = detail.split("SETIP:")[1]
-            if  tmp_test.find(":") != -1:
-                new_ip = tmp_test.split(':')[0]
-                # print("tmp_test:{} new_ip:{}".format(tmp_test,new_ip))
-                new_com = tmp_test.split(':')[1]
-                # new_md5 = detail.split(':')[3]
-                if len(new_ip) > 0 and len(new_com) > 0:
-                    EventMesh.publish("set_new_ip", [new_ip,new_com,tmp[0]])#设置关机时间
-                    # EventMesh.publish("set_new_ip", [new_ip,new_com,new_md5])#设置关机时间
-        
-    if index >= sms_max-1:
-        EventMesh.publish("load_screen", {"screen": "message_full"})
-    else:
-        EventMesh.publish("load_screen", {"screen": "message_popup"})
-
-sms.setCallback(msg_cb)
-style_sms_bg_btn =  lv.style_t()
-style_sms_bg_btn.init()
-style_sms_bg_btn.set_radius(5)
-style_sms_bg_btn.set_bg_color(lv.color_make(0xff, 0xff, 0xff))
-style_sms_bg_btn.set_bg_grad_color(lv.color_make(0xff, 0xff, 0xff))
-style_sms_bg_btn.set_bg_opa(255)
-style_sms_bg_btn.set_border_color(lv.color_make(0xff, 0xff, 0xff))
-style_sms_bg_btn.set_border_opa(255)
-
-
-msg_list_screen = None
-msg_top_title = None
-msg_cont_detail = None
-msg_list_t = None
-msg_list_t_done_img = None
-no_msg_text = None
-msg_cont_list_screen = None
-
-class PopupScreen(Screen):
-    NAME = "popup"
-
-    def __init__(self):
-        super().__init__()
-        # -------------------------------------------popup_menu screen----------------------------------------------------------
-        self.meta = None
-        self.msg_detail = {}
-        self.msg_nums = 0
-        self.sms_detail_list = None
-        self.sms_detail_list_dict = []
-
-    def post_processor_before_initialization(self):
-        self.msg_nums = sms.getMsgNums() #获取短信条数
-
-    def initialization(self):
-        global msg_list_screen,msg_top_title,msg_cont_detail,msg_list_t,msg_list_t_done_img,no_msg_text,msg_cont_list_screen
-        print("PopupScreen:initialization1")
-        if msg_list_screen == None :
-            msg_list_screen = lv.obj()
-            print("msg_list_screen")
-            msg_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            msg_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-          
-
-            msg_top_title = lv.label(msg_list_screen)
-            msg_top_title.set_pos(0, 10)
-            msg_top_title.set_size(240, 40)
-            msg_top_title.set_text("信息")
-            msg_top_title.set_long_mode(lv.label.LONG.WRAP)
-            msg_top_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            msg_top_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            msg_cont_list_screen = lv.obj(msg_list_screen)
-            msg_cont_list_screen.set_pos(0, 50)
-            msg_cont_list_screen.set_size(240, 270)
-            msg_cont_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            msg_cont_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            msg_list_t_done_img = lv.img(msg_cont_list_screen)
-            msg_list_t_done_img.set_pos(53, 20)
-            msg_list_t_done_img.set_size(134, 117)
-            msg_list_t_done_img.set_src("U:/static/IMAGE_NOTICE_NONE.png")
-            msg_list_t_done_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_msg_text = lv.label(msg_cont_list_screen)
-            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)
-            no_msg_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_msg_text.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            self.sms_detail_list = lv.obj(msg_cont_list_screen)
-            self.sms_detail_list.set_pos(0, 0)
-            self.sms_detail_list.set_size(230, 271)
-            self.sms_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            self.sms_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            for i in range(MSG_MAX):
-                msg_btn = lv.btn(self.sms_detail_list)
-                msg_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sms_cb(e)),
-                                        lv.EVENT.CLICKED, None)
-                msg_btn.add_flag(lv.obj.FLAG.HIDDEN)
-                _btn_label2 = lv.label(msg_btn)
-                _btn_label3 = lv.label(msg_btn)
-                _btn_label4 = lv.label(msg_btn)
-                _btn_label5 = lv.label(msg_btn)
-                self.sms_detail_list_dict.append({"msg_btn":msg_btn,"_btn_label2":_btn_label2,"_btn_label3":_btn_label3,
-                                              "_btn_label4":_btn_label4,"_btn_label5":_btn_label5})
-            self.meta = msg_list_screen
-
-        
-        self.msg_nums = sms.getMsgNums() 
-        # print("self.msg_nums:{} type:{}".format(self.msg_nums,type(sms.getMsgNums())))
-        self.btn_create(1)
-        print("PopupScreen:initialization2")
-    def sms_create_list(self,event,msg):
-        self.msg_nums = sms.getMsgNums() 
-        self.btn_create(1)
-
-
-    def btn_create(self,msg):
-        EventMesh.publish("publish_message_event_ui",{"func":self.btn_create_screen,"data":msg})
-
-    def btn_create_screen(self,msg):
-        global msg_list_screen,msg_top_title,msg_cont_detail,msg_list_t,msg_list_t_done_img,no_msg_text,msg_cont_list_screen
-        count = 0
-        j = 0
-        print("self.msg_nums:{}".format(self.msg_nums))
-        if self.msg_nums > 0 :
-            
-            msg_list_t_done_img.add_flag(lv.obj.FLAG.HIDDEN)
-            no_msg_text.add_flag(lv.obj.FLAG.HIDDEN)
-            self.sms_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)
-            # self.sms_detail_list.delete()#先删除一次控件
-            # self.sms_detail_list = lv.obj(msg_cont_list_screen)
-            # self.sms_detail_list.set_pos(0, 0)
-            # self.sms_detail_list.set_size(230, 271)
-            # self.sms_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            # self.sms_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            if self.msg_nums > MSG_MAX:
-                j = self.msg_nums-MSG_MAX
-            for i in range(MSG_MAX):
-                # if count > (MSG_MAX-1):#j = 12 -5 7 6 5 4 3 2 1
-                #     break
-                if i >= self.msg_nums :
-                    self.sms_detail_list_dict[i]["msg_btn"].add_flag(lv.obj.FLAG.HIDDEN)
-                    continue
-                tmp = sms.searchTextMsg(j)
-                if tmp != -1:
-                    #msg_btn = lv.btn(self.sms_detail_list)
-                    self.sms_detail_list_dict[i]["msg_btn"].set_size(230,65)
-                    self.sms_detail_list_dict[i]["msg_btn"].set_pos(0,67*count)
-                    self.sms_detail_list_dict[i]["msg_btn"].add_style(style_sms_bg_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
-                    # self.sms_detail_list_dict[i]["msg_btn"].add_event_cb(lambda e: EventMesh.callback_wrapper(self.sms_cb(e)),
-                    #                         lv.EVENT.CLICKED, None)
-                
-                    title = tmp[0] 
-                    # print("title:{}".format(title))
-                    #_btn_label2 = lv.label(msg_btn)
-                    self.sms_detail_list_dict[i]["_btn_label2"].set_pos(0, 0)
-                    self.sms_detail_list_dict[i]["_btn_label2"].set_size(0, 0)
-                    self.sms_detail_list_dict[i]["_btn_label2"].set_text(title)
-                    # _btn_label2.set_long_mode(lv.label.LONG.DOT)
-                    # _btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-                    #
-                    detail = tmp[1]
-                    #_btn_label3 = lv.label(msg_btn)
-                    self.sms_detail_list_dict[i]["_btn_label3"].set_pos(0, 0)
-                    self.sms_detail_list_dict[i]["_btn_label3"].set_size(0, 0)
-                    self.sms_detail_list_dict[i]["_btn_label3"].set_text(detail)
-                    # _btn_label3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-                    detail1 = tmp[1]
-                    #_btn_label4 = lv.label(msg_btn)
-                    self.sms_detail_list_dict[i]["_btn_label4"].set_pos(0, 34)
-                    self.sms_detail_list_dict[i]["_btn_label4"].set_size(180, 28)
-                    self.sms_detail_list_dict[i]["_btn_label4"].set_text(detail1)
-                    self.sms_detail_list_dict[i]["_btn_label4"].set_long_mode(lv.label.LONG.DOT)
-                    self.sms_detail_list_dict[i]["_btn_label4"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-                    title1 = tmp[0]
-                    #_btn_label5 = lv.label(msg_btn)
-                    self.sms_detail_list_dict[i]["_btn_label5"].set_pos(0, 5)
-                    self.sms_detail_list_dict[i]["_btn_label5"].set_size(180, 25)
-                    self.sms_detail_list_dict[i]["_btn_label5"].set_text(title1)
-                    self.sms_detail_list_dict[i]["_btn_label5"].set_long_mode(lv.label.LONG.DOT)
-                    self.sms_detail_list_dict[i]["_btn_label5"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-                    
-                    self.sms_detail_list_dict[i]["msg_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
-                    #if msg == 1:
-                    self.sms_detail_list_dict[i]["msg_btn"].scroll_to_view(lv.ANIM.OFF)
-
-                    count = count + 1
-                else :
-                    self.sms_detail_list_dict[i]["msg_btn"].add_flag(lv.obj.FLAG.HIDDEN)
-                j = j + 1
-                
-            
-        else:
-            if msg_cont_list_screen != None:
-                msg_list_t_done_img.clear_flag(lv.obj.FLAG.HIDDEN)
-                no_msg_text.clear_flag(lv.obj.FLAG.HIDDEN)
-                no_msg_text.set_text("暂无信息")
-            self.sms_detail_list.add_flag(lv.obj.FLAG.HIDDEN)
-            
-            
-    def sms_cb(self,e):
-        code = e.get_code()
-        if code == lv.EVENT.CLICKED:
-            print("tp test!!!!!!!!!!!!!!")
-            #上传标题和内容
-            _name = e.get_target().get_child(0).get_text()
-            EventMesh.publish("save_msg_name", _name)       
-            content = e.get_target().get_child(1).get_text()
-            EventMesh.publish("save_msg_content", content) 
-       
-        #显示详细页面
-        EventMesh.publish("load_screen", {"screen": "msg_detail"})
-    
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-
-msg_detail_screen = None
-msg_detail_title = None
-msg_detail_cont = None
-class MsgDetailScreen(Screen):
-    NAME = "msg_detail"
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-
-        self.name = ""
-        self.contetn = ""
-
-
-    def initialization(self):
-        global msg_detail_screen,msg_detail_title,msg_detail_cont
-        if msg_detail_screen == None:    
-            msg_detail_screen = lv.obj()
-            print("msg_detail_screen")
-            msg_detail_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            msg_detail_title = lv.label(msg_detail_screen)
-            msg_detail_title.set_pos(0, 10)
-            msg_detail_title.set_size(240, 40)
-            msg_detail_title.set_long_mode(lv.label.LONG.WRAP)
-            msg_detail_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            msg_detail_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            msg_detail_cont = lv.label(msg_detail_screen)
-            msg_detail_cont.set_pos(0, 50)
-            msg_detail_cont.set_size(240, 270)
-            msg_detail_cont.set_long_mode(lv.label.LONG.WRAP)
-            msg_detail_cont.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-            msg_detail_cont.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            self.meta = msg_detail_screen
-        #获取字符串
-        self.name = EventMesh.publish("get_msg_name")
-        self.content = EventMesh.publish("get_msg_content")
-        msg_detail_title.set_text(self.name)
-        msg_detail_cont.set_text(self.content)
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "popup"})
-
-    def hangup(self,e):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "popup"})
-
-
-
-# -------------------------------------------heartrate screen----------------------------------------------------------
-heartrate_screen = None
-heartrate_label = None
-heartrate_done_img = None
-heartrate_start_label = None
-heartrate_bpm_label = None
-heartrate_done_label = None
-heartrate_line_bg_img = None
-hr_line1 = None
-hr_line2 = None
-hr_line3 = None
-hr_line4 = None
-hr_line5 = None
-hr_line6 = None
-hr_line7 = None
-heartrate_reset_btn_img = None
-
-style_line_red = lv.style_t()
-style_line_red.init()
-style_line_red.set_line_width(10)
-style_line_red.set_line_color(lv.color_make(0xff, 0x00, 0x00))
-
-hr_line_points = [{"x":0,"y":0},{"x":0,"y":0}]
-
-class HeartrateScreen(Screen):
-    NAME = "heartrate"
-
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.timer = osTimer()
-        self.point = 0
-        self.heart_value = 0
-
-    def initialization(self):
-        global heartrate_screen,heartrate_label,heartrate_reset_btn_img,hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7,heartrate_line_bg_img,heartrate_done_img ,heartrate_start_label,heartrate_bpm_label ,heartrate_done_label 
-        if heartrate_screen == None:
-            heartrate_screen = lv.obj()
-            print("heartrate_screen")
-            heartrate_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            heartrate_label = lv.label(heartrate_screen)
-            heartrate_label.set_pos(0, 20)
-            heartrate_label.set_size(240, 40)
-            heartrate_label.set_text("心率")
-            heartrate_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            heartrate_label.set_long_mode(lv.label.LONG.WRAP)
-            heartrate_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            heartrate_line_bg_img = lv.img(heartrate_screen)
-            heartrate_line_bg_img.set_pos(5, 60)
-            heartrate_line_bg_img.set_size(230, 120)
-            heartrate_line_bg_img.set_src("U:/static/hr_line_bg.png")
-
-            
-            heartrate_done_img = lv.img(heartrate_screen)
-            heartrate_done_img.set_pos(20, 249)
-            heartrate_done_img.set_src("U:/static/hr_gif_03.png")
-
-            heartrate_reset_btn_img = lv.img(heartrate_screen)
-            heartrate_reset_btn_img.set_pos(0, 192)
-            heartrate_reset_btn_img.set_src("U:/static/reset_hr_btn.png")
-            heartrate_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
-            heartrate_reset_btn_img.add_flag(lv.obj.FLAG.CLICKABLE)
-
-            heartrate_start_label = lv.label(heartrate_screen)
-            heartrate_start_label.set_size(240,40)
-            heartrate_start_label.set_pos(0,200)
-            heartrate_start_label.set_text(" ")
-            heartrate_start_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            heartrate_start_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            heartrate_start_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-
-            hr_line1 = lv.line(heartrate_screen)
-            hr_line1.set_points(hr_line_points,2)
-            hr_line1.set_pos(25,60)
-            hr_line1.set_size(10,0)
-            hr_line1.add_style(style_line_red,0)
-
-            hr_line2 = lv.line(heartrate_screen)
-            hr_line2.set_points(hr_line_points,2)
-            hr_line2.set_pos(53,60)
-            hr_line2.set_size(10,0)
-            hr_line2.add_style(style_line_red,0)
-
-            hr_line3 = lv.line(heartrate_screen)
-            hr_line3.set_points(hr_line_points,2)
-            hr_line3.set_pos(80,60)
-            hr_line3.set_size(10,0)
-            hr_line3.add_style(style_line_red,0)
-
-            hr_line4 = lv.line(heartrate_screen)
-            hr_line4.set_points(hr_line_points,2)
-            hr_line4.set_pos(109,60)
-            hr_line4.set_size(10,0)
-            hr_line4.add_style(style_line_red,0)
-
-            hr_line5 = lv.line(heartrate_screen)
-            hr_line5.set_points(hr_line_points,2)
-            hr_line5.set_pos(136,60)
-            hr_line5.set_size(10,0)
-            hr_line5.add_style(style_line_red,0)
-
-            hr_line6 = lv.line(heartrate_screen)
-            hr_line6.set_points(hr_line_points,2)
-            hr_line6.set_pos(164,60)
-            hr_line6.set_size(10,0)
-            hr_line6.add_style(style_line_red,0)
-
-            hr_line7 = lv.line(heartrate_screen)
-            hr_line7.set_points(hr_line_points,2)
-            hr_line7.set_pos(192,60)
-            hr_line7.set_size(10,0)
-            hr_line7.add_style(style_line_red,0)
-
-            heartrate_bpm_label = lv.label(heartrate_screen)
-            heartrate_bpm_label.set_size(120, 40)
-            heartrate_bpm_label.set_pos(120, 270)
-            heartrate_bpm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            heartrate_bpm_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-            heartrate_done_label = lv.label(heartrate_screen)
-            heartrate_done_label.set_size(240, 40)
-            heartrate_done_label.set_pos(0, 270)
-            heartrate_done_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            heartrate_done_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            heartrate_done_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-            self.meta = heartrate_screen
-            heartrate_reset_btn_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.restart_up(e)),
-                lv.EVENT.CLICKED, None)
-        heartrate_done_label.set_text(" ")
-        heartrate_bpm_label.set_text("-- bpm")
-        heartrate_start_label.set_text("正在测量中.")
-        EventMesh.publish("set_hr_state",1)#1代表手动进入测试界面
-        
-        EventMesh.publish(constants.EVENT.START_HEART)
-
-    def post_processor_after_initialization(self):
-        self.point = 0
-        self.heart_value = 0
-        self.show_history_data()
-        self.restart_up(0)
-
-    def restart_up(self,e):
-        global heartrate_done_label,heartrate_bpm_label,heartrate_start_label,heartrate_reset_btn_img
-        self.timer.start(1*500, 1, self.start_measure)
-        heartrate_bpm_label.set_text("-- bpm")
-        if heartrate_reset_btn_img != None:
-            heartrate_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
-        self.point = 0
-        self.heart_value = 0
-        
-        heartrate_done_label.set_text(" ")
-        heartrate_bpm_label.set_text("-- bpm")
-        heartrate_start_label.set_text("正在测量中.")
-        EventMesh.publish("set_hr_state",1)#1代表手动进入测试界面
-        
-        EventMesh.publish(constants.EVENT.START_HEART)
-
-    def show_history_data(self):
-        global hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7
-        read_data = {}
-        read_data = EventMesh.publish("get_history_hr_value")
-        print("hr history read_data",read_data)
-        if read_data != None:
-            count = len(read_data)
-            if count != 0:
-                if count >= 7:
-                    for i in  range(count):
-                        value = read_data["0{}".format(i+1)]
-                        if value < 30:
-                            value = 30
-                        if value >= 210:
-                            value = 210
-                        line_value = value - 30 #180-80 = 100 160-100 = 60
-                        line_value = int(line_value*0.58)+1
-                        if line_value >= 100:
-                            line_value = 100
-                        #print("hr hist",line_value)
-                        hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
-                        if i == 0:
-                            hr_line1.set_points(hr_line_points,2)
-                            hr_line1.set_pos(25,160-line_value)
-                            hr_line1.set_size(10,line_value)
-                        if i == 1:
-                            hr_line2.set_points(hr_line_points,2)
-                            hr_line2.set_pos(53,160-line_value)
-                            hr_line2.set_size(10,line_value)
-
-                        if i == 2:
-                            hr_line3.set_points(hr_line_points,2)
-                            hr_line3.set_pos(80,160-line_value)
-                            hr_line3.set_size(10,line_value)
-
-                        if i == 3:
-                            hr_line4.set_points(hr_line_points,2)
-                            hr_line4.set_pos(109,160-line_value)
-                            hr_line4.set_size(10,line_value)
-
-                        if i == 4:
-                            hr_line5.set_points(hr_line_points,2)
-                            hr_line5.set_pos(136,160-line_value)
-                            hr_line5.set_size(10,line_value)
-
-                        if i == 5:
-                            hr_line6.set_points(hr_line_points,2)
-                            hr_line6.set_pos(164,160-line_value)
-                            hr_line6.set_size(10,line_value)
-
-                        if i == 6:
-                            hr_line7.set_points(hr_line_points,2)
-                            hr_line7.set_pos(192,160-line_value)
-                            hr_line7.set_size(10,line_value)
-                else:
-                    value = read_data["0{}".format(count)]
-                    if value < 30:
-                        value = 30
-                    if value >= 180:
-                        value = 180
-                    line_value = value - 30 #180-80 = 100 160-100 = 60
-                    line_value = int(line_value*0.58)+1
-                   #
-                    hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
-                    if count == 1:
-                        hr_line1.set_points(hr_line_points,2)
-                        hr_line1.set_pos(25,160-line_value)
-                        hr_line1.set_size(10,line_value)
-                    if count == 2:
-                        hr_line2.set_points(hr_line_points,2)
-                        hr_line2.set_pos(53,160-line_value)
-                        hr_line2.set_size(10,line_value)
-
-                    if count == 3:
-                        hr_line3.set_points(hr_line_points,2)
-                        hr_line3.set_pos(80,160-line_value)
-                        hr_line3.set_size(10,line_value)
-
-                    if count == 4:
-                        hr_line4.set_points(hr_line_points,2)
-                        hr_line4.set_pos(109,160-line_value)
-                        hr_line4.set_size(10,line_value)
-
-                    if count == 5:
-                        hr_line5.set_points(hr_line_points,2)
-                        hr_line5.set_pos(136,160-line_value)
-                        hr_line5.set_size(10,line_value)
-
-                    if count == 6:
-                        hr_line6.set_points(hr_line_points,2)
-                        hr_line6.set_pos(164,160-line_value)
-                        hr_line6.set_size(10,line_value)
-
-                    if count == 7:
-                        hr_line7.set_points(hr_line_points,2)
-                        hr_line7.set_pos(192,160-line_value)
-                        hr_line7.set_size(10,line_value)      
-
-
-    def start_measure(self,*args):
-        global heartrate_screen,heartrate_label,heartrate_done_img ,heartrate_reset_btn_img,heartrate_start_label,heartrate_bpm_label ,heartrate_done_label
-        self.point = self.point + 1
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-        print("self.heart_value:{}".format(self.heart_value))
-        if self.point >= 2:
-            if self.heart_value < 40:
-                self.heart_value = 0
-            if self.heart_value != 0:
-                heartrate_bpm_label.set_text("{} bpm".format(self.heart_value))
-            else:
-                heartrate_bpm_label.set_text("-- bpm")
-        
-        if self.point%4 == 0 :
-            heartrate_start_label.set_text("正在测量中..")
-            heartrate_done_img.set_src("U:/static/hr_gif_02.png")
-        if self.point%4 == 1 :
-            heartrate_start_label.set_text("正在测量中...")
-            heartrate_done_img.set_src("U:/static/hr_gif_01.png")
-        if self.point%4 == 2 :
-            heartrate_start_label.set_text("正在测量中.")
-            heartrate_done_img.set_src("U:/static/hr_gif_02.png")
-        
-        if self.point%4 == 3 :
-            heartrate_start_label.set_text("正在测量中.")
-            heartrate_done_img.set_src("U:/static/hr_gif_03.png")
-
-
-
-        if self.point > 120: #测20s
-            heartrate_done_img.set_src("U:/static/hr_gif_03.png")
-            self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-            EventMesh.publish("set_old_hr_data",self.heart_value)
-            if self.heart_value > 50:
-                
-                EventMesh.publish("set_history_hr_value",self.heart_value)
-                EventMesh.publish(constants.PROTOCOL.HEART_SEND,self.heart_value)
-            heartrate_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
-            
-            heartrate_start_label.set_text("测量结束,点击重测")
-            if self.heart_value != 0:
-                heartrate_bpm_label.set_text("{} bpm".format(self.heart_value))
-                # heartrate_done_label.set_text("测量完成")
-            else:
-                heartrate_bpm_label.set_text("-- bpm")
-                
-            self.show_history_data()
-
-            self.timer.stop()
-            self.point = 0
-            EventMesh.publish("set_hr_state",0)#0代表关闭测试
-            print("stop debug9")
-            EventMesh.publish(constants.EVENT.STOP_HEART)
-
-    def Close(self):
-        self.timer.stop()
-        get_hr_state = EventMesh.publish("get_hr_state")
-        get_spo2_state = EventMesh.publish("get_spo2_state")
-        if get_hr_state == 1 or get_spo2_state == 1:
-            EventMesh.publish("set_hr_state",0)#0代表关闭测试
-            print("stop debug10")
-            EventMesh.publish(constants.EVENT.STOP_HEART)
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "health"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "health"})
-        
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    
-# -------------------------------------------toolbox screen----------------------------------------------------------
-
-toolbox_screen = None
-toolbox_text_img = None
-toolbox_cont = None
-toolbox_step_img = None
-toolbox_weather_img = None
-toolbox_alarm_img = None
-# toolbox_sms_img = None
-toolbox_countdown_img = None
-toolbox_stopwatch_img = None
-
-toolbox_cont_style = lv.style_t()
-toolbox_cont_style.init()
-toolbox_cont_style.set_radius(0)
-toolbox_cont_style.set_bg_color(lv.color_make(0x00, 0x00, 0x00))
-toolbox_cont_style.set_bg_grad_color(lv.color_make(0x00, 0x00, 0x00))
-toolbox_cont_style.set_bg_grad_dir(lv.GRAD_DIR.VER)
-toolbox_cont_style.set_bg_opa(255)
-toolbox_cont_style.set_border_width(0)
-toolbox_cont_style.set_pad_left(0)
-toolbox_cont_style.set_pad_right(0)
-toolbox_cont_style.set_pad_top(0)
-toolbox_cont_style.set_pad_bottom(0)
-
-class ToolboxScreen(Screen):
-    NAME = "toolbox"
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-
-    def initialization(self):
-        global toolbox_screen,toolbox_text_img,toolbox_cont,toolbox_step_img,toolbox_weather_img ,toolbox_alarm_img  ,\
-            toolbox_countdown_img,toolbox_stopwatch_img
-        if toolbox_screen == None:
-            tool_set_y = 0
-            toolbox_screen = lv.obj()
-            print("toolbox_screen")
-            toolbox_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            toolbox_screen.set_scrollbar_mode(0)
-
-            toolbox_text_img = lv.img(toolbox_screen)
-            toolbox_text_img.set_pos(75, 10)
-            toolbox_text_img.set_size(90, 30)
-            toolbox_text_img.set_src("U:/static/tool/tool_text.png")
-            toolbox_text_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            toolbox_cont = lv.obj(toolbox_screen)
-            toolbox_cont.set_pos(0, 50)
-            toolbox_cont.set_size(240, 270)
-            toolbox_cont.add_style(toolbox_cont_style,lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            toolbox_step_img = lv.img(toolbox_cont)
-            toolbox_step_img.set_pos(4, tool_set_y)
-            toolbox_step_img.set_size(232, 80)
-            toolbox_step_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            toolbox_step_img.set_src("U:/static/tool/IMAGE_SECMENU_STEP.png")
-            toolbox_step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            tool_set_y+=90
-
-            toolbox_weather_img = lv.img(toolbox_cont)
-            toolbox_weather_img.set_pos(4, tool_set_y)
-            toolbox_weather_img.set_size(232, 80)
-            toolbox_weather_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            toolbox_weather_img.set_src("U:/static/tool/IMAGE_SECMENU_WEATHER.png")
-            toolbox_weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            tool_set_y+=90
-            toolbox_alarm_img = lv.img(toolbox_cont)
-            toolbox_alarm_img.set_pos(4, tool_set_y)
-            toolbox_alarm_img.set_size(232, 80)
-            toolbox_alarm_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            toolbox_alarm_img.set_src("U:/static/tool/IMAGE_SECMENU_ALARM.png")
-            toolbox_alarm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            # tool_set_y+=90
-            # toolbox_sms_img = lv.img(toolbox_cont)
-            # toolbox_sms_img.set_pos(4, tool_set_y)
-            # toolbox_sms_img.set_size(232, 80)
-            # toolbox_sms_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            # toolbox_sms_img.set_src("U:/static/tool/sms_setting.png")
-            # toolbox_sms_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            tool_set_y+=90
-            toolbox_countdown_img = lv.img(toolbox_cont)
-            toolbox_countdown_img.set_pos(4, tool_set_y)
-            toolbox_countdown_img.set_size(232, 80)
-            toolbox_countdown_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            toolbox_countdown_img.set_src("U:/static/tool/IMAGE_SECMENU_COUNTDOWN.png")
-            toolbox_countdown_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            tool_set_y+=90
-            toolbox_stopwatch_img = lv.img(toolbox_cont)
-            toolbox_stopwatch_img.set_pos(4, tool_set_y)
-            toolbox_stopwatch_img.set_size(232, 80)
-            toolbox_stopwatch_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            toolbox_stopwatch_img.set_src("U:/static/tool/IMAGE_SECMENU_STOPWATCH.png")
-            toolbox_stopwatch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            toolbox_step_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "step"})), lv.EVENT.CLICKED, None)
-            toolbox_weather_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "weather"})), lv.EVENT.CLICKED, None)
-            toolbox_alarm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "clk_list"})), lv.EVENT.CLICKED, None)
-            # toolbox_sms_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "popup"})), lv.EVENT.CLICKED, None)
-            toolbox_countdown_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "countdown"})), lv.EVENT.CLICKED, None)
-            toolbox_stopwatch_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "stopwatch"})), lv.EVENT.CLICKED, None)
-            self.meta = toolbox_screen
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-        
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-incoming_call_screen = None
-incoming_call_img = None
-incoming_call_name_label = None
-incoming_call_answer = None
-incoming_call_hangup = None
-# CALL_LOG_MAX = 50
-class IncomingCallScreen(Screen):
-    NAME = "incoming_call"
-
-    def __init__(self):
-        super().__init__()
-        self.CALL_LOG_MAX = CALL_LOG_MAX
-        self.read_data = {}
-        self.volum_size = 8
-        check_volum = ql_fs.path_exists("/usr/static/storage_file/config.json")
-        if check_volum == True :
-            with open("/usr/static/storage_file/config.json","r") as fd:#音频文件编号
-                self.read_data = ujson.load(fd)
-                if self.read_data != {}:
-                    b = str("volum") in self.read_data.keys()
-                    if b == True:
-                        self.volum_size = self.read_data["volum"]  
-                    else:
-                        self.volum_size = 8
-                else:
-                    self.volum_size = 8
-        else:
-            self.volum_size = 8
-        self.aud = audio.Audio(0)
-        self.aud.set_pa(Pin.GPIO29)
-        self.aud.setVolume(11)
-        self.call_timer = osTimer()
-        self.name = None
-        self.phonebook = {}
-        self.pro_state = 0
-        self.meta = None
-        
-
-        self.call_log = {}
-        self.call_log_value = {}
-        self.read_call_log = {}
-        self.number_tmp = {}
-        
-    def initialization(self):
-        global incoming_call_screen,incoming_call_img,incoming_call_name_label,incoming_call_answer ,incoming_call_hangup  
-        if incoming_call_screen == None :
-            # -------------------------------------------incoming_call screen----------------------------------------------------------
-            incoming_call_screen = lv.obj()
-            print("incoming_call_screen")
-            incoming_call_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            incoming_call_img = lv.img(incoming_call_screen)
-            incoming_call_img.set_pos(80, 20)
-            incoming_call_img.set_size(64, 64)
-            incoming_call_img.set_src("U:/static/IMAGE_NOTICE_CALL.png")
-            incoming_call_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            incoming_call_name_label = lv.label(incoming_call_screen)
-            incoming_call_name_label.set_pos(0, 140)
-            incoming_call_name_label.set_text(" ")
-            incoming_call_name_label.set_size(240, 50)
-            incoming_call_name_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            incoming_call_name_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            incoming_call_answer = lv.img(incoming_call_screen)
-            incoming_call_answer.set_size(64, 64)
-            incoming_call_answer.add_flag(lv.obj.FLAG.CLICKABLE)
-            incoming_call_answer.set_pos(30, 220)
-            incoming_call_answer.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            incoming_call_answer.set_src("U:/static/answer.png")
-
-            incoming_call_hangup = lv.img(incoming_call_screen)
-            incoming_call_hangup.set_size(64, 64)
-            incoming_call_hangup.add_flag(lv.obj.FLAG.CLICKABLE)
-            incoming_call_hangup.set_pos(150, 220)
-            incoming_call_hangup.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            incoming_call_hangup.set_src("U:/static/hang_up.png")
-            incoming_call_answer.add_event_cb(lambda e: EventMesh.callback_wrapper(self.answer(e)),
-                                     lv.EVENT.CLICKED, None)
-            incoming_call_hangup.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
-                                     lv.EVENT.CLICKED, None)
-            self.meta = incoming_call_screen 
-        EventMesh.publish("set_UI_high_priority", 1)
-
-
-    def post_processor_after_initialization(self):
-        global incoming_call_screen,incoming_call_img,incoming_call_name_label,incoming_call_answer ,incoming_call_hangup  
-        utime.sleep_ms(200)#不加延时会切屏
-        data = EventMesh.publish("get_phonebook_list")
-        if data != None:
-            check = data[0]
-            self.phonebook = data[1]
-            if check == 1:#先检查通讯录
-                phonebook_keys = sorted(self.phonebook.keys())
-                b = self.meta_info in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
-                j = 0
-                if b == True:
-                    for i in range(len(self.phonebook)): #字典 key value
-                        #'001:邓雪英':15521469561
-                        name = self.phonebook[phonebook_keys[j]]
-                        name_value = phonebook_keys[j]
-                        number_tmp = str(self.meta_info)
-                        # print("name :{} number_tmp:{}".format(name,number_tmp))
-                        if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
-                            number_f= name_value
-                            name_s = number_f.split(':')
-                            name_s = name_s[1]
-                            self.name = name_s
-                            self.pro_state = 1
-                            break
-                        j+=1
-                else:
-                    self.name = str(self.meta_info)
-                    self.pro_state = 0
-            else:
-                self.name = str(self.meta_info)
-                self.pro_state = 0
-
-        read_call_log = EventMesh.publish("get_call_log_list")
-        check_call_log_json = read_call_log[0]
-        self.read_call_log = read_call_log[1]
-        if self.pro_state == 0 and check_call_log_json == 1:#电话本没有就在通话记录查找电话号码并且文件存在是查找
-            
-            sort_tmp = self.read_call_log.values()
-            for sort_new_tmp in sort_tmp: #字典 key value
-                number = sort_new_tmp["number"]
-                find_ok = self.meta_info in number
-                # print("find_ok:{} sort_tmp :{} self.meta_info:{}\r\n".format(find_ok,number,self.meta_info))
-                if find_ok == True:
-                    name_value = sort_new_tmp["name"]#查找到相同的电话号码就退出break
-                    self.name = name_value
-                    break
-        
-        if self.name == None:
-            self.name = str(self.meta_info)
-
-        # incoming_call_label.set_text(str(self.meta_info))
-        incoming_call_name_label.set_text(self.name)
-        EventMesh.publish("save_phonename",self.name)
-        time = EventMesh.publish("screen_get_time")#获取系统时间
-
-        # ["15692025051","2","12:59","哥gdh符合双方和开发商开发好看的思考"],
-        # 格式:{"电话号码":{"timesec":'时间戳',"number":'电话号码',"name":'名字',"time":'时间',"count":'通话次数'}}
-        self.num = 0
-   
-        date_tmp = utime.localtime()
-        time_tmp = utime.mktime(date_tmp)
-        # print("time_tmp:{}".format(time_tmp))
-        read_call_log = EventMesh.publish("get_call_log_list")
-        check_json = read_call_log[0]
-
-        if check_json == True:
-            self.read_call_log = read_call_log[1]
-            print("读取通话记录")
-            b = str(self.meta_info) in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
-
-            if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
-                number_tmp = {}
-                number_tmp = self.read_call_log[str(self.meta_info)] #通话次数加一
-                num_tmp_t = number_tmp["count"]#读取本地保存的通话次数
-            else :
-                num_tmp_t = 0
-            self.num = num_tmp_t 
-        else:
-            self.num = 0 #通话次数
-
-        sort_tmp = {}
-        sort_tmp = self.read_call_log.values()
-        sort_new = {}
-        sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
-        i = 0
-        if len(self.read_call_log) >= self.CALL_LOG_MAX:
-            for sort_new_tmp in sort_new: #字典 key value
-                i+=1 # 1 
-                if i >= self.CALL_LOG_MAX:#大于50条把最后一条删除掉只保留前面50调最新的数据
-                    key_tmp = sort_new_tmp["number"]
-                    del self.read_call_log[key_tmp]
-
-        tmp = {}
-        self.num = self.num +1
-        if self.num > 99:
-            self.num = 99
-        tmp["count"]= self.num #通话次数
-        tmp["time"]= "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通话时间
-        tmp["name"]= self.name #名称
-        tmp["timesec"]= time_tmp #时间戳
-        tmp["number"] = self.meta_info
-
-        self.read_call_log[self.meta_info] = tmp
-        with open("/usr/static/storage_file/Call_log.json","w",encoding="utf-8") as fd:
-            ujson.dump(self.read_call_log,fd)
-            print("创建通话记录")
-        EventMesh.publish("set_call_log_list", [1,self.read_call_log])
-        EventMesh.publish("call_log_update_show_list")
-
-        self.call_timer.start(6000, 1, self.call_timer_cb)
-        self.aud.play(1, 1, 'U:/static/R_CALL_mp3.mp3')  #播放来电铃声
-
-    def call_timer_cb(self,e):
-       self.aud.play(1, 1, 'U:/static/R_CALL_mp3.mp3')  #播放来电铃声
-
-    def answer(self,e):
-        self.call_timer.stop()
-        self.aud.stop() 
-        EventMesh.publish("set_UI_high_priority", 0)
-        voiceCall.callAnswer()
-
-    def Close(self):
-        self.call_timer.stop()
-        self.aud.stop() 
-    
-    def hangup(self,e):
-        EventMesh.publish("set_UI_high_priority", 0)
-        self.aud.stop()
-        self.call_timer.stop()
-        voiceCall.callEnd()
-
-
-    def btn1_release(self):
-        pass
-        
-    def btn8_press(self):
-        flag = EventMesh.publish("get_lcd_state")
-        if flag == 1:
-            EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
-        else:
-            EventMesh.publish(constants.EVENT.SYSTEM_UP)
-        pass
-
-    def done_left_to_right(self):
-        pass
-    
-    def done_right_to_left(self):
-        pass
-
-    def done_bottom_to_top(self):
-        pass
-    
-    def done_top_to_bottom(self):
-        pass
-    
-    def done_return(self):
-        pass
-        
-
-on_call_screen = None
-on_call_obj =None
-on_call_label_name = None
-on_call_second_label = None
-on_call_volum_label = None
-on_call_tab_label = None
-on_call_hangup = None
-on_call_bar = None
-on_call_volum_reduce = None
-on_call_volum_add = None
-on_call_phone_one = None
-on_call_phone_two = None
-on_call_phone_three = None
-on_call_phone_four = None
-on_call_phone_five = None
-on_call_phone_six = None
-on_call_phone_seven = None
-on_call_phone_eight = None
-on_call_phone_nine = None
-on_call_phone_start = None
-on_call_phone_zero = None
-on_call_screen_tab = None
-on_call_phone_hash = None
-on_call_phone_return =None
-on_call_screen_tab_label =None
-on_call_phone_return_btn = None
-ON_CALL_MAX_DATA = 9
-class OnCallScreen(Screen):
-    NAME = "on_call"
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.count_sec = 0
-        self.timer = osTimer()
-        self.aud = audio.Audio(0)
-        self.aud.set_pa(Pin.GPIO29)
-        self.read_data = {}
-        self.volum_size = 8
-        self.open_volum = 0
-        self.phone_num = ''
-        self.phone_list = []
-        self.button = 0
-
-    def initialization(self):
-        EventMesh.publish("set_UI_high_priority", 1)
-        global on_call_screen,on_call_label_name,on_call_second_label ,on_call_hangup ,on_call_volum_label,on_call_tab_label,on_call_bar,on_call_obj,\
-        on_call_volum_reduce,on_call_volum_add,on_call_phone_one ,on_call_phone_two ,on_call_phone_three,on_call_phone_four,on_call_phone_five,\
-        on_call_phone_six,on_call_phone_seven,on_call_screen_tab_label ,on_call_phone_return,on_call_phone_eight ,on_call_phone_nine ,on_call_phone_start ,\
-        on_call_phone_zero ,on_call_phone_hash,on_call_phone_return_btn,\
-        on_call_screen_tab 
-        if on_call_screen ==None :
-            on_call_screen = lv.obj()
-            on_call_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_obj = lv.obj(on_call_screen)
-            on_call_obj.set_size(240,320)
-            on_call_obj.set_pos(0,0)
-            on_call_obj.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            print("on_call_screen")
-            
-            on_call_label_name = lv.label(on_call_obj)
-            on_call_label_name.set_pos(0, 80)
-            on_call_label_name.set_size(240, 50)
-            on_call_label_name.set_text(" ")
-            on_call_label_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            on_call_label_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            on_call_second_label = lv.label(on_call_obj)
-            on_call_second_label.set_pos(0, 140)
-            on_call_second_label.set_size(240, 30)
-            on_call_second_label.set_text("00:00")
-            on_call_second_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            on_call_second_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            on_call_bar = lv.bar(on_call_obj)
-            on_call_bar.set_pos(49, 183)
-            on_call_bar.set_size(140, 25)
-            on_call_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-            on_call_bar.set_mode(lv.bar.MODE.NORMAL)
-            on_call_bar.set_value(50, lv.ANIM.OFF)
-            on_call_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-
-            on_call_volum_reduce = lv.img(on_call_obj)
-            on_call_volum_reduce.set_size(36, 36)
-            on_call_volum_reduce.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_volum_reduce.set_pos(4, 178)
-            on_call_volum_reduce.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_volum_reduce.set_src("U:/static/REDUCE_VOLUM_ICON.png")
-            on_call_volum_reduce.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_volum_size(e)),
-                                     lv.EVENT.CLICKED, None)
-            
-            on_call_volum_add = lv.img(on_call_obj)
-            on_call_volum_add.set_size(36, 36)
-            on_call_volum_add.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_volum_add.set_pos(194, 178)
-            on_call_volum_add.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_volum_add.set_src("U:/static/VOLUM_ADD_ICON.png")
-            on_call_volum_add.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_volum_size(e)),
-                                     lv.EVENT.CLICKED, None)
-
-
-            on_call_volum_label = lv.label(on_call_obj)
-            on_call_volum_label.set_pos(0, 270)
-            on_call_volum_label.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_volum_label.set_size(85, 50)
-            on_call_volum_label.set_text("静音")
-            on_call_volum_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            on_call_volum_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_volum_label.add_event_cb(lambda e: EventMesh.callback_wrapper(self.open_volum_show(e)),
-                                    lv.EVENT.CLICKED, None)
-
-            on_call_hangup = lv.img(on_call_obj)
-            on_call_hangup.set_size(64, 64)
-            on_call_hangup.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_hangup.set_pos(85, 245)
-            on_call_hangup.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_hangup.set_src("U:/static/hang_up.png")
-            on_call_hangup.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
-                                     lv.EVENT.CLICKED, None)
-            
-            on_call_tab_label = lv.label(on_call_obj)
-            on_call_tab_label.set_pos(150, 270)
-            on_call_tab_label.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_tab_label.set_size(90, 50)
-            on_call_tab_label.set_text("键盘")
-            on_call_tab_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            on_call_tab_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_tab_label.add_event_cb(lambda e: EventMesh.callback_wrapper(self.on_call_tab_show(e)),
-                                    lv.EVENT.CLICKED, None)
-
-            on_call_screen_tab = lv.obj(on_call_screen)
-            on_call_screen_tab.set_size(240,320)
-            on_call_screen_tab.set_pos(0,0)
-            on_call_screen_tab.add_flag(lv.obj.FLAG.HIDDEN)
-            on_call_screen_tab.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-                                              
-            on_call_screen_tab_label = lv.label(on_call_screen_tab)                                                                
-            on_call_screen_tab_label.set_pos(40, 34)
-            on_call_screen_tab_label.set_size(0, 30)
-            on_call_screen_tab_label.set_text(" ")
-            on_call_screen_tab_label.set_long_mode(lv.label.LONG.CLIP)
-            on_call_screen_tab_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_screen_tab_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            
-            on_call_phone_return = lv.img(on_call_screen_tab)
-            on_call_phone_return.set_src("U:/static/RED_RETURN_PNG.png")
-            on_call_phone_return.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_return.set_pos(0, 30)
-            on_call_phone_return.set_size(36, 36)
-            
-            on_call_phone_return_btn = lv.img(on_call_screen_tab)
-            on_call_phone_return_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_return_btn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_return_btn.set_pos(0, 0)
-            on_call_phone_return_btn.set_size(50, 100)
-            on_call_phone_return_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.on_return_show(e)),
-                                    lv.EVENT.CLICKED, None)
-            
-
-            on_call_phone_one = lv.img(on_call_screen_tab)
-            on_call_phone_one.set_src("U:/static/IMAGE_NUMBER_KEY1_ICON.png")
-            on_call_phone_one.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_one.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_one.set_pos(3, 110)
-            on_call_phone_one.set_size(76, 50)
-
-            on_call_phone_two = lv.img(on_call_screen_tab)
-            on_call_phone_two.set_size(76, 50)
-            on_call_phone_two.set_src("U:/static/IMAGE_NUMBER_KEY2_ICON.png")
-            on_call_phone_two.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_two.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_two.set_pos(82, 110)
-
-            on_call_phone_three = lv.img(on_call_screen_tab)
-            on_call_phone_three.set_size(76, 50)
-            on_call_phone_three.set_src("U:/static/IMAGE_NUMBER_KEY3_ICON.png")
-            on_call_phone_three.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_three.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_three.set_pos(161, 110)#1
-
-            on_call_phone_four = lv.img(on_call_screen_tab)
-            on_call_phone_four.set_size(76, 50)
-            on_call_phone_four.set_src("U:/static/IMAGE_NUMBER_KEY4_ICON.png")
-            on_call_phone_four.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_four.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_four.set_pos(3, 162)
-
-            on_call_phone_five = lv.img(on_call_screen_tab)
-            on_call_phone_five.set_size(76, 50)
-            on_call_phone_five.set_src("U:/static/IMAGE_NUMBER_KEY5_ICON.png")
-            on_call_phone_five.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_five.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_five.set_pos(82, 162)
-
-            on_call_phone_six = lv.img(on_call_screen_tab)
-            on_call_phone_six.set_size(76, 50)
-            on_call_phone_six.set_src("U:/static/IMAGE_NUMBER_KEY6_ICON.png")
-            on_call_phone_six.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_six.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_six.set_pos(161, 162)#2
-
-            on_call_phone_seven = lv.img(on_call_screen_tab)
-            on_call_phone_seven.set_size(76, 50)
-            on_call_phone_seven.set_src("U:/static/IMAGE_NUMBER_KEY7_ICON.png")
-            on_call_phone_seven.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_seven.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_seven.set_pos(3, 214)
-
-            on_call_phone_eight = lv.img(on_call_screen_tab)
-            on_call_phone_eight.set_size(76, 50)
-            on_call_phone_eight.set_src("U:/static/IMAGE_NUMBER_KEY8_ICON.png")
-            on_call_phone_eight.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_eight.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_eight.set_pos(82, 214)
-
-            on_call_phone_nine = lv.img(on_call_screen_tab)
-            on_call_phone_nine.set_size(76, 50)
-            on_call_phone_nine.set_src("U:/static/IMAGE_NUMBER_KEY9_ICON.png")
-            on_call_phone_nine.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_nine.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_nine.set_pos(161, 214)
-
-            on_call_phone_start = lv.img(on_call_screen_tab)
-            on_call_phone_start.set_size(76, 50)
-            on_call_phone_start.set_src("U:/static/IMAGE_NUMBER_KEYSTAR_ICON.png")
-            on_call_phone_start.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_start.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_start.set_pos(3, 266)
-
-            on_call_phone_zero = lv.img(on_call_screen_tab)
-            on_call_phone_zero.set_size(76, 50)
-            on_call_phone_zero.set_src("U:/static/IMAGE_NUMBER_KEY0_ICON.png")
-            on_call_phone_zero.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_zero.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_zero.set_pos(82, 266)
-
-            on_call_phone_hash = lv.img(on_call_screen_tab)
-            on_call_phone_hash.set_size(76, 50)
-            on_call_phone_hash.set_src("U:/static/IMAGE_NUMBER_KEYHASH_ICON.png")
-            on_call_phone_hash.add_flag(lv.obj.FLAG.CLICKABLE)
-            on_call_phone_hash.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            on_call_phone_hash.set_pos(161, 266)
-
-            self.meta = on_call_screen
-            
-
-            on_call_phone_one.add_event_cb(lambda e: EventMesh.callback_wrapper(self.one(e)),
-                                     lv.EVENT.CLICKED, None)
-            on_call_phone_two.add_event_cb(lambda e: EventMesh.callback_wrapper(self.two(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_three.add_event_cb(lambda e: EventMesh.callback_wrapper(self.three(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_four.add_event_cb(lambda e: EventMesh.callback_wrapper(self.four(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_five.add_event_cb(lambda e: EventMesh.callback_wrapper(self.five(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_six.add_event_cb(lambda e: EventMesh.callback_wrapper(self.six(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_eight.add_event_cb(lambda e: EventMesh.callback_wrapper(self.eight(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine(e)),
-                                        lv.EVENT.CLICKED, None)
-            on_call_phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero(e)),
-                                        lv.EVENT.CLICKED, None)
-            
-            on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
-                                        lv.EVENT.CLICKED, None)#短按显示* 
-            
-            on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.pressed_start(e)),
-                                        lv.EVENT.LONG_PRESSED, None)#长按显示+
-            
-            on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.endpressed_start(e)),
-                                        lv.EVENT.RELEASED, None)#释放按键
-        
-            on_call_phone_hash.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hash(e)),
-                                        lv.EVENT.CLICKED, None)
-        name = EventMesh.publish("get_phonename")
-        on_call_label_name.set_text(name)
-        # on_call_label.set_text(str(self.meta_info))
-        on_call_second_label.set_text("00:00")
-        self.phone_num = ''
-        self.phone_list = []
-        self.button = 0
-
-
-    def show_num(self):
-        global on_call_screen_tab_label
-        #print("phone self.phone_num ",self.phone_num,self.phone_list)
-        on_call_screen_tab_label.set_size(200, 30)
-        on_call_screen_tab_label.set_text(self.phone_num)
-    def one(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-            #return
-        
-        voiceCall.startDtmf("1",100)
-        self.phone_list.append("1")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-    
-    def two(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("2",100)
-        self.phone_list.append("2")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def three(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-        voiceCall.startDtmf("3",100)
-        self.phone_list.append("3")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def four(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-        voiceCall.startDtmf("4",100)
-        self.phone_list.append("4")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def five(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("5",100)
-        self.phone_list.append("5")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def six(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("6",100)
-        self.phone_list.append("6")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def seven(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("7",100)
-        self.phone_list.append("7")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def eight(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("8",100)
-        self.phone_list.append("8")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def nine(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("9",100)
-        self.phone_list.append("9")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def zero(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:#限制拨号数量20个数字
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("0",100)
-        self.phone_list.append("0")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-    
-    def start(self,e):
-        self.button = 0
-
-    def pressed_start(self,e):
-        self.button = 1
-    def Close(self):
-        self.timer_cb = 0
-        self.timer.stop()
-
-    def endpressed_start(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:#限制拨号数量20个数字
-            self.phone_list.pop(0)
-            #return
-  
-        # if self.button == 1:#长按
-        #     voiceCall.startDtmf("+",100)
-        #     self.phone_list.append("+")  
-        # else:#短按
-        voiceCall.startDtmf("*",100)
-        self.phone_list.append("*")  
-                      
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-    
-    def hash(self,e):
-        if len(self.phone_list) >= ON_CALL_MAX_DATA:#限制拨号数量20个数字
-            self.phone_list.pop(0)
-            #return
-        voiceCall.startDtmf("#",100)
-        self.phone_list.append("#")                
-        self.phone_num = ''.join(self.phone_list)
-        self.show_num()
-
-    def add_show_hidden(self):
-        on_call_volum_add.add_flag(lv.obj.FLAG.HIDDEN)
-        on_call_volum_reduce.add_flag(lv.obj.FLAG.HIDDEN)
-        on_call_bar.add_flag(lv.obj.FLAG.HIDDEN)
-    
-    def clear_show_hidden(self):
-        on_call_volum_add.clear_flag(lv.obj.FLAG.HIDDEN)
-        on_call_volum_reduce.clear_flag(lv.obj.FLAG.HIDDEN)
-        on_call_bar.clear_flag(lv.obj.FLAG.HIDDEN)
-
-    def open_volum_show(self, e):
-        global on_call_screen_tab,on_call_screen,on_call_obj
-       # self.aud.setVolume(0)
-        # if self.open_volum_state == 1:
-        #     self.open_volum_state = 0
-        # else:
-        #     self.open_volum_state = 1
-        # if self.open_volum_state == 1:
-        #     self.add_show_hidden()
-        # else:
-        #     self.clear_show_hidden()
-        
-    
-    def on_call_tab_show(self, e):
-        global on_call_screen_tab,on_call_screen,on_call_obj
-        if on_call_screen_tab != None:
-            self.phone_num = ''
-            self.phone_list = []
-            self.show_num()
-            on_call_screen_tab.clear_flag(lv.obj.FLAG.HIDDEN)
-            on_call_obj.add_flag(lv.obj.FLAG.HIDDEN)
-
-        
-    def on_return_show(self, e):
-        global on_call_screen_tab,on_call_screen,on_call_obj
-        if on_call_screen_tab != None:
-            on_call_screen_tab.add_flag(lv.obj.FLAG.HIDDEN)
-            on_call_obj.clear_flag(lv.obj.FLAG.HIDDEN)
-
-    def add_volum_size(self, e):
-        self.volum_size+=2
-        if self.volum_size >= 11:
-            self.volum_size = 11
-        self.show_bar(1)
-
-    def reduce_volum_size(self, e):
-        
-        self.volum_size -= 2
-        if self.volum_size < 0:
-            self.volum_size = 0
-        self.show_bar(1)
-
-    def show_bar(self,msg):
-        on_call_bar.set_value((100 // 11) * self.volum_size, lv.ANIM.OFF)
-        if msg == 1:
-            self.read_data = EventMesh.publish("get_storage_data")
-            self.read_data["volum"] = self.volum_size
-            self.aud.setVolume(self.volum_size)
-            EventMesh.publish("set_storage_data", self.read_data)
-            EventMesh.publish("set_volum_size",self.volum_size)
-            # print("self.read_data:size :{}".format(self.read_data))
-            with open("/usr/static/storage_file/config.json","w",encoding="utf-8") as fd:
-                ujson.dump(self.read_data,fd)
-
-    def post_processor_after_initialization(self):
-        global on_call_screen_tab,on_call_obj
-        self.count_sec = 0
-        self.timer.start(1000,1,self.refresh)
-        self.read_data = EventMesh.publish("get_storage_data")
-        # print("self.read_data:{}".format(self.read_data))
-        num = EventMesh.publish("get_volum_size")
-        if num == None:
-            self.volum_size = 8
-        else:
-            self.volum_size = num
-        self.aud.setVolume(self.volum_size)
-        self.show_bar(0)
-        self.open_volum = 0
-        self.phone_num = ''
-        self.phone_list = []
-        self.button = 0
-        if on_call_obj != None:
-            on_call_obj.clear_flag(lv.obj.FLAG.HIDDEN)
-        if on_call_screen_tab != None:
-            on_call_screen_tab.add_flag(lv.obj.FLAG.HIDDEN)
-        self.show_num()
-
-
-    def refresh(self,e):
-        # print("call_in")
-        global on_call_screen,on_call_label_name,on_call_second_label ,on_call_hangup
-        min = self.count_sec/60
-        sec = self.count_sec%60
-        if min > 99:
-            total = "%03d:%02d"%(min,sec)
-        else:
-            total = "%02d:%02d"%(min,sec)
-        on_call_second_label.set_text(str(total))
-        self.count_sec+=1
-    
-    def hangup(self,e):
-        EventMesh.publish("set_UI_high_priority", 0)
-        self.timer.stop()
-        voiceCall.callEnd()
-        
-    def Close(self):
-        self.timer.stop()
-
-    def btn1_release(self):
-        pass
-        #EventMesh.publish("load_screen", {"screen": "main_menu"})
-        
-    def btn8_press(self):
-        flag = EventMesh.publish("get_lcd_state")
-        if flag == 1:
-            EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
-        else:
-            EventMesh.publish(constants.EVENT.SYSTEM_UP)
-        #EventMesh.publish("load_screen", {"screen": "main_menu"})
-# -------------------------------------------step screen----------------------------------------------------------#
-
-step_screen = None
-step_label = None
-step_label_01 = None
-step_img = None
-class StepScreen(Screen):
-    NAME = "step"
-    
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.timer = osTimer()
-        
-    def initialization(self): 
-        global step_screen,step_label ,step_label_01 ,step_img 
-        if step_screen == None:
-            step_screen = lv.obj()
-            print("step_screen")
-            step_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            step_label = lv.label(step_screen)
-            step_label.set_pos(10, 30)
-            step_label.set_size(230, 50)
-            step_label.set_text("今日步数")
-            step_label.set_long_mode(lv.label.LONG.WRAP)
-            step_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-            step_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            step_label_01 = lv.label(step_screen)
-            step_label_01.set_pos(0, 100)
-            step_label_01.set_size(240, 50)
-            step_label_01.set_text("0步")
-            step_label_01.set_long_mode(lv.label.LONG.WRAP)
-            step_label_01.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            step_label_01.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            step_img = lv.img(step_screen)
-            step_img.set_pos(100, 150)
-            step_img.set_size(40, 65)
-            step_img.set_src("U:/static/IMAGE_STEP.png")
-            step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            self.meta = step_screen
-
-        step = EventMesh.publish("get_old_step_value")
-        step_label_01.set_text("{}步".format(step))
-        self.timer.start(1000, 1, self.revcing)
-
-    def revcing(self, *args, **kwargs):
-        global step_screen,step_label ,step_label_01 ,step_img 
-        step = EventMesh.publish("get_old_step_value")
-        step_label_01.set_text("{}步".format(step))
-
-    def Close(self):
-        self.timer.stop()
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-        
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-# -------------------------------------------weather screen----------------------------------------------------------
-
-weather_screen = None
-weather_img = None
-no_weather_img = None
-weather_tem_label = None
-no_weather_degree = None
-weather_detail_label = None
-weather_location_label = None
-no_connect_label = None
-no_connect_label1 = None
-class WeatherScreen(Screen):
-    NAME = "weather"
-    
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.weather_data = {}
-        EventMesh.subscribe("updata_weather_show", self.update_weather_data)
-
-    def initialization(self):
-        global weather_screen,weather_img,no_weather_img,weather_tem_label,no_weather_degree,\
-            weather_detail_label,weather_location_label,no_connect_label ,no_connect_label1 
-        if weather_screen == None :
-            weather_screen = lv.obj()
-            print("weather_screen")
-            weather_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            weather_img = lv.img(weather_screen)
-            weather_img.set_pos(10, 10)
-            weather_img.set_size(135, 120)
-
-            weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_weather_img = lv.img(weather_screen)
-            no_weather_img.set_pos(10, 10)
-            no_weather_img.set_size(135, 120)
-            no_weather_img.set_src("U:/static/update.png")
-            no_weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            weather_tem_label = lv.label(weather_screen)
-            weather_tem_label.set_pos(155, 44)
-            weather_tem_label.set_size(60, 50)
-            weather_tem_label.set_text("_ _")
-            weather_tem_label.set_long_mode(lv.label.LONG.WRAP)
-            weather_tem_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            weather_tem_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_weather_degree = lv.img(weather_screen)
-            no_weather_degree.set_pos(200, 40)
-            no_weather_degree.set_size(22, 22)
-            no_weather_degree.set_src("U:/static/degree.png")
-            no_weather_degree.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            weather_detail_label = lv.label(weather_screen)
-            weather_detail_label.set_pos(155, 80)
-            weather_detail_label.set_size(85, 50)
-            weather_detail_label.set_text("-/-")
-            weather_detail_label.set_long_mode(lv.label.LONG.WRAP)
-            weather_detail_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            weather_detail_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            weather_location_label = lv.label(weather_screen)
-            weather_location_label.set_pos(0, 200)
-            weather_location_label.set_size(240, 50)
-            weather_location_label.set_text("--")
-            weather_location_label.set_long_mode(lv.label.LONG.WRAP)
-            weather_location_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            weather_location_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_connect_label = lv.label(weather_screen)
-            no_connect_label.set_pos(0, 200)
-            no_connect_label.set_size(240, 40)
-            no_connect_label.set_text("找不到服务器")
-            no_connect_label.set_long_mode(lv.label.LONG.WRAP)
-            no_connect_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_connect_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            no_connect_label1 = lv.label(weather_screen)
-            no_connect_label1.set_pos(0, 250)
-            no_connect_label1.set_size(240, 70)
-            no_connect_label1.set_text("请联网后重试")
-            no_connect_label1.set_long_mode(lv.label.LONG.WRAP)
-            no_connect_label1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            no_connect_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            self.meta = weather_screen
-
-    def post_processor_after_initialization(self):
-        EventMesh.publish("updata_weather_show")
-
-
-    def update_weather_data(self, event, msg):
-        global weather_screen,weather_img,no_weather_img,weather_tem_label,no_weather_degree,\
-            weather_detail_label,weather_location_label,no_connect_label ,no_connect_label1 
-        connect = EventMesh.publish(constants.EVENT.GET_CONNECT) #获取网络状态
-        self.weather_data = EventMesh.publish("get_weather_data")
-        if weather_screen != None:
-            if connect != 0 and self.weather_data != None:
-                no_data = self.weather_data[8]
-                if no_data != 0 :
-                    no_weather_img.add_flag(lv.obj.FLAG.HIDDEN)
-                    weather_img.clear_flag(lv.obj.FLAG.HIDDEN)
-                    no_connect_label.set_text(" ")
-                    no_connect_label1.set_text(" ")
-                    # print("self.weather_data:{}".format(self.weather_data))
-                    type = self.weather_data[3]
-                    if type == None:
-                        weather_img.set_src("U:/static/update.png")#天气类型
-                    else:
-                        weather_img.set_src("U:/static/{}_weather.png".format(type))#天气类型
-
-                    temp = self.weather_data[4]
-                    if temp == None:
-                        weather_tem_label.set_text("_ _")
-                    else:
-                        weather_tem_label.set_text("{}".format(temp))
-
-                    date = self.weather_data[0]
-                    if date != '{}':
-                        date_month = date.split('-')[1]
-                        date_day = date.split('-')[2]
-                        weather_detail_label.set_text("{}/{}".format(date_month,date_day))#天气更新时间
-                    else:
-                        weather_detail_label.set_text("-/-")
-
-                    city = self.weather_data[7]
-                    if city != '{}':
-                        weather_location_label.set_text("{}".format(city))#城市
-                    else:
-                        weather_location_label.set_text("--")
-                else:#已联网未获取到天气数据
-                    weather_location_label.set_text(" ")
-                    weather_detail_label.set_text("-/-")
-                    weather_tem_label.set_text("_ _")
-
-                    no_connect_label.set_text("未获取网络数据")
-                    no_connect_label1.set_text("请稍候重试")
-
-            else:
-                weather_location_label.set_text(" ")
-                weather_detail_label.set_text("-/-")
-                weather_tem_label.set_text("_ _")
-                
-                no_weather_img.clear_flag(lv.obj.FLAG.HIDDEN)
-                weather_img.add_flag(lv.obj.FLAG.HIDDEN)
-                no_connect_label.set_text("找不到服务器")
-                no_connect_label1.set_text("请联网后重试")
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-        
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-import audio
-from machine import Pin
-
-
-
-
-# -----------------------------联系人--------------contacts screen----------------------------------------------------------
-
-CONTACT_FLAG = 0
-contacts_screen = None
-contacts_cont = None
-contacts_top_title = None
-contact_none_label = None
-contacts_screen_list_screen = None
-class ContactsScreen(Screen):
-    NAME = "contacts"
-
-    def __init__(self):
-        super().__init__()
-        # -------------------------------------------popup_menu screen----------------------------------------------------------
-        self.meta = None
-        self.phonebook = {}
-        self.count = 0
-        self.phone_num_count = 0
-        self.phone_num = {}
-        self.name = []
-        self.check_json = 0
-        self.timer = osTimer()
-        self.contact_detail_list = None
-        EventMesh.subscribe("contact_updata_list_show", self.btn_create_list)
-        self.MXA_phone_num = 50 #最大显示号码个数
-        self.contact_detail_listt_dict = []
-        self.calling_btn = []
-
-    def post_processor_before_initialization(self):
-        data = EventMesh.publish("get_phonebook_list")
-        if data != None:
-            self.check_json = data[0]
-            self.phonebook = data[1]
-            self.count = 0
-
-    def initialization(self):
-        global contacts_screen,contacts_cont,contacts_top_title,contact_none_label,contacts_screen_list_screen
-        if contacts_screen == None:
-            contacts_screen = lv.obj()
-            print("contacts_screen")
-            contacts_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            contacts_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            contacts_screen_list_screen = lv.obj(contacts_screen)
-            contacts_screen_list_screen.set_pos(0, 50)
-            contacts_screen_list_screen.set_size(240, 270)
-            contacts_screen_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            contacts_screen_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            contacts_top_title = lv.label(contacts_screen)
-            contacts_top_title.set_pos(0, 10)
-            contacts_top_title.set_size(240, 40)
-            contacts_top_title.set_text("联系人")
-            contacts_top_title.set_long_mode(lv.label.LONG.WRAP)
-            contacts_top_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            contacts_top_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-        
-
-            contact_none_label = lv.label(contacts_screen_list_screen)
-            contact_none_label.set_pos(0, 80)
-            contact_none_label.set_size(240, 50)
-            contact_none_label.set_text("无联系人,请在手机\nAPP上添加")
-            contact_none_label.set_long_mode(lv.label.LONG.WRAP)
-            contact_none_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            contact_none_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            self.contact_detail_list = lv.obj(contacts_screen_list_screen)
-            self.contact_detail_list.set_pos(0, 0)
-            self.contact_detail_list.set_size(240, 271)
-            self.contact_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            self.contact_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            for i in range(self.MXA_phone_num):
-                contact_btn = lv.btn(self.contact_detail_list)
-                contact_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-                contact_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling_cb(e)),
-                                        lv.EVENT.CLICKED, None)
-                contact_btn.add_flag(lv.obj.FLAG.HIDDEN)
-                
-                contact_btn_label_1 = lv.label(contact_btn)
-                contact_btn_label_2 = lv.label(contact_btn)
-                contact_btn_label_3 = lv.label(contact_btn)
-                self.contact_detail_listt_dict.append({"contact_btn":contact_btn,"contact_btn_label_1":contact_btn_label_1,"contact_btn_label_2":contact_btn_label_2,"contact_btn_label_3":contact_btn_label_3})
-            self.meta = contacts_screen
-        self.count = 0
-        self.btn_create_list_show(0)
-
-    def btn_create_list(self,event,msg):
-        self.post_processor_before_initialization()
-        self.timer.start(1 * 1000, 0, self.OutTime_s)
-
-    def OutTime_s(self,e):
-        self.btn_create_list_show(1)
-
-    def btn_create_list_show(self,state):
-        EventMesh.publish("publish_message_event_ui",{"func":self.btn_create_list_show_screen,"data":state})
-
-    def btn_create_list_show_screen(self,state):
-        global contacts_screen,contacts_cont,contacts_top_title,contact_none_label,contacts_screen_list_screen
-        print("btn_create_list_show_screen!!!!!!!!!!!")
-        if contacts_screen == None:
-            return
-        #读取json文件中的键作为label文本;
-        if self.check_json == True and len(self.phonebook) != 0:
-            self.contact_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)
-            contact_none_label.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
-            j =0
-            print("self.phonebook sorted :{} len(self.phonebook) :{}".format(sorted(self.phonebook.keys()),len(self.phonebook)))
-            phonebook_keys = sorted(self.phonebook.keys())
-
-            # self.contact_detail_list.delete()#先删除一次控件
-            # self.contact_detail_list = lv.obj(contacts_screen_list_screen)
-            # self.contact_detail_list.set_pos(0, 0)
-            # self.contact_detail_list.set_size(240, 271)
-            # self.contact_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            # self.contact_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            # print("self.phonebook sorted :{}".format(len(self.phonebook)))
-            if len(self.phonebook) > self.MXA_phone_num:
-                    j = len(self.phonebook) - self.MXA_phone_num
-            for i in range(self.MXA_phone_num): #字典 key value
-                if(j >= len(self.phonebook)):
-                    self.contact_detail_listt_dict[i]["contact_btn"].add_flag(lv.obj.FLAG.HIDDEN)
-                    continue
-                name = self.phonebook[phonebook_keys[j]]
-                key_tmp = phonebook_keys[j]
-
-                print("name :{} key_tmp:{}".format(name,key_tmp))
-                
-                #contact_btn = lv.btn(self.contact_detail_list)
-                self.contact_detail_listt_dict[i]["contact_btn"].set_size(230,80)
-                self.contact_detail_listt_dict[i]["contact_btn"].set_pos(0,82*i )
-                self.contact_detail_listt_dict[i]["contact_btn"].add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
-                # contact_btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED)
-                # self.contact_detail_listt_dict[i]["contact_btn"].add_event_cb(lambda e: EventMesh.callback_wrapper(self.calling(e)),
-                #                         lv.EVENT.CLICKED, None)
-
-                #contact_btn_label_1 = lv.label(contact_btn)
-                self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_pos(0, 5)
-                self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_size(180, 25)
-                self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_text(key_tmp[4:])
-                self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_long_mode(lv.label.LONG.DOT)
-                self.contact_detail_listt_dict[i]["contact_btn_label_1"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-                #contact_btn_label_2 = lv.label(contact_btn)
-                self.contact_detail_listt_dict[i]["contact_btn_label_2"].set_pos(0, 5)
-                self.contact_detail_listt_dict[i]["contact_btn_label_2"].set_size(0, 0)
-                self.contact_detail_listt_dict[i]["contact_btn_label_2"].set_text(key_tmp)
-                
-
-                #contact_btn_label_3 = lv.label(contact_btn)
-                self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_pos(0, 30)
-                self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_size(220, 35)
-                self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_text(name)
-                self.contact_detail_listt_dict[i]["contact_btn_label_3"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-                
-                
-                self.contact_detail_listt_dict[i]["contact_btn"].clear_flag(lv.obj.FLAG.HIDDEN)
-                #self.contact_detail_listt_dict[i]["contact_btn"].scroll_to_view(lv.ANIM.OFF)
-                j+=1
-
-                if state == 1:
-                    self.contact_detail_listt_dict[i]["contact_btn"].scroll_to_view(lv.ANIM.OFF)  
-             
-        else:
-            if contacts_screen_list_screen != None:
-                contact_none_label.clear_flag(lv.obj.FLAG.HIDDEN) #显示空文本
-            if self.contact_detail_list != None:
-                self.contact_detail_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
-            
-
-    def calling_cb(self,e):
-        code = e.get_code()
-        if code == lv.EVENT.CLICKED:
-            if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
-                msg_text = e.get_target().get_child(1).get_text()
-                EventMesh.publish("publish_message_event_ui",{"func":self.calling,"data":msg_text})
-            else:
-                EventMesh.publish("load_screen", {"screen": "no_sim_popup_screen"})
-
-    def calling(self,msg_text):    
-        _msg = msg_text
-        print("contacts:calling_cb1:{}".format(_msg))
-        # print("_msg:{}".format(_msg))
-        msg_tmp = _msg.split(':')
-        msg_tmp = msg_tmp[1]
-        EventMesh.publish("save_phonename", msg_tmp)   
-
-        phone_num = self.phonebook[_msg]
-        EventMesh.publish("save_phonenum", phone_num)  
-
-        # phone_num_tmp = int(phone_num)
-        
-        "dialing_noplay_popup"
-        EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
-
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-# -------------------------------------------temperature screen----------------------------------------------------------
-
-temperature_screen = None
-temperature_bg_img = None
-temperature_body_label = None
-temperature_degree_img = None
-temperature_value_label = None
-temperature_wrist_label = None
-temperature_wrist_degree_img = None
-temperature_wrist_value_label = None
-temperature_measure_end_label = None
-temperature_measure_countdown_label = None
-temp_reset_btn_img = None
-temp_line1 = None
-temp_line2 = None
-temp_line3 = None
-temp_line4 = None
-temp_line5 = None
-temp_line6 = None
-temp_line7 = None
-temperature_label = None
-temperature_line_bg_img = None
-temperature_done_img = None
-temperature_start_label=None
-temperature_bpm_label = None
-temperature_done_label = None
-temperature_keep_label = None
-
-style_line_blue = lv.style_t()
-style_line_blue.init()
-style_line_blue.set_line_width(10)
-style_line_blue.set_line_color(lv.color_make(35, 141, 255))
-
-class TemperatureScreen(Screen):
-    NAME = "temperature"
-
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.timer = osTimer()
-        self.point = 0
-        self.temp_value = 0
-
-    def initialization(self):
-        global temperature_screen,temperature_keep_label,temperature_label,temp_reset_btn_img,temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,\
-            temp_line6,temp_line7,temperature_line_bg_img,temperature_done_img ,temperature_start_label,temperature_bpm_label ,temperature_done_label 
-        if temperature_screen == None:
-            temperature_screen = lv.obj()
-            print("temp_screen")
-            temperature_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            temperature_label = lv.label(temperature_screen)
-            temperature_label.set_pos(0, 10)
-            temperature_label.set_size(240, 40)
-            temperature_label.set_text("体温")
-            temperature_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            temperature_label.set_long_mode(lv.label.LONG.WRAP)
-            temperature_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            temperature_line_bg_img = lv.img(temperature_screen)
-            temperature_line_bg_img.set_pos(5, 50)
-            temperature_line_bg_img.set_size(230, 120)
-            temperature_line_bg_img.set_src("U:/static/temp_line_bg.png")
-
-            
-            temperature_done_img = lv.img(temperature_screen)
-            temperature_done_img.set_pos(20, 226)
-            temperature_done_img.set_src("U:/static/temp_gif03.png")
-
-            temp_reset_btn_img = lv.img(temperature_screen)
-            temp_reset_btn_img.set_pos(0, 182)
-            temp_reset_btn_img.set_src("U:/static/reset_hr_btn.png")
-            temp_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
-            temp_reset_btn_img.add_flag(lv.obj.FLAG.CLICKABLE)
-
-            temperature_start_label = lv.label(temperature_screen)
-            temperature_start_label.set_size(240,40)
-            temperature_start_label.set_pos(0,190)
-            temperature_start_label.set_text(" ")
-            temperature_start_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            temperature_start_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            temperature_start_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-            # hr_line_points1 = [{"x":0,"y":0},{"x":0,"y":30}]
-            # hr_line_points2 = [{"x":0,"y":0},{"x":0,"y":47}]
-            # hr_line_points3 = [{"x":0,"y":0},{"x":0,"y":67}]
-            # hr_line_points4 = [{"x":0,"y":0},{"x":0,"y":85}]
-            # hr_line_points5 = [{"x":0,"y":0},{"x":0,"y":100}]
-            # hr_line_points6 = [{"x":0,"y":0},{"x":0,"y":100}]
-            # hr_line_points7 = [{"x":0,"y":0},{"x":0,"y":100}]
-
-            temp_line1 = lv.line(temperature_screen)
-            temp_line1.set_points(hr_line_points,2)
-            temp_line1.set_pos(29,120)
-            temp_line1.set_size(10,0)
-            temp_line1.add_style(style_line_blue,0)
-
-            temp_line2 = lv.line(temperature_screen)
-            temp_line2.set_points(hr_line_points,2)
-            temp_line2.set_pos(57,103)
-            temp_line2.set_size(10,0)
-            temp_line2.add_style(style_line_blue,0)
-
-            temp_line3 = lv.line(temperature_screen)
-            temp_line3.set_points(hr_line_points,2)
-            temp_line3.set_pos(84,82)
-            temp_line3.set_size(10,0)
-            temp_line3.add_style(style_line_blue,0)
-
-            temp_line4 = lv.line(temperature_screen)
-            temp_line4.set_points(hr_line_points,2)
-            temp_line4.set_pos(110,66)
-            temp_line4.set_size(10,0)
-            temp_line4.add_style(style_line_blue,0)
-
-            temp_line5 = lv.line(temperature_screen)
-            temp_line5.set_points(hr_line_points,2)
-            temp_line5.set_pos(140,50)
-            temp_line5.set_size(10,0)
-            temp_line5.add_style(style_line_blue,0)
-
-            temp_line6 = lv.line(temperature_screen)
-            temp_line6.set_points(hr_line_points,2)
-            temp_line6.set_pos(167,50)
-            temp_line6.set_size(10,0)
-            temp_line6.add_style(style_line_blue,0)
-
-            temp_line7 = lv.line(temperature_screen)
-            temp_line7.set_points(hr_line_points,2)
-            temp_line7.set_pos(195,50)
-            temp_line7.set_size(10,0)
-            temp_line7.add_style(style_line_blue,0)
-
-            temperature_bpm_label = lv.label(temperature_screen)
-            temperature_bpm_label.set_size(120, 40)
-            temperature_bpm_label.set_pos(100, 244)
-            temperature_bpm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            temperature_bpm_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-            temperature_keep_label = lv.label(temperature_screen)
-            temperature_keep_label.set_size(140, 40)
-            temperature_keep_label.set_pos(100, 280)
-            temperature_keep_label.set_text(" ")
-            temperature_keep_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-
-            temperature_degree_img = lv.img(temperature_screen)
-            temperature_degree_img.set_pos(156, 242)
-            temperature_degree_img.set_size(22, 22)
-            temperature_degree_img.set_src("U:/static/degree.png")
-            temperature_degree_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            self.meta = temperature_screen
-            temp_reset_btn_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.restart_up(e)),
-                lv.EVENT.CLICKED, None)
-            
-        temperature_bpm_label.set_text("- -")
-        temperature_start_label.set_text("正在测量中.")
-        
-
-    def post_processor_after_initialization(self):
-        self.restart_up(0)
-
-    def restart_up(self,e):
-        global temperature_done_label,temperature_keep_label,temperature_bpm_label,temperature_start_label,temp_reset_btn_img
-        temperature_bpm_label.set_text("- -")
-        temperature_keep_label.set_text(" ")
-        temp_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
-        self.point = 0
-        temperature_bpm_label.set_text("- -")
-        temperature_start_label.set_text("正在测量中.")
-        EventMesh.publish("set_temp_state",1)
-        EventMesh.publish(constants.EVENT.START_TEMP)
-        self.show_history_data()
-        self.timer.start(1*500, 1, self.start_measure)
-
-    def show_history_data(self):
-        global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7
-        read_data = {}
-        read_data = EventMesh.publish("get_history_temp_value")
-        print("hr history read_data",read_data)
-        if read_data != None:
-            count = len(read_data)
-            if count != 0:
-                if count >= 7:
-                    for i in  range(count):
-                        value = read_data["0{}".format(i+1)]
-                        value_temp = int(value)
-                        if value <= 30:
-                            line_value = int(value_temp)
-                        elif value <= 34:
-                            line_value = int((value_temp-30)*4.25)+30
-                        elif value <= 38:
-                            line_value = int((value_temp-34)*5)+47
-                        elif value <= 42:
-                            line_value = int((value_temp-38)*4)+67
-                        elif value < 46:
-                            line_value = int((value_temp-42)*3.75)+85
-                        else:
-                            value = 46
-                            line_value = 100
-                        
-
-                        if line_value >= 100:
-                            line_value = 100
-                        #print("hr hist",line_value)
-                        hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
-                        if i == 0:
-                            temp_line1.set_points(hr_line_points,2)
-                            temp_line1.set_pos(29,150-line_value)
-                            temp_line1.set_size(10,line_value)
-                            if value >= 37.3:
-                                temp_line1.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                            else:
-                                temp_line1.set_style_line_color(lv.color_make(35,141,255),0)
-                        if i == 1:
-                            temp_line2.set_points(hr_line_points,2)
-                            temp_line2.set_pos(57,150-line_value)
-                            temp_line2.set_size(10,line_value)
-                            if value >= 37.3:
-                                temp_line2.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                            else:
-                                temp_line2.set_style_line_color(lv.color_make(35,141,255),0)
-
-                        if i == 2:
-                            temp_line3.set_points(hr_line_points,2)
-                            temp_line3.set_pos(84,150-line_value)
-                            temp_line3.set_size(10,line_value)
-                            if value >= 37.3:
-                                temp_line3.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                            else:
-                                temp_line3.set_style_line_color(lv.color_make(35,141,255),0)
-                        if i == 3:
-                            temp_line4.set_points(hr_line_points,2)
-                            temp_line4.set_pos(112,150-line_value)
-                            temp_line4.set_size(10,line_value)
-                            if value >= 37.3:
-                                temp_line4.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                            else:
-                                temp_line4.set_style_line_color(lv.color_make(35,141,255),0)
-                        if i == 4:
-                            temp_line5.set_points(hr_line_points,2)
-                            temp_line5.set_pos(140,150-line_value)
-                            temp_line5.set_size(10,line_value)
-                            if value >= 37.3:
-                                temp_line5.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                            else:
-                                temp_line5.set_style_line_color(lv.color_make(35,141,255),0)
-
-                        if i == 5:
-                            temp_line6.set_points(hr_line_points,2)
-                            temp_line6.set_pos(167,150-line_value)
-                            temp_line6.set_size(10,line_value)
-                            if value >= 37.3:
-                                temp_line6.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                            else:
-                                temp_line6.set_style_line_color(lv.color_make(35,141,255),0)
-
-                        if i == 6:
-                            temp_line7.set_points(hr_line_points,2)
-                            temp_line7.set_pos(195,150-line_value)
-                            temp_line7.set_size(10,line_value)
-                            if value >= 37.3:
-                                temp_line7.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                            else:
-                                temp_line7.set_style_line_color(lv.color_make(35,141,255),0)
-                else:
-                    value = read_data["0{}".format(count)]
-                    value_temp = int(value)
-                    if value <= 30:
-                        line_value = int(value_temp)
-                    elif value <= 34:
-                        line_value = int((value_temp-30)*4.25)+30
-                    elif value <= 38:
-                        line_value = int((value_temp-34)*5)+47
-                    elif value <= 42:
-                        line_value = int((value_temp-38)*4)+67
-                    elif value < 46:
-                        line_value = int((value_temp-42)*3.75)+85
-                    else:
-                        value = 46
-                        line_value = 100
-                    
-
-                    if line_value >= 100:
-                        line_value = 100
-                   #
-                    hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
-                    if count == 1:
-                        temp_line1.set_points(hr_line_points,2)
-                        temp_line1.set_pos(29,150-line_value)
-                        temp_line1.set_size(10,line_value)
-                        if value >= 37.3:
-                            temp_line1.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                        else:
-                            temp_line1.set_style_line_color(lv.color_make(35,141,255),0)
-                    
-                    if count == 2:
-                        temp_line2.set_points(hr_line_points,2)
-                        temp_line2.set_pos(57,150-line_value)
-                        temp_line2.set_size(10,line_value)
-                        if value >= 37.3:
-                            temp_line2.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                        else:
-                            temp_line2.set_style_line_color(lv.color_make(35,141,255),0)
-
-                    if count == 3:
-                        temp_line3.set_points(hr_line_points,2)
-                        temp_line3.set_pos(84,150-line_value)
-                        temp_line3.set_size(10,line_value)
-                        if value >= 37.3:
-                            temp_line3.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                        else:
-                            temp_line3.set_style_line_color(lv.color_make(35,141,255),0)
-
-
-                    if count == 4:
-                        temp_line4.set_points(hr_line_points,2)
-                        temp_line4.set_pos(112,150-line_value)
-                        temp_line4.set_size(10,line_value)
-                        if value >= 37.3:
-                            temp_line4.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                        else:
-                            temp_line4.set_style_line_color(lv.color_make(35,141,255),0)
-
-                    if count == 5:
-                        temp_line5.set_points(hr_line_points,2)
-                        temp_line5.set_pos(140,150-line_value)
-                        temp_line5.set_size(10,line_value)
-                        if value >= 37.3:
-                            temp_line5.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                        else:
-                            temp_line5.set_style_line_color(lv.color_make(35,141,255),0)
-
-                    if count == 6:
-                        temp_line6.set_points(hr_line_points,2)
-                        temp_line6.set_pos(167,150-line_value)
-                        temp_line6.set_size(10,line_value)
-                        if value >= 37.3:
-                            temp_line6.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                        else:
-                            temp_line6.set_style_line_color(lv.color_make(35,141,255),0)
-
-                    if count == 7:
-                        temp_line7.set_points(hr_line_points,2)
-                        temp_line7.set_pos(195,150-line_value)
-                        temp_line7.set_size(10,line_value)      
-                        if value >= 37.3:
-                            temp_line7.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
-                        else:
-                            temp_line7.set_style_line_color(lv.color_make(35,141,255),0)
-
-    def start_measure(self,*args):
-        global temperature_label,temperature_keep_label,temperature_done_img ,temp_reset_btn_img,temperature_start_label,temperature_bpm_label ,temperature_done_label
-        self.point = self.point + 1
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        
-        temp = EventMesh.publish(constants.EVENT.GET_TEMP) 
-        tmp = str(temp).split('.')[0] + '.' + str(temp).split('.')[1][:1]#获取小数点后一位 舍去小数点最后一位
-        print("self.temp:{}".format(temp))
-        if self.point >= 2:
-            if temp != 0:
-                temperature_bpm_label.set_text("{}".format(tmp))
-            else:
-                temperature_bpm_label.set_text("- -")
-        
-        if self.point%4 == 0 :
-            temperature_start_label.set_text("正在测量中..")
-            temperature_done_img.set_src("U:/static/temp_gif02.png")
-        if self.point%4 == 1 :
-            temperature_start_label.set_text("正在测量中...")
-            temperature_done_img.set_src("U:/static/temp_gif01.png")
-        if self.point%4 == 2 :
-            temperature_start_label.set_text("正在测量中.")
-            temperature_done_img.set_src("U:/static/temp_gif02.png")
-        
-        if self.point%4 == 3 :
-            temperature_start_label.set_text("正在测量中.")
-            temperature_done_img.set_src("U:/static/temp_gif03.png")
-
-        tmp_f = str(temp).split('.')[0] 
-        tmp_f_tmp = int(tmp_f)
-
-        tmp_d = str(temp).split('.')[1][:1]
-        tmp_d_tmp = int(tmp_d)
-        if self.point >= 2:
-            if temp >= 37.3:
-                temperature_keep_label.set_text("体温偏高")
-                temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0x00, 0x00), lv.STATE.DEFAULT)
-            else:
-                temperature_keep_label.set_text("体温正常")
-                temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-        if self.point > 120 : #测2min
-
-            if temp >= 37.3:
-                temperature_done_img.set_src("U:/static/temp_high.png")
-            else:
-                temperature_done_img.set_src("U:/static/temp_gif03.png")
-            temp_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
-            temperature_start_label.set_text("测量结束,点击重测")
-            
-            EventMesh.publish("set_history_temp_value",temp)
-            self.show_history_data()
-            self.timer.stop()
-            self.point = 0
-            EventMesh.publish("set_temp_state",0)
-            EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
-            EventMesh.publish(constants.EVENT.STOP_TEMP)
-            
-
-            print("stop debug9")
-
-    def Close(self):
-        self.timer.stop()
-        EventMesh.publish("set_temp_state",0)
-        EventMesh.publish(constants.EVENT.STOP_TEMP)
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "health"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "health"})
-        
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-  
-# class TemperatureScreen(Screen):
-#     NAME = "temperature"
-
-#     def __init__(self):
-#         super().__init__()
-#         self.meta = None
-#         self.temp_timer = osTimer()
-#         self.count = 0
-#     def initialization(self):
-#         global temperature_screen,temperature_bg_img ,temperature_body_label ,temperature_degree_img ,temperature_value_label,\
-#             temperature_wrist_label,temperature_wrist_degree_img ,temperature_wrist_value_label,temperature_measure_end_label,temperature_measure_countdown_label
-#         if temperature_screen == None:
-#             temperature_screen = lv.obj()
-#             print("temperature_screen")
-#             temperature_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             temperature_bg_img = lv.img(temperature_screen)
-#             temperature_bg_img.set_pos(30, 50)
-#             temperature_bg_img.set_size(31, 32)
-#             temperature_bg_img.set_src("U:/static/temp_hand.png")
-#             temperature_bg_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             temperature_body_label = lv.label(temperature_screen)
-#             temperature_body_label.set_pos(80, 40)
-#             temperature_body_label.set_size(160, 20)
-#             temperature_body_label.set_text("当前腕温")
-#             temperature_body_label.set_long_mode(lv.label.LONG.WRAP)
-#             temperature_body_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-#             temperature_body_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             temperature_degree_img = lv.img(temperature_screen)
-#             temperature_degree_img.set_pos(146, 70)
-#             temperature_degree_img.set_size(22, 22)
-#             temperature_degree_img.set_src("U:/static/degree.png")
-#             temperature_degree_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             temperature_value_label = lv.label(temperature_screen)
-#             temperature_value_label.set_pos(90,73)
-#             temperature_value_label.set_size(50, 30)
-#             temperature_value_label.set_text("--")
-#             temperature_value_label.set_long_mode(lv.label.LONG.WRAP)
-#             temperature_value_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             temperature_value_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             # temperature_wrist_label = lv.label(temperature_screen)
-#             # temperature_wrist_label.set_pos(80,120)
-#             # temperature_wrist_label.set_size(100, 20)
-#             # temperature_wrist_label.set_text("当前腕温")
-#             # temperature_wrist_label.set_long_mode(lv.label.LONG.WRAP)
-#             # temperature_wrist_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             # temperature_wrist_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             # temperature_wrist_degree_img = lv.img(temperature_screen)
-#             # temperature_wrist_degree_img.set_pos(150, 150)
-#             # temperature_wrist_degree_img.set_size(22, 22)
-#             # temperature_wrist_degree_img.set_src("U:/static/degree.png")
-#             # temperature_wrist_degree_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             # temperature_wrist_value_label = lv.label(temperature_screen)
-#             # temperature_wrist_value_label.set_pos(96,155)
-#             # temperature_wrist_value_label.set_size(50, 30)
-#             # temperature_wrist_value_label.set_text("--")
-#             # temperature_wrist_value_label.set_long_mode(lv.label.LONG.WRAP)
-#             # temperature_wrist_value_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             # temperature_wrist_value_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             temperature_measure_countdown_label = lv.label(temperature_screen)
-#             temperature_measure_countdown_label.set_pos(0,160)
-#             temperature_measure_countdown_label.set_size(240, 30)
-#             temperature_measure_countdown_label.set_text("03:00")
-#             temperature_measure_countdown_label.set_long_mode(lv.label.LONG.WRAP)
-#             temperature_measure_countdown_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             temperature_measure_countdown_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             temperature_measure_end_label = lv.label(temperature_screen)
-#             temperature_measure_end_label.set_pos(0,220)
-#             temperature_measure_end_label.set_size(240, 30)
-#             temperature_measure_end_label.set_text(" ")
-#             temperature_measure_end_label.set_long_mode(lv.label.LONG.WRAP)
-#             temperature_measure_end_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             temperature_measure_end_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-#             self.meta = temperature_screen
-#         if temperature_value_label != None:
-#             temperature_value_label.set_text("--")
-#         if temperature_measure_end_label != None:
-#             temperature_measure_end_label.set_text(" ")
-#         if temperature_measure_countdown_label != None:
-#             temperature_measure_countdown_label.set_text("03:00")
-#         EventMesh.publish("set_temp_state",1)
-#         EventMesh.publish(constants.EVENT.START_TEMP)
-#         self.count = 0
-#         self.countdown = 3*60
-#         self.temp_timer.start(1*1000, 1, self.temp_timerout)
-#     def temp_timerout(self,*args):
-#         global temperature_value_label,temperature_measure_countdown_label,temperature_measure_end_label
-#         self.count += 1
-#         EventMesh.publish("system_sleep_rest")#防止黑屏
-#         temp = EventMesh.publish(constants.EVENT.GET_TEMP) 
-#         tmp = str(temp).split('.')[0] + '.' + str(temp).split('.')[1][:1]#获取小数点后一位 舍去小数点最后一位
-#         if temperature_measure_end_label != None:
-#             temperature_value_label.set_text("{}".format(tmp))
-
-#         tmp_f = str(temp).split('.')[0] 
-#         tmp_f_tmp = int(tmp_f)
-
-#         tmp_d = str(temp).split('.')[1][:1]
-#         tmp_d_tmp = int(tmp_d)
-        
-#         if self.countdown > 0:
-#             self.countdown-=1
-#         min = self.countdown / 60
-#         sec = self.countdown % 60
-#         if temperature_measure_countdown_label != None:
-#             temperature_measure_countdown_label.set_text("{}:{}".format("%02d"%(min),"%02d"%(sec)))
-
-#         # print("temp:{} tmp_f:{} tmp_f_tmp:{} tmp_d:{} tmp_d_tmp:{} self.count:{}".format(temp,tmp_f,tmp_f_tmp,tmp_d,tmp_d_tmp,self.count)) 
-#         if self.count >= 3*60:
-#             self.count = 0
-#             EventMesh.publish("set_temp_state",0)
-#             if temperature_measure_end_label != None:
-#                 temperature_measure_end_label.set_text("测量完成")
-#             self.temp_timer.stop()
-#             EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
-#             EventMesh.publish(constants.EVENT.STOP_TEMP)
-#     def Close(self):
-#         self.count = 0
-#         self.temp_timer.stop()
-#         EventMesh.publish("set_temp_state",0)
-#         EventMesh.publish(constants.EVENT.STOP_TEMP)
-        
-#     def done_return(self):
-#         EventMesh.publish("load_screen", {"screen": "health"})
-
-#     def btn1_release(self):
-#         EventMesh.publish("load_screen", {"screen": "health"})
-        
-#     def btn8_press(self):
-#         EventMesh.publish("watch_top_show")
-#         EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-
-line_points = [{"x":0,"y":0},{"x":240,"y":0}]
-spo2_screen = None
-spo2_label_0 = None
-spo2_done_img = None
-spo2_label = None
-spo2_label_1 = None
-spo2_line = None
-spo2_last_time = None
-spo2_last_value = None
-heartrate_screen = None
-heartrate_label = None
-heartrate_done_img = None
-heartrate_start_label = None
-heartrate_bpm_label = None
-heartrate_done_label = None
-heartrate_line_bg_img = None
-spo2_line1 = None
-spo2_line2 = None
-spo2_line3 = None
-spo2_line4 = None
-spo2_line5 = None
-spo2_line6 = None
-spo2_line7 = None
-spo2_reset_btn_img = None
-spo2_label = None
-spo2_line_bg_img = None
-spo2_done_img = None
-spo2_done_label = None
-spo2_value_label = None
-spo2_start_label = None
-
-style_line_red = lv.style_t()
-style_line_red.init()
-style_line_red.set_line_width(10)
-style_line_red.set_line_color(lv.color_make(0xff, 0x00, 0x00))
-
-spo2_line_points = [{"x":0,"y":0},{"x":0,"y":0}]
-
-class Spo2Screen(Screen):
-    NAME = "spo2"
-
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.timer = osTimer()
-        self.point = 0
-        self.spo2_value = 0
-
-    def initialization(self):
-        global spo2_screen,spo2_label,spo2_value_label,spo2_reset_btn_img,spo2_done_img,spo2_line_bg_img,spo2_line1,spo2_line2,\
-            spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7,spo2_line_bg_img ,spo2_start_label ,spo2_done_label 
-        if spo2_screen == None:
-            spo2_screen = lv.obj()
-            print("spo2_screen")
-            spo2_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            spo2_label = lv.label(spo2_screen)
-            spo2_label.set_pos(0, 20)
-            spo2_label.set_size(240, 40)
-            spo2_label.set_text("血氧")
-            spo2_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            spo2_label.set_long_mode(lv.label.LONG.WRAP)
-            spo2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            spo2_line_bg_img = lv.img(spo2_screen)
-            spo2_line_bg_img.set_pos(5, 60)
-            spo2_line_bg_img.set_size(230, 120)
-            spo2_line_bg_img.set_src("U:/static/spo2_line_bg.png")
-
-            
-            spo2_done_img = lv.img(spo2_screen)
-            spo2_done_img.set_pos(20, 240)
-            spo2_done_img.set_src("U:/static/spo2_gif04.png")
-
-            spo2_reset_btn_img = lv.img(spo2_screen)
-            spo2_reset_btn_img.set_pos(0, 192)
-            spo2_reset_btn_img.set_src("U:/static/reset_hr_btn.png")
-            spo2_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
-            spo2_reset_btn_img.add_flag(lv.obj.FLAG.CLICKABLE)
-
-            spo2_start_label = lv.label(spo2_screen)
-            spo2_start_label.set_size(240,40)
-            spo2_start_label.set_pos(0,200)
-            spo2_start_label.set_text(" ")
-            spo2_start_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
-            spo2_start_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            spo2_start_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-
-            spo2_line1 = lv.line(spo2_screen)
-            spo2_line1.set_points(spo2_line_points,2)
-            spo2_line1.set_pos(25,60)
-            spo2_line1.set_size(10,0)
-            spo2_line1.add_style(style_line_red,0)
-
-            spo2_line2 = lv.line(spo2_screen)
-            spo2_line2.set_points(spo2_line_points,2)
-            spo2_line2.set_pos(53,60)
-            spo2_line2.set_size(10,0)
-            spo2_line2.add_style(style_line_red,0)
-
-            spo2_line3 = lv.line(spo2_screen)
-            spo2_line3.set_points(spo2_line_points,2)
-            spo2_line3.set_pos(80,60)
-            spo2_line3.set_size(10,0)
-            spo2_line3.add_style(style_line_red,0)
-
-            spo2_line4 = lv.line(spo2_screen)
-            spo2_line4.set_points(spo2_line_points,2)
-            spo2_line4.set_pos(109,60)
-            spo2_line4.set_size(10,0)
-            spo2_line4.add_style(style_line_red,0)
-
-            spo2_line5 = lv.line(spo2_screen)
-            spo2_line5.set_points(spo2_line_points,2)
-            spo2_line5.set_pos(136,60)
-            spo2_line5.set_size(10,0)
-            spo2_line5.add_style(style_line_red,0)
-
-            spo2_line6 = lv.line(spo2_screen)
-            spo2_line6.set_points(spo2_line_points,2)
-            spo2_line6.set_pos(164,60)
-            spo2_line6.set_size(10,0)
-            spo2_line6.add_style(style_line_red,0)
-
-            spo2_line7 = lv.line(spo2_screen)
-            spo2_line7.set_points(spo2_line_points,2)
-            spo2_line7.set_pos(192,60)
-            spo2_line7.set_size(10,0)
-            spo2_line7.add_style(style_line_red,0)
-
-            spo2_value_label = lv.label(spo2_screen)
-            spo2_value_label.set_size(110, 40)
-            spo2_value_label.set_pos(130, 270)
-            spo2_value_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            spo2_value_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
-
-            self.meta = spo2_screen
-            spo2_reset_btn_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.restart_up(e)),
-                lv.EVENT.CLICKED, None)
-
-    def post_processor_after_initialization(self):
-        self.point = 0
-        self.spo2_value = 0
-        self.show_history_data()
-        self.restart_up(0)
-
-    def restart_up(self,e):
-        global spo2_value_label,heartrate_bpm_label,spo2_start_label,spo2_reset_btn_img
-        self.timer.start(1*500, 1, self.start_measure)
-        if spo2_reset_btn_img != None:
-            spo2_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
-        self.point = 0
-        
-        spo2_value_label.set_text("- -%")
-        spo2_start_label.set_text("正在测量中.")
-        EventMesh.publish("set_spo2_state",1)#2代表后台进入血氧测试
-        EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)
-
-    def show_history_data(self):
-        global spo2_line1,spo2_line2,spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7
-        read_data = {}
-        read_data = EventMesh.publish("get_history_spo2_value")
-        print("hr get_history_spo2_value",read_data)
-        if read_data != None:
-            count = len(read_data)
-            if count != 0:
-                if count >= 7:
-                    for i in  range(count):
-                        value = read_data["0{}".format(i+1)]
-                        if value < 80:
-                            value = 80
-                        if value >= 100:
-                            value = 100
-                        if value <= 85:
-                            value = value - 80
-                            line_value = int(value*6)
-                        elif value <= 90:
-                            value = value-85
-                            line_value = int((17/5)*value)+30
-                        elif value <= 95:
-                            value = value-90
-                            line_value = int((21/5)*value)+47
-                        elif value <= 100:
-                            value = value-95
-                            line_value = int((16/5)*value)+68
-                        
-                       
-                        if line_value >= 100:
-                            line_value = 100
-                        #print("hr hist",line_value)
-                        hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
-                        if i == 0:
-                            spo2_line1.set_points(hr_line_points,2)
-                            spo2_line1.set_pos(25,160-line_value)
-                            spo2_line1.set_size(10,line_value)
-                        if i == 1:
-                            spo2_line2.set_points(hr_line_points,2)
-                            spo2_line2.set_pos(53,160-line_value)
-                            spo2_line2.set_size(10,line_value)
-
-                        if i == 2:
-                            spo2_line3.set_points(hr_line_points,2)
-                            spo2_line3.set_pos(80,160-line_value)
-                            spo2_line3.set_size(10,line_value)
-
-                        if i == 3:
-                            spo2_line4.set_points(hr_line_points,2)
-                            spo2_line4.set_pos(109,160-line_value)
-                            spo2_line4.set_size(10,line_value)
-
-                        if i == 4:
-                            spo2_line5.set_points(hr_line_points,2)
-                            spo2_line5.set_pos(136,160-line_value)
-                            spo2_line5.set_size(10,line_value)
-
-                        if i == 5:
-                            spo2_line6.set_points(hr_line_points,2)
-                            spo2_line6.set_pos(164,160-line_value)
-                            spo2_line6.set_size(10,line_value)
-
-                        if i == 6:
-                            spo2_line7.set_points(hr_line_points,2)
-                            spo2_line7.set_pos(192,160-line_value)
-                            spo2_line7.set_size(10,line_value)
-                else:
-                    value = read_data["0{}".format(count)]
-                    if value < 80:
-                            value = 80
-                    if value >= 100:
-                        value = 100
-
-                    if value <= 85:
-                        value = value - 80
-                        line_value = int(value*6)
-                    elif value <= 90:
-                        value = value-85
-                        line_value = int((17/5)*value)+30
-                    elif value <= 95:
-                        value = value-90
-                        line_value = int((21/5)*value)+47
-                    elif value <= 100:
-                        value = value-95
-                        line_value = int((16/5)*value)+68
-                    
-                    
-                    if line_value >= 100:
-                        line_value = 100
-                   #
-                    hr_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
-                    if count == 1:
-                        spo2_line1.set_points(hr_line_points,2)
-                        spo2_line1.set_pos(25,160-line_value)
-                        spo2_line1.set_size(10,line_value)
-                    if count == 2:
-                        spo2_line2.set_points(hr_line_points,2)
-                        spo2_line2.set_pos(53,160-line_value)
-                        spo2_line2.set_size(10,line_value)
-
-                    if count == 3:
-                        spo2_line3.set_points(hr_line_points,2)
-                        spo2_line3.set_pos(80,160-line_value)
-                        spo2_line3.set_size(10,line_value)
-
-                    if count == 4:
-                        spo2_line4.set_points(hr_line_points,2)
-                        spo2_line4.set_pos(109,160-line_value)
-                        spo2_line4.set_size(10,line_value)
-
-                    if count == 5:
-                        spo2_line5.set_points(hr_line_points,2)
-                        spo2_line5.set_pos(136,160-line_value)
-                        spo2_line5.set_size(10,line_value)
-
-                    if count == 6:
-                        spo2_line6.set_points(hr_line_points,2)
-                        spo2_line6.set_pos(164,160-line_value)
-                        spo2_line6.set_size(10,line_value)
-
-                    if count == 7:
-                        spo2_line7.set_points(hr_line_points,2)
-                        spo2_line7.set_pos(192,160-line_value)
-                        spo2_line7.set_size(10,line_value)      
-
-
-    def start_measure(self,*args):
-        global spo2_screen,spo2_label,spo2_start_label,spo2_value_label,spo2_done_img ,spo2_reset_btn_img 
-        self.point = self.point + 1
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-        if self.point >= 2:
-            if self.spo2_value != 0:
-                spo2_value_label.set_text("{}%".format(self.spo2_value))
-            else:
-                spo2_value_label.set_text("- - %")
-        
-        if self.point%4 == 0 :
-            spo2_start_label.set_text("正在测量中..")
-            spo2_done_img.set_src("U:/static/spo2_gif03.png")
-
-        if self.point%4 == 1 :
-            spo2_start_label.set_text("正在测量中...")
-            spo2_done_img.set_src("U:/static/spo2_gif02.png")
-
-        if self.point%4 == 2 :
-            spo2_start_label.set_text("正在测量中.")
-            spo2_done_img.set_src("U:/static/spo2_gif01.png")
-        
-        if self.point%4 == 3 :
-            spo2_start_label.set_text("正在测量中.")
-            spo2_done_img.set_src("U:/static/spo2_gif04.png")
-
-
-
-        if self.point > 120: #测20s
-            spo2_done_img.set_src("U:/static/spo2_gif04.png")
-            self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-            if self.spo2_value >= 85:
-                EventMesh.publish("set_old_spo2_data",self.spo2_value)
-                EventMesh.publish("set_history_spo2_value",self.spo2_value)
-                EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,self.spo2_value)
-            spo2_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
-            
-            
-            if self.spo2_value != 0:
-                spo2_start_label.set_text("测量结束,点击重测")
-                spo2_value_label.set_text("{}%".format(self.spo2_value))
-                # heartrate_done_label.set_text("测量完成")
-            else:
-                spo2_value_label.set_text("- - %")
-                spo2_start_label.set_text("测量异常,点击重测")
-                
-            self.show_history_data()
-
-            self.timer.stop()
-            self.point = 0
-            EventMesh.publish("set_spo2_state",0)#0代表关闭测试
-            print("stop debug9")
-            EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-
-    def Close(self):
-        self.timer.stop()
-        get_hr_state = EventMesh.publish("get_hr_state")
-        get_spo2_state = EventMesh.publish("get_spo2_state")
-        if get_hr_state == 1 or get_spo2_state == 1:
-            EventMesh.publish("set_spo2_state",0)#0代表关闭测试
-            EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "health"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "health"})
-        
-    def btn8_press(self):
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-
-
-# class Spo2Screen(Screen):
-#     NAME = "spo2"
-
-#     def __init__(self):
-#         super().__init__()
-#         self.meta = None
-#         self.timer = osTimer()
-#         self.point = 0
-#         self.spo2_value = 0
-#         self.last_spo2_value = 0
-#         self.rtc = RTC()
-
-#     def initialization(self):
-#         global spo2_screen ,spo2_label_0 ,spo2_done_img ,spo2_label ,spo2_label_1 ,spo2_line ,spo2_last_time,spo2_last_value 
-#         if spo2_screen == None:
-#             spo2_screen = lv.obj()
-#             print("spo2_screen")
-#             spo2_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             spo2_label_0 = lv.label(spo2_screen)
-#             spo2_label_0.set_pos(0, 10)
-#             spo2_label_0.set_size(240, 40)
-#             spo2_label_0.set_text("血氧")
-#             spo2_label_0.set_long_mode(lv.label.LONG.WRAP)
-#             spo2_label_0.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             spo2_label_0.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             spo2_done_img = lv.img(spo2_screen)
-#             spo2_done_img.set_pos(89, 50)
-#             spo2_done_img.set_size(62, 84)
-#             spo2_done_img.set_src("U:/static/IMAGE_SPO2_ONLY_TEST_DONE.png")
-
-#             spo2_label = lv.label(spo2_screen)
-#             spo2_label.set_size(240,30)
-#             spo2_label.set_pos(0,160)
-#             spo2_label.set_text(" ")
-#             spo2_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             spo2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-#             spo2_label_1 = lv.label(spo2_screen)
-#             spo2_label_1.set_size(240,40)
-#             spo2_label_1.set_pos(0,200)
-#             spo2_label_1.set_text("测量中.")
-#             spo2_label_1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             spo2_label_1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            
-#             spo2_line = lv.line(spo2_screen)
-#             spo2_line.set_points(line_points,2)
-#             spo2_line.set_pos(0,240)
-#             spo2_line.set_size(240,10)
-#             spo2_line.add_style(style_line,0)
-
-#             spo2_last_time = lv.label(spo2_screen)
-#             spo2_last_time.set_size(240, 15)
-#             spo2_last_time.set_pos(0, 250)
-#             spo2_last_time.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-#             spo2_last_time.set_text(" ")
-#             spo2_last_time.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-
-#             spo2_last_value = lv.label(spo2_screen)
-#             spo2_last_value.set_size(240, 15)
-#             spo2_last_value.set_pos(0, 280)
-#             spo2_last_value.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-#             spo2_last_value.set_text(" ")
-#             spo2_last_value.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-#             self.meta = spo2_screen
-
-#         self.point = 0
-#         self.spo2_value = 0
-#         self.timer.start(1*1000, 1, self.start_measure)
-#         EventMesh.publish("set_spo2_state",1)#2代表后台进入血氧测试
-#         EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)
-#         self.last_spo2_value = EventMesh.publish("get_old_spo2_data")
-#         spo2_label.set_text("--%")
-#         if self.last_spo2_value == 0:
-#             spo2_last_value.set_text(" ")
-#         else:
-#             spo2_last_value.set_text("{}%".format(self.last_spo2_value))
-
-#     def start_measure(self,*args):
-#         global spo2_screen ,spo2_label_0 ,spo2_done_img ,spo2_label ,spo2_label_1 ,spo2_line ,spo2_last_time,spo2_last_value 
-#         self.point = self.point + 1
-#         EventMesh.publish("system_sleep_rest")#防止黑屏
-#         self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-#         if self.spo2_value == 0:
-#             spo2_label.set_text("--%")
-#         else:
-#             spo2_label.set_text("{} %".format(self.spo2_value))
-#         if self.point%4 == 0 :
-#             spo2_label_1.set_text("测量中..")
-#         if self.point%4 == 1 :
-#             spo2_label_1.set_text("测量中...")
-#         if self.point%4 == 2 :
-#             spo2_label_1.set_text("测量中....")
-#         if self.point%4 == 3 :
-#             spo2_label_1.set_text("测量中.")
-
-#         if self.point > 60: #测20s
-#             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:
-#                 spo2_label.set_text(" ")
-#                 spo2_label_1.set_text("退出,请重新测量")
-#                 self.last_spo2_value = EventMesh.publish("get_old_spo2_data")
-#                 spo2_last_value.set_text(" ")
-#             else:
-#                 self.last_spo2_value = self.spo2_value
-#                 spo2_last_value.set_text("{}%".format(self.last_spo2_value))
-#                 spo2_label_1.set_text("测量完成")
-#                 time = EventMesh.publish("screen_get_time")
-#                 #print("time ",time)
-#                 rtc_time = self.rtc.datetime()
-#                 time_time ="  {}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#测量时间
-#                 spo2_last_time.set_text(str(rtc_time[0])+'/'+str(rtc_time[1])+'/'+str(rtc_time[2])+str(time_time))
-            
-            
-
-#             self.timer.stop()
-#             self.point = 0
-#             EventMesh.publish("set_spo2_state",0)#0代表关闭测试
-#             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-#             # spo2_last_time.set_text()
-
-#     def Close(self):
-#         self.timer.stop()
-#         get_hr_state = EventMesh.publish("get_hr_state")
-#         get_spo2_state = EventMesh.publish("get_spo2_state")
-#         if get_hr_state == 1 or get_spo2_state == 1:
-#             EventMesh.publish("set_spo2_state",0)#0代表关闭测试
-#             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-
-#     def done_return(self):
-#         EventMesh.publish("load_screen", {"screen": "health"})
-
-#     def btn1_release(self):
-#         EventMesh.publish("load_screen", {"screen": "health"})
-        
-#     def btn8_press(self):
-#         EventMesh.publish("watch_top_show")
-#         EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-
-
-
-
-
-
-# -------------------------------------------countdown screen----------------------------------------------------------
-countdown_screen = None 
-countdown_title = None
-countdown_hour = None
-countdown_mao = None
-countdown_mao = None
-countdown_mao1 = None
-countdown_sec = None
-countdown_hour_up = None
-countdown_hour_up_btn = None
-countdown_hour_down = None
-countdown_hour_down_btn = None
-countdown_min_up = None
-countdown_min_up_btn = None
-countdown_min_down = None
-countdown_min_down_btn = None
-countdown_sec_up = None
-countdown_sec_up_btn = None
-countdown_sec_down = None
-countdown_sec_down_btn = None
-countdown_reset_img = None
-countdown_reset_imgbtn = None
-countdown_start_img = None
-countdown_start_imgbtn = None
-countdown_stop_img = None
-countdown_min = None
-class CountdownScreen(Screen):
-    NAME = "countdown"
-    
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.timer = osTimer()
-        self.sec = 0
-        self.min = 0
-        self.hour = 0
-        self.total = 0
-        self.flag = 1
-        self.g_state = 0
-        self.g_end = 0
-        self.total = 0
-        self.time_tmp = 0
-        self.timer_cb = 0
-
-    def initialization(self):
-        global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
-            countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
-            countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
-            countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
-            countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min 
-        if countdown_screen == None :           
-            countdown_screen = lv.obj()
-            print("countdown_screen")
-            countdown_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_title = lv.label(countdown_screen)
-            countdown_title.set_pos(0, 20)
-            countdown_title.set_size(240, 20)
-            countdown_title.set_text("倒计时")
-            countdown_title.set_long_mode(lv.label.LONG.WRAP)
-            countdown_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            countdown_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_hour = lv.label(countdown_screen)
-            countdown_hour.set_pos(30, 140)
-            countdown_hour.set_size(60, 30)
-            countdown_hour.set_text("00")
-            countdown_hour.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_hour.set_long_mode(lv.label.LONG.WRAP)
-            countdown_hour.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-            countdown_mao = lv.label(countdown_screen)
-            countdown_mao.set_pos(82, 138)
-            countdown_mao.set_size(30, 30)
-            countdown_mao.set_text(":")
-            countdown_mao.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_mao.set_long_mode(lv.label.LONG.WRAP)
-            countdown_mao.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-
-            countdown_min = lv.label(countdown_screen)
-            countdown_min.set_pos(95, 140)
-            countdown_min.set_size(60, 30)
-            countdown_min.set_text("00")
-            countdown_min.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_min.set_long_mode(lv.label.LONG.WRAP)
-            countdown_min.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-            countdown_mao1 = lv.label(countdown_screen)
-            countdown_mao1.set_pos(146, 138)
-            countdown_mao1.set_size(30, 30)
-            countdown_mao1.set_text(":")
-            countdown_mao1.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_mao1.set_long_mode(lv.label.LONG.WRAP)
-            countdown_mao1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-
-            countdown_sec = lv.label(countdown_screen)
-            countdown_sec.set_pos(160, 140)
-            countdown_sec.set_size(60, 30)
-            countdown_sec.set_text("00")
-            countdown_sec.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_sec.set_long_mode(lv.label.LONG.WRAP)
-            countdown_sec.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-            countdown_hour_up = lv.img(countdown_screen)
-            countdown_hour_up.set_size(34, 30)
-            countdown_hour_up.set_pos(36, 100)
-            countdown_hour_up.set_src("U:/static/time_up.png")
-            countdown_hour_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_hour_up_btn= lv.img(countdown_screen)
-            countdown_hour_up_btn.set_size(62, 70)
-            countdown_hour_up_btn.set_pos(20, 80)
-            countdown_hour_up_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-
-            countdown_hour_down = lv.img(countdown_screen)
-            countdown_hour_down.set_size(34, 30)
-            countdown_hour_down.set_pos(36, 180)
-            countdown_hour_down.set_src("U:/static/time_down.png")
-            countdown_hour_down.add_flag(lv.obj.FLAG.CLICKABLE)
-            countdown_hour_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_hour_down_btn= lv.img(countdown_screen)
-            countdown_hour_down_btn.set_size(62, 80)
-            countdown_hour_down_btn.set_pos(20, 150)
-            countdown_hour_down_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-
-            countdown_min_up = lv.img(countdown_screen)
-            countdown_min_up.set_size(34, 30)
-            countdown_min_up.set_pos(99, 100)
-            countdown_min_up.set_src("U:/static/time_up.png")
-            countdown_min_up.add_flag(lv.obj.FLAG.CLICKABLE)
-            countdown_min_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_min_up_btn= lv.img(countdown_screen)
-            countdown_min_up_btn.set_size(64, 70)
-            countdown_min_up_btn.set_pos(82, 80)
-            countdown_min_up_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-
-
-            countdown_min_down = lv.img(countdown_screen)
-            countdown_min_down.set_size(34, 30)
-            countdown_min_down.set_pos(99, 180)
-            countdown_min_down.set_src("U:/static/time_down.png")
-            countdown_min_down.add_flag(lv.obj.FLAG.CLICKABLE)
-            countdown_min_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_min_down_btn= lv.img(countdown_screen)
-            countdown_min_down_btn.set_size(64, 80)
-            countdown_min_down_btn.set_pos(82, 150)
-            countdown_min_down_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-
-            countdown_sec_up = lv.img(countdown_screen)
-            countdown_sec_up.set_size(34, 30)
-            countdown_sec_up.set_pos(165, 100)
-            countdown_sec_up.set_src("U:/static/time_up.png")
-            countdown_sec_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_sec_up_btn = lv.img(countdown_screen)
-            countdown_sec_up_btn.set_size(64, 70)
-            countdown_sec_up_btn.set_pos(146, 80)
-            countdown_sec_up_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-            countdown_sec_down = lv.img(countdown_screen)
-            countdown_sec_down.set_size(34, 30)
-            countdown_sec_down.set_pos(165, 180)
-            countdown_sec_down.set_src("U:/static/time_down.png")
-            countdown_sec_down.add_flag(lv.obj.FLAG.CLICKABLE)
-            countdown_sec_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_sec_down_btn = lv.img(countdown_screen)
-            countdown_sec_down_btn.set_size(64, 80)
-            countdown_sec_down_btn.set_pos(146, 150)
-            countdown_sec_down_btn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-            countdown_reset_img = lv.img(countdown_screen)
-            countdown_reset_img.set_size(99, 36)
-            countdown_reset_img.set_src("U:/static/stopwatch_reset.png")
-            countdown_reset_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_reset_img.set_pos(10, 260)
-
-            countdown_reset_imgbtn = lv.img(countdown_screen)
-            countdown_reset_imgbtn.set_size(99, 70)
-            countdown_reset_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-            countdown_reset_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_reset_imgbtn.set_pos(10, 240)
-
-
-
-            countdown_start_img = lv.img(countdown_screen)
-            countdown_start_img.set_size(99, 36)
-            countdown_start_img.set_src("U:/static/stopwatch_play.png")
-            countdown_start_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_start_img.set_pos(120, 260)
-
-            countdown_start_imgbtn = lv.img(countdown_screen)
-            countdown_start_imgbtn.set_size(99, 70)
-            countdown_start_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-            countdown_start_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_start_imgbtn.set_pos(120, 240)
-
-
-
-            countdown_stop_img = lv.img(countdown_screen)
-            countdown_stop_img.set_size(99, 36)
-            countdown_stop_img.set_src("U:/static/stopwatch_stop.png")
-            countdown_stop_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_stop_img.set_pos(120, 260)
-            countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-            countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-
-            countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-            countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
-
-            self.meta = countdown_screen
-
-            countdown_sec_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sec_up(e)),
-                                        lv.EVENT.CLICKED, None)
-            countdown_sec_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sec_down(e)),
-                                        lv.EVENT.CLICKED, None)
-            countdown_min_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.min_up(e)),
-                                        lv.EVENT.CLICKED, None)
-            countdown_min_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.min_down(e)),
-                                        lv.EVENT.CLICKED, None)
-            countdown_hour_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hour_up(e)),
-                                        lv.EVENT.CLICKED, None)
-            countdown_hour_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hour_down(e)),
-                                        lv.EVENT.CLICKED, None)
-            countdown_start_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
-                                        lv.EVENT.CLICKED, None)
-            countdown_reset_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reset(e)),
-                                        lv.EVENT.CLICKED, None)
-            # countdown_stop_imgbtn.add_event_cb(lambda e: self.stop(e),
-            #                              lv.EVENT.CLICKED, None)  
-        date_tmp = utime.localtime()
-        self.time_tmp = utime.mktime(date_tmp) 
-        if self.g_state == 0:
-            countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-            countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_hour_up.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_hour_down.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_min_up.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_min_down.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_sec_up.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_sec_down.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_sec.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_min.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_hour.clear_flag(lv.obj.FLAG.HIDDEN)
-            countdown_title.clear_flag(lv.obj.FLAG.HIDDEN)
-            self.g_end = 0
-            self.total = 0
-            self.hour = 0
-            self.min = 0
-            self.sec = 0
-            self.show_value()
-        if self.g_state == 1:
-            if self.timer_cb == 1:
-                EventMesh.publish("set_countdown_off_state", [0,self.g_state])
-                self.timer.start(1000,1,self.fun)
-
-    def sec_up(self,e):
-        EventMesh.publish("add_countdown_sec")
-        self.sec = EventMesh.publish("get_countdown_sec")
-        print("sec_up:",self.sec)
-        self.show_value()
-
-    def sec_down(self,e):
-        EventMesh.publish("reduce_countdown_sec")
-        self.sec = EventMesh.publish("get_countdown_sec")
-        print("sec_down:",self.sec)
-        self.show_value()
-
-    def min_up(self,e):
-        EventMesh.publish("add_countdown_min")
-        self.min = EventMesh.publish("get_countdown_min")
-        print("min_up:",self.min)
-        self.show_value()
-
-    def min_down(self,e):
-        EventMesh.publish("reduce_countdown_min")
-        self.min = EventMesh.publish("get_countdown_min")
-        print("min_down:",self.min)
-        self.show_value()
-
-    def hour_up(self,e):
-        EventMesh.publish("add_countdown_hour")
-        self.hour = EventMesh.publish("get_countdown_hour")
-         
-        print("hour_up:",self.hour)
-        self.show_value()
-
-    def hour_down(self,e):
-        EventMesh.publish("reduce_countdown_hour")
-        self.hour = EventMesh.publish("get_countdown_hour")
-        print("hour_down:",self.hour)
-        self.show_value()
-    
-    def start(self,e):
-        global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
-            countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
-            countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
-            countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
-            countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min 
-        self.total = self.hour*60*60 + self.min*60 + self.sec
-        print("--00:",self.total,self.hour,self.min,self.sec,self.g_state)
-        if self.g_state == 1:
-            self.g_state = 2
-            self.stop()
-        elif self.g_state == 2:
-            self.g_state = 1
-        if self.total > 0:
-            date_tmp = utime.localtime()
-            timeSecond = utime.mktime(date_tmp) 
-            print("start self.timeSecond:{}".format(timeSecond))
-            EventMesh.publish("set_countdown_all_time", [self.total,timeSecond])
-            if self.g_state != 2:
-                self.g_state = 1
-                self.g_end = 0
-                date_tmp = utime.localtime()
-                self.timeSecond = utime.mktime(date_tmp) 
-                self.show_value()
-                self.timer.start(1000,1,self.fun)
-                countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_min_up.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_min_down.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_sec_up.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_sec_down.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_start_img.add_flag(lv.obj.FLAG.HIDDEN)
-                countdown_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
-                countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
-        EventMesh.publish("set_countdown_off_state", [0,self.g_state])
-
-    def stop(self):
-        global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
-            countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
-            countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
-            countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
-            countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min 
-        print("in stop")
-        countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_min_up.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_min_down.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_sec_up.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_sec_down.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-        countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
-        
-        self.g_end = 0
-        self.timer.stop()
-        # self.show_value()
-        # EventMesh.publish("load_screen", {"screen": "countdown"})
-    
-    def fun(self,e):
-        date_tmp = utime.localtime()
-        self.time_tmp = utime.mktime(date_tmp) 
-        total_sec = self.time_tmp - self.timeSecond
-        # print("total_sec:{} self.time_tmp:{} self.timeSecond:{} self.total:{}".format(total_sec,self.time_tmp,self.timeSecond,self.total))
-        if self.total > 0:
-            self.total = self.total - total_sec
-        self.timeSecond = self.time_tmp
-        
-        
-        self.hour = self.total//3600
-        self.min = self.total%3600//60
-        self.sec =  self.total%60
-        
-
-        # print("self.total:{} self.time_tmp:{} self.timeSecond:{} test_hour:{} test_min:{} test_sec:{}".format(self.total,self.time_tmp,self.timeSecond,test_hour,test_min,test_sec))
-        self.show_value()  
-        # print("Close self.timeSecond:22")
-        EventMesh.publish("set_countdown_all_time", [self.total,self.timeSecond])
-        if self.total <= 0:
-            self.g_state = 0
-            self.g_end = 1
-            self.hour = 0
-            self.min = 0
-            self.sec = 0
-            EventMesh.publish("set_countdown_off_state", [0,self.g_state])
-            self.timer.stop()
-            self.show_value()
-            EventMesh.publish("load_screen", {"screen": "countdown_end"})
-        
-        # self.total = self.total - 1
-        
-        # self.sec = self.sec - 1 
-        # if self.sec < 0:
-        #     self.sec = 59
-        
-    def Close(self):
-        time = EventMesh.publish("get_countdown_all_time")
-        if time > 0 and self.g_state == 1:
-            self.timer_cb = 1
-            date_tmp = utime.localtime()
-            self.timeSecond = utime.mktime(date_tmp)
-            EventMesh.publish("set_countdown_off_state", [1,self.g_state])
-            # print("Close self.timeSecond:{}".format(self.timeSecond))
-            EventMesh.publish("set_countdown_all_time", [self.total,self.timeSecond]) 
-            self.timer.stop()
-        else:
-            msg_tmp = EventMesh.publish("get_countdown_off_state")
-            self.g_state = msg_tmp[1]
-            EventMesh.publish("set_countdown_off_state", [0,self.g_state]) 
-
-    def reset(self,e):
-        global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
-            countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
-            countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
-            countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
-            countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min 
-        # print("in reset")
-        self.timer.stop()
-        self.hour = 0
-        self.min = 0
-        self.sec = 0
-        self.g_state = 0
-        self.g_end = 0
-        self.total = 0
-        EventMesh.publish("set_countdown_off_state", [0,self.g_state])
-        EventMesh.publish("reset_time_countdown")
-        countdown_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-        countdown_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-        countdown_reset_img.clear_flag(lv.obj.FLAG.HIDDEN)
-
-        countdown_hour_up.clear_flag(lv.obj.FLAG.HIDDEN)
-        countdown_hour_down.clear_flag(lv.obj.FLAG.HIDDEN)
-        countdown_min_up.clear_flag(lv.obj.FLAG.HIDDEN)
-        countdown_min_down.clear_flag(lv.obj.FLAG.HIDDEN)
-        countdown_sec_up.clear_flag(lv.obj.FLAG.HIDDEN)
-        countdown_sec_down.clear_flag(lv.obj.FLAG.HIDDEN)
-        self.show_value()
-        
-
-    def show_value(self):
-        global countdown_screen ,countdown_title,countdown_hour ,countdown_mao ,countdown_mao ,countdown_mao1 ,\
-            countdown_sec ,countdown_hour_up ,countdown_hour_up_btn ,countdown_hour_down ,countdown_hour_down_btn ,\
-            countdown_min_up,countdown_min_up_btn ,countdown_min_down,countdown_min_down_btn,countdown_sec_up ,\
-            countdown_sec_up_btn,countdown_sec_down ,countdown_sec_down_btn ,countdown_reset_img ,countdown_reset_imgbtn ,\
-            countdown_start_img,countdown_start_imgbtn,countdown_stop_img ,countdown_min 
-
-        countdown_sec.set_text(str("%02d"%(self.sec)))
-        countdown_min.set_text(str("%02d"%(self.min)))
-        countdown_hour.set_text(str("%02d"%(self.hour)))
-    
-    def lcd_on(self):
-        print("lcd_on self.timer_cb:{}".format(self.timer_cb))
-        time = EventMesh.publish("get_countdown_all_time")
-
-        if time > 0 and self.g_state != 0:
-            if self.g_state == 1:
-                if self.timer_cb != 0:
-                    self.timer_cb = 0
-                    EventMesh.publish("set_countdown_off_state", [0,self.g_state])
-                    date_tmp = utime.localtime()
-                    time_tmp = utime.mktime(date_tmp) 
-                    total_sec = time_tmp - self.timeSecond
-                    # print("total_sec:{} self.time_tmp:{} self.timeSecond:{} self.total:{}".format(total_sec,self.time_tmp,self.timeSecond,self.total))
-                    if self.total > 0:
-                        self.total = self.total - total_sec
-                    self.timeSecond = self.time_tmp
-                    self.hour = self.total//3600
-                    self.min = self.total%3600//60
-                    self.sec =  self.total%60
-                    self.show_value()
-                    self.timer.start(1000,1,self.fun)
-            else:
-                msg_tmp = EventMesh.publish("get_countdown_off_state")
-                self.g_state = msg_tmp[1]
-                EventMesh.publish("set_countdown_off_state", [0,self.g_state]) 
-
-        else:
-            self.reset(0)
-            msg_tmp = EventMesh.publish("get_countdown_off_state")
-            self.g_state = msg_tmp[1]
-            EventMesh.publish("set_countdown_off_state", [0,self.g_state])
-
-    def lcd_off(self):
-        time = EventMesh.publish("get_countdown_all_time")
-        if time > 0 and self.g_state == 1:
-            self.timer_cb = 1
-            date_tmp = utime.localtime()
-            self.timeSecond = utime.mktime(date_tmp) 
-            EventMesh.publish("set_countdown_off_state", [1,self.g_state])
-            EventMesh.publish("set_countdown_all_time", [self.total,self.timeSecond]) 
-            self.timer.stop() 
-        else:
-            EventMesh.publish("set_countdown_off_state", [0,self.g_state])
-
-    def done_return(self):
-        if self.g_state == 0:
-            self.timer.stop()
-        if self.g_end == 1:
-            EventMesh.publish("load_screen", {"screen": "countdown"})
-        else:
-            EventMesh.publish("load_screen", {"screen": "toolbox"})
-
-    def btn1_release(self):
-        if self.g_state == 0:
-            self.timer.stop()
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-        
-    def btn8_press(self):
-        if self.g_state == 0:
-            self.timer.stop()
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-#结束倒计时显示图标
-countdown_end_screen = None
-countdown_end_img = None
-countdown_end_label = None
-class CountdownEndScreen(Screen):
-    NAME = "countdown_end"
-    
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.FIND_timer=osTimer()
-        self.aud = audio.Audio(0)
-        self.FIND_timer_count = 0
-
-    def initialization(self):
-        global countdown_end_screen ,countdown_end_img ,countdown_end_label 
-        if countdown_end_screen == None:
-            countdown_end_screen = lv.obj()
-            print("countdown_end_screen")
-            countdown_end_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_end_img = lv.img(countdown_end_screen)
-            countdown_end_img.set_size(140, 140)
-            countdown_end_img.set_pos(50, 60)
-            countdown_end_img.set_src("U:/static/time_finish.png")
-            countdown_end_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            countdown_end_label = lv.label(countdown_end_screen)
-            countdown_end_label.set_pos(0, 240)
-            countdown_end_label.set_size(240, 40)
-            countdown_end_label.set_text("时间到")
-            countdown_end_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            countdown_end_label.set_long_mode(lv.label.LONG.WRAP)
-            countdown_end_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            self.meta = countdown_end_screen
-        self.FIND_timer_count = 0
-        self.FIND_timer.start(3000, 1, self.FIND_timer_cb)
-        self.aud.play(1, 1, 'U:/static/audio_audio_haixiu.mp3')  #播放声音
-
-    def FIND_timer_cb(self, *args):
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.FIND_timer_count += 1
-        if self.FIND_timer_count >= 4: #120秒
-            self.stop_FIND()
-            EventMesh.publish("load_screen", {"screen": "countdown"})
-            return
-        self.aud.play(1, 1, 'U:/static/audio_audio_haixiu.mp3') 
-    
-    def stop_FIND(self) :
-        self.FIND_timer.stop()
-        self.aud.stopAll()
-
-    def Close(self):
-       self.stop_FIND()
-
-    def done_left_to_right(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
-
-    def done_right_to_left(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
-
-    def done_bottom_to_top(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
-
-    def done_top_to_bottom(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
-
-    def done_return(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
-
-    def done_click(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
-
-    def btn1_release(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
-
-    def btn8_press(self):
-        self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-# -------------------------------------------stopwatch screen----------------------------------------------------------
-
-
-stopwatch_screen = None
-stopwatch_title = None
-stopwatch_label_min = None
-stopwatch_mao = None
-stopwatch_label_sec = None
-stopwatch_mao1 = None
-stopwatch_label_ms = None
-stopwatch_reset_img = None
-stopwatch_reset_imgbtn = None
-stopwatch_start_img = None
-stopwatch_start_imgbtn = None
-stopwatch_stop_img = None
-class StopwatchScreen(Screen):
-    NAME = "stopwatch"
-
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.ms_value = 0
-        self.sec_value = 0
-        self.min_value = 0
-        self.s_state = 0
-        self.total_time = 0
-        self.TimeSecond = 0
-        self.timer = osTimer()
-        
-    def initialization(self): 
-        global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
-            stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
-            stopwatch_start_imgbtn, stopwatch_stop_img  
-        if  stopwatch_screen == None :
-            stopwatch_screen = lv.obj()
-            print("stopwatch_screen")
-            stopwatch_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            stopwatch_title = lv.label(stopwatch_screen)
-            stopwatch_title.set_pos(0, 20)
-            stopwatch_title.set_size(240, 20)
-            stopwatch_title.set_text("秒表")
-            stopwatch_title.set_long_mode(lv.label.LONG.WRAP)
-            stopwatch_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            stopwatch_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            stopwatch_label_min = lv.label(stopwatch_screen)
-            stopwatch_label_min.set_pos(30, 140)
-            stopwatch_label_min.set_size(60, 30)
-            stopwatch_label_min.set_text("00")
-            stopwatch_label_min.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_label_min.set_long_mode(lv.label.LONG.WRAP)
-            stopwatch_label_min.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-            stopwatch_mao = lv.label(stopwatch_screen)
-            stopwatch_mao.set_pos(82, 138)
-            stopwatch_mao.set_size(30, 30)
-            stopwatch_mao.set_text(":")
-            stopwatch_mao.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_mao.set_long_mode(lv.label.LONG.WRAP)
-            stopwatch_mao.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-
-            stopwatch_label_sec = lv.label(stopwatch_screen)
-            stopwatch_label_sec.set_pos(95, 140)
-            stopwatch_label_sec.set_size(60, 30)
-            stopwatch_label_sec.set_text("00")
-            stopwatch_label_sec.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_label_sec.set_long_mode(lv.label.LONG.WRAP)
-            stopwatch_label_sec.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-            stopwatch_mao1 = lv.label(stopwatch_screen)
-            stopwatch_mao1.set_pos(146, 138)
-            stopwatch_mao1.set_size(30, 30)
-            stopwatch_mao1.set_text(".")
-            stopwatch_mao1.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_mao1.set_long_mode(lv.label.LONG.WRAP)
-            stopwatch_mao1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-
-            stopwatch_label_ms = lv.label(stopwatch_screen)
-            stopwatch_label_ms.set_pos(160, 140)
-            stopwatch_label_ms.set_size(60, 30)
-            stopwatch_label_ms.set_text("0")
-            stopwatch_label_ms.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_label_ms.set_long_mode(lv.label.LONG.WRAP)
-            stopwatch_label_ms.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-
-
-
-
-            stopwatch_reset_img = lv.img(stopwatch_screen)
-            stopwatch_reset_img.set_size(99, 36)
-            stopwatch_reset_img.set_src("U:/static/stopwatch_reset.png")
-            stopwatch_reset_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_reset_img.set_pos(10, 210)
-
-            stopwatch_reset_imgbtn = lv.img(stopwatch_screen)
-            stopwatch_reset_imgbtn.set_size(99, 76)
-            stopwatch_reset_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-            stopwatch_reset_imgbtn.set_pos(10, 190)
-
-
-            stopwatch_start_img = lv.img(stopwatch_screen)
-            stopwatch_start_img.set_size(99, 36)
-            stopwatch_start_img.set_src("U:/static/stopwatch_play.png")
-            stopwatch_start_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_start_img.set_pos(115, 210)
-
-
-            stopwatch_start_imgbtn = lv.img(stopwatch_screen)
-            stopwatch_start_imgbtn.set_size(99, 76)
-            stopwatch_start_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-            stopwatch_start_imgbtn.set_pos(115, 190)
-
-
-            stopwatch_stop_img = lv.img(stopwatch_screen)
-            stopwatch_stop_img.set_size(99, 36)
-            stopwatch_stop_img.set_src("U:/static/stopwatch_stop.png")
-            stopwatch_stop_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            stopwatch_stop_img.set_pos(115, 210)
-            stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-            stopwatch_start_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
-                                     lv.EVENT.CLICKED, None)
-        
-            stopwatch_reset_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reset(e)),
-                                     lv.EVENT.CLICKED, None)
-            self.meta = stopwatch_screen
-
-        if self.s_state == 0:
-            self.reset(0)
-        if self.s_state == 1:
-            date_tmp = utime.localtime()
-            timeSecond = utime.mktime(date_tmp)
-            reduce = timeSecond - self.TimeSecond
-            self.total_time = self.total_time+reduce
-            if self.total_time >= 99*60:
-                self.total_time = 99*60
-                self.ms_value = 0
-                stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-                stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-                self.show_value()
-            else:
-                self.timer.start(100,1,self._fun)
-            
-
-    def start(self, e):      
-        global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
-            stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
-            stopwatch_start_imgbtn, stopwatch_stop_img 
-        print("stopwatch start:{}".format(self.s_state))
-        #self.timer.start(100, 1, self._fun)  
-        
-        if self.s_state == 1:
-            self.s_state = 2
-            self.paused()
-        elif self.s_state == 2:
-            self.s_state = 1
-        if self.s_state != 2:
-            self.s_state = 1
-            if self.total_time >= 99*60:
-                self.ms_value = 0   
-                self.sec_value = 0
-                self.min_value = 0
-                self.total_time = 0
-            self.show_value()
-            self.timer.start(100,1,self._fun)
-            stopwatch_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
-            stopwatch_start_img.add_flag(lv.obj.FLAG.HIDDEN)
-            # print("ms_value start:{} {} {}".format(self.ms_value,self.sec_value,self.min_value))
-           
-        
-
-    def paused(self):        
-        global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
-            stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
-            stopwatch_start_imgbtn, stopwatch_stop_img 
-        print("stopwatch pause")
-        stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-        stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-        self.timer.stop()
-        self.show_value()
-
-    def reset(self,e):
-        global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
-            stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
-            stopwatch_start_imgbtn, stopwatch_stop_img 
-        print("stopwatch reset")        
-
-        self.sec_value = 0
-        self.min_value = 0
-        self.ms_value = 0
-        self.s_state = 0
-        self.total_time = 0
-        stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-        stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-        self.timer.stop()
-        self.show_value()
-
-    def _fun(self,e):
-        self.ms_value += 1
-        if self.ms_value > 9:
-            self.ms_value = 0   
-            self.sec_value += 1
-            self.total_time+=1
-        if self.sec_value > 59:
-            self.sec_value = 0
-        if self.total_time > 99*60:
-            self.total_time = 99*60
-            self.timer.stop()
-            stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-            stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-        
-        self.show_value()
-
-    def show_value(self):
-        global stopwatch_screen,stopwatch_title,stopwatch_label_min,stopwatch_mao,stopwatch_label_sec ,\
-            stopwatch_mao1 ,stopwatch_label_ms,stopwatch_reset_img ,topwatch_reset_imgbtn ,stopwatch_start_img ,\
-            stopwatch_start_imgbtn, stopwatch_stop_img 
-        if self.total_time >= 99*60:
-            self.total_time = 99*60
-        test_s = self.total_time % 60
-        test_m = self.total_time//60
-        # print("test_s:{} test_m:{} self.total_time:{}".format(test_s,test_m,self.total_time))
-
-        stopwatch_label_ms.set_text(str("%d"%(self.ms_value)))
-        stopwatch_label_sec.set_text(str("%02d"%(test_s)))
-        stopwatch_label_min.set_text(str("%02d"%(test_m)))
-
-    def Close(self):
-        if self.s_state == 1:
-            self.timer.stop()
-            date_tmp = utime.localtime()
-            self.TimeSecond = utime.mktime(date_tmp)
-
-    def lcd_on(self):
-        if self.s_state == 1:
-            date_tmp = utime.localtime()
-            timeSecond = utime.mktime(date_tmp)
-            reduce = timeSecond - self.TimeSecond
-            self.total_time = self.total_time+reduce
-            total = self.total_time // 60 
-            if total >= 99:
-                self.total_time = 99*60
-                self.timer.stop()
-                self.s_state = 0
-                self.ms_value = 0
-                stopwatch_start_img.clear_flag(lv.obj.FLAG.HIDDEN)
-                stopwatch_stop_img.add_flag(lv.obj.FLAG.HIDDEN)
-                self.show_value()
-            else:    
-                
-                print("stopwatch reset start:{}".format(self.s_state))
-                #self.timer.start(100, 1, self._fun)  
-                self.show_value()
-                self.timer.start(100,1,self._fun)
-                stopwatch_stop_img.clear_flag(lv.obj.FLAG.HIDDEN)
-                stopwatch_start_img.add_flag(lv.obj.FLAG.HIDDEN)
-                # print("ms_value start:{} {} {}".format(self.ms_value,self.sec_value,self.min_value))
-           
-        pass
-
-    def lcd_off(self):
-        if self.s_state == 1:
-            date_tmp = utime.localtime()
-            timeSecond = utime.mktime(date_tmp) 
-            self.TimeSecond = timeSecond
-            self.timer.stop()
-        pass
-
-    def done_return(self):
-        if self.s_state == 0:
-            self.timer.stop()
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-
-    def btn1_release(self):
-        if self.s_state == 0:
-            self.timer.stop()
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-        
-    def btn8_press(self):
-        if self.s_state == 0:
-            self.timer.stop()
-        EventMesh.publish("watch_top_show")
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-       
-FIND_screen = None
-watchface_mpsignal_img = None
-class UIFINDScreen(Screen):
-    NAME = "FIND"
-    def __init__(self):
-        super().__init__()
-        self.read_data = {}
-        self.volum_size = 8
-        check_volum = ql_fs.path_exists("/usr/static/storage_file/config.json")
-        if check_volum == True :
-            with open("/usr/static/storage_file/config.json","r") as fd:#音频文件编号
-                self.read_data = ujson.load(fd)
-                if self.read_data != {}:
-                    b = str("volum") in self.read_data.keys()
-                    if b == True:
-                        self.volum_size = self.read_data["volum"]  
-                    else:
-                        self.volum_size = 8
-                else:
-                    self.volum_size = 8
-        else:
-            self.volum_size = 8
-        self.aud = audio.Audio(0)
-        self.aud.set_pa(Pin.GPIO29)
-        self.aud.setVolume(self.volum_size)
-        self.FIND_timer = osTimer()
-        self.FIND_timer_count = 0
-
-        self.meta = None
-    
-    def initialization(self):
-        self.meta = FIND_screen
-
-    def post_processor_after_initialization(self):
-        self.FIND_timer_count = 0
-        print("self.FIND_timer_count:{}".format(self.FIND_timer_count))
-        self.FIND_timer.start(3000, 1, self.FIND_timer_cb)
-        self.aud.play(1, 1, 'U:/static/audio_audio_haixiu.mp3')  #播放声音
-
-    def FIND_timer_cb(self, *args):
-        self.aud.play(1, 1, 'U:/static/audio_audio_haixiu.mp3') 
-        self.FIND_timer_count += 1
-        if self.FIND_timer_count > 20: #120秒
-            self.stop_FIND()
-    
-    def stop_FIND(self) :
-        self.FIND_timer.stop()
-        self.aud.stop()  #播放声音
-        
-
-    def Close(self):
-        print("self.FIND_timer_Close")
-        self.FIND_timer.stop()
-        self.aud.stop() #播放声音
-
-    def done_left_to_right(self):
-        self.stop_FIND()
-
-    def done_right_to_left(self):
-        self.stop_FIND()
-    def done_bottom_to_top(self):
-        self.stop_FIND()
-
-    def done_top_to_bottom(self):
-        self.stop_FIND()
-
-    def done_return(self):
-        self.stop_FIND()
-
-    def done_click(self):
-       self.stop_FIND()
-
-
-    def btn1_release(self):
-        self.stop_FIND()
-
-
-    def btn8_press(self):
-        self.stop_FIND()
- 
-Lowpower_screen = None
-Lowpower_screen_img = None
-class LowPowerScreen(Screen):
-    NAME = "LOW_POWER"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-
-    def initialization(self):
-        global Lowpower_screen ,Lowpower_screen_img  
-        if Lowpower_screen == None :
-            Lowpower_screen = lv.obj()
-            print("Lowpower_screen")
-            Lowpower_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            # add style for watchface
-            Lowpower_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
-            #进入图片
-            Lowpower_screen_img = lv.img(Lowpower_screen)
-            Lowpower_screen_img.set_pos(int(40),int(45))
-            Lowpower_screen_img.set_size(160,230)
-            Lowpower_screen_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            Lowpower_screen_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            Lowpower_screen_img.set_src("U:/static/low_power.png")
-            Lowpower_screen_img.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
-            self.meta = Lowpower_screen
-
-    def done_left_to_right(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def done_right_to_left(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def done_bottom_to_top(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def done_top_to_bottom(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-    def done_click(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-sos_screen = None
-sos_screen_label = None
-sos_screen_label_p = None
-
-#sos求组提示界面
-class sosScreen(Screen):
-    NAME = "SOS_POPUP"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.timer = osTimer()
-        self.meta_type = "popup"
-        self.count = 0
-
-    def initialization(self):
-        global sos_screen ,sos_screen_label  
-        if sos_screen == None :
-            sos_screen = lv.obj()
-            print("SOS_POPUP")
-            sos_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            # add style for watchface
-            sos_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
-            #进入图片
-
-            sos_screen_label = lv.label(sos_screen)
-            sos_screen_label.set_pos(0, 20)
-            sos_screen_label.set_size(240, 30)
-            sos_screen_label.set_text("SOS")
-            sos_screen_label.add_style(style_font_youyuan_20_red, lv.PART.MAIN | lv.STATE.DEFAULT)
-            sos_screen_label.set_long_mode(lv.label.LONG.WRAP)
-            sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-
-
-            sos_screen_label = lv.label(sos_screen)
-            sos_screen_label.set_text("是否拨打紧急\n求助电话?")
-            sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            sos_screen_label.set_size(240, 50)
-            sos_screen_label.set_pos(0,65)
-            sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            sos_screen_label = lv.label(sos_screen)
-            sos_screen_label.set_text("无操作10s后\n自动拨打")
-            sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            sos_screen_label.set_size(240, 50)
-            sos_screen_label.set_pos(0,140)
-            sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-            sos_screen_confirm_img = lv.img(sos_screen)
-            sos_screen_confirm_img.set_size(176, 46)
-            sos_screen_confirm_img.set_pos(32, 210)
-            sos_screen_confirm_img.set_src("U:/static/off_icon.png")
-            sos_screen_confirm_img.add_flag(lv.obj.FLAG.CLICKABLE)
-            sos_screen_confirm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            sos_screen_confirm_label = lv.label(sos_screen_confirm_img)
-            sos_screen_confirm_label.set_text("确定")
-            sos_screen_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
-            sos_screen_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-            sos_screen_return = lv.img(sos_screen)
-            sos_screen_return.set_size(176, 46)
-            sos_screen_return.set_pos(32, 270)
-            sos_screen_return.set_src("U:/static/cancel_icon.png")
-            sos_screen_return.add_flag(lv.obj.FLAG.CLICKABLE)
-            sos_screen_return.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-            sos_screen_return_label = lv.label(sos_screen_return)
-            sos_screen_return_label.set_text("取消")
-            sos_screen_return_label.align(lv.ALIGN.CENTER, 0, 5)
-            sos_screen_return_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            sos_screen_return_label.set_ext_click_area(20)
-
-            self.meta = sos_screen
-            sos_screen_confirm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
-                                     lv.EVENT.CLICKED, None)
-            
-            sos_screen_return.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_cancel_cb(e)),
-                                     lv.EVENT.CLICKED, None)
-
-    def timer_comfirm_cb(self,e):
-        EventMesh.publish("set_sos_flag", 1)
-    
-    def timer_cancel_cb(self,e):
-        EventMesh.publish("return_prev_screen")
-
-    def post_processor_before_initialization(self):
-        self.count = 0
-        self.timer.start(5000,1,self.timer_cb_onescond)
-    
-    def timer_cb_onescond(self,e):
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.count+=1
-        if self.count >= 2:
-            self.count = 0
-            EventMesh.publish("set_sos_flag", 1)
-
-    def Close(self):
-        self.timer.stop()
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_click(self):
-        #EventMesh.publish("return_prev_screen")
-        pass
-
-    def btn8_press(self):
-        
-        pass
-    def btn1_press(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def btn1_release(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-
-
-no_sos_screen = None
-no_sos_screen_label = None
-
-#没有设置紧急联系人的号码
-class noSosDataScreen(Screen):
-    NAME = "NO_SOS_POPUP"
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.meta_type = "popup"
-        self.count = 0
-        self.timer = osTimer()
-
-    def initialization(self):
-        global no_sos_screen ,no_sos_screen_label  
-        if no_sos_screen == None :
-            no_sos_screen = lv.obj()
-            print("NO_SOS_POPUP")
-            no_sos_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-            # add style for watchface
-            no_sos_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
-            #进入图片
-
-            no_sos_screen_label = lv.label(no_sos_screen)
-            no_sos_screen_label.set_pos(0, 110)
-            no_sos_screen_label.set_size(240, 80)
-            no_sos_screen_label.set_text("请在手机app上设置\n紧急联系人号码")
-            no_sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            no_sos_screen_label.set_long_mode(lv.label.LONG.WRAP)
-            no_sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-
-
-            self.meta = no_sos_screen
-    def post_processor_before_initialization(self):
-        self.count = 0
-        self.timer.start(1000,1,self.timer_cb_onescond)
-    
-    def Close(self):
-        self.timer.stop()
-
-    def timer_cb_onescond(self,e):
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.count+=1
-        if self.count >= 10:
-            self.count = 0
-            EventMesh.publish("return_prev_screen")
-
-
-    def done_left_to_right(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_right_to_left(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_bottom_to_top(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_top_to_bottom(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_return(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def done_click(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-
-    def btn8_press(self):
+def msg_cb(args):
+    index = args[1]
+    storage = args[2]
+    print("index:{}".format(index))
+    sms_data = sms.getSaveLoc()
+    sms_max = sms_data[0][2]
+    if index != -1:
+        tmp = sms.searchTextMsg(index)
+        detail = tmp[1]#内容
+        print("msg_cb:detail {}".format,detail)
+        if  detail.find("SETIP:") != -1:#寻找是否有这个字符串
+            tmp_test = detail.split("SETIP:")[1]
+            if  tmp_test.find(":") != -1:
+                new_ip = tmp_test.split(':')[0]
+                # print("tmp_test:{} new_ip:{}".format(tmp_test,new_ip))
+                new_com = tmp_test.split(':')[1]
+                # new_md5 = detail.split(':')[3]
+                if len(new_ip) > 0 and len(new_com) > 0:
+                    EventMesh.publish("set_new_ip", [new_ip,new_com,tmp[0]])#设置关机时间
+                    # EventMesh.publish("set_new_ip", [new_ip,new_com,new_md5])#设置关机时间
         
-        pass
-    def btn1_press(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-    def btn1_release(self):
-        EventMesh.publish("return_prev_screen")
-        pass
-
-
-
-
-system_init_screen = None
-system_init_label = None
-class SystemInitScreen(Screen):
-    #系统初始化中...
-    NAME = "system_init"
-    
-    def __init__(self):
-        super().__init__()
-        self.meta = None
-        self.system_init_timer=osTimer()
-        self.system_init_timer_count = 0
-
-    def initialization(self):
-        global system_init_screen ,system_init_label  
-        if system_init_screen == None:
-            system_init_screen = lv.obj()
-            print("Lowpower_screen")
-            system_init_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-       
-            system_init_label = lv.label(system_init_screen)
-            system_init_label.set_pos(0, 150)
-            system_init_label.set_size(240, 40)
-            system_init_label.set_text("系统初始化中")
-            system_init_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-            system_init_label.set_long_mode(lv.label.LONG.WRAP)
-            system_init_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-            self.meta = system_init_screen
-        self.system_init_timer_count = 0
-        self.system_init_timer.start(1000, 1, self.system_init_timer_cb)
-
-    def system_init_timer_cb(self, *args):
-        EventMesh.publish("system_sleep_rest")#防止黑屏
-        self.system_init_timer_count += 1
-        if self.system_init_timer_count > 4:
-            self.system_init_timer_count = 1
-        if system_init_screen != None:
+    if index >= sms_max-1:#删除短信
+        EventMesh.publish("delete_sms_event")#删除短信
+sms.setCallback(msg_cb)
 
-            system_init_label_str = "系统初始化中"
-            if self.system_init_timer_count == 1:
-                system_init_label.set_text("系统初始化中.")
-            elif self.system_init_timer_count == 2:
-                system_init_label.set_text("系统初始化中..")
-            elif self.system_init_timer_count == 3:
-                system_init_label.set_text("系统初始化中...")
-            else:
-                system_init_label.set_text("系统初始化中....")
+import audio
+from machine import Pin
 
-    def Close(self):
-       self.system_init_timer.stop()
 
-    
 
 #from usr.ui_WatchFaceScreen import WatchFaceScreen
 class UI(object):
@@ -5943,7 +74,7 @@ class UI(object):
         self.screen_old = None
         self.screen_prev = None
         self.screen_list = []
-        self.lv = lv
+        #self.lv = lv
         self.system_sleep_timer = osTimer()
         self.system_sleep_timer_count = 0
         self.sleep_flag = 1
@@ -5983,27 +114,27 @@ class UI(object):
         self.sleep_lock = 0
 
     def post_processor_after_instantiation(self):
-        EventMesh.subscribe("load_screen", self.load_screen_cb)
+        # EventMesh.subscribe("load_screen", self.load_screen_cb)
 
-        EventMesh.subscribe("btn1_press", self.btn_press)
-        EventMesh.subscribe("btn8_press", self.btn_press)
-        EventMesh.subscribe("btn8_long_press", self.btn_press)
+        # EventMesh.subscribe("btn1_press", self.btn_press)
+        # EventMesh.subscribe("btn8_press", self.btn_press)
+        # EventMesh.subscribe("btn8_long_press", self.btn_press)
 
-        EventMesh.subscribe("btn1_release", self.btn_release)
-        EventMesh.subscribe("btn8_release", self.btn_release)
+        # EventMesh.subscribe("btn1_release", self.btn_release)
+        # EventMesh.subscribe("btn8_release", self.btn_release)
 
-        EventMesh.subscribe("done_left_to_right", self.ui_press)
-        EventMesh.subscribe("done_right_to_left", self.ui_press)
-        EventMesh.subscribe("done_bottom_to_top", self.ui_press)
-        EventMesh.subscribe("done_top_to_bottom", self.ui_press)
-        EventMesh.subscribe("done_return", self.ui_press)
-        EventMesh.subscribe("done_click", self.ui_press)
-        EventMesh.subscribe("done_error", self.ui_press)
-        EventMesh.subscribe("done_press", self.ui_press)
-        EventMesh.subscribe("call_in", self.publish_call_in)
+        # EventMesh.subscribe("done_left_to_right", self.ui_press)
+        # EventMesh.subscribe("done_right_to_left", self.ui_press)
+        # EventMesh.subscribe("done_bottom_to_top", self.ui_press)
+        # EventMesh.subscribe("done_top_to_bottom", self.ui_press)
+        # EventMesh.subscribe("done_return", self.ui_press)
+        # EventMesh.subscribe("done_click", self.ui_press)
+        # EventMesh.subscribe("done_error", self.ui_press)
+        # EventMesh.subscribe("done_press", self.ui_press)
+        # EventMesh.subscribe("call_in", self.publish_call_in)
 
-        EventMesh.subscribe("get_lcd_state", self.get_lcd_state)
-        EventMesh.subscribe("set_lcd_state", self.set_lcd_state)
+        # EventMesh.subscribe("get_lcd_state", self.get_lcd_state)
+        # EventMesh.subscribe("set_lcd_state", self.set_lcd_state)
         
         #EventMesh.subscribe("call_in", self.publish_call_in)
         #EventMesh.subscribe("set_bg_img", self.set_bg_img)
@@ -6011,14 +142,14 @@ class UI(object):
         EventMesh.subscribe(constants.EVENT.SYSTEM_SLEEP, self.system_sleep)
         EventMesh.subscribe(constants.EVENT.SYSTEM_UP, self.system_up)
         EventMesh.subscribe("system_sleep_rest", self.system_sleep_rest)
-        EventMesh.subscribe("set_UI_high_priority", self.set_UI_high_priority)
-        EventMesh.subscribe("get_UI_high_priority", self.get_UI_high_priority)
+        # EventMesh.subscribe("set_UI_high_priority", self.set_UI_high_priority)
+        # EventMesh.subscribe("get_UI_high_priority", self.get_UI_high_priority)
 
-        EventMesh.subscribe("set_interrup_incall", self.set_interrup_incall)
-        EventMesh.subscribe("get_interrup_incall", self.get_interrup_incall)
-        EventMesh.subscribe("get_screen_NAME",self.get_screen_NAME)
+        # EventMesh.subscribe("set_interrup_incall", self.set_interrup_incall)
+        # EventMesh.subscribe("get_interrup_incall", self.get_interrup_incall)
+        # EventMesh.subscribe("get_screen_NAME",self.get_screen_NAME)
         EventMesh.subscribe("publish_message_event_ui",self.publish_message_event_ui)
-        EventMesh.subscribe("return_prev_screen",self.return_prev_screen)
+        # EventMesh.subscribe("return_prev_screen",self.return_prev_screen)
 
         self.system_sleep_timer.start(1000, 1, self.system_sleep_timer_cb)
 
@@ -6066,88 +197,7 @@ class UI(object):
         #print("system_sleep_rest!!!!!")
         self.system_sleep_timeout_rest()
 
-    def ui_press(self, event, key):
-        screen_NAME = EventMesh.publish("get_screen_NAME")
-        if screen_NAME == "system_init":
-            return
-        self.system_sleep_timeout_rest()
-        #print("ui press {}".format(event))
-        if event == "done_left_to_right":
-            self.screen.done_left_to_right()
-        if event == "done_right_to_left":
-            self.screen.done_right_to_left()
-        if event == "done_bottom_to_top":
-            self.screen.done_bottom_to_top()
-        if event == "done_top_to_bottom":
-            self.screen.done_top_to_bottom()
-        if event == "done_return":
-            self.screen.done_return()
-        if event == "done_click":
-            self.screen.done_click()
-        # if event == "done_press":
-        #     self.system_sleep_timeout_rest()
-    def btn_press(self, event, key):
-        screen_NAME = EventMesh.publish("get_screen_NAME")
-        if screen_NAME == "system_init":
-            return
-        print("btn_press: {}".format(event))
-        #主表盘按电源键,息屏
-        
-        #息屏状态按按钮都亮屏
-        
-        
-        if self.main_flag != 1 and self.sleep_flag == 0:
-            if event == "btn8_long_press":
-                if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
-                    sos_number = EventMesh.publish("get_dial_sos_number")
-                    if sos_number != None:
-                        if len(sos_number) != 0:
-                            screen_NAME = EventMesh.publish("get_screen_NAME")
-                            if screen_NAME != None:
-                                if screen_NAME != "SOS_POPUP":
-                                    EventMesh.publish("load_screen", {"screen": "SOS_POPUP"})
-                        else:
-                            EventMesh.publish("load_screen", {"screen": "NO_SOS_POPUP"})
-                else:
-                    EventMesh.publish("load_screen", {"screen": "no_sim_power_screen"})
-            else:
-                self.__lcd_on()
-            return
-        # if event == "btn1_press":
-        #     self.screen.btn1_press()
-        # self.__lcd_on()
-        if event == "btn8_press":
-            self.screen.btn8_press()
-        if event == "btn8_long_press":
-            if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
-                sos_number = EventMesh.publish("get_dial_sos_number")
-                if sos_number != None:
-                    if len(sos_number) != 0:
-                        screen_NAME = EventMesh.publish("get_screen_NAME")
-                        if screen_NAME != None:
-                            if screen_NAME != "SOS_POPUP":
-                                EventMesh.publish("load_screen", {"screen": "SOS_POPUP"})
-                    else:
-                        EventMesh.publish("load_screen", {"screen": "NO_SOS_POPUP"})
-            else:
-                EventMesh.publish("load_screen", {"screen": "no_sim_power_screen"})
-
-        if event == "btn1_press":        
-            pass   
-            
-        
-
-    def btn_release(self, event, msg):
-        screen_NAME = EventMesh.publish("get_screen_NAME")
-        if screen_NAME == "system_init":
-            return
-        print("btn_release: {}".format(event))
-        # if self.main_flag != 1 and self.sleep_flag == 0:
-        #     self.__lcd_on()
-        #     return 
-        # if event == "btn1_release":
-            
-        #     self.screen.btn1_release()
+    
 
     def __lcd_on(self):
         self.system_sleep_timeout_rest()
@@ -6167,7 +217,7 @@ class UI(object):
             EventMesh.publish("set_lcd_state",self.sleep_flag)
            
             utime.sleep_ms(2)
-            lv.autoSleep(0)
+            #lv.autoSleep(0)
             pm.autosleep(0)
             pm.sclkEx_set(0, 1, 5)
             utime.sleep_ms(60)
@@ -6176,9 +226,6 @@ class UI(object):
             self.sleep_lock = 0
             
 
-    def publish_call_in(self, event, msg):
-        EventMesh.publish("load_screen", {"screen": "dialing", "meta": msg})
-
     def __lcd_off(self):
         
         if self.sleep_flag == 1 :
@@ -6191,25 +238,23 @@ class UI(object):
            
             #lcd_ctrl.write(0)
             #
-            lv.autoSleep(1)
+            #lv.autoSleep(1)
             pm.autosleep(1)
             pm.sclkEx_set(1, 1, 5)
-            utime.sleep_ms(2)
+            #utime.sleep_ms(2)
            
             #utime.sleep_ms(80)
-            EventMesh.publish("set_lcd_state",self.sleep_flag)
+            #EventMesh.publish("set_lcd_state",self.sleep_flag)
             self.sleep_lock = 0
            
             self.system_sleep_timer.stop()
             EventMesh.publish("Hsensor_set_sleep") #让系统更快休眠
 
     def system_sleep(self, event, msg) :
-        pass
-        # self.__lcd_off()
+        self.__lcd_off()
 
     def system_up(self, event, msg):
-        pass
-        # self.__lcd_on()
+        self.__lcd_on()
 
     def system_sleep_timer_cb(self, *args):
         #print("system_sleep_timer_count:{}".format(self.system_sleep_timer_count))
@@ -6219,7 +264,7 @@ class UI(object):
         self.system_sleep_timer_count += 1
         if self.system_sleep_timer_count >= time :
             self.system_sleep_timer_count = 0
-            # self.__lcd_off()
+            self.__lcd_off()
 
     def system_sleep_timeout_rest(self) :
         #print("system_sleep_timeout_rest")
@@ -6262,8 +307,8 @@ class UI(object):
 
                 if self.screen_old != None :
                     self.screen_old.Close() #先关闭上一次界面
-                    self.lv.img.cache_invalidate_src(None) #清img cache
-                    self.lv.img.cache_set_size(16) #开img cache
+                    # self.lv.img.cache_invalidate_src(None) #清img cache
+                    # self.lv.img.cache_set_size(16) #开img cache
                     if self.screen_old.meta_type != "popup": #不是弹窗,保存上一个界面,用来返回
                         self.screen_prev = self.screen_old #
                 self.screen_old = self.screen
@@ -6275,8 +320,8 @@ class UI(object):
                 # self.screen.initialization()
                 
                 print("load_screen.load()")
-                self.screen.load()
-                self.lv.scr_load(self.screen.get_meta())
+                # self.screen.load()
+                # self.lv.scr_load(self.screen.get_meta())
                 
                 self.screen.post_processor_after_initialization()
                 # self.__lcd_on()
diff --git a/2.sdk/project/S6/usr/static/R_POWER_OFF_1.mp3 b/2.sdk/project/S6/usr/static/R_POWER_OFF_1.mp3
new file mode 100644 (file)
index 0000000..3ff519d
Binary files /dev/null and b/2.sdk/project/S6/usr/static/R_POWER_OFF_1.mp3 differ
index d18e50b..c4c3aaa 100644 (file)
Binary files a/2.sdk/project/S6/usr/static/audio.bin and b/2.sdk/project/S6/usr/static/audio.bin differ