1.优化天气协议和界面显示
authord15521469561 <d155214695615@qq.com>
Fri, 7 Apr 2023 10:20:03 +0000 (18:20 +0800)
committerd15521469561 <d155214695615@qq.com>
Fri, 7 Apr 2023 10:20:03 +0000 (18:20 +0800)
2.增加开机界面
3.心率血氧界面优化出值

3.code/1.watch/2.code/alarm.py
3.code/1.watch/2.code/lcd.py
3.code/1.watch/2.code/main_1.py
3.code/1.watch/2.code/mgr.py
3.code/1.watch/2.code/protocol.py
3.code/1.watch/2.code/test_sms.py
3.code/1.watch/2.code/ui.py
3.code/1.watch/2.code/ui_WatchFaceScreen.py

index ced93ed..045bbf6 100644 (file)
@@ -157,7 +157,7 @@ clk_repeat_btn.set_pos(9,40)
 clk_repeat_btn.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_repeat_label = lv.label(clk_repeat_btn)
-clk_repeat_label.set_pos(8, 0)
+clk_repeat_label.set_pos(8, 10)
 clk_repeat_label.set_size(103, 40)
 clk_repeat_label.set_text("星期一")
 clk_repeat_label.set_long_mode(lv.label.LONG.DOT)
@@ -180,7 +180,7 @@ clk_repeat_btn1.set_pos(9,90)
 clk_repeat_btn1.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_repeat_label1 = lv.label(clk_repeat_btn1)
-clk_repeat_label1.set_pos(8, 0)
+clk_repeat_label1.set_pos(8, 10)
 clk_repeat_label1.set_size(103, 40)
 clk_repeat_label1.set_text("星期二")
 clk_repeat_label1.set_long_mode(lv.label.LONG.DOT)
@@ -204,7 +204,7 @@ clk_repeat_btn2.set_pos(9,140)
 clk_repeat_btn2.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_repeat_label2 = lv.label(clk_repeat_btn2)
-clk_repeat_label2.set_pos(8, 0)
+clk_repeat_label2.set_pos(8, 10)
 clk_repeat_label2.set_size(103, 40)
 clk_repeat_label2.set_text("星期三")
 clk_repeat_label2.set_long_mode(lv.label.LONG.DOT)
@@ -228,7 +228,7 @@ clk_repeat_btn3.set_pos(9,190)
 clk_repeat_btn3.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_repeat_label3 = lv.label(clk_repeat_btn3)
-clk_repeat_label3.set_pos(8, 0)
+clk_repeat_label3.set_pos(8, 10)
 clk_repeat_label3.set_size(103, 40)
 clk_repeat_label3.set_text("星期四")
 clk_repeat_label3.set_long_mode(lv.label.LONG.DOT)
@@ -251,7 +251,7 @@ clk_repeat_btn4.set_pos(9,240)
 clk_repeat_btn4.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_repeat_label4 = lv.label(clk_repeat_btn4)
-clk_repeat_label4.set_pos(8, 0)
+clk_repeat_label4.set_pos(8, 10)
 clk_repeat_label4.set_size(103, 40)
 clk_repeat_label4.set_text("星期五")
 clk_repeat_label4.set_long_mode(lv.label.LONG.DOT)
@@ -274,7 +274,7 @@ clk_repeat_btn5.set_pos(9,290)
 clk_repeat_btn5.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_repeat_label5 = lv.label(clk_repeat_btn5)
-clk_repeat_label5.set_pos(8, 0)
+clk_repeat_label5.set_pos(8, 10)
 clk_repeat_label5.set_size(103, 40)
 clk_repeat_label5.set_text("星期六")
 clk_repeat_label5.set_long_mode(lv.label.LONG.DOT)
