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