C06S:
authordxy15521469561 <1731678236@qq.com>
Wed, 6 Dec 2023 01:28:22 +0000 (09:28 +0800)
committerdxy15521469561 <1731678236@qq.com>
Wed, 6 Dec 2023 01:28:22 +0000 (09:28 +0800)
优化

2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/alarm.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/appFactoryMode.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/appWechat.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/constants.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/main_init.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/mgr.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/protocol.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui_WatchFaceScreen.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui_health.py
2.sdk/project/C06S/sdk/services/microPython/ports/quectel/core/ui_setting.py

index 4ab88a5..6ec3121 100644 (file)
@@ -816,7 +816,7 @@ class PopupAlarmScreen(Screen):
         self.timer.start(1000,1,self.exit_alarm_page)
         time = EventMesh.publish("screen_get_time")#获取系统时间
         popup_alarm_time.set_text("{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1])))
-
+        EventMesh.publish("set_motor_time",[1,2,8*6,8,4])#设置马达参数
 
     def Close(self):
         self.alarm_count=0
@@ -837,43 +837,45 @@ class PopupAlarmScreen(Screen):
             if play_state == 0:#在上一个界面在播放音频时切换界面则关闭 以免一直播放
                 self.aud.stop()
                 self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3')  #播放声音
-    
+
     def close_timer(self):
         self.alarm_count=0
         self.timer.stop()
         self.aud.stop()
+        EventMesh.publish("close_motor_infor")#关闭马达和定时器
+
 
     def done_left_to_right(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_right_to_left(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_bottom_to_top(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_top_to_bottom(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_return(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
                
     def done_click(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def btn1_release(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
         self.close_timer()
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
 ALARM_LIST_SIZE = 70
 #闹钟列表
@@ -913,6 +915,7 @@ class ClkListScreen(Screen):
             self.contact_detail_listt_dict.append({"_btn":_btn,"_btn_label1":_btn_label1,"_btn_label2":_btn_label2,"_btn_label3":_btn_label3})
 
     def initialization(self): 
+        
         EventMesh.publish("read_alarminjson")
         EventMesh.publish("set_rtc_alarm")
         print("n闹钟列表初始化!!")
index 43d9405..27f0160 100644 (file)
@@ -247,8 +247,8 @@ class FactoryModeLogScreen(Screen):
         self.Log_timer = osTimer()
         self.log_data = ""
         self.log_count = 0
-        FactoryModeLogClean_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.LogClean_cb(e)), lv.EVENT.CLICKED, None)
-        FactoryModeLogNext_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.LogNext_cb(e)), lv.EVENT.CLICKED, None)
+        FactoryModeLogClean_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.LogClean_cb(e)), lv.EVENT.SHORT_CLICKED, None)
+        FactoryModeLogNext_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.LogNext_cb(e)), lv.EVENT.SHORT_CLICKED, None)
     def initialization(self):
         print("FactoryModeLogScreen")
         self.Log_timer.start(1000,1,self.Log_timer_cb) 
@@ -413,8 +413,8 @@ class FactoryModeHsensorTestScreen(Screen):
         self.hsensorTest_timer_count = 0
         self.hsensorTest_timer = osTimer()
         self.Hsensor = None
-        FactoryModeHsensorCali_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.HsensorCali_cb(e)), lv.EVENT.CLICKED, None)
-        FactoryModeHsensorLeakLight_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.HsensorLeakLight_cb(e)), lv.EVENT.CLICKED, None)
+        FactoryModeHsensorCali_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.HsensorCali_cb(e)), lv.EVENT.SHORT_CLICKED, None)
+        FactoryModeHsensorLeakLight_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.HsensorLeakLight_cb(e)), lv.EVENT.SHORT_CLICKED, None)
     def initialization(self):
         print("FactoryModeHsensorTestScreen")
         self.hsensorTest_timer.start(1000,1,self.hsensorTest_timer_cb) 
index 7f1c669..1f3a4f3 100644 (file)
@@ -656,7 +656,132 @@ class NewWechatPopupScreen(Screen):
         EventMesh.publish("load_screen", {"screen": "main_menu"})
 
 
+class TKS_ProtoCol(ProtoCol):
+    """微聊"""
+    TYPE = "TKS"
+    
+
+    def send(self, event, msg):
+        if len(str(msg)) == 1:
+            len_size = len(str(msg))+len("TKS,")
+            #  实例:[XT*334588000000156*0009*TK,1]
+            send_data = self.PID+"*%s*%04X*TKS"%(self.imei,len_size)
+            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"TKS")
+            MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+            data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
+            print("TKS:data:%s"%(data))
+            # 通过socket发送到服务器端
+            EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+        else:
+            # [SZKW*YYYYYYYYYYYYYYY*LEN*TK,AMR 格式音频数据]
+            #[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
+            arm_data = msg[1]
+            arm_sec = msg[0]
+            # print("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
+
+            arm = bytearray()
+            for i in range(len(arm_data)):
+                if arm_data[i] == 0x7d:
+                    arm.extend(b'\x7d\x01')
+                elif arm_data[i] == 0x5b :
+                    arm.extend(b'\x7d\x02')
+                elif arm_data[i] == 0x5d :
+                    arm.extend(b'\x7d\x03')
+                elif arm_data[i] == 0x2c :
+                    arm.extend(b'\x7d\x04')
+                elif arm_data[i] == 0x2a :
+                    arm.extend(b'\x7d\x05')
+                else :
+                    arm.append(arm_data[i])
+                
+            datalen = len(arm) + len(str("TKS,"))+len(str(arm_sec))+1
+            #Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
+            send_data = bytearray("SZKW*%s*%04X*TKS,%d,"%(self.imei,datalen,arm_sec))
+            send_data.extend(arm)
+            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,datalen,"TKS")
+            MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+            data = bytearray('[')
+            data.extend(MD5_SIGN)
+            data.extend(send_data)
+            data.extend(']')
+            # print("TK:send data:%s MD5_head_data:%s"%(data,MD5_head_data))
+            EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+
+    def recv(self, event, msg):
+        """
+
+        ("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+        @param event: 微聊
+        @param msg: 接收到的下行数据
+        [SZKW*860132060004322*20BD*TK,#!AMR...]
+        """
+        #Wechat_log("K_ProtoCol:recv:data:{}".format(msg))
+        # print("TK recv:{}".format(msg))
+        msg_tmp = msg.decode('ascii')
+        str = msg_tmp.split('TKS,')
+        # Wechat_log("TK_ProtoCol:recv:len:{} {} {}".format(len(msg),len(str),msg_tmp.find("#!AMR")))
+        if  msg_tmp.find("#!AMR") != -1: #是否是服务器下发音频数据
+            # Wechat_log("TK_ProtoCol:recv:datalen{}".format(len(msg)))
+            arm_data = bytearray(str[1])#获取amr输出
+            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_log("TK_ProtoCol:datalen:{} {} {}".format(wechat_num,MXA_MSG,wechat_recode_list))
+            
+            if wechat_num >= MXA_MSG:
+                wechat_num = 0 
+            if wechat_num == 0:
+                wechat_num += 1 
+            elif wechat_num > 0:
+                wechat_num += 1 
+          
+
+            Wechat_log("num_total:datalen:{} {}".format(MXA_MSG,wechat_recode_list))
+            wechat_recode_list["%02d"%(wechat_num)] = "R:{}".format(3)
+            wechat_recode_list['num'] = wechat_num
+            EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_recode_list])
+            #写语音文件数据
+            screen_NAME = EventMesh.publish("get_screen_NAME")
+            get_lcd_state = EventMesh.publish("get_lcd_state")
+            if screen_NAME != "wechat" or get_lcd_state == 0:
+                EventMesh.publish("load_screen", {"screen": "wechat_popup"})
+            else:
+                EventMesh.publish("wechat_updata_list_show")
+            # path = "/ext/static/storage_file/audio_amr/amr/{}.amr".format(wechat_num)
+            path = "/ext/static/storage_file/{}.amr".format(wechat_num)
+            with open(path,"w") as fd:
+                arm = bytearray()
+                j = 0
+                for i in range(len(arm_data)):
+                    if arm_data[j] == 0x7d and arm_data[j+1] == 0x01:
+                        arm.extend(b'\x7d')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x02:
+                        arm.extend(b'\x5b')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x03:
+                        arm.extend(b'\x5d')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x04:
+                        arm.extend(b'\x2c')
+                        j+=1
+                    elif arm_data[j] == 0x7d and arm_data[j+1] == 0x05:
+                        arm.extend(b'\x2a')
+                        j+=1
+                    else :
+                        arm.append(arm_data[j])
+                    j+=1
+                    if j >= len(arm_data):
+                        break
+                fd.write(arm)
+            EventMesh.publish(constants.PROTOCOL.TKS_SEND,1)
 
+            
+            
 
 
 class TK_ProtoCol(ProtoCol):
@@ -668,10 +793,10 @@ class TK_ProtoCol(ProtoCol):
         # print("TK send:{}".format(msg))
         if len(str(msg)) == 1:
 
-            len_size = len(str(msg))+len("TKS,")
+            len_size = len(str(msg))+len("TK,")
             #  实例:[XT*334588000000156*0009*TK,1]
-            send_data = self.PID+"*%s*%04X*TKS"%(self.imei,len_size)
-            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"TKS")
+            send_data = self.PID+"*%s*%04X*TK"%(self.imei,len_size)
+            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"TK")
             MD5_SIGN = self.pack_MD5_head(MD5_head_data)
             data = "[%s%s,%d]"%(str(MD5_SIGN),send_data,msg)
             print("TK:data:%s"%(data))
@@ -700,11 +825,11 @@ class TK_ProtoCol(ProtoCol):
                 else :
                     arm.append(arm_data[i])
                 
-            datalen = len(arm) + 4+len(str(arm_sec))+1
+            datalen = len(arm) +len(str("TK,"))+len(str(arm_sec))+1
             #Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
-            send_data = bytearray("SZKW*%s*%04X*TKS,%d,"%(self.imei,datalen,arm_sec))
+            send_data = bytearray("SZKW*%s*%04X*TK,%d,"%(self.imei,datalen,arm_sec))
             send_data.extend(arm)
-            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,datalen,"TKS")
+            MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,datalen,"TK")
             MD5_SIGN = self.pack_MD5_head(MD5_head_data)
             data = bytearray('[')
             data.extend(MD5_SIGN)
index ff4d2d2..6e94c27 100644 (file)
@@ -99,6 +99,18 @@ class PROTOCOL:
     BTEMP2_SEND ="btemp2_SEND"
     BTEMP2_RECV ="btemp2_RECV"
 
+    SCREEN_SHOW_SEND = "SCREEN_SHOW_SEND"
+    SCREEN_SHOW_RECV = "SCREEN_SHOW_RECV"
+
+    TKS_SEND = "TKS_SEND"
+    TKS_SEND = "TKS_SEND"
+
+    BLOOD_SEND = "blood_SEND"
+    BLOOD_RECV = "blood_RECV"
+
+    BLDSTART_SEND ="bldstart_SEND"
+    BLDSTART_RECV = "bldstart_RECV"
+
 class EVENT:
     CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND"
     START_LOCATION = "START_LOCATION" 
index 3084186..0d524f4 100644 (file)
@@ -66,9 +66,10 @@ def main_init():
     # from ui_WatchFaceScreen import WatchFaceScreen
     from ui_health import HealthScreen,Spo2Screen,TemperatureScreen,bloodpressureScreen,HeartrateScreen
     from appFactoryMode import  FactoryModestepScreen,FactoryModeLocationScreen,FactoryModeScreen ,FactoryModeBatTestScreen,FactoryModeHsensorTestScreen,FactoryModeLogScreen
-    from mgr import setCallStateManager,setclassTimeManager,setSmsIndexManager,ConfigStoreManager,testSmsSetIPManager,playPowerAudioManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
+    from mgr import schoolclassManager,setCallStateManager,setclassTimeManager,setSmsIndexManager,ConfigStoreManager,testSmsSetIPManager,playPowerAudioManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
     AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
     from motor import motorEventManager
+    from appWechat import WechatScreen,TKS_ProtoCol,TK_ProtoCol,MESSAGE_ProtoCol,NewWechatPopupScreen
     import ui as _ui
     # import ui as _ui
     #print("init4:{}".format(utime.localtime()))
@@ -111,8 +112,9 @@ def main_init():
     except Exception as e:
         usys.print_exception(e)
     try:
-        from appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol,NewWechatPopupScreen
+        
         ui.add_screen(WechatScreen()) 
+        
         from alarm import ClkListScreen,ClockManager,NewEditClk,CLKTimeScreen,ClkPeriod,PopupAlarmScreen
         
         ui.add_screen(ClkListScreen()) 
@@ -208,7 +210,7 @@ def main_init():
     #print("init6:{}".format(utime.localtime()))
     
     try:
-        from protocol import btemp2_ProtoCol,bodytemp2_ProtoCol,TEMP_Hour_ProtoCol,SILENCETIMEFS_ProtoCol,KEYBRD_ProtoCol,SILENCETIME2_ProtoCol,WLKEY_ProtoCol,LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,\
+        from protocol import bldstart_ProtoCol,blood_ProtoCol,SCREEN_SHOWProtoCol,btemp2_ProtoCol,bodytemp2_ProtoCol,TEMP_Hour_ProtoCol,SILENCETIMEFS_ProtoCol,KEYBRD_ProtoCol,SILENCETIME2_ProtoCol,WLKEY_ProtoCol,LK_ProtoCol,PING_ProtoCol,HEART_ProtoCol,OXYGEN_ProtoCol,OXYGEN_One_ProtoCol,HRSTART_ProtoCol,CENTER_ProtoCol,UPLOAD_ProtoCol,\
             TEMP_ProtoCol,DLT_ProtoCol,WT_ProtoCol,UD_ProtoCol,REMIND_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,Time_ProtoCol,\
                 ProtoColResolver,PHL_ProtoCol,MONITOR_ProtoCol,bootoff_ProtoCol,WDSTART_ProtoCol,LOWBAT_ProtoCol,sosHome_dial_ProtoCol,SockManager,NetManager
         import mgr as mgr
@@ -238,7 +240,7 @@ def main_init():
             # .append_manager(mgr.StopwatchManager()) \
             # .append_manager(mgr.CountdownManager()) \
         app.append_manager(playPowerAudioManager())
-        
+        app.append_manager(schoolclassManager())
         #app.append_manager(Alipay()) 
         app.append_manager(ConfigStoreManager())
         app.append_manager(NetManager())
@@ -285,8 +287,7 @@ def main_init():
         pcr.add_support(FIND_ProtoCol())
         pcr.add_support(POWEROFF_ProtoCol())
         pcr.add_support(PHL_ProtoCol())
-        pcr.add_support(TK_ProtoCol())
-        pcr.add_support(MESSAGE_ProtoCol())
+        
         pcr.add_support(WT_ProtoCol())
         pcr.add_support(REMIND_ProtoCol())
         pcr.add_support(HRSTART_ProtoCol())
@@ -311,6 +312,13 @@ def main_init():
         pcr.add_support(TEMP_Hour_ProtoCol())
         pcr.add_support(bodytemp2_ProtoCol())
         pcr.add_support(btemp2_ProtoCol())