@@ -297,7 +297,7 @@ clk_repeat_btn6.set_pos(9,340)
 clk_repeat_btn6.add_style(style_cont_alarm, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 clk_repeat_label6 = lv.label(clk_repeat_btn6)
-clk_repeat_label6.set_pos(8, 0)
+clk_repeat_label6.set_pos(8, 10)
 clk_repeat_label6.set_size(103, 40)
 clk_repeat_label6.set_text("星期日")
 clk_repeat_label6.set_long_mode(lv.label.LONG.DOT)
@@ -398,18 +398,18 @@ class ClockManager(Abstract):
         alarm_list[idx]["days"] = msg["days"]
         alarm_list[idx]["enabled"] = msg["enabled"]
 
-        with open("/usr/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+        with open("/ext/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/alarm_msg.json") 
+        IFEXIST = ql_fs.path_exists("/ext/static/storage_file/alarm_msg.json") 
         global alarm_list      
         if IFEXIST == False:
-            with open("/usr/alarm_msg.json","w",encoding='utf-8') as fd:
+            with open("/ext/static/storage_file/alarm_msg.json","w",encoding='utf-8') as fd:
                 ujson.dump(alarm_list,fd)
                 print("闹钟信息加载完成")
         else:
-            with open("/usr/alarm_msg.json","r",encoding='utf-8') as fd:
+            with open("/ext/static/storage_file/alarm_msg.json","r",encoding='utf-8') as fd:
                 alarm_list = ujson.load(fd)
 
     def add_alarm(self, event, msg):
@@ -417,7 +417,7 @@ class ClockManager(Abstract):
         idx = len(alarm_list)
         print("add_here-----idx:",idx)
         alarm_list.append({"idx": idx, "hour": 0, "minute": 0, "days": [], "enabled": False})
-        with open("/usr/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+        with open("/ext/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
             ujson.dump(alarm_list,fd)
 
     def remove_alarm(self, event, msg):
@@ -439,7 +439,7 @@ class ClockManager(Abstract):
                         alarm_list[j]["idx"] -= 1
                         print("delete_here4-----",alarm_list)
 
-        with open("/usr/alarm_msg.json", 'w+',encoding='utf-8') as fd:
+        with open("/ext/static/storage_file/alarm_msg.json", 'w+',encoding='utf-8') as fd:
             ujson.dump(alarm_list,fd)
 
     def _rtc_callback(self,args):
index 69a9619..4acbcde 100644 (file)
@@ -140,7 +140,7 @@ displayon = bytearray(init_data4)
 
 lcd_ctrl = Pin(Pin.GPIO18, Pin.OUT, Pin.PULL_DISABLE, 1)
 lcd.lcd_init(init_buf, 240, 320, 52000, 1, 4, 0, invalid, displayon, displayoff, None,TESel = True,TEPin = 5)
-gpio_backlight = Pin(Pin.GPIO37, Pin.OUT, Pin.PULL_PU, 0)
+gpio_backlight = Pin(Pin.GPIO37, Pin.OUT, Pin.PULL_DISABLE, 0)
 gpio_backlight.write(1)
 
 LCD_SIZE_W = 240
index efab430..10a8b52 100644 (file)
@@ -47,11 +47,11 @@ if __name__ == '__main__':
     from ext.common import Abstract
     from ext.lcd import gpio_backlight,tp_cst816
     from ext.btn_device_ec800m import BtnDevice
-    from ext.protocol import LK_ProtoCol,PING_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver
+    from ext.protocol import LK_ProtoCol,PING_ProtoCol,WT_ProtoCol,UD_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol
     import ext.mgr as mgr
     import ext.ui as _ui
-    from ext.mgr import ConfigStoreManager, DeviceInfoManager, LocationManager, SockManager, \
-    NetManager, BatteryManager,AddrBookManager,MsgdetailManager,PhoneCallingManager,CallLogManager
+    from ext.mgr import ConfigStoreManager, LocationManager, SockManager, \
+    NetManager,AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldHrDataManager
     from ext.appAlipay import Alipay ,AlipayOpenScreen,Alipay_1_1,Alipay_invite,Alipay_inviting,\
     Alipay_success,Alipay_paycode,Alipay_pay_success,Alipay_collect,Alipay_parent
     from ext.ui_WatchFaceScreen import WatchFaceScreen
@@ -59,7 +59,7 @@ if __name__ == '__main__':
     from ext.ui_main_menu import MainMenuScreen
     from ext.appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol
     import ext.ui_setting as _ui_setting
-    from usr.test_sms import WT_ProtoCol,UD_ProtoCol,getWeatherDataManager,PHL_ProtoCol
+    # from usr.test_sms import WeatherScreen
 
    #from usr.ui_wechat import WechatScreen,TK_ProtoCol
     btn_device = BtnDevice(tp_cst816)
@@ -117,6 +117,7 @@ if __name__ == '__main__':
     ui.add_screen(_ui.MsgDetailScreen())
     ui.add_screen(_ui.IncomingCallScreen())
     ui.add_screen(_ui.OnCallScreen())
+    ui.add_screen(_ui.PowerOnScreen())
     # ui.add_screen(_ui.Setting2Screen())
     # ui.add_screen(_ui.Setting3Screen())  
 
@@ -141,9 +142,10 @@ if __name__ == '__main__':
     app.append_manager(mgr.MsgManager())
     app.append_manager(MsgdetailManager())
     app.append_manager(mgr.CallLogManager())
-    app.append_manager(getWeatherDataManager())
+    app.append_manager(mgr.getWeatherDataManager())
     app.append_manager(PhoneCallingManager())
     app.append_manager(ClockManager())
+    app.append_manager(getOldHrDataManager())
         
     pcr = ProtoColResolver()
     pcr.add_support(LK_ProtoCol())
@@ -162,5 +164,5 @@ if __name__ == '__main__':
     app.append_manager(sm)
     app.start()
 
-    EventMesh.publish("load_screen", {"screen": "watchface"})
+    EventMesh.publish("load_screen", {"screen": "PowerOn"})
 
index b3c0224..b174204 100644 (file)
@@ -454,12 +454,30 @@ class ConfigStoreManager(Abstract):
 def voice_callback(args):
    print('voicecall iinfo:{}'.format(args))
    if args[0] == 10:
-        print('voicecall incoming call, PhoneNO.: ', args[6])
-        EventMesh.publish("load_screen", {"screen": "incoming_call","meta":str(args[6])})
+        # print('voicecall incoming call, PhoneNO.: ', args[6])
+        size_len = len(str(args[6]))
+        tmp = []
+        tmp = args[6]
+        find_num = tmp[0]
+        # print("tmp:{} find_num:{}".format(tmp,find_num))
+        b = tmp.isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了
+        if find_num != 0 and size_len > 11:
+            tmp = tmp[size_len-11:]
+            # print('tmp end', tmp)
+        EventMesh.publish("load_screen", {"screen": "incoming_call","meta":str(tmp)})
 
    elif args[0] == 11:
-        print('voicecall connected, PhoneNO.: ', args[6])
-        EventMesh.publish("load_screen", {"screen": "on_call","meta":str(args[6])})
+        # print('voicecall connected, PhoneNO.: ', args[6])
+        size_len = len(str(args[6]))
+        tmp = []
+        tmp = args[6]
+        find_num = tmp[0]
+        # print("tmp:{} find_num:{}".format(tmp,find_num))
+        b = tmp.isdigit()#判断是否不是数字开头 暂时不用 因为截取了+判断不了
+        if find_num != 0 and size_len > 11:
+            tmp = tmp[size_len-11:]
+            # print('tmp end', tmp)
+        EventMesh.publish("load_screen", {"screen": "on_call","meta":str(tmp)})
 
    elif args[0] == 12:
         print('voicecall disconnect')
@@ -683,13 +701,14 @@ class DeviceInfoManager(Abstract):
         """
         XYZ = self.gsensor.get_x_y_z()
         tmp = 0
-        #print("x:%d,y:%d,z:%d",XYZ[0],XYZ[1],XYZ[2])
+       
         tmp =  self.gsensor.get_step() 
+        # print("x:%d,y:%d,z:%d tmp %d",XYZ[0],XYZ[1],XYZ[2],tmp)
         self.step[0]= tmp 
         self.step[1] = XYZ[0]
         self.step[2] = XYZ[1]
         self.step[3] = XYZ[2]
-        #print(self.step)
+        
         return self.step
 
     def get_ic_cid(self, event, msg):
@@ -909,6 +928,7 @@ class SockManager(Abstract):
         self.connect()
 
     def send(self, topic, msg):
+        # print("send msg:{}".format(msg))
         self.sock.send(msg)
 
     def recv(self):
@@ -1022,7 +1042,7 @@ class LocationManager(Abstract):
 
     def start_location(self, event, msg):
         #self.gps_open(event, msg)
-        #print("start_location")
+        # print("start_location")
         EventMesh.publish(constants.EVENT.GPSOPEN)
         self.location_timer_count = 0
         self.timer_read_GPS_info.start(1000, 1, self.location_timer)
@@ -1070,7 +1090,7 @@ class LocationManager(Abstract):
     def location_timer(self, *args, **kwargs):
         self.location_timer_count = self.location_timer_count +1
         if self.location_timer_count > 60 : #1分钟定位超时,超时发送数据,停止定时器及关闭定位
-            #print("publish:CLOSE_LOCATION")
+            # print("publish:CLOSE_LOCATION")
             self.location_timer_count = 0
             EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
             EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data])#发送数据
@@ -1273,3 +1293,63 @@ class PhoneCallingManager(Abstract):
     def get_phonenum(self, event, msg):
         return self.phonenum
 
+#获取心率 血氧历史数据
+class getOldHrDataManager(Abstract):
+    def __init__(self):
+        self.oldHr = 0
+        self.oldspo2 = 0
+
+    def post_processor_after_instantiation(self):
+        EventMesh.subscribe("set_old_hr_data", self.save_hr_value)
+        EventMesh.subscribe("get_old_hr_data", self.get_hr_value)
+        EventMesh.subscribe("set_old_spo2_data", self.save_spo2_value)
+        EventMesh.subscribe("get_old_spo2_data", self.get_spo2_value)
+
+    def save_hr_value(self, event, msg): 
+        self.oldHr = msg
+
+    def get_hr_value(self, event, msg): 
+        return self.oldHr
+
+    def save_spo2_value(self, event, msg): 
+        self.oldspo2 = msg
+
+    def get_spo2_value(self, event, msg): 
+        return self.oldspo2
+    
+
+class getWeatherDataManager(Abstract):
+    # 获取天气数据
+    def __init__(self):
+        self.date = {} #日期23-04-07
+        self.time = {} #14:41:41
+        self.content = {} #天气描述 
+        self.type = None #天气类型
+        self.temp = None #当前温度
+        self.min_temp = None #最低温度
+        self.max_temp = None #最高温度
+        self.city = {} #城市
+        self.no_data = 0#0沒有数据 1有数据
+
+    def post_processor_after_instantiation(self):
+        EventMesh.subscribe("get_weather_data", self.get)
+        EventMesh.subscribe("set_weather_data", self.set)
+
+    def get(self, event, msg):
+        return [self.date,self.time,self.content,self.type,self.temp,self.min_temp,self.max_temp,self.city,self.no_data]
+
+    def set(self, event, msg):
+        self.date = msg[0]
+        self.time = msg[1]
+        self.content = msg[2]
+        self.type = msg[3]
+        self.temp = msg[4]
+        self.min_temp = msg[5]
+        self.max_temp = msg[6]
+        self.city = msg[7]
+        self.no_data = msg[8]
+
+
+
+
+
index 9ba8d1f..8ee4c67 100644 (file)
@@ -87,7 +87,7 @@ class ProtoCol(Abstract):
 
     def handler(self, event, msg):
         self.password = EventMesh.publish(constants.EVENT.GET_PASSWORD)
-        self.imei = EventMesh.publish(constants.EVENT.GET_IMEI)
+        self.imei = "860132060004322"#EventMesh.publish(constants.EVENT.GET_IMEI)
         self.cid = EventMesh.publish(constants.EVENT.GET_CID)
         self.imsi = EventMesh.publish(constants.EVENT.GET_IMSI)
         self.key = EventMesh.publish(constants.EVENT.GET_KEY)
@@ -148,7 +148,7 @@ class LK_ProtoCol(ProtoCol):
         send_data = "SZKW*%s*0002*LK"%(self.imei)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("LK_ProtoCol:send:%s"%(data))
+        print("LK_ProtoCol:send:%s"%(data))
 
         
         # 通过socket发送到服务器端
@@ -163,7 +163,7 @@ class LK_ProtoCol(ProtoCol):
         print("LK_ProtoCol:recv:%s"%(msg))
         EventMesh.publish(constants.PROTOCOL.PING_SEND)
         EventMesh.publish(constants.PROTOCOL.KA_SEND)
-        
+        EventMesh.publish(constants.EVENT.START_LOCATION) #开始定位
 
 class PING_ProtoCol(ProtoCol):
     """获取绑定状态"""
@@ -227,7 +227,6 @@ class KA_ProtoCol(ProtoCol):
 class UD_ProtoCol(ProtoCol):
     """位置信息"""
     TYPE = "UD"
-
     def send(self, event, msg):
         #"{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
         #[6f62cfc40fc50173f9a7b21e87be3424IS*861217001020120*00f6*UD,220726,211210,A,22.649529,N,114.119165,E,0.28,137.4,100.0,8,24,63,119,0,00000000,2,1,460,11,30472,125667122,24,30472,218944048,19,4,
@@ -308,14 +307,25 @@ class UD_ProtoCol(ProtoCol):
         send_data += ",%d,%s"%(WIFI_num,WIFI_data)
 
         send_len = len(send_data)
-
+        wt_data = "%s"%(send_data)
         send_data = "SZKW*%s*%04X*%s"%(self.imei,send_len,send_data)
         MD5_SIGN = self.pack_MD5_head(send_data)
         data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("UD_ProtoCol:send:%s"%(data))
 
-        
+
+    
+        #这个是发送WT位置数据到手机端
+        msg_tmp = wt_data.split('UD,')
+        msg_tmp = msg_tmp[1]
+        # print("WT_ProtoCol:msg_tmp:%s"%(msg_tmp))
+        send_data_1 = "SZKW*%s*%04x*WT"%(self.imei,len(msg_tmp))
+        MD5_SIGN_1 = self.pack_MD5_head(send_data_1)
+        data_1 = "[%s%s,%s]"%(str(MD5_SIGN_1),send_data_1,msg_tmp)
+        # print("WT_ProtoCol:send:%s"%(data_1))
+        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data_1)
         # 通过socket发送到服务器端
+        
+
         EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
     def recv(self, event, msg):
@@ -324,7 +334,7 @@ class UD_ProtoCol(ProtoCol):
         @param event: PING
         @param msg: 接收到的下行数据
         """
-        #print("KA_ProtoCol:recv:%s"%(msg))   
+        # print("UD_ProtoCol:recv:%s"%(msg))  
 
 class CR_ProtoCol(ProtoCol):
     """立即定位"""
@@ -455,37 +465,55 @@ class PHL_ProtoCol(ProtoCol):
 
          
 class WT_ProtoCol(ProtoCol):
-    pass
-    # """温度数据"""
-    # TYPE = "WT"
-
-
-    # def send(self, event, msg):
-    #     # [SZKW*867387060319491*0008*PHL]
-    #     print("WT_ProtoCol:msg:%s"%(msg))
-    #     send_data = "SZKW*%s*0003*WT"%(self.imei)
-    #     MD5_SIGN = self.pack_MD5_head(send_data)
-    #     data = "[%s%s,%s]"%(str(MD5_SIGN),msg)
-    #     print("WT_ProtoCol:send:%s"%(data))
-    #     # 通过socket发送到服务器端
-    #     EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
-
-    # def recv(self, event, msg):
-    #     """
-
-    #     @param event: 温度数据下发
-    #     @param msg: 接收到的下行数据
-    #     """
-    #     msg = msg[1:-1]
-    #     print("WT_ProtoCol RECV msg:%s"%(msg))
-    #     # UnicodeHexStr_To_Utf8Str(phonebook_tmp)
+    """天气数据"""
+    TYPE = "WT"
 
-        
-    #     # EventMesh.publish(constants.PROTOCOL.WT_SEND)
-    #     # EventMesh.publish("set_phonebook_list",[1,phonebook])
-    #     # EventMesh.publish("contact_updata_list_show")
 
-   
+    def send(self, event, msg):
+        # [SZKW*867387060319491*0008*WT]
+        send_data = "SZKW*%s*003*WT"%(self.imei)
+        MD5_SIGN = self.pack_MD5_head(send_data)
+        data = "[%s%s]"%(str(MD5_SIGN),send_data)
+        # print("WT_ProtoCol:send:%s"%(data))
+        # 通过socket发送到服务器端
+        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+    def recv(self, event, msg):
+        """
+
+        @param event: T天气温度数据下发
+        @param msg: 接收到的下行数据
+        """
+        # b'SZKW*860132060004322*0035*WT,23-04-06,14:41:06,b6e0d4c6,1,27,-1,40,6DF157335E02'
+        msg = msg[1:-1]
+        msg_tmp = msg.decode('ascii')
+        msg_tmp = msg_tmp.split('WT,')
+        # print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
+        msg_tmp = msg_tmp[1]
+
+        # print("msg_tmp :%s"%(msg_tmp))
+
+        msg_date = msg_tmp.split(',')[0]
+
+        msg_time = msg_tmp.split(',')[1]
+        msg_weather_content = msg_tmp.split(',')[2]
+        msg_type = msg_tmp.split(',')[3]
+        msg_temp = msg_tmp.split(',')[4]
+        msg_min_temp = msg_tmp.split(',')[5]
+        msg_max_temp = msg_tmp.split(',')[6]
+        msg_city = msg_tmp.split(',')[7]
+
+        msg_city = UnicodeHexStr_To_Utf8Str(msg_city)
+        msg_weather_content = UnicodeHexStr_To_Utf8Str(msg_weather_content)
+        # print("msg_date:{} msg_time:{} msg_weather_content:{} msg_type:{} msg_temp:{} msg_min_temp:{} msg_max_temp:{} msg_city:{}".format(msg_date,msg_time,\
+        #     msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city))
+        # print("WT_ProtoCol RECV msg:%s"%(msg))
+
+        EventMesh.publish("set_weather_data",[msg_date,msg_time,msg_weather_content,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city,1])
+        EventMesh.publish("updata_weather_show")
+        EventMesh.publish(constants.PROTOCOL.WT_SEND)
+
+ 
 
 class ProtoColResolver(object):
     def __init__(self):
index dd6baf6..d5af6fc 100644 (file)
@@ -14,142 +14,6 @@ from ext import constants
 import osTimer
 import utime
 
-
-######################拨号盘##################################
-
-# -------------------------------------------血氧----------------------------------------------------------
-
-
-# spo2_screen = lv.obj()
-# spo2 = lv.obj(spo2_screen)
-# spo2.center()
-# spo2.set_size(240, 320)
-# spo2.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-# spo2_label = lv.label(spo2)
-# spo2_label.set_pos(0, 10)
-# spo2_label.set_size(240, 40)
-# spo2_label.set_text("血氧")
-# spo2_label.set_long_mode(lv.label.LONG.WRAP)
-# 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_done_img = lv.img(spo2)
-# spo2_done_img.set_pos(0, 50)
-# spo2_done_img.set_size(240, 96)
-# spo2_done_img.set_src("E:/static/IMAGE_SPO2_ONLY_TEST_DONE.jpg")
-
-# # spo2_finish_gif = lv.gif(spo2)
-# # spo2_finish_gif.set_pos(0, 40)
-# # spo2_finish_gif.set_size(240, 120)
-# # #spo2_finish_img.add_flag(lv.obj.FLAG.CLICKABLE)
-# # spo2_finish_gif.set_src("E:/static/IMAGE_SPO2_ONLY_ANI.gif")
-# # #spo2_finish_gif.set_opa(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-# spo2_label = lv.label(spo2)
-# 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)
-# 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)
-
-
-
-# line_points = [{"x":0,"y":0},{"x":240,"y":0}]
-# spo2_line = lv.line(spo2)
-# 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)
-# 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)
-# 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)
-
-
-# class Spo2Screen(Screen):
-#     NAME = "spo2"
-
-#     def __init__(self):
-#         super().__init__()
-#         self.meta = spo2_screen
-#         self.timer = osTimer()
-#         self.point = 0
-#         self.old_spo2_value = 0
-#         self.spo2_value = 0
-
-#     def post_processor_after_initialization(self):
-#         self.point = 0
-#         self.spo2_value = 0
-#         self.timer.start(1*1000, 1, self.start_measure)
-
-#     def start_measure(self,*args):
-#         self.point = self.point + 1
-#         if self.point == 1:
-#             self.spo2_value = 96
-#             spo2_label.set_text("96 %")
-#             spo2_label_1.set_text("测量中")
-
-#         if self.point == 2:
-#             self.spo2_value = 97
-#             spo2_label.set_text("97 %")
-#             spo2_label_1.set_text("测量中")
-
-#         if self.point == 3:
-#             self.spo2_value = 98
-#             spo2_label.set_text("98 %")
-#             spo2_label_1.set_text("测量中")
-
-#         if self.point == 4:
-#             self.spo2_value = 99
-#             spo2_label.set_text("99 %")
-#             spo2_label_1.set_text("测量完成")
-#             self.timer.stop()
-#             self.point = 0
-#             self.old_spo2_value = self.spo2_value
-#             time = EventMesh.publish("screen_get_time")#获取系统时间
-
-#             # result = [time, time_quantum, date , week,year]
-            
-#             time_tmp = "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#时间
-#             date_year = time[4]#年份
-#             date_month = time[2]#日期 04月05日
-#             print("date_year:{} date_month:{} time_tmp:{}".format(date_year,date_month,time_tmp))
-#             spo2_last_time.set_text(str(date_year)+str(date_month)+" {}".format(str(time_tmp)))
-#             spo2_last_value.set_text(str(self.old_spo2_value)+'%')
-            
-#     def done_return(self):
-#         self.timer.stop()
-#         EventMesh.publish("load_screen", {"screen": "main_menu"})
-
-#     def btn1_release(self):
-#         EventMesh.publish("load_screen", {"screen": "watchface"})
-#         self.timer.stop()
-        
-#     def btn8_press(self):
-#         EventMesh.publish("load_screen", {"screen": "watchface"})
-#         self.timer.stop()
-
 #-------------------------------------weather-----------------#
 weather_screen = lv.obj()
 weather = lv.obj(weather_screen)
@@ -163,31 +27,51 @@ weather_img.set_size(135, 120)
 
 weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
+no_weather_img = lv.img(weather)
+no_weather_img.set_pos(10, 10)
+no_weather_img.set_size(135, 120)
+no_weather_img.set_src("E:/static/update.jpg")
+no_weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 weather_tem_label = lv.label(weather)
-weather_tem_label.set_pos(140, 40)
-weather_tem_label.set_size(50, 50)
-weather_tem_label.set_text("19°C")
+weather_tem_label.set_pos(155, 40)
+weather_tem_label.set_size(85, 50)
+weather_tem_label.set_text("_ _C")
 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)
 
 weather_detail_label = lv.label(weather)
-weather_detail_label.set_pos(140, 80)
-weather_detail_label.set_size(50, 50)
-weather_detail_label.set_text("01/30")
+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)
-weather_location_label.set_pos(100, 200)
-weather_location_label.set_size(80, 50)
-weather_location_label.set_text("深圳市")
+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)
+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)
+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)
 
 class WeatherScreen(Screen):
     NAME = "weather"
@@ -195,11 +79,67 @@ class WeatherScreen(Screen):
     def __init__(self):
         super().__init__()
         self.meta = weather_screen
+        self.weather_data = {}
+        EventMesh.subscribe("updata_weather_show", self.update_weather_data)
+
 
     def post_processor_after_initialization(self):
-        EventMesh.publish(constants.PROTOCOL.WT_SEND)
-        #weather_img.set_src(name)
-        
+        EventMesh.publish("updata_weather_show")
+
+
+    def update_weather_data(self, event, msg):
+
+        connect = EventMesh.publish(constants.EVENT.GET_CONNECT) #获取网络状态
+        self.weather_data = EventMesh.publish("get_weather_data")
+        if connect != 0:
+            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("E:/static/update.jpg")#天气类型
+                else:
+                    weather_img.set_src("E:/static/{}_weather.jpg".format(type))#天气类型
+
+                temp = self.weather_data[4]
+                if temp == None:
+                    weather_tem_label.set_text("_ _C")
+                else:
+                    weather_tem_label.set_text("{}C".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("_ _C")
+                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("_ _C")
+            
+            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"})
@@ -210,254 +150,8 @@ class WeatherScreen(Screen):
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "watchface"})
 
-class getWeatherDataManager(Abstract):
-    # 通话记录
-    def __init__(self):
-        self.date = ""#日期
-        self.time = ""#14:41:41
-        self.type = 0#天气类型
-        self.temp = 0#当前温度
-        self.min_temp = 0#最低温度
-        self.max_temp = 0#最高温度
-        self.city = ""#城市
-
-
-
-
-    def post_processor_after_instantiation(self):
-        EventMesh.subscribe("get_weather_data", self.get)
-        EventMesh.subscribe("set_weather_data", self.set)
-
-
-
-    def get(self, event, msg):
-        return [self.date,self.time,self.type,self.temp,self.min_temp,self.max_temp,self.city]
-
-    def set(self, event, msg):
-        self.date = msg[0]
-        self.time = msg[1]
-        self.type = msg[2]
-        self.temp = msg[3]
-        self.min_temp = msg[4]
-        self.max_temp = msg[5]
-        self.city = msg[6]
-    
-    # def call_usr(self,event,msg):
-    #     content = self.log[msg]
-    #     # 参数1 姓名  参数2  电话   参数3 1/主动呼叫  0别人呼叫
-    #     EventMesh.publish("call_in", [content[2], content[0], 1])
-
-
-class WT_ProtoCol(ProtoCol):
-    """天气数据"""
-    TYPE = "WT"
-
-
-    def send(self, event, msg):
-        # [SZKW*867387060319491*0008*WT]
-        send_data = "SZKW*%s*003*WT"%(self.imei)
-        MD5_SIGN = self.pack_MD5_head(send_data)
-        data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        print("WT_ProtoCol:send:%s"%(data))
-        # 通过socket发送到服务器端
-        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
-
-    def recv(self, event, msg):
-        """
-
-        @param event: T天气温度数据下发
-        @param msg: 接收到的下行数据
-        """
-        # b'SZKW*860132060004322*0035*WT,23-04-06,14:41:06,b6e0d4c6,1,27,-1,40,6DF157335E02'
-        msg = msg[1:-1]
-        msg_tmp = msg.decode('ascii')
-        msg_tmp = msg_tmp.split('WT,')
-        # print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
-        msg_tmp = msg_tmp[1]
-
-        print("msg_tmp :%s"%(msg_tmp))
 