+        pcr.add_support(SCREEN_SHOWProtoCol())
+        pcr.add_support(TKS_ProtoCol())
+        pcr.add_support(TK_ProtoCol())
+        pcr.add_support(MESSAGE_ProtoCol())
+
+        pcr.add_support(blood_ProtoCol())
+        pcr.add_support(bldstart_ProtoCol())
     except Exception as e:
         usys.print_exception(e)
     try:    
index 3b26b5f..e1391a1 100644 (file)
@@ -699,6 +699,8 @@ class DeviceInfoManager(Abstract):
 
         self.alarm_count = 0
 
+        self.old_bp_time = 0
+
         self.charge_full_count = 0
         self.GPS_step_t = 0#记录步数
         self.usb = USB()
@@ -1042,6 +1044,9 @@ class DeviceInfoManager(Abstract):
             self.get_spo2_state = 0
         get_temp_time  = EventMesh.publish("get_temp_time")
         get_temp_state  = EventMesh.publish("get_temp_state")
+        get_bp_state  = EventMesh.publish("get_bp_state")
+        if get_bp_state == None:
+            get_bp_state = 0
         if get_temp_state == None :
             get_temp_state = 0
         hr_time = {}
@@ -1050,14 +1055,50 @@ class DeviceInfoManager(Abstract):
             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 or self.get_spo2_state > 1 or get_bp_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:
+                elif get_bp_state > 1:
+                    EventMesh.publish("set_bp_state",0)#2代表后台进入测试
+                    EventMesh.publish(constants.EVENT.STOP_HEART)
+
+        
+        if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1"and WEAR == 1:
+            get_hr_state = EventMesh.publish("get_hr_state")
+            get_spo2_state = EventMesh.publish("get_spo2_state")
+            get_bp_state  = EventMesh.publish("get_bp_state")
+            if get_bp_state != None:
+                if get_bp_state == 3:
+                    self.old_bp_time+=1
+                    if self.old_bp_time == 1:
+                        EventMesh.publish("set_bp_state",3)#2代表后台进入测试
+                        EventMesh.publish(constants.EVENT.START_HEART)
+                        # print("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
+                    elif self.old_bp_time > 9:
+                        self.old_bp_time = 0
+                        EventMesh.publish("set_bp_state",0)#2代表后台进入测试
+                        blood_data = EventMesh.publish("get_autoblood_value")
+                        if blood_data == None:
+                            blood_data[0] = 0
+                            blood_data[1] = 0
+
+                        max_value = blood_data[0]
+                        min_value = blood_data[1]
+                        if max_value != 0 and min_value != 0:
+                            EventMesh.publish("set_old_blood_data",[max_value,min_value])
+                            
+                            EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value])
+                        EventMesh.publish(constants.EVENT.STOP_HEART)
+                else:
+                    self.old_bp_time = 0
+            else:
+                self.old_bp_time = 0
+
+
 
             # print("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state))
             if get_temp_time != None:#定时测量体温
@@ -1192,306 +1233,317 @@ class DeviceInfoManager(Abstract):
             self.mearsure_btn = int(hr_time[0])
             self.mearsure_timer = int(hr_time[1])
             if self.mearsure_btn != None and self.mearsure_timer != None:
-                print("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1]))
-                if self.mearsure_btn > 0:
-                    if self.mearsure_timer > 0:
-                        #print("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer))
-                        if self.get_hr_state != 1 and self.get_spo2_state != 1:
-                            if self.get_hr_state == 0 and self.get_spo2_state == 0:
-                                if self.HR_state == 0 or self.HR_state == 3:
-                                    self.HR_Onestate = 0
-                                    self.HR_OneTime = 0
-                            
-                            if self.old_time != self.mearsure_timer:#重复修改测量间隔时间
-                                self.SENSOR_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量
-                                if self.get_hr_state == 2 and self.HR_state == 1:#自动检测的心率还在测量立马关了测试
-                                    heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                                    if heart_value > 50 and heart_value != None:
-                                        EventMesh.publish("set_old_hr_data",heart_value)
-                                        EventMesh.publish("set_history_hr_value",heart_value)
-                                        EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)
-                                    print("stop debug1")
-                                    EventMesh.publish(constants.EVENT.STOP_HEART)
-                                    self.HR_state = 0
-                                elif self.get_spo2_state == 2 and self.HR_state == 2:
-                                    self.HR_state = 0
-                                    spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-                                    if spo2_value > 85 and spo2_value != None:
-                                        EventMesh.publish("set_old_spo2_data",spo2_value)
-                                        EventMesh.publish("set_history_spo2_value",spo2_value)
-                                        EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-                                    EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-                            self.old_time = self.mearsure_timer
-
-                            if self.HR_state == 3 or self.HR_state == 0:#
-                                if (time_tmp - self.SENSOR_time) >= self.mearsure_timer:
-                                    if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量没有完毕优先测量间隔时间测量的
-                                        if self.get_hr_state == 3:
-                                            print("stop debug2")
-                                            EventMesh.publish(constants.EVENT.STOP_HEART)
+                if get_hr_state != None and get_bp_state != None:
+                    if get_bp_state == 0:
+                        print("hr......01....{} {}\r\n".format(hr_time[0],hr_time[1]))
+                        if self.mearsure_btn > 0:
+                            if self.mearsure_timer > 0:
+                                #print("get_hr_state:{} get_spo2_state:{} self.old_time:{} mearsure_timer:{}".format(self.get_hr_state,self.get_spo2_state,self.old_time,mearsure_timer))
+                                if self.get_hr_state != 1 and self.get_spo2_state != 1:
+                                    if self.get_hr_state == 0 and self.get_spo2_state == 0:
+                                        if self.HR_state == 0 or self.HR_state == 3:
+                                            self.HR_Onestate = 0
+                                            self.HR_OneTime = 0
+                                    
+                                    if self.old_time != self.mearsure_timer:#重复修改测量间隔时间
+                                        self.SENSOR_time = time_tmp#防止改变时间的时候正在开启测量突然10s就停止测量
+                                        if self.get_hr_state == 2 and self.HR_state == 1:#自动检测的心率还在测量立马关了测试
                                             heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
                                             if heart_value > 50 and heart_value != None:
                                                 EventMesh.publish("set_old_hr_data",heart_value)
                                                 EventMesh.publish("set_history_hr_value",heart_value)
                                                 EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)
-                                            
-                                        elif self.get_spo2_state == 3:
-                                            EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+                                            print("stop debug1")
+                                            EventMesh.publish(constants.EVENT.STOP_HEART)
+                                            self.HR_state = 0
+                                        elif self.get_spo2_state == 2 and self.HR_state == 2:
+                                            self.HR_state = 0
                                             spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
                                             if spo2_value > 85 and spo2_value != None:
-                                                EventMesh.publish("set_history_spo2_value",spo2_value)
                                                 EventMesh.publish("set_old_spo2_data",spo2_value)
+                                                EventMesh.publish("set_history_spo2_value",spo2_value)
                                                 EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-
-                                        self.HR_state = 0
-                                        self.SENSOR_time = time_tmp
-                                    self.SENSOR_time = time_tmp
-                                    self.HR_state = 0
-                                
-                            #print("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state))
-                            if (time_tmp - self.SENSOR_time) == 0 and self.HR_state == 0:
-                                print("START_HEART:1")
-                                EventMesh.publish("set_hr_state",2)#2代表后台进入测试
-                                EventMesh.publish(constants.EVENT.START_HEART)
-                                self.HR_state = 1
-                                self.HR_Onestate = 0
-                                self.HR_OneTime = 0
-                            elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_state == 1:
-                                EventMesh.publish("set_hr_state",0)#2代表后台进入测试
-                                print("stop debug3")
-                                EventMesh.publish(constants.EVENT.STOP_HEART)
-                                heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                                print("heart_value:{}".format(heart_value))
-                                if heart_value > 50 and heart_value != None:
-                                    EventMesh.publish("set_old_hr_data",heart_value)
-                                    EventMesh.publish("set_history_hr_value",heart_value)
-                                    EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
-                                #获取心率数据上传数据app
-                                print("STOP_HEART:")
-                            
-                                self.HR_state = 3
-                                # EventMesh.publish("set_spo2_state",2)#2代表后台进入血氧测试
-                                # EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
-                                # print("START_BLOOD_OXYGEN:")
-                            # elif (time_tmp - self.SENSOR_time) >= 120 and self.HR_state == 2:#有需要再打开
-                            #     print("STOP_BLOOD_OXYGEN:")
-                            #     EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                            #     EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试
-                            #     spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-                            #     print("spo2_value:{}".format(spo2_value))
-                            #     if spo2_value > 85 and spo2_value != None:
-                            #         EventMesh.publish("set_old_spo2_data",spo2_value)
-                            #         EventMesh.publish("set_history_spo2_value",spo2_value)
-                            #         EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-                            #     self.HR_state = 3
-                        else:
-                            self.HR_state = 0
-                            self.old_time = self.mearsure_timer
-
-                        if self.HR_state == 3 or self.HR_state == 0:#只有不在测量的时候才测单次的
-                            if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量
-                                self.HR_state = 0
-                                self.HR_OneTime+=1
-                                if self.HR_OneTime == 1 and self.HR_Onestate == 0:
-                                    print("hr..........\r\n")
-                                    if self.get_hr_state == 3:
-                                        self.Hr_Need_Open = 1
-                                        EventMesh.publish("set_hr_state",3)#2代表后台进入测试
+                                            EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+                                    self.old_time = self.mearsure_timer
+
+                                    if self.HR_state == 3 or self.HR_state == 0:#
+                                        if (time_tmp - self.SENSOR_time) >= self.mearsure_timer:
+                                            if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量没有完毕优先测量间隔时间测量的
+                                                if self.get_hr_state == 3:
+                                                    print("stop debug2")
+                                                    EventMesh.publish(constants.EVENT.STOP_HEART)
+                                                    heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                                                    if heart_value > 50 and heart_value != None:
+                                                        EventMesh.publish("set_old_hr_data",heart_value)
+                                                        EventMesh.publish("set_history_hr_value",heart_value)
+                                                        EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)
+                                                    
+                                                elif self.get_spo2_state == 3:
+                                                    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("set_history_spo2_value",spo2_value)
+                                                        EventMesh.publish("set_old_spo2_data",spo2_value)
+                                                        EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+
+                                                self.HR_state = 0
+                                                self.SENSOR_time = time_tmp
+                                            self.SENSOR_time = time_tmp
+                                            self.HR_state = 0
+                                        
+                                    #print("time_tmp :{} self.SENSOR_time :{} time_tmp - self.SENSOR_time:{} self.HR_state:{}".format(time_tmp,self.SENSOR_time,time_tmp - self.SENSOR_time,self.HR_state))
+                                    if (time_tmp - self.SENSOR_time) == 0 and self.HR_state == 0:
+                                        print("START_HEART:1")
+                                        EventMesh.publish("set_hr_state",2)#2代表后台进入测试
                                         EventMesh.publish(constants.EVENT.START_HEART)
-                                    else:
-                                        self.Hr_Need_Open = 0
-
-                                    if self.get_spo2_state == 3 and self.Hr_Need_Open == 0:
-                                        self.Spo2_Need_Open = 1
-                                        EventMesh.publish("set_spo2_state",3)#2代表后台进入测试
-                                        EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
-                                    else:
-                                        self.Spo2_Need_Open = 0
-                                    self.HR_Onestate = 1
-                                    # print("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
-                                elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
-                                    # print("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
-                                    if self.Hr_Need_Open == 1:#需要关闭心率测量
-                                        print("stop debug4")
+                                        self.HR_state = 1
+                                        self.HR_Onestate = 0
+                                        self.HR_OneTime = 0
+                                    elif (time_tmp - self.SENSOR_time) >= 60 and self.HR_state == 1:
+                                        EventMesh.publish("set_hr_state",0)#2代表后台进入测试
+                                        print("stop debug3")
                                         EventMesh.publish(constants.EVENT.STOP_HEART)
                                         heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                                        print("heart_value:{}".format(heart_value))
                                         if heart_value > 50 and heart_value != None:
+                                            EventMesh.publish("set_old_hr_data",heart_value)
                                             EventMesh.publish("set_history_hr_value",heart_value)
                                             EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
-                                            EventMesh.publish("set_old_hr_data",heart_value)
-                                
-                                        if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3:
-                                            EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试
-                                            EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
-                                            
-                                            self.HR_Onestate = 2
-                                            self.set_hsenor_crt = 2#血氧关闭
-                                        else:
-                                            self.HR_Onestate = 0
-                                            self.HR_OneTime = 0
-                                            self.set_hsenor_crt = 0#
-                                        
-                                            EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
-                                            EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                    else:
-                                        if self.Spo2_Need_Open == 1:#停止测试血氧
-                                            EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                            EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧
-                                            spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-                                        
-                                            if spo2_value > 85 and spo2_value != None:
-                                                EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-                                                EventMesh.publish("set_old_spo2_data",spo2_value)
-                                                EventMesh.publish("set_history_spo2_value",spo2_value)
-                                            if self.Hr_Need_Open == 0 and self.get_hr_state == 3:
+                                        #获取心率数据上传数据app
+                                        print("STOP_HEART:")
+                                    
+                                        self.HR_state = 3
+                                        # EventMesh.publish("set_spo2_state",2)#2代表后台进入血氧测试
+                                        # EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+                                        # print("START_BLOOD_OXYGEN:")
+                                    # elif (time_tmp - self.SENSOR_time) >= 120 and self.HR_state == 2:#有需要再打开
+                                    #     print("STOP_BLOOD_OXYGEN:")
+                                    #     EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                    #     EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#停止血氧测试
+                                    #     spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+                                    #     print("spo2_value:{}".format(spo2_value))
+                                    #     if spo2_value > 85 and spo2_value != None:
+                                    #         EventMesh.publish("set_old_spo2_data",spo2_value)
+                                    #         EventMesh.publish("set_history_spo2_value",spo2_value)
+                                    #         EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+                                    #     self.HR_state = 3
+                                else:
+                                    self.HR_state = 0
+                                    self.old_time = self.mearsure_timer
+
+                                if self.HR_state == 3 or self.HR_state == 0:#只有不在测量的时候才测单次的
+                                    if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量
+                                        self.HR_state = 0
+                                        self.HR_OneTime+=1
+                                        if self.HR_OneTime == 1 and self.HR_Onestate == 0:
+                                            print("hr..........\r\n")
+                                            if self.get_hr_state == 3:
+                                                self.Hr_Need_Open = 1
                                                 EventMesh.publish("set_hr_state",3)#2代表后台进入测试
                                                 EventMesh.publish(constants.EVENT.START_HEART)
-                                                self.HR_Onestate = 2
-                                                self.set_hsenor_crt = 1#心率
                                             else:
-                                                self.HR_Onestate = 0
-                                                self.HR_OneTime = 0
-                                                self.set_hsenor_crt = 2#血氧关闭
-                                            
-                                            
-                                elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
-                                    print("HR_OneTime:....05")
-                                    if self.set_hsenor_crt == 2:
-                                        EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                        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("set_history_spo2_value",spo2_value)
-                                            EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-                                            EventMesh.publish("set_old_spo2_data",spo2_value)
-                                    elif self.set_hsenor_crt == 1:
-                                        EventMesh.publish("set_hr_state",0)#0代表g关闭测试
-                                        print("stop debug5")
-                                        EventMesh.publish(constants.EVENT.STOP_HEART)
-                                        heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                                        if heart_value > 50 and heart_value != None:
-                                            EventMesh.publish("set_history_hr_value",heart_value)
-                                            EventMesh.publish("set_old_hr_data",heart_value)
-                                            EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
-                                    self.HR_Onestate = 0
-                            else:
-                                if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量
-                                    if self.get_hr_state == 2:
-                                        EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
-                                        EventMesh.publish(constants.EVENT.STOP_HEART)
-                                    elif self.get_spo2_state == 2:
-                                        EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                        EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-                                self.HR_state = 0
-                                self.HR_Onestate = 0
-                                self.HR_OneTime = 0
-                                self.set_hsenor_crt = 0
-                else:
-                    #print("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate))
-                    self.SENSOR_time = time_tmp#进入最后一次的时间戳
-                    self.old_time = 0
-
-                    self.set_hsenor_crt = 0
-                    if self.get_hr_state != 1 and self.get_spo2_state != 1:#没有设置间隔时间单次测量
-                        if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量
-                            self.HR_state = 0
-                            self.HR_OneTime+=1
-                            if self.HR_OneTime == 1 and self.HR_Onestate == 0:
-                                if self.get_hr_state == 3:
-                                    self.Hr_Need_Open = 1
-                                    EventMesh.publish("set_hr_state",3)#2代表后台进入测试
-                                    EventMesh.publish(constants.EVENT.START_HEART)
-                                else:
-                                    self.Hr_Need_Open = 0
+                                                self.Hr_Need_Open = 0
 
-                                if self.get_spo2_state == 3 and self.Hr_Need_Open == 0:
-                                    self.Spo2_Need_Open = 1
-                                    EventMesh.publish("set_spo2_state",3)#2代表后台进入测试
-                                    EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
-                                else:
-                                    self.Spo2_Need_Open = 0
-                                self.HR_Onestate = 1
-                        
-                            elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
-                                print("stop_heart Onec ")
-                                if self.Hr_Need_Open == 1:#需要关闭心率测量
-                                    print("stop debug6")
-                                    EventMesh.publish(constants.EVENT.STOP_HEART)
-                                    heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
-                                    print("stop_heart heart_value:{}".format(heart_value))
-                                    if heart_value > 50 and heart_value != None:
-                                        EventMesh.publish("set_old_hr_data",heart_value)
-                                        EventMesh.publish("set_history_hr_value",heart_value)
-                                        EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
-                                    if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3:
-                                        EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试
-                                        EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
-                                        self.HR_Onestate = 2
-                                        self.set_hsenor_crt = 2#血氧关闭
+                                            if self.get_spo2_state == 3 and self.Hr_Need_Open == 0:
+                                                self.Spo2_Need_Open = 1
+                                                EventMesh.publish("set_spo2_state",3)#2代表后台进入测试
+                                                EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+                                            else:
+                                                self.Spo2_Need_Open = 0
+                                            self.HR_Onestate = 1
+                                            # print("self.HR_Onestate....3..:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
+                                        elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
+                                            # print("self.HR_Onestate...4....:{} {} {} {} {}".format(self.HR_Onestate,self.get_hr_state,self.get_spo2_state,self.Hr_Need_Open,self.Spo2_Need_Open))
+                                            if self.Hr_Need_Open == 1:#需要关闭心率测量
+                                                print("stop debug4")
+                                                EventMesh.publish(constants.EVENT.STOP_HEART)
+                                                heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                                                if heart_value > 50 and heart_value != None:
+                                                    EventMesh.publish("set_history_hr_value",heart_value)
+                                                    EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+                                                    EventMesh.publish("set_old_hr_data",heart_value)
+                                        
+                                                if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3:
+                                                    EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试
+                                                    EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+                                                    
+                                                    self.HR_Onestate = 2
+                                                    self.set_hsenor_crt = 2#血氧关闭
+                                                else:
+                                                    self.HR_Onestate = 0
+                                                    self.HR_OneTime = 0
+                                                    self.set_hsenor_crt = 0#
+                                                
+                                                    EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+                                                    EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                            else:
+                                                if self.Spo2_Need_Open == 1:#停止测试血氧
+                                                    EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                                    EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧
+                                                    spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+                                                
+                                                    if spo2_value > 85 and spo2_value != None:
+                                                        EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+                                                        EventMesh.publish("set_old_spo2_data",spo2_value)
+                                                        EventMesh.publish("set_history_spo2_value",spo2_value)
+                                                    if self.Hr_Need_Open == 0 and self.get_hr_state == 3:
+                                                        EventMesh.publish("set_hr_state",3)#2代表后台进入测试
+                                                        EventMesh.publish(constants.EVENT.START_HEART)
+                                                        self.HR_Onestate = 2
+                                                        self.set_hsenor_crt = 1#心率
+                                                    else:
+                                                        self.HR_Onestate = 0
+                                                        self.HR_OneTime = 0
+                                                        self.set_hsenor_crt = 2#血氧关闭
+                                                    
+                                                    
+                                        elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
+                                            print("HR_OneTime:....05")
+                                            if self.set_hsenor_crt == 2:
+                                                EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                                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("set_history_spo2_value",spo2_value)
+                                                    EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+                                                    EventMesh.publish("set_old_spo2_data",spo2_value)
+                                            elif self.set_hsenor_crt == 1:
+                                                EventMesh.publish("set_hr_state",0)#0代表g关闭测试
+                                                print("stop debug5")
+                                                EventMesh.publish(constants.EVENT.STOP_HEART)
+                                                heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                                                if heart_value > 50 and heart_value != None:
+                                                    EventMesh.publish("set_history_hr_value",heart_value)
+                                                    EventMesh.publish("set_old_hr_data",heart_value)
+                                                    EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+                                            self.HR_Onestate = 0
                                     else:
+                                        if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量
+                                            if self.get_hr_state == 2:
+                                                EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+                                                EventMesh.publish(constants.EVENT.STOP_HEART)
+                                            elif self.get_spo2_state == 2:
+                                                EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                                EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+                                        self.HR_state = 0
                                         self.HR_Onestate = 0
                                         self.HR_OneTime = 0
-                                        self.set_hsenor_crt = 0#
-                                        EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
-                                        EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                else:
-                                    if self.Spo2_Need_Open == 1:#停止测试血氧
-                                        EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                        EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧
-                                        spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
-                                        print("spo2_value:{}.......01..".format(spo2_value))
-                                        if spo2_value > 85 and spo2_value != None:
-                                            EventMesh.publish("set_old_spo2_data",spo2_value)
-                                            EventMesh.publish("set_history_spo2_value",spo2_value)
-                                            EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-                                        if self.Hr_Need_Open == 0 and self.get_hr_state == 3:
+                                        self.set_hsenor_crt = 0
+                        else:
+                            #print("hr......01....{} {} self.HR_Onestate {} {}".format(self.get_hr_state,self.get_spo2_state,self.HR_OneTime,self.HR_Onestate))
+                            self.SENSOR_time = time_tmp#进入最后一次的时间戳
+                            self.old_time = 0
+
+                            self.set_hsenor_crt = 0
+                            if self.get_hr_state != 1 and self.get_spo2_state != 1:#没有设置间隔时间单次测量
+                                if self.get_spo2_state == 3 or self.get_hr_state == 3:#单次测量
+                                    self.HR_state = 0
+                                    self.HR_OneTime+=1
+                                    if self.HR_OneTime == 1 and self.HR_Onestate == 0:
+                                        if self.get_hr_state == 3:
+                                            self.Hr_Need_Open = 1
                                             EventMesh.publish("set_hr_state",3)#2代表后台进入测试
                                             EventMesh.publish(constants.EVENT.START_HEART)
-                                            self.HR_Onestate = 2
-                                            self.set_hsenor_crt = 1#心率
                                         else:
-                                            self.HR_Onestate = 0
-                                            self.HR_OneTime = 0
-                                            self.set_hsenor_crt = 2#血氧关闭
-                                        print("STOP_BLOOD_OXYGEN:....06.....")
-                                        
-                            elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
-                                if self.set_hsenor_crt == 2:
-                                    EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                    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("set_old_spo2_data",spo2_value)
-                                        EventMesh.publish("set_history_spo2_value",spo2_value)
-                                        EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
-                                elif self.set_hsenor_crt == 1:
-                                    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("set_old_hr_data",heart_value)
-                                        EventMesh.publish("set_history_hr_value",heart_value)
-                                        EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
-                                self.HR_Onestate = 0
-                        else:
-                            if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量
-                                if self.get_hr_state == 2:
-                                    EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
-                                    EventMesh.publish(constants.EVENT.STOP_HEART)
-                                elif self.get_spo2_state == 2:
-                                    EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
-                                    EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
-                            self.HR_Onestate = 0
-                            self.HR_OneTime = 0
-                            self.old_time = 0
+                                            self.Hr_Need_Open = 0
+
+                                        if self.get_spo2_state == 3 and self.Hr_Need_Open == 0:
+                                            self.Spo2_Need_Open = 1
+                                            EventMesh.publish("set_spo2_state",3)#2代表后台进入测试
+                                            EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+                                        else:
+                                            self.Spo2_Need_Open = 0
+                                        self.HR_Onestate = 1
+                                
+                                    elif self.HR_OneTime > 6 and self.HR_Onestate == 1:
+                                        print("stop_heart Onec ")
+                                        if self.Hr_Need_Open == 1:#需要关闭心率测量
+                                            print("stop debug6")
+                                            EventMesh.publish(constants.EVENT.STOP_HEART)
+                                            heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+                                            print("stop_heart heart_value:{}".format(heart_value))
+                                            if heart_value > 50 and heart_value != None:
+                                                EventMesh.publish("set_old_hr_data",heart_value)
+                                                EventMesh.publish("set_history_hr_value",heart_value)
+                                                EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+                                            if self.Spo2_Need_Open == 0 and self.get_spo2_state == 3:
+                                                EventMesh.publish("set_spo2_state",3)#2代表后台进入血氧测试
+                                                EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)#K开血氧
+                                                self.HR_Onestate = 2
+                                                self.set_hsenor_crt = 2#血氧关闭
+                                            else:
+                                                self.HR_Onestate = 0
+                                                self.HR_OneTime = 0
+                                                self.set_hsenor_crt = 0#
+                                                EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+                                                EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                        else:
+                                            if self.Spo2_Need_Open == 1:#停止测试血氧
+                                                EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                                EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)#K开血氧
+                                                spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+                                                print("spo2_value:{}.......01..".format(spo2_value))
+                                                if spo2_value > 85 and spo2_value != None:
+                                                    EventMesh.publish("set_old_spo2_data",spo2_value)
+                                                    EventMesh.publish("set_history_spo2_value",spo2_value)
+                                                    EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+                                                if self.Hr_Need_Open == 0 and self.get_hr_state == 3:
+                                                    EventMesh.publish("set_hr_state",3)#2代表后台进入测试
+                                                    EventMesh.publish(constants.EVENT.START_HEART)
+                                                    self.HR_Onestate = 2
+                                                    self.set_hsenor_crt = 1#心率
+                                                else:
+                                                    self.HR_Onestate = 0
+                                                    self.HR_OneTime = 0
+                                                    self.set_hsenor_crt = 2#血氧关闭
+                                                print("STOP_BLOOD_OXYGEN:....06.....")
+                                                
+                                    elif self.HR_OneTime > 6+6 and self.HR_Onestate == 2:
+                                        if self.set_hsenor_crt == 2:
+                                            EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                            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("set_old_spo2_data",spo2_value)
+                                                EventMesh.publish("set_history_spo2_value",spo2_value)
+                                                EventMesh.publish(constants.PROTOCOL.OXYGEN_SEND,spo2_value)
+                                        elif self.set_hsenor_crt == 1:
+                                            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("set_old_hr_data",heart_value)
+                                                EventMesh.publish("set_history_hr_value",heart_value)
+                                                EventMesh.publish(constants.PROTOCOL.HEART_SEND,heart_value)#上传心率数据
+                                        self.HR_Onestate = 0
+                                else:
+                                    if self.get_spo2_state == 2 or self.get_hr_state == 2:#单次测量
+                                        if self.get_hr_state == 2:
+                                            EventMesh.publish("set_hr_state",0)#2代表后台进入血氧测试
+                                            EventMesh.publish(constants.EVENT.STOP_HEART)
+                                        elif self.get_spo2_state == 2:
+                                            EventMesh.publish("set_spo2_state",0)#2代表后台进入血氧测试
+                                            EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+                                    self.HR_Onestate = 0
+                                    self.HR_OneTime = 0
+                                    self.old_time = 0
+                    else:
+                        self.old_temp_time = 0
+                        self.old_time = 0
+                        self.SENSOR_time = time_tmp
+                        self.HR_Onestate = 0
+                        self.HR_OneTime = 0
+                        self.HR_state = 0
+                        self.old_time = 0    
+                        self.set_hsenor_crt = 0
+        
         else:
-            self.old_temp_time = 0
-            self.old_time = 0
             if battery[0] == "1":
                 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_bp_state  = EventMesh.publish("get_bp_state")
+                if get_hr_state != None and get_spo2_state != None and get_bp_state != None:
                     if get_hr_state == 2 or get_hr_state == 3:
                         EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率 
                         print("stop debug8")
@@ -1499,6 +1551,11 @@ class DeviceInfoManager(Abstract):
                     elif get_spo2_state == 2 or get_spo2_state == 3:
                         EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
                         EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+                        print("stop debug13")
+                    elif get_bp_state == 2 or get_bp_state == 3:
+                        EventMesh.publish("set_bp_state",0)#2代表后台进入测试
+                        EventMesh.publish(constants.EVENT.STOP_HEART)
+                        print("stop debug14")
                 
                 if get_temp_time != None:
                     get_temp_state  = EventMesh.publish("get_temp_state")
@@ -1528,12 +1585,15 @@ class DeviceInfoManager(Abstract):
                                 num = str(tmp_f_tmp)+"."+ str(tmp_d_tmp)
                                 EventMesh.publish(constants.PROTOCOL.BTEMP2_SEND,[1,num])
                         EventMesh.publish(constants.EVENT.STOP_TEMP)
+            self.old_temp_time = 0
+            self.old_time = 0
             self.SENSOR_time = time_tmp
             self.HR_Onestate = 0
             self.HR_OneTime = 0
             self.HR_state = 0
             self.old_time = 0    
             self.set_hsenor_crt = 0
+            self.old_bp_time = 0
 
         
         #quecgnss.gnssEnable(0)  
@@ -2559,6 +2619,7 @@ class gethistoryDataManager(Abstract):
                 ujson.dump(self.read_histroy_blood_data,fd)
             print(self.read_histroy_blood_data)
             EventMesh.publish("show_history_blood_data")
+            EventMesh.publish("set_oldblood_value",[self.blMax,self.blMin])
 
     def get_old_blood_data(self, event, msg): #近7次血压历史数据统计显示
         if self.read_histroy_blood_data:
@@ -2799,6 +2860,13 @@ class getTempTimeManager(Abstract):
 
         if read_data != None:
             self.set_time = read_data
+
+        self.set_bptime = 0
+        self.get_bpstate = 0
+        read_data = EventMesh.publish("get_storage_config","bp_time")
+
+        if read_data != None:
+            self.set_bptime = read_data
  
 
     def post_processor_after_instantiation(self):
@@ -2808,6 +2876,30 @@ class getTempTimeManager(Abstract):
         EventMesh.subscribe("set_temp_state", self.set_temp_state)
         EventMesh.subscribe("get_temp_state", self.get_temp_state)
 
+        EventMesh.subscribe("set_bp_time", self.set_bp_time)
+        EventMesh.subscribe("get_bp_time", self.get_bp_time)
+
+        EventMesh.subscribe("set_bp_state", self.set_bp_state)
+        EventMesh.subscribe("get_bp_state", self.get_bp_state)
+
+    def set_bp_time(self, event, msg): 
+        self.set_bptime = msg
+        EventMesh.publish("set_storage_config",["bp_time",self.set_time])
+
+    def get_bp_time(self, event, msg): 
+        if self.set_bptime:
+            return self.set_bptime
+        else :
+            return 0
+        
+    def set_bp_state(self, event, msg): 
+        self.get_bpstate = msg
+
+    def get_bp_state(self, event, msg): 
+        if self.get_bpstate:
+            return self.get_bpstate
+        else :
+            return 0
 
     def set_temp_time(self, event, msg): 
         self.set_time = msg
@@ -3210,7 +3302,71 @@ class testSmsSetIPManager(Abstract):#
         if(tmp_data != None):
             return [self.newip,self.newcom]
 
+class schoolclassManager(Abstract):#
+    def __init__(self):
+        # ['火星情报局', '一年级二班', '柠檬茶']
+        self.school_name = ''
+        self.class_name = ''
+        self.full_name = ''
+        tmp_data = EventMesh.publish("get_storage_config","school_name")
+        if tmp_data != None:
+            self.school_name = tmp_data
+        tmp_data = EventMesh.publish("get_storage_config","class_name")
+        if tmp_data != None:
+            self.class_name = tmp_data
+        tmp_data = EventMesh.publish("get_storage_config","full_name")
+        if tmp_data != None:
+            self.full_name = tmp_data    
 
+        
+
+    def post_processor_after_instantiation(self):
+        EventMesh.subscribe("set_schoolname", self.set_school_name)#设置关机时间
+        EventMesh.subscribe("get_schoolname", self.get_school_name)
+
+        EventMesh.subscribe("set_classname", self.set_classname)#设置关机时间
+        EventMesh.subscribe("get_classname", self.get_classname)
+
+        EventMesh.subscribe("set_fullname", self.set_full_name)#设置关机时间
+        EventMesh.subscribe("get_fullname", self.get_full_name)
+
+    def set_school_name(self, event, msg): 
+        if msg != None:
+            if len(msg) != 0:
+                self.school_name = str(msg)
+                EventMesh.publish("set_storage_config",["school_name",str(msg)])
+        
+
+    def get_school_name(self, event, msg):
+        if self.school_name:
+            return self.school_name
+        else:
+            return None
+    
+    def set_classname(self, event, msg): 
+        if msg != None:
+            if len(msg) != 0:
+                self.class_name = str(msg)
+                EventMesh.publish("set_storage_config",["class_name",str(msg)])
+            
+        
+    def get_classname(self, event, msg):
+        if self.class_name:
+            return self.class_name
+        else:
+            return None
+    def set_full_name(self, event, msg): 
+        if msg != None:
+            if len(msg) != 0:
+                self.full_name = str(msg)
+                EventMesh.publish("set_storage_config",["full_name",str(msg)])
+
+    def get_full_name(self, event, msg):
+        if self.full_name:
+            return self.full_name
+        else:
+            return None
+    
 class setCallStateManager(Abstract):#设置电话通话状态
     def __init__(self):
         self.call_state = 0
index 159ff9e..7586d85 100644 (file)
@@ -30,7 +30,7 @@ def server_init(server_type = None):
     d_server_addr = "api.xcloudtech.com"
     d_server_port = 9000
     d_md5_key = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
-    d_PID = "SZKW"
+    d_PID = "SZKW" 
     if server_type == 1:
         pass
         # server_addr = "api.xcloudtech.com"
@@ -1012,6 +1012,92 @@ class TEMP_ProtoCol(ProtoCol):
         # print("HRSTART_ProtoCol RECV msg:")
         #EventMesh.publish(constants.PROTOCOL.TEMP_SEND)
 
+# 设置血压上传频率
+# 平台发送[XT*YYYYYYYYYYYYYYY*LEN*bldstart,x]
+# x为上传间隔时间,单位秒,连续上传时最小时间不小于300秒,最大不超过65535.
+# 示例[XT*334588000000156*0008*bldstart,300]
+# 终端回复:
+# [XT*334588000000156*0005*bldstart]
+# x为1则代表终端单次上传。
+# x为0则代表终端上传关闭。
+class bldstart_ProtoCol(ProtoCol):
+    """app下发血压测试频率"""
+    TYPE = "bldstart"
+    def send(self, event, msg):
+        #[XT*334588000000156*len*wdstart,300]
+        send_data = self.PID+"*%s*0008*bldstart"%(self.imei)
+        MD5_SIGN = self.pack_MD5_head(send_data)
+        data = "[%s%s]"%(str(MD5_SIGN),send_data)
+        # print("temp:data:%s"%(data))
+        # 通过socket发送到服务器端
+        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+    def recv(self, event, msg):
+        """
+        @param event: 体温下发频率数据
+        @param msg: 接收到的下行数据
+        """
+        # print("WDSTART_ProtoCol RECV msg:")
+        print("bldstart:{}".format(msg))
+        msg = msg[1:-1]
+        msg_tmp = msg.decode('ascii')
+        msg_tmp = msg_tmp.split(',')
+        msg_tmp = msg_tmp[1]
+
+        bldstartTotal = int(msg_tmp)
+        print("bldstartTotal:{}".format(bldstartTotal))
+        if bldstartTotal == 1:#单次测量
+            get_bp_state = EventMesh.publish("get_bp_state")
+            get_hr_state = EventMesh.publish("get_hr_state")
+            get_spo2_state = EventMesh.publish("get_spo2_state")
+            print("get_bp_state:{}".format(get_bp_state))
+            if get_bp_state == 0 and get_hr_state == 0 and get_spo2_state == 0:#只要两个不在测量 单次优先级最低
+                EventMesh.publish("set_bp_state",3)#3代表单次测量
+        else:
+            if bldstartTotal > 0 and bldstartTotal <= 300:
+                bldstartTotal = 300
+            elif bldstartTotal >= 65536:
+                bldstartTotal = 65536
+            EventMesh.publish("set_bp_time", bldstartTotal)
+           
+        EventMesh.publish(constants.PROTOCOL.BLDSTART_SEND)
+
+
+# 注:回复完后开始测量血压并上传(一般测一次90秒,app端会提醒用户两分钟后刷新页面查看)
+# 上传血压数据
+# 终端发送[XT*YYYYYYYYYYYYYYY*LEN*blood,x,y]
+# x 是收缩压(高压)
+# y 是舒张压(低压)
+# 示例[XT*334588000000156*000C*blood,150,70]
+# 平台回复:
+# [XT*334588000000156*0005*blood]
+class blood_ProtoCol(ProtoCol):
+    """上传血压测试数据"""
+    TYPE = "blood"
+    def send(self, event, msg):
+        len_size = len(str(msg[0]))+len("blood,")+1+len(str(msg[1]))
+        print("blood:send:{} len:{}".format(msg,len_size))
+        #  实例:[XT*334588000000156*0009*blood,36,2]
+        # 代表终端的
+        # 平台回复:
+        # [XT*334588000000156*0004*blood]
+        send_data = self.PID+"*%s*%04X*blood"%(self.imei,len_size)
+        MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,len_size,"blood")
+        MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+        data = "[%s%s,%d,%d]"%(str(MD5_SIGN),send_data,msg[0],msg[1])
+        print("blood:data:%s"%(data))
+        # 通过socket发送到服务器端
+        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+        
+    def recv(self, event, msg):
+        """
+        @param event: 
+        @param msg: 接收到的下行数据
+        """
+        # print("HRSTART_ProtoCol RECV msg:")
+        #EventMesh.publish(constants.PROTOCOL.TEMP_SEND)
+
+
 
 class TEMP_Hour_ProtoCol(ProtoCol): #云米服务独立指令体温
     """上传体温频率 小时单位"""
@@ -1340,7 +1426,7 @@ class sosHome_dial_ProtoCol(ProtoCol):
             EventMesh.publish("set_dial_sos_number",[msg_tmp[1]])
              
         EventMesh.publish(constants.PROTOCOL.SOS_SEND)  
-  
+
 # 低电提醒
 #[XT*334588000000156*0008*LOWBAT,1]
 class LOWBAT_ProtoCol(ProtoCol):
@@ -1608,7 +1694,6 @@ class SILENCETIME2_ProtoCol(ProtoCol):
         EventMesh.publish("get_class_in_time_page")
 #键盘开关
 
-#键盘开关
 class KEYBRD_ProtoCol(ProtoCol):
     """免打扰"""
     TYPE = "KEYBRD"
@@ -1631,6 +1716,69 @@ class KEYBRD_ProtoCol(ProtoCol):
         # print("KEYBRD!!!!!!!!!!!!!",msg)
         EventMesh.publish(constants.PROTOCOL.KEYBRD_SEND)  
 
+
+
+
+# 平台发送:
+# [XT*YYYYYYYYYYYYYYY*LEN*SCREEN_SHOW,参数内容]
+# 实例:[XT*334588000000156*0016*SCREEN_SHOW,00000000000]
+# 参数内容用 unicode 编码呈现,设备收到后需解码。
+# 解码后的参数内容可能有多个参数,不同参数用逗号分隔,设备自己决定如何在屏幕中显示这些参数。比如 "SCREEN_SHOW,深圳第一中学,三年1班、张三"
+# 终端回复:
+# [XT*YYYYYYYYYYYYYYY*LEN*SCREEN_SHOW]
+# 实例:[XT*334588000000156*000B*SCREEN_SHOW]
+
+class SCREEN_SHOWProtoCol(ProtoCol):
+    """开屏显示"""
+    TYPE = "SCREEN_SHOW"
+    def send(self, event, msg):
+        # [XT*334588000000156*0006*SILENCETIME2]
+        send_data = self.PID+"*%s*000B*SCREEN_SHOW"%(self.imei)
+        MD5_SIGN = self.pack_MD5_head(send_data)
+        data = "[%s%s]"%(str(MD5_SIGN),send_data)
+        # print("KEYBRD:data:%s"%(data))
+        # print("KEYBRD!!!!!!!!!!!!!",msg)
+        # 通过socket发送到服务器端
+        EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
+
+    def recv(self, event, msg):
+        """
+        @param event:
+        @param msg: 接收到的下行数据
+        """
+        msg = msg[1:-1]
+        msg_tmp = msg.decode('ascii')
+        msg_tmp = msg_tmp.split(',')
+        msg_tmp = msg_tmp[1:]
+        msg_tmp = msg_tmp[0]
+
+        j = 0
+        i = 0
+        videobook_old = {}
+        videobook_name_tmp = UnicodeHexStr_To_Utf8Str(msg_tmp)
+        lst = videobook_name_tmp.split(",")
+        print("lst data",lst)
+
+         # 0 1 2 3
+        screen_school_data = ""#学校
+        screen_class_data = ""#班级
+        screen_fullname_data = ""#姓名
+        if len(lst) != 0: 
+            screen_school_data = lst[0]
+            screen_class_data = lst[1]
+            screen_fullname_data= lst[2]
+            EventMesh.publish("set_schoolname", screen_school_data)#
+            EventMesh.publish("set_classname", screen_class_data)#
+            EventMesh.publish("set_fullname", screen_fullname_data)#
+            EventMesh.publish("update_screen_show")#更新开屏显示
+
+        print("screen_school_data!!!:",screen_school_data,screen_class_data,screen_fullname_data)
+
+        EventMesh.publish(constants.PROTOCOL.SCREEN_SHOW_SEND)  
+
+
+
+
 class ProtoColResolver(object):
     def __init__(self):
         self.protocol_list = []
index 57c6fe1..927e183 100644 (file)
@@ -133,6 +133,11 @@ 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_font_youyuan_20_white = lv.style_t()
+style_font_youyuan_20_white.init()
+style_font_youyuan_20_white.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_20_white.set_text_font_v2("font_28.bin",28,0)
+
 style_img = lv.style_t()
 style_img.init()
 style_img.set_img_opa(255)
@@ -241,6 +246,7 @@ class Screen(Abstract):
         return self.meta
 
     def Close(self):
+        
         pass
     def lcd_on(self):
         pass