-        msg_date = msg_tmp.split(',')[0]
 
-        msg_time = msg_tmp.split(',')[1]
-        msg_weather_content = msg_tmp.split(',')[2]
-        msg_type = msg_tmp.split(',')[3]
-        msg_temp = msg_tmp.split(',')[4]
-        msg_min_temp = msg_tmp.split(',')[5]
-        msg_max_temp = msg_tmp.split(',')[6]
-        msg_city = msg_tmp.split(',')[7]
-
-        print("msg_date:{} msg_time:{} msg_type:{} msg_temp:{} msg_min_temp:{} msg_max_temp:{} msg_city:{}".format(msg_date,msg_time,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city))
-        print("WT_ProtoCol RECV msg:%s"%(msg))
-
-        # UnicodeHexStr_To_Utf8Str(phonebook_tmp)
-
-        
-        EventMesh.publish(constants.PROTOCOL.WT_SEND)
-        # EventMesh.publish("set_phonebook_list",[1,phonebook])
-        # EventMesh.publish("contact_updata_list_show")
-class PHL_ProtoCol(ProtoCol):
-    """电话本同步"""
-    TYPE = "PHL"
-
-
-    def send(self, event, msg):
-        # [SZKW*867387060319491*0008*PHL]
-        send_data = "SZKW*%s*0003*PHL"%(self.imei)
-        MD5_SIGN = self.pack_MD5_head(send_data)
-        data = "[%s%s]"%(str(MD5_SIGN),send_data)
-        #print("POWEROFF_ProtoCol:send:%s"%(data))
-        # 通过socket发送到服务器端
-        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
-
-    def recv(self, event, msg):
-        """
-
-        @param event: 电话本同步
-        @param msg: 接收到的下行数据
-        """
-        msg = msg[1:-1]
-        # print("phonebook:msg:%s\r\n"%msg)
-        msg_tmp = msg.decode('ascii')
-        msg_tmp = msg_tmp.split(',')
-        # print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp))
-
-        phonebook = {}
-        msg_tmp = msg_tmp[1:]
-        # print("msg_tmp1:{}".format(msg_tmp))
-        j = 0
-        i = 0
-        phonebook_oldtmp = {}
-        # 0 1 2 3
-        for phonebook_tmp in msg_tmp: 
-            j+=1
-            # print("phonebook_tmp:{} msg_tmp:{}".format(phonebook_tmp,msg_tmp))
-
-            if (j%2) == 0:
-                i+=1
-                phonebook_name = UnicodeHexStr_To_Utf8Str(phonebook_tmp)
-                phonebook_name = "{}:{}".format("%03d"%i,phonebook_name)                                      
-                phonebook[phonebook_name] = phonebook_oldtmp
-                
-            phonebook_oldtmp = phonebook_tmp
-            print("phonebook_oldtmp!!!:{}".format(str(phonebook_oldtmp)))
-        # print("phonebook!!!:{}".format(str(phonebook)))
-        with open("/ext/static/storage_file/phonebook.json","w",encoding="utf-8") as fd:
-            ujson.dump(phonebook,fd)
-            print("创建电话簿")
-        
-        EventMesh.publish(constants.PROTOCOL.PHL_SEND)
-        EventMesh.publish("set_phonebook_list",[1,phonebook])
-        EventMesh.publish("contact_updata_list_show")
-
-class UD_ProtoCol(ProtoCol):
-    """位置信息"""
-    TYPE = "UD"
-    def send(self, event, msg):
-        #"{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
-        #[6f62cfc40fc50173f9a7b21e87be3424IS*861217001020120*00f6*UD,220726,211210,A,22.649529,N,114.119165,E,0.28,137.4,100.0,8,24,63,119,0,00000000,2,1,460,11,30472,125667122,24,30472,218944048,19,4,
-        # wifi0,34:93:44:01:28:b9,-74,wifi1,34:20:03:96:35:ad,-78,wifi2,ea:b5:7b:e8:56:54,-80,wifi3,c4:49:bb:d4:d9:78,-88]
-        date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
-        date = date[2:]
-        GPS_type = "V"
-        latitude = "0.000000,N"
-        longitude = "0.000000,E"
-        speed = "0.00"
-        direction = "0.0"
-        high = "100.0"
-        number = "0"
-        if msg[0] != [] :#有GPS数据
-            GPS_type = "A"
-            # 纬度
-            latitude = msg[0]["latitude"]
-            # 经度
-            longitude = msg[0]["longitude"]
-            # 速度
-            speed = msg[0]["speed"]
-            # 方向
-            direction = "0"
-            if msg[0]["direction"] :
-                direction = msg[0]["direction"]
-            # 高度
-            high = msg[0]["high"]
-            high_tmp = high.split(".")
-            if len(high_tmp) >= 2 :
-                high = "%s"%(high_tmp[0])
-            # 讯号质量:搜索到的卫星数目
-            number = msg[0]["number"]
-        #gsm 信号强度
-        gsm_sig =  str((100//31)*EventMesh.publish("screen_get_sig"))
-        # 电池电量百分比 
-        bat_tmp = EventMesh.publish("screen_get_battery")
-        battery_caption =  str(bat_tmp[1])
-        #步数
-        step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
-        #翻转次数
-        turn_count = "0"
-        #终端状态
-        state = "00000000"
-        #基站数据
-        CELL_num = len(msg[2])
-        CELL_data = "1," #时延
-        if msg[2] != []:
-            for CELL in msg[2] :
-                if CELL[0] == 0 :
-                    CELL_data += "%X,"%(int(CELL[2])) #MCC
-                    CELL_data += str(CELL[3]) +","#MNC
-                    CELL_data += str(CELL[5]) +","#tac,区域码
-                    CELL_data += str(CELL[1]) +","#基站编号 CID
-                    CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
-                else :
-                    CELL_data += str(CELL[5]) +","#tac,区域码
-                    CELL_data += str(CELL[1]) +","#基站编号 CID
-                    CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
-            CELL_data = CELL_data[:(len(CELL_data)-1)]
-        #WIFI数据
-        WIFI_num = 0 
-        WIFI_data = ""
-        if msg[1] :
-            WIFI_num = msg[1][0]
-            i = 0
-            for MAC in msg[1][1] :
-                WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
-                i += 1
-            WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
-        WIFI_data = WIFI_data.lower()
-        #send_data = "UD ,%s ,%s     ,%s       ,%s       ,%s   ,%s       ,%s  ,%s    ,%s     ,%s             ,%s  ,%s        ,%s   ,%d     ,%s       ,%d      ,%s"\
-        #              %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
-        send_data = "UD,%s,%s,%s"%(date,GPS_type,latitude)
-        send_data += ",%s,%s,%s"%(longitude,speed,direction)
-        send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
-        send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
-        send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
-        send_data += ",%d,%s"%(WIFI_num,WIFI_data)
-
-        send_len = len(send_data)
-        wt_data = "%s"%(send_data)
-        send_data = "SZKW*%s*%04X*%s"%(self.imei,send_len,send_data)
-        MD5_SIGN = self.pack_MD5_head(send_data)
-        data = "[%s%s]"%(str(MD5_SIGN),send_data)
-
-
-    
-        #这个是发送WT位置数据到手机端
-        msg_tmp = wt_data.split('UD,')
-        msg_tmp = msg_tmp[1]
-        # print("WT_ProtoCol:msg_tmp:%s"%(msg_tmp))
-        send_data_1 = "SZKW*%s*%04x*WT"%(self.imei,len(msg_tmp))
-        MD5_SIGN_1 = self.pack_MD5_head(send_data_1)
-        data_1 = "[%s%s,%s]"%(str(MD5_SIGN_1),send_data_1,msg_tmp)
-        # print("WT_ProtoCol:send:%s"%(data_1))
-        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data_1)
-        # 通过socket发送到服务器端
-        
 
-        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
 
-    def recv(self, event, msg):
-        """
 
-        @param event: PING
-        @param msg: 接收到的下行数据
-        """
-        print("UD_ProtoCol:recv:%s"%(msg))   
\ No newline at end of file
index ad60d8e..73fb3df 100644 (file)
@@ -165,51 +165,6 @@ style_circle.set_radius(0x7FFF)
 
 
 
-# -------------------------------------------heartrate screen----------------------------------------------------------
-heartrate_screen = lv.obj()
-heartrate = lv.obj(heartrate_screen)
-heartrate.center()
-heartrate.set_size(240, 320)
-heartrate.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-heartrate_label = lv.label(heartrate)
-heartrate_label.set_pos(0, 10)
-heartrate_label.set_size(240, 40)
-heartrate_label.set_text("心率")
-heartrate_label.set_long_mode(lv.label.LONG.WRAP)
-heartrate_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-heartrate_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-heartrate_done_img = lv.img(heartrate)
-heartrate_done_img.set_pos(0, 50)
-heartrate_done_img.set_size(240, 96)
-heartrate_done_img.set_src("E:/static/IMAGE_HEART_ONLY_TEST_DONE.jpg")
-
-heartrate_start_label = lv.label(heartrate)
-heartrate_start_label.set_size(240,40)
-heartrate_start_label.set_pos(0,160)
-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)
-
-
-heartrate_bpm_label = lv.label(heartrate)
-heartrate_bpm_label.set_size(240, 40)
-heartrate_bpm_label.set_pos(0, 200)
-heartrate_bpm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-
-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_mmhg_label = lv.label(heartrate)
-heartrate_mmhg_label.set_size(240, 40)
-heartrate_mmhg_label.set_pos(0, 240)
-heartrate_mmhg_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-
-heartrate_mmhg_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-heartrate_mmhg_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
 
 
 
@@ -318,72 +273,10 @@ toolbox_stopwatch_img.set_src("E:/static/IMAGE_SECMENU_STOPWATCH.jpg")
 toolbox_stopwatch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 
-# -------------------------------------------step screen----------------------------------------------------------
-step_screen = lv.obj()
-step = lv.obj(step_screen)
-step.center()
-step.set_size(240, 320)
-step.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
 
-step_label = lv.label(step)
-step_label.set_pos(10, 30)
-step_label.set_size(100, 50)
-step_label.set_text("今日步数")
-step_label.set_long_mode(lv.label.LONG.WRAP)
-step_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-step_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
 
-step_label_01 = lv.label(step)
-step_label_01.set_pos(50, 100)
-step_label_01.set_size(100, 50)
-step_label_01.set_text("666 步")
-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)
-step_img.set_pos(100, 150)
-step_img.set_size(40, 65)
-step_img.set_src("E:/static/IMAGE_STEP.jpg")
-step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
-# -------------------------------------------weather screen----------------------------------------------------------
-weather_screen = lv.obj()
-weather = lv.obj(weather_screen)
-weather.center()
-weather.set_size(240, 320)
-weather.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-weather_img = lv.img(weather)
-weather_img.set_pos(10, 10)
-weather_img.set_size(135, 120)
-weather_img.set_src("E:/static/cloudy.jpg")
-weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-weather_tem_label = lv.label(weather)
-weather_tem_label.set_pos(140, 40)
-weather_tem_label.set_size(50, 50)
-weather_tem_label.set_text("19°C")
-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)
-
-weather_detail_label = lv.label(weather)
-weather_detail_label.set_pos(140, 80)
-weather_detail_label.set_size(50, 50)
-weather_detail_label.set_text("01/30")
-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)
-weather_location_label.set_pos(100, 200)
-weather_location_label.set_size(80, 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)
 
 # -------------------------------------------alarm screen----------------------------------------------------------
 alarm_screen = lv.obj()