@@ -467,37 +473,37 @@ class PhoneScreen(Screen):
             self.meta = phone_screen
 
             phone_one.add_event_cb(lambda e: EventMesh.callback_wrapper(self.one(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
             # phone_one.add_event_cb(lambda e: EventMesh.callback_wrapper(self.one(e)),
             #                          lv.EVENT.PRESSING, None)
 
             phone_two.add_event_cb(lambda e: EventMesh.callback_wrapper(self.two(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             # phone_two.add_event_cb(lambda e: EventMesh.callback_wrapper(self.two(e)),
             #                             lv.EVENT.PRESSING, None)
             
             phone_three.add_event_cb(lambda e: EventMesh.callback_wrapper(self.three(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             # phone_three.add_event_cb(lambda e: EventMesh.callback_wrapper(self.three(e)),
             #                             lv.EVENT.PRESSING, None)
             
             phone_four.add_event_cb(lambda e: EventMesh.callback_wrapper(self.four(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             # phone_four.add_event_cb(lambda e: EventMesh.callback_wrapper(self.four(e)),
             #                             lv.EVENT.PRESSING, None)
             
             phone_five.add_event_cb(lambda e: EventMesh.callback_wrapper(self.five(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             # phone_five.add_event_cb(lambda e: EventMesh.callback_wrapper(self.five(e)),
             #                             lv.EVENT.PRESSING, None)
             
             phone_six.add_event_cb(lambda e: EventMesh.callback_wrapper(self.six(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             # phone_six.add_event_cb(lambda e: EventMesh.callback_wrapper(self.six(e)),
             #                             lv.EVENT.PRESSING, None)
             
             phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven_longpress(e)),
                                         lv.EVENT.LONG_PRESSED, None)
             phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven_release(e)),
@@ -506,12 +512,12 @@ class PhoneScreen(Screen):
             #                             lv.EVENT.PRESSING, None)
             
             phone_eight.add_event_cb(lambda e: EventMesh.callback_wrapper(self.eight(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             # phone_eight.add_event_cb(lambda e: EventMesh.callback_wrapper(self.eight(e)),
             #                             lv.EVENT.PRESSING, None)
             
             phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine_longpress(e)),
                                         lv.EVENT.LONG_PRESSED, None)
             phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine_release(e)),
@@ -520,7 +526,7 @@ class PhoneScreen(Screen):
             #                             lv.EVENT.PRESSING, None)
             
             phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero_longpress(e)),
                                         lv.EVENT.LONG_PRESSED, None)
             phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero_release(e)),
@@ -535,7 +541,7 @@ class PhoneScreen(Screen):
             # # 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)
+                                        lv.EVENT.SHORT_CLICKED, None)
             
             
             # # phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
@@ -1158,8 +1164,6 @@ class DialingScreen(Screen):
             hangup_imgbtn.set_pos(80, 210)
             hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
                                     lv.EVENT.SHORT_CLICKED, None)
-            hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
-                                    lv.EVENT.PRESSING, None)
             self.meta = dialing_screen
         if dialing_name != None:
             name = EventMesh.publish("get_phonename")#获取拨打电话名称
@@ -1171,38 +1175,28 @@ class DialingScreen(Screen):
         
     def hangup(self,e):
         code = e.get_code()
-        if code == lv.EVENT.PRESSING:
-            #print("PRESSING")
-            self.is_sliding += 1
-
-        elif  code == lv.EVENT.SHORT_CLICKED:
-            #utime.sleep_ms(10)
-            print("1self.is_sliding",self.is_sliding)
-            if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
-                self.is_sliding =0
-                EventMesh.publish("set_UI_high_priority", 0)
-                EventMesh.publish("set_hangup_mode", 1)
-                voiceCall.callEnd()
-                EventMesh.publish("set_interrup_incall",0)
-                EventMesh.publish("set_UI_high_priority",0)
-                
-
-                screen_NAME = EventMesh.publish("get_screen_NAME")
-                if screen_NAME != None:
-                    if screen_NAME != "dialing_noplay_popup":
-                        EventMesh.publish("return_prev_screen")
+        if  code == lv.EVENT.SHORT_CLICKED:
+            EventMesh.publish("set_UI_high_priority", 0)
+            EventMesh.publish("set_hangup_mode", 1)
+            voiceCall.callEnd()
+            EventMesh.publish("set_interrup_incall",0)
+            EventMesh.publish("set_UI_high_priority",0)
+            
+            screen_NAME = EventMesh.publish("get_screen_NAME")
+            if screen_NAME != None:
+                if screen_NAME != "dialing_noplay_popup":
+                    EventMesh.publish("return_prev_screen")
                 
-            self.is_sliding =0
        
 
     def Close(self):
         self.timer.stop()
 
     def call_end(self,*argc):
-        call_state = EventMesh.publish("get_call_state")#设置关机时间
+        call_state = EventMesh.publish("get_call_state")#
         if call_state != None:
             if call_state == 0:#未打通
-                EventMesh.publish("load_screen", {"screen": "main_menu"})  
+                EventMesh.publish("return_prev_screen")
 
 
     def done_return(self):
@@ -1668,8 +1662,6 @@ class DialingNoPlayPopupScreen(Screen):#正在拨号中...未打出
             dialing_popup_hangup_imgbtn.set_pos(80, 210)
             dialing_popup_hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
                                     lv.EVENT.SHORT_CLICKED, None)
-            dialing_popup_hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
-                                    lv.EVENT.PRESSING, None)
             self.meta = dialing_popup_screen
         if dialing_popup_name != None:
             name = EventMesh.publish("get_phonename")#获取拨打电话名称
@@ -1755,27 +1747,20 @@ class DialingNoPlayPopupScreen(Screen):#正在拨号中...未打出
         code = e.get_code()
         #print("code!!!!!!!!",code,msg)
         if code == lv.EVENT.PRESSING:
-            #print("PRESSING")
-            self.is_sliding += 1
+            pass
 
         elif  code == lv.EVENT.SHORT_CLICKED:
-            #utime.sleep_ms(10)
-            print("1self.is_sliding",self.is_sliding)
-            if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
-                self.is_sliding =0
-                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("set_interrup_incall",0)
-                EventMesh.publish("set_UI_high_priority",0)
+            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("set_interrup_incall",0)
+            EventMesh.publish("set_UI_high_priority",0)
 
-                EventMesh.publish("return_prev_screen")
-                
-            self.is_sliding =0
+            EventMesh.publish("return_prev_screen")
         
 
     def Close(self):
@@ -2264,7 +2249,7 @@ class PopupScreen(Screen):
 
             self.sms_detail_list = lv.obj(msg_cont_list_screen)
             self.sms_detail_list.set_pos(0, 0)
-            self.sms_detail_list.set_size(LCD_SIZE_W-10, LCD_SIZE_H-50+1)
+            self.sms_detail_list.set_size(LCD_SIZE_W, LCD_SIZE_H-50+1)
             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)
             self.sms_detail_list.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sms_cb(e)),
@@ -2888,9 +2873,11 @@ class IncomingCallScreen(Screen):
         self.read_call_log = {}
         self.number_tmp = {}
         self.meta_type = "popup"
+        self.time_count = 0
         
     def initialization(self):
         self.is_sliding =0
+        self.time_count = 0
         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----------------------------------------------------------
@@ -2925,14 +2912,10 @@ class IncomingCallScreen(Screen):
             incoming_call_hangup.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
             incoming_call_hangup.set_src("E:/static/hang_up.png")
 
-            incoming_call_answer.add_event_cb(lambda e: EventMesh.callback_wrapper(self.answer(e)),
+            incoming_call_answer.add_event_cb(lambda e: EventMesh.callback_wrapper(self.answer_cb(e)),
                                      lv.EVENT.SHORT_CLICKED, None)
-            incoming_call_hangup.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+            incoming_call_hangup.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup_cb(e)),
                                      lv.EVENT.SHORT_CLICKED, None)
-            incoming_call_answer.add_event_cb(lambda e: EventMesh.callback_wrapper(self.answer(e)),
-                                     lv.EVENT.PRESSING, None)
-            incoming_call_hangup.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
-                                     lv.EVENT.PRESSING, None)
             self.meta = incoming_call_screen 
         EventMesh.publish("set_UI_high_priority", 1)
 
@@ -3047,62 +3030,49 @@ class IncomingCallScreen(Screen):
             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.time_count = 0
+        self.call_timer.start(1000, 1, self.call_timer_cb)
         self.aud.play(1, 1, 'U:/static/R_CALL_mp3.mp3')  #播放来电铃声
+        EventMesh.publish("set_motor_time",[1,2,8*20,8,4])#设置马达参数
 
     def call_timer_cb(self,e):
-       self.aud.play(1, 1, 'U:/static/R_CALL_mp3.mp3')  #播放来电铃声
+       EventMesh.publish("system_sleep_rest")#防止黑屏
+       self.time_count+=1
+       if self.time_count % 6 == 0:
+            self.aud.play(1, 1, 'U:/static/R_CALL_mp3.mp3')  #播放来电铃声
 
-    def answer(self,e):
+    def answer_cb(self,e):
         code = e.get_code()
-        if code == lv.EVENT.PRESSING:
-            #print("PRESSING")
-            self.is_sliding += 1
-
-        elif  code == lv.EVENT.SHORT_CLICKED:
-            #utime.sleep_ms(10)
-            print("1self.is_sliding",self.is_sliding)
-            if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
-                self.is_sliding =0
-                self.call_timer.stop()
-                self.aud.stop() 
-                EventMesh.publish("set_UI_high_priority", 0)
-                voiceCall.callAnswer()
+        if code == lv.EVENT.SHORT_CLICKED:
+            self.call_timer.stop()
+            self.aud.stop() 
+            EventMesh.publish("set_UI_high_priority", 0)
+            voiceCall.callAnswer()
+            name = EventMesh.publish("get_phonename")
+            EventMesh.publish("load_screen", {"screen": "on_call","meta":str(name)})
                 
-            self.is_sliding =0
-       
 
     def Close(self):
         self.call_timer.stop()
         self.aud.stop() 
+        EventMesh.publish("close_motor_infor")#设置马达参数
     
-    def hangup(self,e):
+    def hangup_cb(self,e):
         code = e.get_code()
-        if code == lv.EVENT.PRESSING:
-            #print("PRESSING")
-            self.is_sliding += 1
-
-        elif  code == lv.EVENT.SHORT_CLICKED:
+        if  code == lv.EVENT.SHORT_CLICKED:
             #utime.sleep_ms(10)
-            print("1self.is_sliding",self.is_sliding)
-            if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
-                self.is_sliding =0
-                EventMesh.publish("set_UI_high_priority", 0)
-                self.aud.stop()
-                self.call_timer.stop()
-                voiceCall.callEnd()
-                EventMesh.publish("set_interrup_incall",0)
-                EventMesh.publish("set_UI_high_priority",0)
-                
+            EventMesh.publish("set_UI_high_priority", 0)
+            self.aud.stop()
+            self.call_timer.stop()
+            voiceCall.callEnd()
+            EventMesh.publish("set_interrup_incall",0)
+            EventMesh.publish("set_UI_high_priority",0)
+            
 
-                screen_NAME = EventMesh.publish("get_screen_NAME")
-                if screen_NAME != None:
-                    if screen_NAME != "dialing_noplay_popup":
-                        EventMesh.publish("return_prev_screen")
-                
-            self.is_sliding =0
-       
+            screen_NAME = EventMesh.publish("get_screen_NAME")
+            if screen_NAME != None:
+                if screen_NAME != "dialing_noplay_popup":
+                    EventMesh.publish("return_prev_screen")
 
     def btn1_release(self):
         pass
@@ -3313,7 +3283,7 @@ class OnCallScreen(Screen):
             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)
+                                    lv.EVENT.SHORT_CLICKED, None)
             
 
             on_call_phone_one = lv.img(on_call_screen_tab)
@@ -3404,31 +3374,31 @@ class OnCallScreen(Screen):
             
 
             on_call_phone_one.add_event_cb(lambda e: EventMesh.callback_wrapper(self.one(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
             on_call_phone_two.add_event_cb(lambda e: EventMesh.callback_wrapper(self.two(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             on_call_phone_three.add_event_cb(lambda e: EventMesh.callback_wrapper(self.three(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             on_call_phone_four.add_event_cb(lambda e: EventMesh.callback_wrapper(self.four(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             on_call_phone_five.add_event_cb(lambda e: EventMesh.callback_wrapper(self.five(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             on_call_phone_six.add_event_cb(lambda e: EventMesh.callback_wrapper(self.six(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             on_call_phone_seven.add_event_cb(lambda e: EventMesh.callback_wrapper(self.seven(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             
             on_call_phone_eight.add_event_cb(lambda e: EventMesh.callback_wrapper(self.eight(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             on_call_phone_nine.add_event_cb(lambda e: EventMesh.callback_wrapper(self.nine(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             
             
             on_call_phone_zero.add_event_cb(lambda e: EventMesh.callback_wrapper(self.zero(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             
             on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
-                                        lv.EVENT.CLICKED, None)#短按显示* 
+                                        lv.EVENT.SHORT_CLICKED, None)#短按显示* 
             
             on_call_phone_start.add_event_cb(lambda e: EventMesh.callback_wrapper(self.pressed_start(e)),
                                         lv.EVENT.LONG_PRESSED, None)#长按显示+
@@ -3437,7 +3407,7 @@ class OnCallScreen(Screen):
                                         lv.EVENT.RELEASED, None)#释放按键
         
             on_call_phone_hash.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hash(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
         name = EventMesh.publish("get_phonename")
         on_call_label_name.set_text(name)
         # on_call_label.set_text(str(self.meta_info))
@@ -3721,28 +3691,18 @@ class OnCallScreen(Screen):
     
     def hangup(self,e):
         code = e.get_code()
-        if code == lv.EVENT.PRESSING:
-            #print("PRESSING")
-            self.is_sliding += 1
-
-        elif  code == lv.EVENT.SHORT_CLICKED:
-            #utime.sleep_ms(10)
-            print("1self.is_sliding",self.is_sliding)
-            if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件
-                self.is_sliding =0
-                EventMesh.publish("set_UI_high_priority", 0)
-                self.timer.stop()
-                voiceCall.callEnd()
-                EventMesh.publish("set_interrup_incall",0)
-                EventMesh.publish("set_UI_high_priority",0)
-                
-
-                screen_NAME = EventMesh.publish("get_screen_NAME")
-                if screen_NAME != None:
-                    if screen_NAME != "dialing_noplay_popup":
-                        EventMesh.publish("return_prev_screen")
-                
-            self.is_sliding =0
+        if  code == lv.EVENT.SHORT_CLICKED:
+            EventMesh.publish("set_UI_high_priority", 0)
+            self.timer.stop()
+            voiceCall.callEnd()
+            EventMesh.publish("set_interrup_incall",0)
+            EventMesh.publish("set_UI_high_priority",0)
+            
+            screen_NAME = EventMesh.publish("get_screen_NAME")
+            if screen_NAME != None:
+                if screen_NAME != "dialing_noplay_popup":
+                    EventMesh.publish("return_prev_screen")
+            
        
 
     def Close(self):
@@ -3825,6 +3785,7 @@ class StepScreen(Screen):
         EventMesh.publish("load_screen", {"screen": "toolbox"})
 
     def done_left_to_right(self):
+        
         EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
@@ -4476,17 +4437,17 @@ class CountdownScreen(Screen):
             self.meta = countdown_screen
 
             countdown_sec_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sec_up(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             countdown_sec_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.sec_down(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             countdown_min_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.min_up(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             countdown_min_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.min_down(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             countdown_hour_up_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hour_up(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             countdown_hour_down_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hour_down(e)),
-                                        lv.EVENT.CLICKED, None)
+                                        lv.EVENT.SHORT_CLICKED, None)
             countdown_start_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.start(e)),
                                         lv.EVENT.SHORT_CLICKED, None)
             countdown_reset_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reset(e)),
@@ -4870,7 +4831,7 @@ class CountdownEndScreen(Screen):
         self.FIND_timer_count += 1
         if self.FIND_timer_count >= 4: #120秒
             self.stop_FIND()
-            EventMesh.publish("load_screen", {"screen": "countdown"})
+            EventMesh.publish("return_prev_screen")
             return
         self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3') 
     
@@ -4886,7 +4847,7 @@ class CountdownEndScreen(Screen):
 
     def done_return(self):
         self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
+        EventMesh.publish("return_prev_screen")
 
     def done_click(self):
         print("count down !!!!!!!!!!")
@@ -4895,23 +4856,23 @@ class CountdownEndScreen(Screen):
 
     def done_left_to_right(self):
         self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
+        EventMesh.publish("return_prev_screen")
 
     def done_right_to_left(self):
         self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
+        EventMesh.publish("return_prev_screen")
 
     def done_bottom_to_top(self):
         self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
+        EventMesh.publish("return_prev_screen")
 
     def done_top_to_bottom(self):
         self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
+        EventMesh.publish("return_prev_screen")
 
     def btn1_release(self):
         self.stop_FIND()
-        EventMesh.publish("load_screen", {"screen": "countdown"})
+        EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
         self.stop_FIND()
@@ -5040,10 +5001,10 @@ class StopwatchScreen(Screen):
             stopwatch_stop_img.set_pos(120, 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)
+                                     lv.EVENT.SHORT_CLICKED, None)
         
             stopwatch_reset_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reset(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
             self.meta = stopwatch_screen
 
         if self.s_state == 0:
@@ -5202,6 +5163,7 @@ class StopwatchScreen(Screen):
     def done_left_to_right(self):
         if self.s_state == 0:
             self.timer.stop()
+        
         EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
@@ -5248,6 +5210,7 @@ class UIFINDScreen(Screen):
         utime.sleep_ms(200)#不加延时会切屏
         self.FIND_timer_count = 0
         print("self.FIND_timer_count:{}".format(self.FIND_timer_count))
+        EventMesh.publish("set_motor_time",[1,2,8*10,8,4])#设置马达参数
         self.FIND_timer.start(3000, 1, self.FIND_timer_cb)
         self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3')  #播放声音
 
@@ -5257,11 +5220,12 @@ class UIFINDScreen(Screen):
         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()  #播放声音
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("close_motor_infor")#关闭马达和定时器
+        EventMesh.publish("return_prev_screen")
 
     def Close(self):
         print("self.FIND_timer_Close")
@@ -5323,21 +5287,21 @@ class LowPowerScreen(Screen):
 
     
     def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
     def done_click(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_left_to_right(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
     def done_right_to_left(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
     def done_bottom_to_top(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
     def done_top_to_bottom(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "main_menu"})
@@ -5398,25 +5362,23 @@ class LowOnePowerScreen(Screen): #0%的电池电量
     
 
     def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_click(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
+        EventMesh.publish("return_prev_screen")
     def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
-
+        EventMesh.publish("return_prev_screen")
     def done_left_to_right(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_right_to_left(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_bottom_to_top(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def done_top_to_bottom(self):
-        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
         EventMesh.publish("load_screen", {"screen": "main_menu"})
@@ -5437,7 +5399,6 @@ class sosScreen(Screen):
         self.meta_type = "popup"
         self.count = 0
         self.is_sliding =0
-        self.meta_type = "popup"
 
     def initialization(self):
         global sos_screen ,sos_screen_label  
@@ -5503,7 +5464,7 @@ class sosScreen(Screen):
                                      lv.EVENT.SHORT_CLICKED, None)
             
             sos_screen_return.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_cancel_cb(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
             sos_screen_confirm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
                                      lv.EVENT.PRESSING, None)
             
@@ -6059,6 +6020,8 @@ class UI(object):
         self.screen = None
         self.screen_old = None
         self.screen_prev = None
+        self.screen_prev_new = None
+        self.screen_last = None
         self.screen_list = []
         self.lv = lv
         self.system_sleep_timer = osTimer()
@@ -6072,6 +6035,8 @@ class UI(object):
         self.main_id = 0
         self.set_interrup_flag = 0
         self.UI_high_priority_flag = 0 #如果=1,则当前ui不被打断
+        self.page_id = ["main_menu"]
+        self.page_count = 0
         self.level = EventMesh.publish("get_storage_config","brightness_level")
 
 
@@ -6121,6 +6086,10 @@ class UI(object):
         EventMesh.subscribe("publish_message_event_ui",self.publish_message_event_ui)
         EventMesh.subscribe("return_prev_screen",self.return_prev_screen)
 
+        EventMesh.subscribe("del_prev_screen",self.del_prev_screen)#退出当前界面就删除当前界面 进去需要保存当前界面
+        EventMesh.subscribe("add_new_screen",self.add_new_screen)#保存新的界面用作返回上一级
+
+
         self.system_sleep_timer.start(1000, 1, self.system_sleep_timer_cb)
 
     def publish_message_event_ui(self,event,msg):
@@ -6140,9 +6109,61 @@ class UI(object):
             # for scr in self.screen_list:
             #     if scr.handle_message_event(data) == 1 :
             #         break
+    
+    def add_new_screen(self, event, msg):
+        if msg == "main_menu":
+            if self.page_count > 0:
+                self.page_id.clear()#清空所有
+            self.page_count = 0
+            self.page_id = ["main_menu"]
+            print("add_new_screen ",self.page_id,self.page_count)
+        else:
+            if self.page_count == None:
+                self.page_count = 0
+                self.page_id.clear()#清空所有
+                self.page_id = ["main_menu"]
+            last_screen = self.page_id[int(self.page_count)]
+            print("self.page_id",last_screen,msg,self.page_id,self.page_count)
+            if last_screen != msg:
+                self.page_count+=1
+                page_pre = "{}".format(msg)
+                self.page_id.append(page_pre) 
+
+    def del_prev_screen(self, event, msg):
+        if self.page_count > 0:
+            # print("del_prev_screen self.page_id",self.page_id,self.page_count)
+            if self.screen.meta_type != "popup":
+                del self.page_id[int(self.page_count)]
+                self.page_count-=1
+
+            if self.page_count == 0:
+                self.page_id.clear()#清空所有
+                self.page_id = ["main_menu"]
+
+        if self.page_count == None:
+            self.page_count = 0
+            self.page_id.clear()#清空所有
+            self.page_id = ["main_menu"]
+
     def return_prev_screen(self, event, msg):
-        if self.screen_prev != None:
-            EventMesh.publish("load_screen", {"screen": self.screen_prev.NAME})
+        EventMesh.publish("del_prev_screen")#退出当前界面就删除当前界面 进去需要保存当前界面
+
+        pre_page = self.page_id[int(self.page_count)]
+        # print("pre_page:data = {} self.page_count:{}".format(pre_page,self.page_count))
+        if len(pre_page) == 0:#预防是空的界面
+           self.page_count = 0
+           pre_page = "main_menu"
+
+        if self.page_count == None:
+            self.page_count = 0
+
+        if self.page_count == 0:
+            pre_page = "main_menu"
+        if pre_page != None:
+            EventMesh.publish("load_screen", {"screen": pre_page})
+        # if self.screen_prev.NAME != None:
+        #     print("self.screen_prev.NAME:data = {} ".format(self.screen_prev.NAME))
+        #     EventMesh.publish("load_screen", {"screen": self.screen_prev.NAME})
 
     def set_interrup_incall(self, event, msg):
         self.set_interrup_flag = msg
@@ -6295,6 +6316,7 @@ class UI(object):
             
 
     def publish_call_in(self, event, msg):
+
         EventMesh.publish("load_screen", {"screen": "dialing", "meta": msg})
 
     def __lcd_off(self):
@@ -6413,8 +6435,28 @@ class UI(object):
                     self.screen_old.Close() #先关闭上一次界面
                     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 #
+                    if self.screen.meta_type != "popup": #只要当前界面不是弹窗界面都要保存当前界面
+                        # print('self.screen_prev.NAME6:{} self.screen_old:{}'.format(self.screen_old.NAME,self.screen.NAME))#第一种
+                        # if self.screen_prev_new != self.screen:#screen_prev = setiing  self.screen = imei self.screen_prev = setiing self.screen_prev_new = imei 
+                        #     self.screen_prev = self.screen_prev_new
+                        #     self.screen_last = self.screen_prev_new
+                        #     self.screen_prev_new = self.screen
+                        #     print('self.screen_prev.NAME5:{} self.screen_prev_new:{} self.screen_old:{}'.format(self.screen_prev.NAME,self.screen_prev_new.NAME,self.screen_old.NAME))
+                        # else:
+                        #     if self.screen_last != None:
+                        #         self.screen_prev = self.screen_last
+                            
+                        #     print('self.screen_prev.NAME4:{} self.screen:{} self.screen_old:{}'.format(self.screen_prev.NAME,self.screen.NAME,self.screen_old.NAME))
+                        # print('self.screen_prev.NAME2:{} self.screen_old:{}'.format(self.screen_prev.NAME,self.screen.NAME))
+
+                        self.screen_prev = self.screen_old #第二种方式
+                        screen_new = msg["screen"]
+                        # print('self.screen_prev.NAME:{} self.screen_old:{}'.format(self.screen_prev.NAME,self.screen.NAME))
+                        if self.screen_prev.NAME != self.screen.NAME:
+                            EventMesh.publish("add_new_screen",screen_new)#保存新的界面用作返回上一级 
+                    # else:
+                    #     if self.screen_prev_new != None:#self.screen_prev = imei self.screen_prev = imei
+                    #         self.screen_prev = self.screen_prev_new
                 
                 if msg.get("meta"):
                     self.screen.meta_info = msg.get("meta")
@@ -6431,7 +6473,12 @@ class UI(object):
                 self.__lcd_on()
                 mem = gc.mem_free()
                 print('2剩余内存RAM:{} KB'.format(mem / 1024))
+                # if self.screen_prev == None:
+                #     self.screen_prev = self.screen
+                # if self.screen_prev_new == None:
+                #     self.screen_prev_new = self.screen
                 self.screen_old = self.screen
+                # print('self.screen:{} self.screen_old:{}'.format(self.screen,self.screen_old))
                 self.system_ui_state = 1
                 self.system_ui_timer.stop()
                 self.system_ui_timer.start(200, 0, self.system_ui_flag)
index 797df5f..90650e6 100644 (file)
@@ -4,7 +4,7 @@ import lvgl as lv
 import EventMesh
 import osTimer
 import constants
-from ui import Screen,style_screen,style_font_youyuan_28
+from ui import Screen,style_screen,style_font_youyuan_28,style_font_youyuan_20_white
 import ql_fs
 import ujson
 from machine import RTC
@@ -95,6 +95,10 @@ watchface1_bg_img.set_src("U:/static/bg.png")
 watchface1_bg_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
 #时间
 
+style_font_youyuan_70_white = lv.style_t()
+style_font_youyuan_70_white.init()
+style_font_youyuan_70_white.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_youyuan_70_white.set_text_font(lv.font_70_bold)
 
 style_font_youyuan_70_black = lv.style_t()
 style_font_youyuan_70_black.init()
@@ -592,13 +596,152 @@ class WatchFace2():
     def done_bottom_to_top(self):
         EventMesh.publish("load_screen", {"screen": "call_log"})
 
+
+Watchface3 = lv.obj(Watchface)
+
+Watchface3.set_size(LCD_SIZE_W,LCD_SIZE_H)
+#Watchface1.set_pos(0,0)
+Watchface3.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+Watchface3.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+#时间
+
+
+watchface3_time1_text = lv.label(Watchface3)
+watchface3_time1_text.set_pos(20, 20)
+watchface3_time1_text.set_size(190, 71)
+watchface3_time1_text.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+watchface3_time1_text.set_text("{}:{}".format("%02d"%(hour),"%02d"%(min)))
+# watchface3_time1_text.set_text("%02d:%02d"%(hour,min))
+watchface3_time1_text.add_style(style_font_youyuan_70_white, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+#日期
+watchface3_week_span = lv.label(Watchface3)
+watchface3_week_span.set_pos(0, 100)
+watchface3_week_span.set_size(240, 30)
+watchface3_week_span.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+watchface3_week_span.set_text("%02d/%02d  周%s"%(date1,date2,get_week(week)))
+watchface3_week_span.add_style(style_font_youyuan_20_white, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+watchface3_school_label = lv.label(Watchface3)
+watchface3_school_label.set_pos(0, 145)
+watchface3_school_label.set_size(240, 30)
+watchface3_school_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+watchface3_school_label.set_text("深圳市第一小学")
+watchface3_school_label.add_style(style_font_youyuan_20_white, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+# watchface3_HB_span = lv.label(Watchface1)
+# watchface3_HB_span.set_pos(52, 235)
+# watchface3_HB_span.set_size(80, 30)
+# watchface3_HB_span.set_align(lv.TEXT_ALIGN.LEFT)
+# watchface3_HB_span.set_text("0")
+# watchface3_HB_span.add_style(style_font_youyuan_28, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface3_class_label = lv.label(Watchface3)
+watchface3_class_label.set_pos(0, 185)
+watchface3_class_label.set_size(240, 30)
+watchface3_class_label.set_text("三年级一班")
+watchface3_class_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+watchface3_class_label.add_style(style_font_youyuan_20_white, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+watchface3_fullname_label = lv.label(Watchface3)
+watchface3_fullname_label.set_pos(0, 225)
+watchface3_fullname_label.set_size(240, 30)
+watchface3_fullname_label.set_text("张三")
+watchface3_fullname_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+watchface3_fullname_label.add_style(style_font_youyuan_20_white, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+class WatchFace3():
+    NAME = "Watchface3"
+    # # #表盘1
+    def __init__(self): 
+        print("Watchface3:__init__")
+        self.meta = Watchface3
+        EventMesh.subscribe("update_screen_show",self.update_screen_show)#更新开屏显示
+    def set_parent(self,main_menu):
+        Watchface3.set_parent(main_menu)#设置父控件
+        
+    def initialization(self):   
+        print("Watchface3:initialization") 
+        time = EventMesh.publish("screen_get_time")
+        #print("publish_time:"+time)
+        if time:
+            self.__time(None, time)
+
+        self.update_screen_show(None, None)
+
+        
+    def timerout_update(self):
+        time = EventMesh.publish("screen_get_time")
+        #print("publish_time:"+time)
+        if time:
+            self.__time(None, time)
+        
+        self.update_screen_show(None, None)
+
+
+    def __time(self, event, msg):
+        data = RTC().datetime()
+        hour = int(data[4])
+        min = int(data[5])
+
+        week = int(data[3])
+
+        date1 = int(data[1])
+        date2 = int(data[2])
+        
+        watchface3_time1_text.set_text("{}:{}".format("%02d"%(hour),"%02d"%(min)))
+        watchface3_week_span.set_text("%02d/%02d  周%s"%(date1,date2,get_week(week)))
+
+    def update_screen_show(self, event, msg):
+        school=EventMesh.publish("get_schoolname")
+        if school != None:
+            watchface3_school_label.set_text(str(school))
+        else:
+            watchface3_school_label.set_text(' ')
+        class_name = EventMesh.publish("get_classname")
+        if class_name != None:
+            watchface3_class_label.set_text(str(class_name))
+        else:
+            watchface3_class_label.set_text(' ')
+
+        fullname = EventMesh.publish("get_fullname")
+        if fullname != None:
+            watchface3_fullname_label.set_text(str(fullname))
+        else:
+            watchface3_fullname_label.set_text(' ')
+
+    def Close(self):
+        pass
+
+    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_top_to_bottom(self):
+        EventMesh.publish("load_screen", {"screen": "popup"})
+
+    def done_bottom_to_top(self):
+        EventMesh.publish("load_screen", {"screen": "call_log"})
+
+
+
 class WatchFace():
     #NAME = "Watchface"
 
     def __init__(self,main_menu):
         #表盘
         self.meta = None
-        self.watchface_style_num = "Watchface1"
+        self.watchface_style_num = "Watchface3"
         self.watchface_list = []
         self.watchface_style = None
         self.timer_update = osTimer()
@@ -610,6 +753,7 @@ class WatchFace():
         if self.watchface_list == [] : #第一次初始化
             self.watchface_list.append( WatchFace1())
             self.watchface_list.append( WatchFace2())
+            self.watchface_list.append( WatchFace3())
             self.set_parent( main_menu)
 
         for wat in self.watchface_list:
@@ -629,6 +773,7 @@ class WatchFace():
     def set_parent(self,main_menu):
         Watchface1.set_parent(main_menu)#设置父控件
         Watchface2.set_parent(main_menu)#设置父控件
+        Watchface3.set_parent(main_menu)#设置父控件
 
     def timerout_update(self, *args, **kwargs):
         self.watchface_style.timerout_update()
index 7eb70e6..fed87f6 100644 (file)
@@ -423,33 +423,78 @@ class TemperatureScreen(Screen):
                 count = len(sort_new)
                 if count != 0:
                     for i in  range(count):
-                        # print(int(sort_new[i]["temp"]))
-                        # print("hr history read_data",read_data)
-                        value = int(sort_new[i]["temp"])
+                        print(int(sort_new[i]["temp"]))
+                        print("hr history read_data",read_data)
+                        value_float = sort_new[i]["temp"]
+                        value_float = 29
+                        value = 0
+                        value_dot = 0
+                        line_value = 0
+                        value_tmp = 0
+                        if str(value_float).find(".") != -1:#如果检测到有小数点就
+                            value = str(value_float).split(".")[0]
+                            value_dot = str(value_float).split('.')[1][:1]
+                        else:
+                            value = int(value_float)
+
                         value_temp = int(value)
-                        if value <= 30:
-                            line_value = int(value_temp)
-                        elif value <= 34:
+                        print("value_float <",value_float,value,value_dot,value_temp)
+                        if value_float <= 30:
+                            line_value = int(value_temp)*0.5+15
+                        elif value_float <= 34:
+                            print("value_float < 34")
                             line_value = int((value_temp-30)*4.25)+30
-                        elif value <= 38:
+                            value_tmp = int(value_dot)*4.25
+                            value_tmp = value_tmp/10
+
+                            if str(value_tmp).find(".") != -1:#如果检测到有小数点就
+                                line_value = int(str(value_tmp).split(".")[0])+line_value
+                            else:
+                                line_value = line_value+int(value_tmp)
+
+                        elif value_float <= 38:
+                            print("value_float < 38")
                             line_value = int((value_temp-34)*5)+47
-                        elif value <= 42:
+                            value_tmp = int(value_dot)*5
+                            value_tmp = value_tmp/10
+
+                            if str(value_tmp).find(".") != -1:#如果检测到有小数点就
+                                line_value = int(str(value_tmp).split(".")[0])+line_value
+                            else:
+                                line_value =line_value+int(value_tmp)
+
+                        elif value_float <= 42:
+                            print("value_float < 42")
                             line_value = int((value_temp-38)*4)+67
-                        elif value < 46:
+                            value_tmp = int(value_dot)*4
+                            value_tmp = value_tmp/10
+
+                            if str(value_tmp).find(".") != -1:#如果检测到有小数点就
+                                line_value = int(str(value_tmp).split(".")[0])+line_value
+                            else:
+                                line_value =line_value+int(value_tmp)
+                        elif value_float < 46:
+                            print("value_float < 46")
                             line_value = int((value_temp-42)*3.75)+85
+                            value_tmp = int(value_dot)*3.75
+                            value_tmp = value_tmp/10
+                            if str(value_tmp).find(".") != -1:#如果检测到有小数点就
+                                line_value = int(str(value_tmp).split(".")[0])+line_value
+                            else:
+                                line_value =line_value+int(value_tmp)
                         else:
-                            value = 46
+                            value_float = 46
                             line_value = 100
                         
                         if line_value >= 100:
                             line_value = 100
-                        #print("hr hist",line_value)
+                        print("temp line_value",line_value)
                         temp_line_points = [{"x":0,"y":0},{"x":0,"y":line_value}]
                         if i == 0:
                             temp_line1.set_points(temp_line_points,2)
                             temp_line1.set_pos(29,145-line_value)
                             temp_line1.set_size(10,line_value)
-                            if value >= 37.3:
+                            if value_float >= 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)
@@ -457,7 +502,7 @@ class TemperatureScreen(Screen):
                             temp_line2.set_points(temp_line_points,2)
                             temp_line2.set_pos(57,145-line_value)
                             temp_line2.set_size(10,line_value)
-                            if value >= 37.3:
+                            if value_float >= 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)
@@ -466,7 +511,7 @@ class TemperatureScreen(Screen):
                             temp_line3.set_points(temp_line_points,2)
                             temp_line3.set_pos(84,145-line_value)
                             temp_line3.set_size(10,line_value)
-                            if value >= 37.3:
+                            if value_float >= 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)
@@ -474,7 +519,7 @@ class TemperatureScreen(Screen):
                             temp_line4.set_points(temp_line_points,2)
                             temp_line4.set_pos(112,145-line_value)
                             temp_line4.set_size(10,line_value)
-                            if value >= 37.3:
+                            if value_float >= 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)
@@ -482,7 +527,7 @@ class TemperatureScreen(Screen):
                             temp_line5.set_points(temp_line_points,2)
                             temp_line5.set_pos(140,145-line_value)
                             temp_line5.set_size(10,line_value)
-                            if value >= 37.3:
+                            if value_float >= 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)
@@ -491,7 +536,7 @@ class TemperatureScreen(Screen):
                             temp_line6.set_points(temp_line_points,2)
                             temp_line6.set_pos(167,145-line_value)
                             temp_line6.set_size(10,line_value)
-                            if value >= 37.3:
+                            if value_float >= 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)
@@ -500,7 +545,7 @@ class TemperatureScreen(Screen):
                             temp_line7.set_points(temp_line_points,2)
                             temp_line7.set_pos(195,145-line_value)
                             temp_line7.set_size(10,line_value)
-                            if value >= 37.3:
+                            if value_float >= 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)
@@ -522,8 +567,8 @@ class TemperatureScreen(Screen):
             tmp = temp#获取小数点后一位 舍去小数点最后一位
 
         # print("self.temp:{}".format(temp))
-        if self.point >= 2:
-            if temp != 0:
+        if self.point >= 10 :
+            if temp != 0 :
                 size_x = len(str(tmp))*14
                 temperature_degree_img.set_pos(100+size_x, 237)
                 temperature_bpm_label.set_text("{}".format(tmp))
@@ -603,14 +648,6 @@ class TemperatureScreen(Screen):
         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 done_left_to_right(self):
         self.timer.stop()
         EventMesh.publish("set_temp_state",0)
@@ -951,16 +988,13 @@ class Spo2Screen(Screen):
 
             self.point = 0
             EventMesh.publish("set_spo2_state",0)#0代表关闭测试
-            print("stop debug9")
+            print("stop debug10")
             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)
+        EventMesh.publish("set_spo2_state",0)#0代表关闭测试
+        EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
 
     def done_return(self):
         EventMesh.publish("load_screen", {"screen": "health"})
@@ -971,12 +1005,6 @@ class Spo2Screen(Screen):
         EventMesh.publish("load_screen", {"screen": "health"})
     
     def done_left_to_right(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)
         EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
@@ -1320,34 +1348,16 @@ class HeartrateScreen(Screen):
             
             self.point = 0
             EventMesh.publish("set_hr_state",0)#0代表关闭测试
-            print("stop debug9")
+            print("stop debug11")
             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"})
+        EventMesh.publish("set_hr_state",0)#0代表关闭测试
+        print("stop debug10")
+        EventMesh.publish(constants.EVENT.STOP_HEART)
     
     def done_left_to_right(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)
         EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
@@ -1403,13 +1413,19 @@ class bloodpressureScreen(Screen):
         self.point = 0
         self.heart_value = 0
         self.count_blood = 0
-        self.max_value = 0
-        self.min_value = 0
+        self.oldmax = 0
+        self.oldmin = 0
+        self.oldSec = 0
         self.is_sliding = 0
         self.blood_Maxvalue = 0
         self.blood_Minvalue = 0
         EventMesh.subscribe("show_history_blood_data",self.show_history_blood_data)
         EventMesh.subscribe("get_blood_value",self.get_blood_value)
+        EventMesh.subscribe("get_autoblood_value",self.get_autoblood_value)
+
+        EventMesh.subscribe("set_oldblood_value",self.set_oldblood_value)
+        EventMesh.subscribe("get_oldblood_value",self.get_oldblood_value)
+
 
     def initialization(self):
         self.is_sliding =0
@@ -1425,7 +1441,7 @@ class bloodpressureScreen(Screen):
             blood_pressure_label = lv.label(blood_pressure_screen)
             blood_pressure_label.set_pos(0, 10)
             blood_pressure_label.set_size(LCD_SIZE_W, 40)
-            blood_pressure_label.set_text("心率")
+            blood_pressure_label.set_text("血压")
             blood_pressure_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
             blood_pressure_label.set_long_mode(lv.label.LONG.WRAP)
             blood_pressure_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
@@ -1579,8 +1595,7 @@ class bloodpressureScreen(Screen):
         blood_pressure_bpm_label.set_text("--/--")
         blood_pressure_start_label.set_text("正在测量中.")
         self.count_blood = 0
-        self.max_value = 0
-        self.min_value = 0
+        
         self.blood_Maxvalue = 0
         self.blood_Minvalue = 0
 
@@ -1606,7 +1621,7 @@ class bloodpressureScreen(Screen):
         
         if self.count_blood >= 10:
             if hour >= 6 and hour <= 10:
-                if self.count_blood <= 15:
+                if self.count_blood <= 20:
                     random_numMax = urandom.randint(0, 10)
                     random_numMin = urandom.randint(0, 6)
                     blood_Maxold = 120+random_numMax
@@ -1634,7 +1649,7 @@ class bloodpressureScreen(Screen):
                         
                     
                     
-                elif self.count_blood <= 25:
+                elif self.count_blood <= 40:
 
                     random_numMax = urandom.randint(0, 20)
                     random_numMin = urandom.randint(0, 12)
@@ -1690,7 +1705,7 @@ class bloodpressureScreen(Screen):
                 print("get_blood_value 6 -10",self.blood_Maxvalue,self.blood_Minvalue)
                 # return [self.blood_Maxvalue,self.blood_Minvalue]
             elif hour > 10 and hour <= 14:#10-14(10,14]
-                if self.count_blood <= 15:
+                if self.count_blood <= 20:
                     random_numMax = urandom.randint(0, 6)
                     random_numMin = urandom.randint(0, 8)
                     blood_Maxold = 115+random_numMax
@@ -1716,7 +1731,7 @@ class bloodpressureScreen(Screen):
                     else:
                         self.blood_Minvalue=blood_Minold
                    
-                elif self.count_blood <= 25:
+                elif self.count_blood <= 40:
                     random_numMax = urandom.randint(0, 12)
                     random_numMin = urandom.randint(0, 18)
                     blood_Maxold = 115+random_numMax
@@ -1770,7 +1785,7 @@ class bloodpressureScreen(Screen):
                 print("get_blood_value 10 -14",self.blood_Maxvalue,self.blood_Minvalue)
                 # return [self.blood_Maxvalue,self.blood_Minvalue]
             elif hour > 14 and hour <= 18:#14-18
-                if self.count_blood <= 15:
+                if self.count_blood <= 20:
                     random_numMax = urandom.randint(0, 8)
                     random_numMin = urandom.randint(0, 5)
                     blood_Maxold = 115+random_numMax
@@ -1796,7 +1811,7 @@ class bloodpressureScreen(Screen):
                     else:
                         self.blood_Minvalue=blood_Minold
 
-                elif self.count_blood <= 25:
+                elif self.count_blood <= 40:
                     random_numMax = urandom.randint(0, 16)
                     random_numMin = urandom.randint(0, 10)
                     blood_Maxold = 115+random_numMax
@@ -1853,7 +1868,7 @@ class bloodpressureScreen(Screen):
                 print("get_blood_value 14 -18",self.blood_Maxvalue,self.blood_Minvalue)
                 # return [self.blood_Maxvalue,self.blood_Minvalue]
             elif hour > 2 and hour < 6:#2-6
-                if self.count_blood <= 15:
+                if self.count_blood <= 20:
                 
                     random_numMax = urandom.randint(0, 10)
                     random_numMin = urandom.randint(0, 6)
@@ -1880,7 +1895,7 @@ class bloodpressureScreen(Screen):
                     else:
                         self.blood_Minvalue=blood_Minold
                     
-                elif self.count_blood <= 25:
+                elif self.count_blood <= 40:
                     random_numMax = urandom.randint(0, 20)
                     random_numMin = urandom.randint(0, 12)
                     blood_Maxold = 105+random_numMax
@@ -1935,7 +1950,7 @@ class bloodpressureScreen(Screen):
                 print("get_blood_value 2 -6",self.blood_Maxvalue,self.blood_Minvalue)
                 # return [self.blood_Maxvalue,self.blood_Minvalue]
             else:#18-2 19 20 21 22 23 1 2
-                if self.count_blood <= 15:
+                if self.count_blood <= 20:
                     
                     random_numMax = urandom.randint(0, 10)
                     random_numMin = urandom.randint(0, 6)
@@ -1962,7 +1977,7 @@ class bloodpressureScreen(Screen):
                     else:
                         self.blood_Minvalue=blood_Minold
                     
-                elif self.count_blood <= 25:
+                elif self.count_blood <= 40:
                    
                     random_numMax = urandom.randint(0, 20)
                     random_numMin = urandom.randint(0, 12)
@@ -2017,6 +2032,77 @@ class bloodpressureScreen(Screen):
                 print("get_blood_value 18 -2",self.blood_Maxvalue,self.blood_Minvalue)
         return [self.blood_Maxvalue,self.blood_Minvalue]
 
+
+    def get_oldblood_value(self,event,msg):
+
+        return [self.oldmax,self.oldmin]
+
+    def set_oldblood_value(self,event,msg):
+        if msg != None:
+            self.oldmax = msg[0]
+            self.oldmin = msg[1]
+        else:
+            self.oldmax = 0
+            self.oldmin = 0
+        
+
+
+    def get_autoblood_value(self,event,msg):
+
+        old_data = EventMesh.publish("get_oldblood_value")
+        old_Max = 0
+        old_Min = 0
+        if old_data != None:
+            old_Max = old_data[0]
+            old_Min = old_data[1]
+
+        data = RTC().datetime()
+        hour = int(data[4])
+        blood_Maxvalue = 0
+        blood_Minvalue = 0
+        if hour >= 6 and hour <= 10:
+            random_numMax = urandom.randint(0, 30)
+            random_numMin = urandom.randint(0, 20)
+            blood_Maxvalue = 120+random_numMax
+            blood_Minvalue = 75+random_numMin
+
+            print("get_autoblood_value 6 -10",blood_Maxvalue,blood_Minvalue)
+            # return [self.blood_Maxvalue,self.blood_Minvalue]
+        elif hour > 10 and hour <= 14:#10-14(10,14]
+            random_numMax = urandom.randint(0, 20)
+            random_numMin = urandom.randint(0, 25)
+            blood_Maxvalue = 115+random_numMax
+            blood_Minvalue = 60+random_numMin
+            print("get_autoblood_value 10 -14",blood_Maxvalue,blood_Minvalue)
+            # return [self.blood_Maxvalue,self.blood_Minvalue]
+        elif hour > 14 and hour <= 18:#14-18
+            random_numMax = urandom.randint(0, 25)
+            random_numMin = urandom.randint(0, 15)
+            blood_Maxvalue = 115+random_numMax
+            blood_Minvalue = 70+random_numMin
+
+            print("get_autoblood_value 14 -18",blood_Maxvalue,blood_Minvalue)
+            # return [self.blood_Maxvalue,self.blood_Minvalue]
+        elif hour > 2 and hour < 6:#2-6
+            random_numMax = urandom.randint(0, 30)
+            random_numMin = urandom.randint(0, 20)
+            blood_Maxvalu = 105+random_numMax
+            blood_Minvalue = 65+random_numMin
+
+            
+            print("get_autoblood_value 2 -6",blood_Maxvalue,blood_Minvalue)
+            # return [self.blood_Maxvalue,self.blood_Minvalue]
+        else:#18-2 19 20 21 22 23 1 2
+            random_numMax = urandom.randint(0, 30)
+            random_numMin = urandom.randint(0, 20)
+            blood_Maxvalue = 100+random_numMax
+            blood_Minvalue = 60+random_numMin
+            print("get_autoblood_value 18 -2",blood_Maxvalue,blood_Minvalue)
+        return [blood_Maxvalue,blood_Minvalue]
+
+
+
+
     def restart_up(self,e):
         global blood_pressure_done_label,blood_pressure_bpm_label,blood_pressure_start_label,blood_pressure_reset_btn_img
 
@@ -2044,7 +2130,7 @@ class bloodpressureScreen(Screen):
                 blood_pressure_done_label.set_text(" ")
                 blood_pressure_bpm_label.set_text("--/--")
                 blood_pressure_start_label.set_text("正在测量中.")
-                EventMesh.publish("set_hr_state",1)#1代表手动进入测试界面
+                EventMesh.publish("set_bp_state",1)#3代表单次测量
                 
                 EventMesh.publish(constants.EVENT.START_HEART)
                         
@@ -2063,7 +2149,7 @@ class bloodpressureScreen(Screen):
         blood_pressure_done_label.set_text(" ")
         blood_pressure_bpm_label.set_text("--/--")
         blood_pressure_start_label.set_text("正在测量中.")
-        EventMesh.publish("set_hr_state",1)#1代表手动进入测试界面
+        EventMesh.publish("set_bp_state",1)#3代表单次测量
         
         EventMesh.publish(constants.EVENT.START_HEART)
         
@@ -2214,12 +2300,7 @@ class bloodpressureScreen(Screen):
             blood_pressure_done_label
         self.point = self.point + 1
         EventMesh.publish("system_sleep_rest")#防止黑屏
-        blood_data = EventMesh.publish("get_blood_value")
-        if blood_data == None:
-            blood_data[0] = 0
-            blood_data[1] = 0
-        self.max_value = blood_data[0]
-        self.min_value = blood_data[1]
+        
         WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
         #print("heart WEAR:{}".format(WEAR))
         # print("self.heart_value:{}".format(self.heart_value))
@@ -2235,7 +2316,7 @@ class bloodpressureScreen(Screen):
             blood_pressure_done_img.set_src("E:/static/blood_gif03.png")
         
         
-        if self.point > 80 or (WEAR == 0 and self.point > 10): #测40s或没佩戴
+        if self.point > 120 or (WEAR == 0 and self.point > 10): #90S
             self.timer.stop()
             blood_pressure_done_img.set_src("E:/static/blood_gif03.png")
             if WEAR == 0:
@@ -2244,44 +2325,40 @@ class bloodpressureScreen(Screen):
                 blood_pressure_start_label.set_text("测量结束,点击重测")
 
             blood_pressure_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
-
-            if (self.max_value != 0 or self.min_value != 0) and WEAR == 1:
-                EventMesh.publish("set_old_blood_data",[self.max_value,self.min_value])
-                blood_pressure_bpm_label.set_text("{}/{}".format(self.max_value,self.min_value))
+            max_value = 0
+            min_value = 0
+            if WEAR == 1:
+                blood_data = EventMesh.publish("get_autoblood_value")
+                if blood_data == None:
+                    blood_data[0] = 0
+                    blood_data[1] = 0
+                max_value = blood_data[0]
+                min_value = blood_data[1]
+
+            if (max_value != 0 or min_value != 0) and WEAR == 1:
+                EventMesh.publish("set_old_blood_data",[max_value,min_value])
+                blood_pressure_bpm_label.set_text("{}/{}".format(max_value,min_value))
+                EventMesh.publish(constants.PROTOCOL.BLOOD_SEND,[max_value,min_value])
                 # heartrate_done_label.set_text("测量完成")
             else:
                 blood_pressure_bpm_label.set_text("--/--")
             
             self.point = 0
-            EventMesh.publish("set_hr_state",0)#0代表关闭测试
+            EventMesh.publish("set_bp_state",0)#3代表单次测量
+
             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"})
-
-    
-
+        EventMesh.publish("set_bp_state",0)#0代表关闭测试
+        print("stop debug10")
+        EventMesh.publish(constants.EVENT.STOP_HEART)
     def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "health"})
+        EventMesh.publish("watch_top_show")
+        EventMesh.publish("load_screen", {"screen": "main_menu"})
     
     def done_left_to_right(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)
         EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
index 59f29b8..f8cda10 100644 (file)
@@ -82,20 +82,20 @@ setting_cont.add_style(setting_cont_style,lv.PART.MAIN | lv.STATE.DEFAULT)
 # setting_language_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 #setting_cont_y += 60
 
-setting_dialswitch_bg_img = lv.img(setting_cont)
-setting_dialswitch_bg_img.set_pos(0, setting_cont_y)
-setting_dialswitch_bg_img.set_size(TOOL_BG_ICON_W_SIZE, TOOL_BG_ICON_H_SIZE)
-setting_dialswitch_bg_img.add_flag(lv.obj.FLAG.CLICKABLE)
-setting_dialswitch_bg_img.set_src("E:/static/list_bg.png")
-setting_dialswitch_bg_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-setting_dialswitch_img = lv.img(setting_cont)
-setting_dialswitch_img.set_pos(8, setting_cont_y+6)
-setting_dialswitch_img.set_size(SETTING_ICON_W_SIZE, SETTING_ICON_H_SIZE)
-# setting_dialswitch_img.add_flag(lv.obj.FLAG.CLICKABLE)
-setting_dialswitch_img.set_src("E:/static/setting/menu_watch_switch.png")
-setting_dialswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-setting_cont_y+=SETTING_ICON_OFFSET_SIZE
+# setting_dialswitch_bg_img = lv.img(setting_cont)
+# setting_dialswitch_bg_img.set_pos(0, setting_cont_y)
+# setting_dialswitch_bg_img.set_size(TOOL_BG_ICON_W_SIZE, TOOL_BG_ICON_H_SIZE)
+# setting_dialswitch_bg_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# setting_dialswitch_bg_img.set_src("E:/static/list_bg.png")
+# setting_dialswitch_bg_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+# setting_dialswitch_img = lv.img(setting_cont)
+# setting_dialswitch_img.set_pos(8, setting_cont_y+6)
+# setting_dialswitch_img.set_size(SETTING_ICON_W_SIZE, SETTING_ICON_H_SIZE)
+# # setting_dialswitch_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# setting_dialswitch_img.set_src("E:/static/setting/menu_watch_switch.png")
+# setting_dialswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+# setting_cont_y+=SETTING_ICON_OFFSET_SIZE
 
 
 setting_themeswitch_bg_img = lv.img(setting_cont)
@@ -260,7 +260,7 @@ class SettingScreen(Screen):
         setting_screen.add_event_cb(lambda e:EventMesh.callback_wrapper(self.setting_cb(e,"void")), lv.EVENT.GESTURE, None)
         # img regist btton
         # setting_language.add_event_cb(lambda e: self.load_screen(e, {"screen": "language"}), lv.EVENT.CLICKED, None)
-        setting_dialswitch_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "dialswitch")), lv.EVENT.SHORT_CLICKED, None)
+        # setting_dialswitch_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "dialswitch")), lv.EVENT.SHORT_CLICKED, None)
         setting_themeswitch_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "themeswitch")), lv.EVENT.SHORT_CLICKED, None)
         setting_imei_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "imei")), lv.EVENT.SHORT_CLICKED, None)
         setting_app_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.setting_cb(e, "app")), lv.EVENT.SHORT_CLICKED, None)
@@ -324,10 +324,8 @@ class SettingScreen(Screen):
         scroll_y = setting_cont.get_scroll_y()
         print("scroll_y:{}".format(scroll_y))
         setting_cont.scroll_to_y(scroll_y-SETTING_ICON_OFFSET_SIZE,lv.ANIM.ON)
-
-        
-        #setting_cont.scroll_to_view(lv.ANIM.ON)
         pass
+
     def done_UP(self):#上滑
         scroll_y = setting_cont.get_scroll_y()
         print("scroll_y:{}".format(scroll_y))
@@ -991,18 +989,9 @@ class RestoreScreen(Screen):
                 self.is_sliding =0
                 EventMesh.publish("load_screen", {"screen": "setting"})
             self.is_sliding =0
-
-        
-
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "setting"})
-
-   
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "setting"})
     
     def done_left_to_right(self):
+
         EventMesh.publish("return_prev_screen")
 
     def btn8_press(self):
@@ -1041,6 +1030,7 @@ class VersionScreen(Screen):
         self.meta = version_screen
         self.btn_count = 0
     def initialization(self):
+        
         imei = EventMesh.publish(constants.EVENT.GET_IMEI)
         # version_label9.set_text(imei)
 
@@ -1359,7 +1349,7 @@ class DialswitchScreen(Screen):
         self.meta = dialswitch_screen
         self.watchface_style_num = "Watchface1"
         dialswitch_img1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.watchface01(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
         self.dial_num = 1
         self.move = 0
         self.timer= osTimer()
@@ -1381,7 +1371,7 @@ class DialswitchScreen(Screen):
 
     def watchface01(self,e):
         code  = e.get_code()
-        if code == lv.EVENT.CLICKED:
+        if code == lv.EVENT.SHORT_CLICKED:
             self.timer.start(50,0,self.enter_main_show)
             
     def enter_main_show(self,e):
@@ -1444,7 +1434,7 @@ class DialswitchScreen(Screen):
         EventMesh.publish("load_screen", {"screen": "main_menu"})
 
 
-class ThemeswitchScreen(Screen):
+class ThemeswitchScreen(Screen):#主题风格选择
     NAME = "themeswitch"
 
     def __init__(self):
@@ -1452,14 +1442,16 @@ class ThemeswitchScreen(Screen):
         self.meta = menustyle_screen
         self.is_sliding1 = 0
         self.is_sliding2 = 0
+        
+
         menustyle_img1_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.fun1(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
 
         menustyle_img1_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.fun1(e)),
                                      lv.EVENT.PRESSING, None)
         
         menustyle_img2_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.fun2(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
 
         menustyle_img2_bg_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.fun2(e)),
                                      lv.EVENT.PRESSING, None)
@@ -1488,7 +1480,7 @@ class ThemeswitchScreen(Screen):
             #print("PRESSING")
             self.is_sliding1 += 1
 
-        elif  code == lv.EVENT.CLICKED:
+        elif  code == lv.EVENT.SHORT_CLICKED:
             #utime.sleep_ms(10)
             print("1self.is_sliding",self.is_sliding1)
             if self.is_sliding1 <= 5 and self.is_sliding1 != 0:#如果是在滑动中则不需要点击事件
@@ -1509,7 +1501,7 @@ class ThemeswitchScreen(Screen):
             #print("PRESSING")
             self.is_sliding2 += 1
 
-        elif  code == lv.EVENT.CLICKED:
+        elif  code == lv.EVENT.SHORT_CLICKED:
             #utime.sleep_ms(10)
             print("2self.is_sliding",self.is_sliding2)
             if self.is_sliding2 <= 5 and self.is_sliding2 != 0:#如果是在滑动中则不需要点击事件
@@ -1519,15 +1511,8 @@ class ThemeswitchScreen(Screen):
                 # menustyle_img2.set_src("E:/static/theme_single2.png")
                 EventMesh.publish("set_mainmenu",msg = ["2",0])   
                 EventMesh.publish("load_screen", {"screen": "main_menu"})
-                
             self.is_sliding2 = 0
 
-    def done_return(self):
-        EventMesh.publish("load_screen", {"screen": "setting"})
-
-    def btn1_release(self):
-        EventMesh.publish("load_screen", {"screen": "setting"})
-        
     def done_left_to_right(self):
         EventMesh.publish("return_prev_screen")
 
@@ -1573,7 +1558,6 @@ class ImeiScreen(Screen):
         self.meta = imei_screen
 
     def initialization(self):
-        print("rrrrrrr1")
         imei = EventMesh.publish(constants.EVENT.GET_IMEI)
         imei_qr_data = str(imei)
         imei_qr.update(imei_qr_data,len(imei_qr_data))
@@ -1731,16 +1715,16 @@ class BrightnessScreen(Screen):
         self.flip_sw =0
         self.meta = brightness_screen
         brightness_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_level(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
         brightness_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_level(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
         
         brightness_time_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_time_level(e)),
-                                     lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
 
         brightness_time_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_time_level(e)),
-                                     lv.EVENT.CLICKED, None)
-        brightness_flip_label_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.flip_sw_cb(e)),lv.EVENT.CLICKED, None)
+                                     lv.EVENT.SHORT_CLICKED, None)
+        brightness_flip_label_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.flip_sw_cb(e)),lv.EVENT.SHORT_CLICKED, None)
     def initialization(self):
         self.level = EventMesh.publish("get_brightness_level")
         self.time = EventMesh.publish("get_brightness_time")
@@ -1770,7 +1754,7 @@ class BrightnessScreen(Screen):
     def flip_sw_cb(self,e):
         code = e.get_code()
         obj = e.get_target()
-        if code == lv.EVENT.CLICKED:
+        if code == lv.EVENT.SHORT_CLICKED:
             if self.flip_sw == 0:
                 self.flip_sw = 1
                 brightness_flip_sw.add_state(lv.STATE.CHECKED)
@@ -1826,9 +1810,9 @@ class VolumeScreen(Screen):
     def __init__(self):
         super().__init__()
         self.meta = volume_screen
-        volume_phone_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "phonering"})), lv.EVENT.CLICKED, None)
-        volume_message_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "msgvolume"})), lv.EVENT.CLICKED, None)
-        volume_alarm_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "alarmvolume"})), lv.EVENT.CLICKED, None)
+        volume_phone_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "phonering"})), lv.EVENT.SHORT_CLICKED, None)
+        volume_message_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "msgvolume"})), lv.EVENT.SHORT_CLICKED, None)
+        volume_alarm_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.load_screen(e, {"screen": "alarmvolume"})), lv.EVENT.SHORT_CLICKED, None)
 
     def done_return(self):
         EventMesh.publish("load_screen", {"screen": "setting"})
@@ -2014,7 +1998,7 @@ totalvolume_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
 totalvolume_add_imgbtn.set_src("E:/static/add_btn.png")
 totalvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
 
-class totalvolumeScreen(Screen):
+class totalvolumeScreen(Screen):#总的铃声调节
     NAME = "totalvolume"
 
     def __init__(self):
@@ -2028,6 +2012,7 @@ class totalvolumeScreen(Screen):
         self.aud = audio.Audio(0)
         
     def initialization(self):
+        
         num = EventMesh.publish("get_volum_size")
         if num == None:
             self.volum_size = 8