@@ -1346,7 +1239,7 @@ class CallLogScreen(Screen):
 
     def call_log_update_show_list(self, event, msg): 
         read_call_log = EventMesh.publish("get_call_log_list")
-        # print("read_call_log:{}".format(read_call_log))
+        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)
@@ -1360,7 +1253,7 @@ class CallLogScreen(Screen):
     
     def btn_create(self):
         h = 0
-        if self.check_json == True:
+        if self.check_json == True and len(self.read_call_log) != 0:
             none_call_log_title.add_flag(lv.obj.FLAG.HIDDEN)
             self.call_log_detail_list.delete()#先删除一次控件
             self.call_log_detail_list = lv.obj(call_log_screen)
@@ -1785,60 +1678,118 @@ class MsgDetailScreen(Screen):
         EventMesh.publish("load_screen", {"screen": "watchface"})
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "popup"})
+# -------------------------------------------heartrate screen----------------------------------------------------------
+heartrate_screen = lv.obj()
+heartrate = lv.obj(heartrate_screen)
+heartrate.center()
+heartrate.set_size(240, 320)
+heartrate.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+heartrate_label = lv.label(heartrate)
+heartrate_label.set_pos(0, 10)
+heartrate_label.set_size(240, 40)
+heartrate_label.set_text("心率")
+heartrate_label.set_long_mode(lv.label.LONG.WRAP)
+heartrate_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+heartrate_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+heartrate_done_img = lv.img(heartrate)
+heartrate_done_img.set_pos(0, 50)
+heartrate_done_img.set_size(240, 96)
+heartrate_done_img.set_src("E:/static/IMAGE_HEART_ONLY_TEST_DONE.jpg")
 
+heartrate_start_label = lv.label(heartrate)
+heartrate_start_label.set_size(240,40)
+heartrate_start_label.set_pos(0,160)
+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)
+
+
+heartrate_bpm_label = lv.label(heartrate)
+heartrate_bpm_label.set_size(240, 40)
+heartrate_bpm_label.set_pos(0, 180)
+heartrate_bpm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+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)
+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)
 
 class HeartrateScreen(Screen):
     NAME = "heartrate"
 
+
     def __init__(self):
         super().__init__()
         self.meta = heartrate_screen
-        self.point = 0
-        #self.timer = Timer(Timer.Timer1)
         self.timer = osTimer()
+        self.point = 0
+        self.heart_value = 0
 
-    def initialization(self):
-        heartrate_bpm_label.add_flag(lv.obj.FLAG.HIDDEN)
-        heartrate_mmhg_label.add_flag(lv.obj.FLAG.HIDDEN)
-        heartrate_start_label.clear_flag(lv.obj.FLAG.HIDDEN)
 
-        #self.monitor_timer.start(7 * 60 * 1000, 1, self.check)
 
     def post_processor_after_initialization(self):
+        self.point = 0
         self.timer.start(1*1000, 1, self.start_measure)
-        #self.timer.start(period=1000, mode=self.timer.PERIODIC, callback=self.start_measure)
+        heartrate_done_label.set_text(" ")
+        heartrate_bpm_label.set_text(" ")
+        heartrate_start_label.set_text("正在测量中.")
+        EventMesh.publish(constants.EVENT.START_HEART)
 
 
     def start_measure(self,*args):
         self.point = self.point + 1
-        print("point:",self.point)
-        if self.point == 1:
-            heartrate_start_label.set_text("测量中...")
-        if self.point == 2:
-            heartrate_start_label.set_text("测量中.....")
-        if self.point == 3:
-            heartrate_bpm_label.clear_flag(lv.obj.FLAG.HIDDEN)
-            heartrate_mmhg_label.clear_flag(lv.obj.FLAG.HIDDEN)
-            heartrate_start_label.add_flag(lv.obj.FLAG.HIDDEN)
-            heartrate_bpm_label.set_text("74 bpm")
-            heartrate_mmhg_label.set_text("110 / 70 mmhg")
-            self.point = 0
+        EventMesh.publish("system_sleep_rest")#防止黑屏
+        self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+        # print("self.heart_value:{}".format(self.heart_value))
+        if self.heart_value < 40:
+            self.heart_value = 0
+        if self.heart_value != 0:
+            heartrate_start_label.set_text(" ")
+            heartrate_bpm_label.set_text("{}  bpm".format(self.heart_value))
+        else:
+            heartrate_bpm_label.set_text(" ")
+            if self.point%4 == 0 :
+                heartrate_start_label.set_text("正在测量中..")
+            if self.point%4 == 1 :
+                heartrate_start_label.set_text("正在测量中...")
+            if self.point%4 == 2 :
+                heartrate_start_label.set_text("正在测量中....")
+            if self.point%4 == 3 :
+                heartrate_start_label.set_text("正在测量中.")   
+
+        if self.point > 60: #测20s
+            self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+            if self.heart_value != 0:
+                heartrate_start_label.set_text(" ")
+                heartrate_bpm_label.set_text("{}  bpm".format(self.heart_value))
+                heartrate_done_label.set_text("测量完成")
+                EventMesh.publish("set_old_hr_data",self.heart_value)
+            else:
+                heartrate_start_label.set_text("退出,请重新测量")
+
             self.timer.stop()
+            self.point = 0
+            EventMesh.publish(constants.EVENT.STOP_HEART)
 
-    def done_return(self):
-        heartrate_bpm_label.add_flag(lv.obj.FLAG.HIDDEN)
-        heartrate_mmhg_label.add_flag(lv.obj.FLAG.HIDDEN)
-        heartrate_start_label.clear_flag(lv.obj.FLAG.HIDDEN)
+    def Close(self):
         self.timer.stop()
+        EventMesh.publish(constants.EVENT.STOP_HEART)
+
+    def done_return(self):
         EventMesh.publish("load_screen", {"screen": "main_menu"})
 
     def btn1_release(self):
         EventMesh.publish("load_screen", {"screen": "watchface"})
-        self.timer.stop()
         
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "watchface"})
-        self.timer.stop()
 
     
 
@@ -2091,6 +2042,34 @@ class OnCallScreen(Screen):
         
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "watchface"})
+# -------------------------------------------step screen----------------------------------------------------------#
+step_screen = lv.obj()
+step = lv.obj(step_screen)
+step.center()
+step.set_size(240, 320)
+step.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+step_label = lv.label(step)
+step_label.set_pos(10, 30)
+step_label.set_size(100, 50)
+step_label.set_text("今日步数")
+step_label.set_long_mode(lv.label.LONG.WRAP)
+step_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+step_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+step_label_01 = lv.label(step)
+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)
+step_img.set_pos(100, 150)
+step_img.set_size(40, 65)
+step_img.set_src("E:/static/IMAGE_STEP.jpg")
+step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
 class StepScreen(Screen):
     NAME = "step"
@@ -2098,7 +2077,14 @@ class StepScreen(Screen):
     def __init__(self):
         super().__init__()
         self.meta = step_screen
+        self.step = 0
+        EventMesh.subscribe(constants.EVENT.PUSH_STEP,self.revcing)
 
+    def revcing(self,event,msg):
+        # print("msg:{}".format(msg))
+        self.step = msg[0]
+        step_label_01.set_text("{}步".format(self.step))
+    
     def done_return(self):
         EventMesh.publish("load_screen", {"screen": "toolbox"})
 
@@ -2108,7 +2094,64 @@ class StepScreen(Screen):
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "watchface"})
 
+# -------------------------------------------weather screen----------------------------------------------------------
+weather_screen = lv.obj()
+weather = lv.obj(weather_screen)
+weather.center()
+weather.set_size(240, 320)
+weather.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+weather_img = lv.img(weather)
+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)
+no_weather_img.set_pos(10, 10)
+no_weather_img.set_size(135, 120)
+no_weather_img.set_src("E:/static/update.jpg")
+no_weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+weather_tem_label = lv.label(weather)
+weather_tem_label.set_pos(155, 40)
+weather_tem_label.set_size(85, 50)
+weather_tem_label.set_text("_ _C")
+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)
 
+weather_detail_label = lv.label(weather)
+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)
+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)
+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)
+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)
 
 class WeatherScreen(Screen):
     NAME = "weather"
@@ -2116,27 +2159,67 @@ class WeatherScreen(Screen):
     def __init__(self):
         super().__init__()
         self.meta = weather_screen
+        self.weather_data = {}
+        EventMesh.subscribe("updata_weather_show", self.update_weather_data)
 
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "toolbox"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "watchface"})
-        
-    def btn8_press(self):
-        EventMesh.publish("load_screen", {"screen": "watchface"})
 
-import audio
-from machine import Pin
+    def post_processor_after_initialization(self):
+        EventMesh.publish("updata_weather_show")
+
+
+    def update_weather_data(self, event, msg):
+
+        connect = EventMesh.publish(constants.EVENT.GET_CONNECT) #获取网络状态
+        self.weather_data = EventMesh.publish("get_weather_data")
+        if connect != 0:
+            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("E:/static/update.jpg")#天气类型
+                else:
+                    weather_img.set_src("E:/static/{}_weather.jpg".format(type))#天气类型
 
+                temp = self.weather_data[4]
+                if temp == None:
+                    weather_tem_label.set_text("_ _C")
+                else:
+                    weather_tem_label.set_text("{}C".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("-/-")
 
-class StepScreen(Screen):
-    NAME = "step"
+                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("_ _C")
+                no_connect_label.set_text("未获取网络数据")
+                no_connect_label1.set_text("请稍候重试")
 
-    def __init__(self):
-        super().__init__()
-        self.meta = step_screen
+        else:
+            weather_location_label.set_text(" ")
+            weather_detail_label.set_text("-/-")
+            weather_tem_label.set_text("_ _C")
+            
+            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"})
@@ -2147,6 +2230,12 @@ class StepScreen(Screen):
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "watchface"})
 
+import audio
+from machine import Pin
+
+
+
+
 # -----------------------------联系人--------------contacts screen----------------------------------------------------------
 
 contacts_screen = lv.obj()
@@ -2219,7 +2308,7 @@ class ContactsScreen(Screen):
     def btn_create_list_show(self,state):
         
         #读取json文件中的键作为label文本;
-        if self.check_json == True:
+        if self.check_json == True and len(self.phonebook) != 0:
             contact_none_label.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
             j =0
             i = 0 
@@ -2453,6 +2542,7 @@ class Spo2Screen(Screen):
         self.timer = osTimer()
         self.point = 0
         self.spo2_value = 0
+        self.last_spo2_value = 0
 
 
 
@@ -2461,13 +2551,22 @@ class Spo2Screen(Screen):
         self.spo2_value = 0
         self.timer.start(1*1000, 1, self.start_measure)
         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):
         self.point = self.point + 1
         EventMesh.publish("system_sleep_rest")#防止黑屏
         #if self.point == 1:
         self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-        spo2_label.set_text("{} %".format(self.spo2_value))
+        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 :
@@ -2480,7 +2579,22 @@ class Spo2Screen(Screen):
         if self.point > 60: #测20s
             self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
             spo2_label.set_text("{} %".format(self.spo2_value))
-            spo2_label_1.set_text("测量完成")
+            if self.spo2_value == 0:
+                spo2_label_1.set_text("退出,请重新测量")
+                self.last_spo2_value = EventMesh.publish("get_old_spo2_data")
+                spo2_last_value.set_text("{}%".format(self.last_spo2_value))
+            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")
+            time_year = time[4]
+            time_month = time[2]
+            time_time ="   {}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通话时间
+            spo2_last_time.set_text(str(time_year)+str(time_month)+str(time_time))
+            
+            EventMesh.publish("set_old_spo2_data",self.spo2_value)
+
             self.timer.stop()
             self.point = 0
             EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
@@ -2788,7 +2902,37 @@ class StopwatchScreen(Screen):
             self.timer.stop()
         EventMesh.publish("load_screen", {"screen": "watchface"})
        
+#开机画面
+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)
+
+power_on_screen = lv.obj()
+power_on = lv.obj(power_on_screen)
+power_on.center()
+power_on.set_size(240, 320)
+power_on.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+power_on_label = lv.label(power_on)
+power_on_label.set_text("WELCOME")
+power_on_label.align(lv.ALIGN.CENTER, 0, 0)
+power_on_label.add_style(style_font_youyuan_40, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+class PowerOnScreen(Screen):
+    NAME = "PowerOn"
 
+    def __init__(self):
+        super().__init__()
+        self.meta = power_on_screen
+        self.timer = osTimer()
+    def post_processor_after_initialization(self):
+        self.timer.start(3*1000,0,self.update_show)
+
+    def update_show(self,*agrs):
+
+        EventMesh.publish("load_screen", {"screen": "watchface"})
 
 
 class UIFINDScreen(Screen):
index cb9cd91..b5cb350 100644 (file)
@@ -14,7 +14,7 @@ from ext.ui import Screen
 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_18.bin",18,0)
+style_font_youyuan_20.set_text_font_v2("font_20.bin",18,0)
 
 class Watchface2():
     NAME = "Watchface2"
@@ -251,11 +251,11 @@ class Watchface1():
         self.watchface1_style_default.set_pad_right(0)
         self.watchface1_style_default.set_pad_top(0)
         self.watchface1_style_default.set_pad_bottom(0)
-        self.watchface1_style_default.set_text_font_v2("font_18.bin",18,0) #将外部字体库与该style对象绑定
+        self.watchface1_style_default.set_text_font_v2("font_20.bin",20,0) #将外部字体库与该style对象绑定
         #日期
         self.watchface1_date = lv.spangroup(self.meta)
         self.watchface1_date.set_pos(int(24),int(131))
-        self.watchface1_date.set_size(84,17)
+        self.watchface1_date.set_size(84,25)
         self.watchface1_date.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
         self.watchface1_date.set_align(lv.TEXT_ALIGN.LEFT)
         self.watchface1_date.set_overflow(lv.SPAN_OVERFLOW.CLIP)
@@ -272,7 +272,7 @@ class Watchface1():
         #星期
         self.watchface1_week = lv.spangroup(self.meta)
         self.watchface1_week.set_pos(int(29),int(163))
-        self.watchface1_week.set_size(64,17)
+        self.watchface1_week.set_size(80,25)
         self.watchface1_week.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
         self.watchface1_week.set_align(lv.TEXT_ALIGN.LEFT)
         self.watchface1_week.set_overflow(lv.SPAN_OVERFLOW.CLIP)
@@ -303,7 +303,7 @@ class Watchface1():
         
         #计步
         self.watchface1_step_img = lv.img(self.meta)
-        self.watchface1_step_img.set_pos(int(130),int(154))
+        self.watchface1_step_img.set_pos(int(130),int(160))
         self.watchface1_step_img.set_size(26,24)
         self.watchface1_step_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
         self.watchface1_step_img.add_flag(lv.obj.FLAG.CLICKABLE)
@@ -312,13 +312,13 @@ class Watchface1():
         
         self.watchface1_step_txt = lv.spangroup(self.meta)
         self.watchface1_step_txt.set_pos(int(170),int(163))
-        self.watchface1_step_txt.set_size(60,18)
+        self.watchface1_step_txt.set_size(80,25)
         self.watchface1_step_txt.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
         self.watchface1_step_txt.set_align(lv.TEXT_ALIGN.LEFT)
         self.watchface1_step_txt.set_overflow(lv.SPAN_OVERFLOW.CLIP)
         self.watchface1_step_txt.set_mode(lv.SPAN_MODE.BREAK)
         self.watchface1_step_span = self.watchface1_step_txt.new_span()
-        self.watchface1_step_span.set_text("16888")
+        self.watchface1_step_span.set_text("0")
         self.watchface1_step_span.style.set_text_color(lv.color_make(0xee,0xe7,0xe7))
         self.watchface1_step_span.style.set_text_decor(lv.TEXT_DECOR.NONE)
         #self.watchface1_week_step_span.style.set_text_font(lv.font_harmony_19)
@@ -337,13 +337,13 @@ class Watchface1():
         
         self.watchface1_HB_txt = lv.spangroup(self.meta)
         self.watchface1_HB_txt.set_pos(int(55),int(235))
-        self.watchface1_HB_txt.set_size(45,18)
+        self.watchface1_HB_txt.set_size(80,25)
         self.watchface1_HB_txt.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
         self.watchface1_HB_txt.set_align(lv.TEXT_ALIGN.LEFT)
         self.watchface1_HB_txt.set_overflow(lv.SPAN_OVERFLOW.CLIP)
         self.watchface1_HB_txt.set_mode(lv.SPAN_MODE.BREAK)
         self.watchface1_HB_span = self.watchface1_HB_txt.new_span()
-        self.watchface1_HB_span.set_text("199")
+        self.watchface1_HB_span.set_text("0")
         self.watchface1_HB_span.style.set_text_color(lv.color_make(0xee,0xe7,0xe7))
         self.watchface1_HB_span.style.set_text_decor(lv.TEXT_DECOR.NONE)
         #self.watchface1_week_HB_span.style.set_text_font(lv.font_harmony_19)
@@ -362,13 +362,13 @@ class Watchface1():
         
         self.watchface1_SPO2_txt = lv.spangroup(self.meta)
         self.watchface1_SPO2_txt.set_pos(int(160),int(235))
-        self.watchface1_SPO2_txt.set_size(42,18)
+        self.watchface1_SPO2_txt.set_size(80,25)
         self.watchface1_SPO2_txt.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
         self.watchface1_SPO2_txt.set_align(lv.TEXT_ALIGN.LEFT)
         self.watchface1_SPO2_txt.set_overflow(lv.SPAN_OVERFLOW.CLIP)
         self.watchface1_SPO2_txt.set_mode(lv.SPAN_MODE.BREAK)
         self.watchface1_SPO2_span = self.watchface1_SPO2_txt.new_span()
-        self.watchface1_SPO2_span.set_text("199")
+        self.watchface1_SPO2_span.set_text("0")
         self.watchface1_SPO2_span.style.set_text_color(lv.color_make(0xee,0xe7,0xe7))
         self.watchface1_SPO2_span.style.set_text_decor(lv.TEXT_DECOR.NONE)
         #self.watchface1_week_SPO2_span.style.set_text_font(lv.font_harmony_19)
@@ -376,6 +376,7 @@ class Watchface1():
         # add style for main_style_1_spangroup_week
         self.watchface1_SPO2_txt.add_style(self.watchface1_style_default, lv.PART.MAIN|lv.STATE.DEFAULT)
 
+       
 
     def initialization(self):    
         #获取信号
@@ -390,7 +391,19 @@ class Watchface1():
         #print("publish_time:"+time)
         if time:
             self.__time(None, time)
+        hrValue = EventMesh.publish("get_old_hr_data")
+        self.__oldHrValue(None, hrValue)
+
+        spo2Value = EventMesh.publish("get_old_spo2_data")
+        self.__oldSpo2Value(None, spo2Value)
         
+
+    def get_step(self,event,msg):
+        # print("main get_step msg:{}".format(msg))
+        self.step = msg[0]
+        self.watchface1_step_span.set_text(str(self.step))
+
+
     def timerout_update(self):
         #获取信号
         signal = EventMesh.publish("screen_get_sig")
@@ -406,6 +419,12 @@ class Watchface1():
         if time:
             self.__time(None, time)
 
+        hrValue = EventMesh.publish("get_old_hr_data")
+        self.__oldHrValue(None, hrValue)
+
+        spo2Value = EventMesh.publish("get_old_spo2_data")
+        self.__oldSpo2Value(None, spo2Value)
+
     def __time(self, event, msg):
         #时间
         hour1_chose = (msg[0][0])//10%10
@@ -439,7 +458,12 @@ class Watchface1():
 
         self.watchface_res_stat_battery_img.set_src("E:/static/vbat_%d.jpg"%(msg[1]))#"E:/vbat_60.jpg"
         pass
+
+    def __oldHrValue(self, event, msg):
+        self.watchface1_HB_span.set_text(str(msg))
     
+    def __oldSpo2Value(self, event, msg):
+        self.watchface1_SPO2_span.set_text(str(msg))
 
 
 class WatchFaceScreen(Screen):
@@ -465,6 +489,7 @@ class WatchFaceScreen(Screen):
                 self.watchface_style = wat
         self.meta = self.watchface_style.meta
         self.watchface_style.initialization()
+        EventMesh.subscribe(constants.EVENT.PUSH_STEP,self.watchface_style.get_step)
         self.timer_update.start(10000, 1, self.timerout_update)
         
     def post_processor_after_initialization(self):