import usys
import sms
from Gsensor import SC7A20
-NEW_ENABLE = 1 #1代表旧的按键功能定义 0代表新的按键功能定义
+NEW_ENABLE = 0 #1代表旧的按键功能定义 0代表新的按键功能定义
if EventMesh.model == "D15_" :
motor_pin = Pin(Pin.GPIO20, Pin.OUT, Pin.PULL_PD, 0)
self.sosKey_timer = osTimer()
self.sosKey_count = 0
self.sosKey_press = 0
+ self.sosKey_long_press = 0
self.wechatKey_press_count = 0
self.Keycall1_count = 0
self.Keycall1_press = 0
self.Keycall1_press_count = 0
+ self.Keycall1_long_press = 0
self.Keycall2_timer = osTimer()
self.Keycall2_count = 0
self.sosKey_count = 0
self.sosKey_press = 0
self.sosKey_press_count=0#sos键
+ self.sosKey_long_press = 0
self.wechatKey_count = 0
self.wechatKey_press = 0
self.Keycall1_count = 0
self.Keycall1_press = 0
self.Keycall1_press_count = 0#call 1键
+ self.Keycall1_long_press = 0
self.Keycall2_count = 0
self.Keycall2_press = 1
- self.Keycall2_timer.start(200, 1, self.publish_call2key_btn_event_cb)
- else:
- if self.Keycall2_long_press == 1:
self.Keycall2_long_press = 0
+ self.Keycall2_timer.start(200, 1, self.publish_call2key_btn_event_cb)
def call2Key_press_cb(self, data):
'''KEY2:联动屏幕右下角或返回键长按关机'''
if self.Keycall2_press == 1 :
self.Keycall2_count += 1
if self.Keycall2_count >= 10*3: #长按3s
- self.Keycall2_count = 0
- self.Keycall2_press = 0
- self.Keycall2_press_count = 0
- self.Keycall2_long_press = 1
- self.Keycall2_timer.stop()
- flag = EventMesh.publish("get_call_state")#获取通话状态
- fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
- if fall_down != None:
- if fall_down != 0 or flag == 2:
- return
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("call_phonebook_num",1)
+ if self.Keycall2_long_press == 0:
+ self.Keycall2_long_press = 1
+ flag = EventMesh.publish("get_call_state")#获取通话状态
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_num",1)
+ return
+
+ if self.KeyCall2_status == 1:
+ self.Keycall2_count = 0
+ self.Keycall2_press = 0
+ self.Keycall2_press_count = 0
+ self.Keycall2_long_press = 0
+ self.Keycall2_timer.stop()
+ return
+
if self.KeyCall2_status == 1:#松开
if self.Keycall2_count >= 1: #防抖100ms
self.sosKey_count = 0
self.sosKey_press = 0
+ self.sosKey_long_press = 0
self.sosKey_press_count=0
self.wechatKey_count = 0
self.Keycall2_count = 0
self.Keycall2_press = 0
self.Keycall2_press_count = 0
+ self.Keycall2_long_press = 0
self.Keycall1_count = 0
self.Keycall1_press = 1
+ self.Keycall1_long_press = 0
self.Keycall1_timer.start(100, 1, self.publish_call1key_btn_event_cb)
def call1Key_press_cb(self, data):
if self.Keycall1_press == 1 :
self.Keycall1_count += 1
if self.Keycall1_count >= 10*3: #长按3s
- self.Keycall1_count = 0
- self.Keycall1_press = 0
- self.Keycall1_press_count = 0
- self.Keycall1_timer.stop()
- flag = EventMesh.publish("get_call_state")#获取通话状态
- fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
- if fall_down != None:
- if fall_down != 0 or flag == 2:
- return
- EventMesh.publish("stop_led_timer")#设置参数
- EventMesh.publish("call_phonebook_num",2)
+ if self.Keycall1_long_press == 0:
+ self.Keycall1_long_press = 1
+ flag = EventMesh.publish("get_call_state")#获取通话状态
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ EventMesh.publish("stop_led_timer")#设置参数
+ EventMesh.publish("call_phonebook_num",2)
+ return
+ if self.KeyCall1_status == 1:#松开
+ self.Keycall1_count = 0
+ self.Keycall1_press = 0
+ self.Keycall1_press_count = 0
+ self.Keycall1_long_press = 0
+ self.Keycall1_timer.stop()
+ return
+
if self.KeyCall1_status == 1:#松开
if self.Keycall1_count >= 1: #防抖100ms
self.sosKey_count = 0
self.sosKey_press = 0
self.sosKey_press_count=0
+ self.sosKey_long_press = 0
self.wechatKey_count = 0
self.wechatKey_press = 0
self.Keycall1_count = 0
self.Keycall1_press = 0
+ self.Keycall1_long_press = 0
self.Keycall1_press_count = 0
self.Keycall2_count = 0
self.Keycall2_press = 0
self.Keycall2_press_count = 0
+ self.Keycall2_long_press = 0
self.pwkey_timer.start(100, 1, self.publish_pwkKey_btn_event_cb)
# EventMesh.debug_log("key22_extint_cb:self.key22_timer.start!!!!\n")
self.Keycall1_count = 0
self.Keycall1_press = 0
+ self.Keycall1_long_press = 0
self.Keycall1_press_count = 0
self.Keycall2_count = 0
self.Keycall2_press = 0
+ self.Keycall2_long_press = 0
self.Keycall2_press_count = 0
self.sosKey_timer.start(100, 1, self.publish_soskey_btn_event_cb)
# EventMesh.publish("set_led_time_arg",[1000,200,1,led_mode.FLASH_LIGHT_RED,led_mode.DEFAULT_LONG_LIGHT_MODE,led_mode.OTHER_MEASURE_MODE])#设置参数
self.sosKey_count += 1
if self.sosKey_count >= 10*3: #长按3s sos拨号
- self.sosKey_count = 0
- self.sosKey_long_press = 1
- self.sosKey_press = 0
- self.sosKey_timer.stop()
- flag = EventMesh.publish("get_call_state")#获取通话状态
- fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
- if fall_down != None:
- if fall_down != 0 or flag == 2:
- return
- EventMesh.publish_async("dial_sos_phone")#拨打sos号码
- return
+ if self.sosKey_long_press == 0:
+ self.sosKey_long_press = 1
+ flag = EventMesh.publish("get_call_state")#获取通话状态
+ fall_down = EventMesh.publish("get_fall_down_state")#跌倒报警标识
+ if fall_down != None:
+ if fall_down != 0 or flag == 2:
+ return
+ EventMesh.publish_async("dial_sos_phone")#拨打sos号码
+ return
+ if self.sosKey_status == 1:#松开
+ self.sosKey_count = 0
+ self.sosKey_long_press = 0
+ self.sosKey_press = 0
+ self.sosKey_timer.stop()
+ return
# EventMesh.debug_log("self.sosKey_count {}",self.sosKey_count)
if self.sosKey_status == 1:#松开
self.Keycall1_timer.stop()
self.sosKey_press_count = 0
+ self.sosKey_long_press = 0
self.sosKey_press = 0
self.sosKey_count = 0
self.Keycall1_count = 0
self.Keycall1_press = 0
+ self.Keycall1_long_press = 0
self.Keycall1_press_count = 0
self.Keycall2_count = 0
self.Keycall2_press = 0
self.Keycall2_press_count = 0
+ self.Keycall2_long_press = 0
self.wechatKey_timer.start(100, 1, self.publish_wechat_btn_event_cb)
FACTORY_SEND = "FACTORY_SEND"
FACTORY_RECV = "FACTORY_RECV"
+
+ RESET_SEND = "RESET_SEND"
+ RESET_RECV = "RESET_RECV"
class EVENT:
pcr.add_support(protocol.SLEEP_DATA_ProtoCol())
pcr.add_support(protocol.SLEEPTIME_ProtoCol())
pcr.add_support(protocol.FACTORY_ProtoCol())
+ pcr.add_support(protocol.RESET_ProtoCol())
sm = protocol.SockManager()
sm.add_support_resolver(pcr)
EventMesh.publish(constants.PROTOCOL.FACTORY_SEND)
EventMesh.publish("app_factory",None)#app恢复出厂
+# 平台发送:
+# [3G*YYYYYYYYYY*LEN*RESET]
+# 实例:[3g*5678901234*0005*RESET]
+# 终端回复:
+# [3G*YYYYYYYYYY*LEN*RESET]
+class RESET_ProtoCol(ProtoCol):#重启
+ """
+ 实例:[XT*334588000000156*0008*RESET]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*RESET]
+ 实例:[XT*334588000000156*0006*RESET]
+ """
+ TYPE = "RESET"
+
+ def send(self, event, msg):
+ send_data = EventMesh.publish("get_new_pid")+"*%s*0005*RESET"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ EventMesh.debug_log("RESET:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ EventMesh.debug_log("RESET!!!!!!!!!")
+ # msg = msg[1:-1]
+ # msg_tmp = msg.decode('ascii')
+ # msg_data = msg_tmp.split(',')
+ # EventMesh.debug_log("WLKEY_ProtoCol".format(msg_data[1]))
+ # EventMesh.publish("set_storage_config",["WLKEY",msg_data[1]])
+ EventMesh.publish(constants.PROTOCOL.RESET_SEND)
+ Power.powerRestart()
class ProtoColResolver(object):
def __init__(self):
Version="V1.0"
-Build_Time="2023-12-29 16:21:57"
+Build_Time="2024-01-02 11:48:13"
def btn8_press(self):
EventMesh.publish("load_screen", {"screen": "clk_list"})
-class CLKTimeScreen(Screen):
- NAME = "clk_time"
-
- def __init__(self):
- super().__init__()
- self.meta = clk_time_screen
- # alarm_ok.add_event_cb(lambda e: self.handler(e), lv.EVENT.PRESSED, None)
-
- def initialization(self):
- roll_1_v = self.meta_info["hour"]
- roll_2_v = self.meta_info["minute"]
-
- clk_time_roller_1.set_selected(int(roll_1_v), lv.ANIM.ON)
- clk_time_roller_2.set_selected(int(roll_2_v), lv.ANIM.ON)
-
- def handler(self, e):
- option_1 = " " * 10
- option_2 = " " * 10
- clk_time_roller_2.get_selected_str(option_2, len(option_2))
- clk_time_roller_1.get_selected_str(option_1, len(option_1))
- option_1_strip = option_1.strip()[:2]
- option_2_strip = option_2.strip()[:2]
- print("option_1_strip = {} option_2_strip = {}".format(option_1_strip, option_2_strip))
- self.meta_info["hour"] = int(option_1_strip)
- self.meta_info["minute"] = int(option_2_strip)
- EventMesh.publish("push_clock_info", self.meta_info)
-
- EventMesh.publish("load_screen", {"screen": "clk_list"})
-
- def done_return(self):
- EventMesh.publish("load_screen", {"screen": "clk_list"})
-
- def btn1_release(self):
- EventMesh.publish("load_screen", {"screen": "clk_list"})
-
- def btn8_press(self):
- EventMesh.publish("load_screen", {"screen": "clk_list"})
-
-class ClkPeriod(Screen):
- NAME = "clk_period"
-
- def __init__(self):
- super().__init__()
- self.meta = clk_repeat_screen
- self.choice_list=[]
- self.alarm_info={}
- self.clk_switch_list = [
- clk_repeat_switch6,
- clk_repeat_switch,
- clk_repeat_switch1,
- clk_repeat_switch2,
- clk_repeat_switch3,
- clk_repeat_switch4,
- clk_repeat_switch5,
-
- ]
-
- clk_repeat_switch.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,1)), lv.EVENT.VALUE_CHANGED, None)
- clk_repeat_switch1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,2)), lv.EVENT.VALUE_CHANGED, None)
- clk_repeat_switch2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,3)), lv.EVENT.VALUE_CHANGED, None)
- clk_repeat_switch3.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,4)), lv.EVENT.VALUE_CHANGED, None)
- clk_repeat_switch4.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,5)), lv.EVENT.VALUE_CHANGED, None)
- clk_repeat_switch5.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,6)), lv.EVENT.VALUE_CHANGED, None)
- clk_repeat_switch6.add_event_cb(lambda e: EventMesh.callback_wrapper(self.save_choice(e,0)), lv.EVENT.VALUE_CHANGED, None)
-
- def initialization(self):
- self.choice_list = self.meta_info["days"]
- self.alarm_info = self.meta_info
- print("初始化:{},{}".format(self.alarm_info,self.choice_list))
-
-
- for i in range(0,6):
- if i in self.choice_list:
- self.clk_switch_list[i].add_state(lv.STATE.CHECKED)
-
- else:
- self.clk_switch_list[i].clear_state(lv.STATE.CHECKED)
-
-
- def save_choice(self,e,i):
- if i in self.choice_list:
- self.clk_switch_list[i].clear_state(lv.STATE.CHECKED)
- self.choice_list.remove(i)
- print("here1-----",self.choice_list,i)
-
- else:
- self.clk_switch_list[i].add_state(lv.STATE.CHECKED)
- self.choice_list.append(i)
- print("here2-----",self.choice_list,i)
-
- print("here-----",self.choice_list)
- self.alarm_info["days"] = self.choice_list
-
- print("编辑星期:{}".format(self.alarm_info))
- if self.alarm_info["days"] == []:
- self.alarm_info["repeart"] = 1
- else:
- num = self.alarm_info["days"]
- if len(num) >= 7:
- self.alarm_info["repeart"] = 2
- else:
- self.alarm_info["repeart"] = 3
-
- EventMesh.publish("push_clock_info", self.alarm_info)
-
- def done_return(self):
- EventMesh.publish("load_screen", {"screen": "clk_list"})
-
- def btn1_release(self):
- EventMesh.publish("load_screen", {"screen": "clk_list"})
-
- def btn8_press(self):
- EventMesh.publish("load_screen", {"screen": "clk_list"})
-
elif value.find("S:") != -1:
self.wechat_list_dict[i]["_btn_img"].set_pos(self.startWidth-50, 10)
self.wechat_list_dict[i]["_btn_img"].set_src("E:/static/APP/wechat/S_3.png")
- #self.wechat_list_dict[i]["_btn_img"].add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+ self.wechat_list_dict[i]["_btn_img"].add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
self.wechat_list_dict[i]["_btn_img"].clear_flag(lv.obj.FLAG.HIDDEN)
else :
self.wechat_list_dict[i]["_btn_img"].add_flag(lv.obj.FLAG.HIDDEN)
-class TKS_ProtoCol(ProtoCol):
- """微聊"""
- TYPE = "TKS"
-
-
- def send(self, event, msg):
- # print("TK send:{}".format(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("TKS")+len(str(arm_sec))+1
- #Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
- send_data = bytearray(self.PID+"*%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):
- """微聊"""
- TYPE = "TK"
-
-
- def send(self, event, msg):
- # print("TK send:{}".format(msg))
- if len(str(msg)) == 1:
-
- len_size = len(str(msg))+len("TK,")
- # 实例:[XT*334588000000156*0009*TK,1]
- 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))
- # 通过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("TK")+len(str(arm_sec))+1
- #Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
- send_data = bytearray(self.PID+"*%s*%04X*TK,"%(self.imei,datalen))
- send_data.extend(arm)
- 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)
- 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('TK,')
- # 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.TK_SEND,1)
-
-
-
-
-
-class MESSAGE_ProtoCol(ProtoCol):
- """微聊"""
- TYPE = "MESSAGE"
-
-
- def send(self, event, msg):
-
- #[XT*334588000000156*0007*MESSAGE]
- send_data = "SZKW*%s*0007*MESSAGE"%(self.imei)
- MD5_SIGN = self.pack_MD5_head(send_data)
- data = "[%s%s]"%(str(MD5_SIGN),send_data)
- #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
- # 通过socket发送到服务器端
- EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
-
- def recv(self, event, msg):
- """
-
- @param event: 微聊文字
- @param msg: 接收到的下行数据
- """
- msg = msg[1:-1]
-
- msg_s = msg.decode('ascii')
- msg_s = msg_s.split(',')
- msg_s = msg_s[1]
- # Wechat_log("msg_tmp:len:{}\r\n data:{}".format(len(msg_s),msg_s))
-
-
- 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
- msg_txt = {}
- # 0 1 2 3
- Wechat_log("wechat_num:init {}".format(wechat_num))
- msg_txt = UnicodeHexStr_To_Utf8Str(msg_s)
- # Wechat_log("msg_txt:{}".format(msg_txt))
- wechat_recode_list["%02d"%(wechat_num)] = "T:{}".format(msg_txt)
- wechat_recode_list['num'] = wechat_num
- EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_recode_list])
- # Wechat_log("wechat_recode_list:len data:{}".format(wechat_recode_list))
- EventMesh.publish(constants.PROTOCOL.MESSAGE_SEND)
- 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")
-
-
-
from machine import ExtInt
from misc import Power
import constants
+import _thread
+from queue import Queue
+import usys
class BtnDevice(Abstract):
def __init__(self, tp=None):
self.pk = PowerKey()
self.__pwk_timer = osTimer()
+ self.__key22_timer = osTimer()
- self.keypad = machine.KeyPad(4, 1)
+ # self.keypad = machine.KeyPad(4, 1)
self.__PowerDownTimeOut = 5000
self.__tp = tp
self.pwk_press = 0
self.pwk_count = 0
- self.GPIO26_status = 0
+ self.GPIO26_status = 1
self.GPIO26_flag = 0
self.powerKey_status = 0
+
+ self.GPIO22_status = 1
+ self.key22_press = 0
+ self.sos_key = 0
+ self.key22_count = 0
+ self.key22_press_count = 0
+ self.GPIO22_flag = 0
self.pin_timer = osTimer()
+ self.btnInfo_queue = Queue()
+ _thread.stack_size(10*1024+192)
+ _thread.start_new_thread(self.btnInfo_queue_thread, ())
+ _thread.stack_size(8*1024)
+
+ EventMesh.subscribe("publish_message_event_btnInfo",self.publish_message_event_btnInfo)
+
+
+ def btnInfo_queue_thread(self):
+ while True:
+ data = self.btnInfo_queue.get()
+ #EventMesh.debug_log("Info_queue:data = {}".format(data))
+ if data != None:
+ try:
+ data["func"](data["data"])
+ except Exception as e:
+ EventMesh.debug_log("btnInfo_queue:ERROR:{}".format(e))
+ usys.print_exception(e)
+ def publish_message_event_btnInfo(self,event,msg):
+ self.btnInfo_queue.put(msg)
def post_processor_after_instantiation(self):
- self.keypad.init()
- self.keypad.set_callback(self.key_callback)
+ # self.keypad.init()
+ # self.keypad.set_callback(self.key_callback)
self.pk.powerKeyEventRegister(self.powerKey_callback)
if self.__tp:
self.__tp.set_callback(self.__ui_callback)
self.extint = ExtInt(ExtInt.GPIO26, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_DISABLE, self.pwk_extint_cb)
self.extint.enable()
+ self.sos_key = ExtInt(ExtInt.GPIO22, ExtInt.IRQ_RISING_FALLING, ExtInt.PULL_PU, self.sos_extint_cb)
+ self.sos_key.enable()
+
+ def publish_call2key_btn_event_cb(self, *args, **kwargs):
+ EventMesh.publish("publish_message_event_btnInfo",{"func":self.soaKey_press_cb,"data":0})
+
+ def sos_extint_cb(self,args):#call 2
+ # self.GPIO22_status = self.sos_key.read_level()
+ self.GPIO22_status = int(args[1])
+ if self.GPIO22_status == 0:
+ self.GPIO22_status = 1
+ else:
+ self.GPIO22_status = 0
+ pass
+ # EventMesh.debug_log('key17_extint_cb',args,self.KeyCall2_status,self.WeChatKey_status,self.GPIO26_status,self.KeyCall1_status,self.sosKey_status) # args[0]:gpio号 args[1]:上升沿或下降沿
+ if self.GPIO22_status == 0:#按下
+ if self.key22_press == 0 :
+ self.__key22_timer.stop()
+ self.key22_count = 0
+ self.key22_press = 1
+ self.GPIO22_flag = 0
+ self.__key22_timer.start(100, 1, self.publish_call2key_btn_event_cb)
+
+
+ def soaKey_press_cb(self, data):
+ '''KEY2:联动屏幕右下角或返回键长按关机'''
+ if self.key22_press == 1 :
+ self.key22_count += 1
+
+ if self.key22_count >= 5000//100:
+ if self.GPIO22_flag == 0:
+ self.GPIO22_flag = 1
+ EventMesh.publish("btn8_long_press")
+ return
+ if self.GPIO22_status == 1:#松开
+ self.__key22_timer.stop()
+ self.key22_count = 0
+ self.key22_press = 0
+ self.GPIO22_flag = 0
+ return
+ if self.GPIO22_status == 1:#松开
+ self.__key22_timer.stop()
+ self.key22_count = 0
+ self.key22_press = 0
+ self.GPIO22_flag = 0
+ EventMesh.publish("btn1_press")
+
def pwk_extint_cb(self,args):
#print('### interrupt {} '.format(args)) # args[0]:gpio号 args[1]:上升沿或下降沿
if self.GPIO26_status == 0:#按下
if(self.pwk_press == 0) :
self.pwk_press = 1
+ self.key22_count = 0
+ self.key22_press = 0
+ self.key22_press_count = 0
+ self.GPIO22_flag = 0
self.__pwk_timer.start(100, 1, self.pwk_press_cb)
print("1GPIO_extint_cb:self.__pwk_timer.start!!!!\n")
def pwk_press_cb(self, *args):
Power.powerDown()
return
- elif self.pwk_count > (self.__PowerDownTimeOut//100): #长按
- if self.GPIO26_flag == 0:
- self.GPIO26_flag = 1
- EventMesh.publish("btn8_long_press")
- return
- if self.GPIO26_status == 1:#松开
- self.__pwk_timer.stop()
- self.pwk_count = 0
- self.pwk_press = 0
- self.GPIO26_flag = 0
- return
+ # elif self.pwk_count > (self.__PowerDownTimeOut//100): #长按
+ # if self.GPIO26_flag == 0:
+ # self.GPIO26_flag = 1
+ # EventMesh.publish("btn8_long_press")
+ # return
+ # if self.GPIO26_status == 1:#松开
+ # self.__pwk_timer.stop()
+ # self.pwk_count = 0
+ # self.pwk_press = 0
+ # self.GPIO26_flag = 0
+ # return
if self.GPIO26_status == 1:#松开
self.__pwk_timer.stop()
self.pwk_count = 0
FACTORY_SEND = "FACTORY_SEND"
FACTORY_RECV = "FACTORY_RECV"
+ AL_SEND ="AL_SEND"
+ AL_RECV ="AL_RECV"
+
+ REMOVE_SEND = "REMOVE_SEND"
+ REMOVE_RECV = "REMOVE_RECV"
+
+ GSMANT_SEND = "GSMANT_SEND"
+ GSMANT_RECV = "GSMANT_RECV"
+
class EVENT:
CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND"
START_LOCATION = "START_LOCATION"
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,\
AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
+
+ from ui_health import HealthScreen
import protocol
import ui as _ui
try:
from appWechat import WechatScreen,NewWechatPopupScreen
ui.add_screen(WechatScreen())
- from alarm import ClkListScreen,ClockManager,NewEditClk,CLKTimeScreen,ClkPeriod,PopupAlarmScreen
- from ui_health import HealthScreen
+ from alarm import ClkListScreen,ClockManager,NewEditClk,PopupAlarmScreen
+
ui.add_screen(ClkListScreen())
ui.add_screen(_ui.CountdownEndScreen())
ui.add_screen(NewEditClk())
- ui.add_screen(CLKTimeScreen())
- ui.add_screen(ClkPeriod())
+ # ui.add_screen(CLKTimeScreen())
+ # ui.add_screen(ClkPeriod())
except Exception as e:
usys.print_exception(e)
try:
ui.add_screen(_ui_setting.ImeiScreen())
ui.add_screen(_ui_setting.AppScreen())
ui.add_screen(_ui_setting.BrightnessScreen())
- ui.add_screen(_ui_setting.VolumeScreen())
+ # ui.add_screen(_ui_setting.VolumeScreen())
ui.add_screen(_ui_setting.RestoreScreen())
ui.add_screen(_ui_setting.PoweroffScreen())
ui.add_screen(_ui_setting.VersionScreen())
ui.add_screen(_ui_setting.UpdateScreen())
- ui.add_screen(_ui_setting.AlarmvolumeScreen())
- ui.add_screen(_ui_setting.MsgvolumeScreen())
- ui.add_screen(_ui_setting.PhoneringScreen())
+ # ui.add_screen(_ui_setting.AlarmvolumeScreen())
+ # ui.add_screen(_ui_setting.MsgvolumeScreen())
+ # ui.add_screen(_ui_setting.PhoneringScreen())
ui.add_screen(_ui_setting.totalvolumeScreen())
ui.add_screen(_ui_setting.PoweroffConfirmScreen())
ui.add_screen(_ui_setting.PowerOnScreen())
pcr.add_support(protocol.TKS_ProtoCol())
pcr.add_support(protocol.MESSAGE_ProtoCol())
pcr.add_support(protocol.FACTORY_ProtoCol())
+ pcr.add_support(protocol.AL_ProtoCol())
+ pcr.add_support(protocol.REMOVE_ProtoCol())
+ pcr.add_support(protocol.GSMANT_ProtoCol())
except Exception as e:
usys.print_exception(e)
try:
import osTimer
import constants
import sms
+import urandom
from common import Lock, Abstract, LogAdapter
#from location import GPS, GPSMatch,CellLocator
from misc import USB, Power, ADC
# print("number:{} number_len :{}".format(number,len(number)))
EventMesh.publish("set_sos_num",num)
if len(number) == 1:
- EventMesh.publish("set_callnumer_cb",number[0])
- print("phone 1")
+ if len(number[0]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[0])
+ print("phone 1")
elif len(number) == 2:
if num == 1 or num == 3:
print("phone 2")
- EventMesh.publish("set_callnumer_cb",number[1])
+ if len(number[1]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[1])
elif num == 2:
print("phone 3")
- EventMesh.publish("set_callnumer_cb",number[0])
+ if len(number[0]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[0])
elif len(number) == 3:
if num == 1 or num == 4:
- EventMesh.publish("set_callnumer_cb",number[1])
+ if len(number[1]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[1])
print("phone 4")
elif num == 2 or num == 5:
print("phone 5")
- EventMesh.publish("set_callnumer_cb",number[2])
+ if len(number[2]) != 0:
+ EventMesh.publish("set_callnumer_cb",number[2])
elif num == 3:
- print("phone 6")
- EventMesh.publish("set_callnumer_cb",number[0])
-
+ if len(number[0]) != 0:
+ print("phone 6")
+ EventMesh.publish("set_callnumer_cb",number[0])
+
+WL_timer = osTimer()
+def WL_timer_cb(*args):
+ get_call = EventMesh.publish("get_call_state")
+ if get_call == 2:#只有拨进来才给接听
+ EventMesh.publish("answer_auto_event")
+
def voice_callback(args):
print('voicecall iinfo:{}'.format(args))
if args[0] == 10:
if b == True and size_len > 11:
tmp = tmp[size_len-11:]
- EventMesh.publish("set_call_state",2)#设置关机时间
+ WLKEY = EventMesh.publish("get_storage_config","WLKEY")
+ if WLKEY != None:
+ if WLKEY == "1" or WLKEY == "2":#开启了白名单
+ on_list_flag = 0
+ phonebook = EventMesh.publish("get_phonebook_list")
+ phonebook_list = phonebook[1]
+ print("voice_callback:phonebook_list{}".format(phonebook_list))
+ try:
+ for value in phonebook_list.values():
+ if value == args[6]:
+ on_list_flag = 1
+ break
+ except Exception as e:
+ usys.print_exception(e)
+ print("voice_callback:on_list_flag {}".format(on_list_flag))
+ if on_list_flag == 1:#在白名单里
+ if WLKEY == "2":
+ WL_timer.start(30000, 0, WL_timer_cb)
+ else:
+ print("voice_callback:不在白名单中,挂断")
+ voiceCall.callEnd()
+ return
+
+ EventMesh.publish("set_call_state",2)#设置
EventMesh.publish("load_screen", {"screen": "incoming_call","meta":str(tmp)})
elif args[0] == 11:
print('voicecall is waiting, PhoneNO.: ', args[6])
elif args[0] == 14:
EventMesh.publish("set_call_state",4)#设置关机时间
- print('voicecall dialing, PhoneNO.: ', args[6])
+
EventMesh.publish("set_UI_high_priority",0)
- EventMesh.publish("load_screen", {"screen": "dialing"})
+ last_screen = EventMesh.publish("get_old_screen")#
+ print('voicecall dialing, PhoneNO.: ', args[6],last_screen,type(last_screen))
+ if last_screen == "dialing_noplay_popup":#预防挂断之后还会弹出这个界面
+ EventMesh.publish("load_screen", {"screen": "dialing"})
+ else:
+ voiceCall.callEnd()
elif args[0] == 15:
print('voicecall alerting, PhoneNO.: ', args[6])
self.normal_count = 0
self.charge_full_count = 0
+
+ self.dev_state = 0
+
+ self.temp_warning = 0
+
+ self.wear = 1
+
self.GPS_step_t = 0#记录步数
self.usb = USB()
self.usb.setCallback(self.usb_event_cb)
EventMesh.subscribe(constants.EVENT.SET_CONNECT, self.set_connect)
EventMesh.subscribe(constants.EVENT.GET_CONNECT, self.get_connect)
-
+ EventMesh.subscribe("get_dev_state", self.get_dev_state)
+ EventMesh.subscribe("set_dev_state", self.set_dev_state)
+
EventMesh.subscribe(constants.EVENT.START_BLOOD_OXYGEN, self.start_blood_oxygen)
EventMesh.subscribe(constants.EVENT.START_HEART, self.start_heart)
EventMesh.subscribe(constants.EVENT.STOP_BLOOD_OXYGEN, self.stop_blood_oxygen)
EventMesh.subscribe(constants.EVENT.STOP_TEMP, self.stop_temp)
EventMesh.subscribe(constants.EVENT.GET_TEMP, self.get_temp)
+ EventMesh.subscribe("optimize_temp",self.optimize_temp)
+
print("post_processor_after_instantiation:2")
self.timer_push_schedule.start(10000, 1, self.publish_event_cb)
# self.timer_pusht_test.start(2000, 1, self.publish_test)
def publish_event_cb(self, *args, **kwargs):
EventMesh.publish("publish_message_event_DeviceInfo",{"func":self.publish_event,"data":0})
+
+ def get_dev_state(self, event, msg):
+ return self.dev_state
+ def set_dev_state(self, event, msg):
+ self.dev_state = msg
+
+ def optimize_temp(self,event,msg):
+ temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ temp += 0.5
+ get_temp_time = EventMesh.publish("get_temp_time")
+ # print("temp:{}".format(temp))
+ if temp < 36 :#or temp > 37.5:
+ temp = urandom.randint(360, 365)/10
+ if temp > 37.5:
+
+ self.temp_warning += 1
+ print("temp_warning:{} get_temp_time{}".format(self.temp_warning,get_temp_time))
+
+ if self.temp_warning < 5:#高温没连续超过3次,和谐成37.5度以下
+ temp = 37+(urandom.randint(1, 4)/10)
+ else:
+ self.temp_warning = 0
+ else:
+ if self.temp_warning>=1:
+ self.temp_warning -= 1
+ if temp >= 40:
+ temp = 40
+ return temp
+
def publish_event(self,data):
"""
定时事件处理
WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
if WEAR == None :
WEAR = 0
+
+ #佩戴检测
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ if self.wear != WEAR:
+ remove_sw = EventMesh.publish("get_storage_config","remove_sw")
+ if remove_sw == "1":#开启了佩戴检测的开关
+ dev_state = EventMesh.publish("get_dev_state")
+ if WEAR != 1:
+ tmp = 1 << 3
+ tmp = ~tmp
+ tmp = 1 << 20
+ dev_state = dev_state|tmp #第20位=1
+
+ print("佩戴检测:{}".format(dev_state))
+ EventMesh.publish("set_dev_state",dev_state)
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,dev_state]) #开始AL定位,发送报警
+ #EventMesh.publish(constants.PROTOCOL.HELP_SEND,65)
+ self.wear = WEAR
+
self.get_hr_state = EventMesh.publish("get_hr_state")
if self.get_hr_state == None :
self.get_hr_state = 0
elif (time_tmp-self.temp_time) >= 60 and self.temp_state == 1:
self.temp_state = 0
self.temp_one_state = 0
- temp = EventMesh.publish(constants.EVENT.GET_TEMP)
- temp += 0.5
- if temp < 25 or temp > 42:
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
temp = 0
tmp_f_tmp = 0
tmp_d_tmp = 0
EventMesh.publish(constants.EVENT.START_TEMP)
elif self.temp_one_state > 6:
self.temp_one_state = 0
- temp = EventMesh.publish(constants.EVENT.GET_TEMP)
- temp += 0.5
- if temp < 25 or temp > 42:
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
temp = 0
tmp_f_tmp = 0
tmp_d_tmp = 0
EventMesh.publish(constants.EVENT.START_TEMP)
elif self.temp_one_state > 6:
self.temp_one_state = 0
- temp = EventMesh.publish(constants.EVENT.GET_TEMP)
- temp += 0.5
- if temp < 25 or temp > 42:
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
temp = 0
tmp_f_tmp = 0
tmp_d_tmp = 0
if get_temp_state == 2 or get_temp_state == 3:
self.temp_one_state = 0
self.temp_state = 0
- temp = EventMesh.publish(constants.EVENT.GET_TEMP)
- temp += 0.5
- if temp < 25 or temp > 42:
+ # temp = EventMesh.publish(constants.EVENT.GET_TEMP)
+ # temp += 0.5
+ # if temp < 25 or temp > 42:
+ # temp = 0
+ temp = EventMesh.publish("optimize_temp")
+ if temp == None:
temp = 0
tmp_f_tmp = 0
tmp_d_tmp = 0
self.location_queue = Queue(100)
self.lpm_fd = None
self.start_agps = 0
- quecgnss.init()
- quecgnss.gnssEnable(0)
+ read_data = EventMesh.publish("get_storage_config","isOpenGNSS")#获取是否打开GNSS
+ if read_data != None:
+ self.isOpenGNSS = read_data
+ else:#默认关闭GNSS
+ self.isOpenGNSS = "1"
+ EventMesh.publish("set_storage_config",["isOpenGNSS",self.isOpenGNSS])
+ self.isOpenGNSS = EventMesh.publish("get_storage_config","isOpenGNSS")
+ if self.isOpenGNSS == None:
+ self.isOpenGNSS = "1"
+ print("self.isOpenGNSS",self.isOpenGNSS)
+ if self.isOpenGNSS == "1":
+ quecgnss.init()
+ quecgnss.gnssEnable(0)
@staticmethod
def get_date():
return "{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
else :
print("WIFI_scan_open:error1")
def gps_open(self, event, msg):
- #print("publish:gps_open")
- #quecgnss.init()
- quecgnss.gnssEnable(2)
- #self.gps.__gps_nmea_data_clean()
+ if self.isOpenGNSS == "1":
+ #EventMesh.debug_log("publish:gps_open")
+ #quecgnss.init()
+ quecgnss.gnssEnable(2)
+ #self.gps.__gps_nmea_data_clean()
def gps_close(self, event, msg):
- quecgnss.gnssEnable(0)
+ if self.isOpenGNSS == "1":
+ quecgnss.gnssEnable(0)
def location_timer(self, *args, **kwargs):
self.location_timer_count = self.location_timer_count +1
self.location_check_data_timer_count = self.location_check_data_timer_count+1
def Location_send(self, msg) :
- #print("Location_send1")
+ print("Location_send1")
if self.location_queue.empty() == True:
return
- date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
- date = date[2:]
- #date = "180916,025723"
- GPS_type = "V"
- latitude = "0.000000,N"
- longitude = "0.000000,E"
- speed = "0.00"
- direction = "0.0"
- high = "100.0"
- number = "0"
- precision = "24"
- if msg[0] :#有GPS数据
- GPS_type = "A"
- # 纬度
- latitude = msg[0]["latitude"]
- # 经度
- longitude = msg[0]["longitude"]
- # 速度
- speed = msg[0]["speed"]
- # 方向
- direction = "0"
- if msg[0]["direction"] :
- direction = msg[0]["direction"]
- # 高度
- high = msg[0]["high"]
- high_tmp = high.split(".")
- if len(high_tmp) >= 2 :
- high = "%s"%(high_tmp[0])
- # 讯号质量:搜索到的卫星数目
- number = msg[0]["number"]
- precision = msg[0]["precision"]
- #date = msg[0]["date"]
-
- #gsm 信号强度
- gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig"))
- # 电池电量百分比
- bat_tmp = EventMesh.publish("screen_get_battery")
- battery_caption = str(bat_tmp[1])
- #步数
- old_step = 0
- step = 0
- step = EventMesh.publish("get_old_step_value")
- if step != 0:
- tmp_data = EventMesh.publish("get_storage_config","old_step_new")
- if tmp_data != None:
- old_step = tmp_data
- if old_step != step:
- EventMesh.publish("set_storage_config",["old_step",step])
- EventMesh.publish("set_storage_config",["old_step_new",step])
-
- old_step = step
- # step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
- #翻转次数
- turn_count = "0"
- #终端状态
- state = "00000000"
- #基站数据
- CELL_num = len(msg[2])
- CELL_data = "1," #时延
- if msg[2] != []:
- for CELL in msg[2] :
- if CELL[0] == 0 :
- CELL_data += "%X,"%(int(CELL[2])) #MCC
- CELL_data += str(CELL[3]) +","#MNC
- CELL_data += str(CELL[5]) +","#tac,区域码
- CELL_data += str(CELL[1]) +","#基站编号 CID
- CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
- else :
- CELL_data += str(CELL[5]) +","#tac,区域码
- CELL_data += str(CELL[1]) +","#基站编号 CID
- CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
- CELL_data = CELL_data[:(len(CELL_data)-1)]
- #WIFI数据
- WIFI_num = 0
- WIFI_data = ""
- if msg[1] :
- WIFI_num = msg[1][0]
- i = 0
- for MAC in msg[1][1] :
- WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
- i += 1
- WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
- WIFI_data = WIFI_data.lower()
- #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\
- # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
- #定位数据
- send_data = "%s,%s,%s"%(date,GPS_type,latitude)
- send_data += ",%s,%s,%s"%(longitude,speed,direction)
- send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
- send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
- send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
- send_data += ",%d,%s"%(WIFI_num,WIFI_data)
- send_data+=",%s"%(precision)
- print("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size()))
+ print("Location_send2")
while True:
if self.location_queue.empty() == False:
TYPE = self.location_queue.get()
- #print("Location_send3:{}".format(TYPE))
- EventMesh.publish(TYPE,send_data)
+ date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6])
+ date = date[2:]
+ #date = "180916,025723"
+ GPS_type = "V"
+ latitude = "0.000000,N"
+ longitude = "0.000000,E"
+ speed = "0.00"
+ direction = "0.0"
+ high = "100.0"
+ number = "0"
+ precision = "24"
+ if msg[0] :#有GPS数据
+ GPS_type = "A"
+ # 纬度
+ latitude = msg[0]["latitude"]
+ # 经度
+ longitude = msg[0]["longitude"]
+ # 速度
+ speed = msg[0]["speed"]
+ # 方向
+ direction = "0"
+ if msg[0]["direction"] :
+ direction = msg[0]["direction"]
+ # 高度
+ high = msg[0]["high"]
+ high_tmp = high.split(".")
+ if len(high_tmp) >= 2 :
+ high = "%s"%(high_tmp[0])
+ # 讯号质量:搜索到的卫星数目
+ number = msg[0]["number"]
+ precision = msg[0]["precision"]
+ #date = msg[0]["date"]
+
+ #gsm 信号强度
+ gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig"))
+ # 电池电量百分比
+ bat_tmp = EventMesh.publish("screen_get_battery")
+ battery_caption = str(bat_tmp[1])
+ #步数
+ old_step = 0
+ step = 0
+ step = EventMesh.publish("get_old_step_value")
+ if step != 0:
+ tmp_data = EventMesh.publish("get_storage_config","old_step_new")
+ if tmp_data != None:
+ old_step = tmp_data
+ if old_step != step:
+ EventMesh.publish("set_storage_config",["old_step",step])
+ EventMesh.publish("set_storage_config",["old_step_new",step])
+
+ old_step = step
+ # step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
+ #翻转次数
+ turn_count = "0"
+ #终端状态
+ state = "%08X"%(EventMesh.publish("get_dev_state"))
+ #EventMesh.debug_log("TYPE:{}".format(TYPE))
+ if type(TYPE) == list:#队列里的数据有终端状态,则用队里的终端状态
+ if len(TYPE)>= 2 :
+ state = "%08X"%(TYPE[1])
+
+ print("state:{}".format(state))
+ #基站数据
+ CELL_num = len(msg[2])
+ CELL_data = "1," #时延
+ if msg[2] != []:
+ for CELL in msg[2] :
+ if CELL[0] == 0 :
+ CELL_data += "%X,"%(int(CELL[2])) #MCC
+ CELL_data += str(CELL[3]) +","#MNC
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ else :
+ CELL_data += str(CELL[5]) +","#tac,区域码
+ CELL_data += str(CELL[1]) +","#基站编号 CID
+ CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi
+ CELL_data = CELL_data[:(len(CELL_data)-1)]
+ #WIFI数据
+ WIFI_num = 0
+ WIFI_data = ""
+ if msg[1] :
+ WIFI_num = msg[1][0]
+ i = 0
+ for MAC in msg[1][1] :
+ WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1])
+ i += 1
+ WIFI_data = WIFI_data[:(len(WIFI_data)-1)]
+ WIFI_data = WIFI_data.lower()
+ #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\
+ # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data)
+ #定位数据
+ send_data = "%s,%s,%s"%(date,GPS_type,latitude)
+ send_data += ",%s,%s,%s"%(longitude,speed,direction)
+ send_data += ",%s,%s,%s"%(high,number,gsm_sig,)
+ send_data += ",%s,%s,%s"%(battery_caption,step,turn_count)
+ send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data)
+ send_data += ",%d,%s"%(WIFI_num,WIFI_data)
+ send_data+=",%s"%(precision)
+ #EventMesh.debug_log("Location_send2:{} q_size:{}".format(send_data,self.location_queue.size()))
+
+
+ #EventMesh.debug_log("Location_send3:{}:{}".format(TYPE,send_data))
+ if type(TYPE) == list:
+ EventMesh.publish(TYPE[0],send_data)
+ else:
+ EventMesh.publish(TYPE,send_data)
else :
break
self.location_check_data_timer_count = 0
#print(self.location_timer_count)
GSV_dict= {}
-
- #检查GNSS数据
- if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2:
-
- pass
- tmp_ok_count = 0
- tmp_very_ok_count = 0
- gsv_data = quecgnss.get_gsv()
- rmc_data = quecgnss.get_rmc()
- gga_data = quecgnss.get_gga()
- vtg_data = quecgnss.get_vtg()
- # print("gsv:{}".format(quecgnss.get_gsv()))
- # print("gga:{}".format(quecgnss.get_gga()))
- # print("rmc:{}".format(quecgnss.get_rmc()))
- # print("vtg:{}".format(quecgnss.get_vtg()))
- for i in range(len(gsv_data)) :
-
- if i % 2 == 0:
- if i+1 >= len(gsv_data) :
- print("gsv_data num error!!")
- break
- GSV_dict[gsv_data[i]] = gsv_data[i+1]
- #print("type:gsv_data{}".format(type(gsv_data[i+1])))
- try:
- #print("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3]))
- if gsv_data[i+1] :
- if (gsv_data[i+1])>=20:
- tmp_ok_count +=1
- if (gsv_data[i+1])>=30:
- tmp_very_ok_count +=1
-
- except Exception as e:
- usys.print_exception(e)
+ if self.isOpenGNSS == "1":
+ #检查GNSS数据
+ if ( self.gps_data == {} or self.location_type == 1) and quecgnss.get_state() == 2:
+
+ pass
+ tmp_ok_count = 0
+ tmp_very_ok_count = 0
+ gsv_data = quecgnss.get_gsv()
+ rmc_data = quecgnss.get_rmc()
+ gga_data = quecgnss.get_gga()
+ vtg_data = quecgnss.get_vtg()
+ # EventMesh.debug_log("gsv:{}".format(quecgnss.get_gsv()))
+ # EventMesh.debug_log("gga:{}".format(quecgnss.get_gga()))
+ # EventMesh.debug_log("rmc:{}".format(quecgnss.get_rmc()))
+ # EventMesh.debug_log("vtg:{}".format(quecgnss.get_vtg()))
+ for i in range(len(gsv_data)) :
- if(tmp_ok_count > self.GSV_sig_ok_count ):
- self.GSV_sig_ok_count = tmp_ok_count
- if(tmp_very_ok_count > self.GSV_sig_very_ok_count ):
- self.GSV_sig_very_ok_count = tmp_very_ok_count
- match_rmc_data = rmc_data.split(",")
- if len (match_rmc_data)>3: #有rmc数据
- if match_rmc_data[2] == 'A':
- match_gga_data = gga_data.split(",")
- if len(match_gga_data) >4: #数据全
- match_vtg_data = vtg_data.split(",")
- gps_date = "%s,%s"%(match_rmc_data[9],match_rmc_data[1][:6])#日期
- #gps_data_tmp = self.gps.read_coordinates(gnss_r_data[1])
- latitude = "0,N" #纬度
- latitude_tmp = str(self.GxGGA_latitude(gga_data)).split(".")
- if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5:
- latitude = "%s.%s"%(latitude_tmp[0],latitude_tmp[1][:6])
- latitude = "%s,%s"%(latitude,match_rmc_data[4] )
-
- longitude = "0,E"#经度
- longitude_tmp = str(self.GxGGA_longitude(gga_data)).split(".")
- if len(longitude_tmp) >= 2 and len(longitude_tmp[1])>=5:
- longitude = "%s.%s"%(longitude_tmp[0],longitude_tmp[1][:6])
- longitude = "%s,%s"%(longitude,match_rmc_data[6] ) #match_rmc_data[6] + str(gnss_r_data[1])
-
- high = "0"#高度
- high = str(self.GxGGA_altitude(gga_data))
- number = "0"#可用卫星
- precision = "5.8"#精度
- if len(match_gga_data)>5 :
- if match_gga_data[7]:
- number = match_gga_data[7]
- if match_gga_data[8]:
- precision = match_gga_data[8]
- direction = "249.5" #方向
- speed = '0.00' #速度
- if(len(match_vtg_data)>5 ):
- if match_vtg_data[1]:
- direction = match_vtg_data[1]
- if match_vtg_data[7]:
- speed = match_vtg_data[7]
- self.gps_data = {
- "latitude": latitude,
- "longitude": longitude,
- "high": high,
- "direction": direction,
- "speed": speed,
- "number": number,
- "date": gps_date,
- "precision": precision
- }
+ if i % 2 == 0:
+ if i+1 >= len(gsv_data) :
+ # EventMesh.debug_log("gsv_data num error!!")
+ break
+ GSV_dict[gsv_data[i]] = gsv_data[i+1]
+ #EventMesh.debug_log("type:gsv_data{}".format(type(gsv_data[i+1])))
+ try:
+ #EventMesh.debug_log("gsv_tmp[i+3]:{}".format(gsv_tmp[i+3]))
+ if gsv_data[i+1] :
+ if (gsv_data[i+1])>=20:
+ tmp_ok_count +=1
+ if (gsv_data[i+1])>=30:
+ tmp_very_ok_count +=1
+
+ except Exception as e:
+ usys.print_exception(e)
+
+ if(tmp_ok_count > self.GSV_sig_ok_count ):
+ self.GSV_sig_ok_count = tmp_ok_count
+ if(tmp_very_ok_count > self.GSV_sig_very_ok_count ):
+ self.GSV_sig_very_ok_count = tmp_very_ok_count
+ match_rmc_data = rmc_data.split(",")
+ if len (match_rmc_data)>3: #有rmc数据
+ if match_rmc_data[2] == 'A':
+ match_gga_data = gga_data.split(",")
+ if len(match_gga_data) >4: #数据全
+ match_vtg_data = vtg_data.split(",")
+ gps_date = "%s,%s"%(match_rmc_data[9],match_rmc_data[1][:6])#日期
+ #gps_data_tmp = self.gps.read_coordinates(gnss_r_data[1])
+ latitude = "0,N" #纬度
+ latitude_tmp = str(self.GxGGA_latitude(gga_data)).split(".")
+ if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5:
+ latitude = "%s.%s"%(latitude_tmp[0],latitude_tmp[1][:6])
+ latitude = "%s,%s"%(latitude,match_rmc_data[4] )
+
+ longitude = "0,E"#经度
+ longitude_tmp = str(self.GxGGA_longitude(gga_data)).split(".")
+ if len(longitude_tmp) >= 2 and len(longitude_tmp[1])>=5:
+ longitude = "%s.%s"%(longitude_tmp[0],longitude_tmp[1][:6])
+ longitude = "%s,%s"%(longitude,match_rmc_data[6] ) #match_rmc_data[6] + str(gnss_r_data[1])
+
+ high = "0"#高度
+ high = str(self.GxGGA_altitude(gga_data))
+ number = "0"#可用卫星
+ precision = "5.8"#精度
+ if len(match_gga_data)>5 :
+ if match_gga_data[7]:
+ number = match_gga_data[7]
+ if match_gga_data[8]:
+ precision = match_gga_data[8]
+ direction = "249.5" #方向
+ speed = '0.00' #速度
+ if(len(match_vtg_data)>5 ):
+ if match_vtg_data[1]:
+ direction = match_vtg_data[1]
+ if match_vtg_data[7]:
+ speed = match_vtg_data[7]
+ self.gps_data = {
+ "latitude": latitude,
+ "longitude": longitude,
+ "high": high,
+ "direction": direction,
+ "speed": speed,
+ "number": number,
+ "date": gps_date,
+ "precision": precision
+ }
# ***********************************************************************************
# EventMesh.txt_log("GGA_count<3:timer:{} ok_count:{} count:{}".format(self.location_timer_count,self.GSV_sig_ok_count,self.GGA_count))
# self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
- if self.GSV_sig_ok_count <= 1 and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 20: #超过40秒且信号大于30的不足3个
- EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
- EventMesh.txt_log("GSV_sig_ok_count<3:timer:{} ok_count:{} ".format(self.location_timer_count,self.GSV_sig_ok_count))
+ if (self.isOpenGNSS != "1" or (self.GSV_sig_ok_count <= 1 and self.location_timer_count > 20)) and self.wifi_data != [] and self.cell_data != [] : #超过40秒且信号大于30的不足3个
+ EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ print("Location_send:CLOSE_LOCATION")
+ #EventMesh.txt_log("GSV_sig_ok_count<3:timer:{} ok_count:{} ".format(self.location_timer_count,self.GSV_sig_ok_count))
self.Location_send([self.gps_data,self.wifi_data,self.cell_data])
#break
# if self.location_type != 1 and self.location_timer_count >= 60*4 : #4分钟关闭
with open("/ext/static/storage_file/history_temp.json","w",encoding="utf-8") as fd:
ujson.dump(self.read_histroy_temp_data,fd)
#print(self.read_histroy_temp_data)
+ EventMesh.publish("show_history_temp_data")
def get_history_hr_value(self, event, msg): #近7次心率历史数据统计显示
if self.read_histroy_hr_data:
with open("/ext/static/storage_file/history_hr.json","w",encoding="utf-8") as fd:
ujson.dump(self.read_histroy_hr_data,fd)
+ EventMesh.publish("show_history_hr_data")
#print(self.read_histroy_hr_data)
with open("/ext/static/storage_file/history_spo2.json","w",encoding="utf-8") as fd:
ujson.dump(self.read_histroy_spo2_data,fd)
+ EventMesh.publish("show_history_spo2_data")
#print(self.read_histroy_spo2_data)
def get_spo2_value(self, event, msg):
pass
def post_processor_after_instantiation(self):
- EventMesh.subscribe("set_storage_data", self.set_storage_data)
EventMesh.subscribe("set_storage_config", self.set_storage_config)
- EventMesh.subscribe("get_storage_data", self.get_storage_data)
EventMesh.subscribe("get_storage_config", self.get_storage_config)
def set_storage_data(self, event, msg):
if number != None:
if len(number) > 0:
+ sos_state = EventMesh.publish("get_dev_state")
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第16位=1
+ EventMesh.publish("set_dev_state",sos_state)
+
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
+
EventMesh.publish("save_phonename",number[0])
EventMesh.publish("save_phonenum",number[0])
EventMesh.publish("set_sos_num",0)
self.call_timer.start(10000, 0, self.call_timer_cb)#延迟10S 继续拨打
def call_timer_cb(self, *args, **kwargs):
+ sos_state = EventMesh.publish("get_dev_state")
+ tmp = 1 << 16
+ sos_state = sos_state|tmp #第16位=1
+ EventMesh.publish("set_dev_state",sos_state)
+
+ EventMesh.publish(constants.EVENT.START_LOCATION,[constants.PROTOCOL.AL_SEND,sos_state]) #开始AL定位
# print("call_timer_cb:{}".format(self.callnumer))
EventMesh.publish("save_phonename",str(self.callnumer))
EventMesh.publish("save_phonenum",str(self.callnumer))
phonebook = {}
msg_tmp = msg_tmp[1:]
-
+
j = 0
i = 0
+ print("phonebook:{} len:{}".format(phonebook,len(phonebook)))
phonebook_oldtmp = {}
# 0 1 2 3
for phonebook_tmp in msg_tmp:
phonebook_oldtmp = phonebook_tmp
# print("phonebook_oldtmp!!!:{}".format(str(phonebook_oldtmp)))
# print("phonebook!!!:{}".format(str(phonebook)))
+ # sos_data = EventMesh.publish("get_dial_sos_number")
+ # if len(phonebook) != 0:
+ # phonebook_keys = sorted(phonebook.keys())
+ # if len(sos_data) != 0:
+ # for i in range(len(sos_data)):
+ # name = ""
+ # dial_num = sos_data[i]
+ # if dial_num in phonebook_keys.values():
+ # name = list(phonebook.keys())[list(phonebook.values()).index(str(dial_num))]
+ # print("name",name[4:])
+ # pass
+ # if len(name) != 0:
+ # phonebook["00{}:{}SOS_{}".format(i+1,name[4:],i+1)] = sos_data[i]
+ # else:
+ # phonebook["00{}:SOS_{}".format(i+1,i+1)] = sos_data[i]
+ # print("phonebook!!!:{}".format(str(phonebook)))
with open("/ext/static/storage_file/phonebook.json","w",encoding="utf-8") as fd:
ujson.dump(phonebook,fd)
print("创建电话簿")
-
+
EventMesh.publish(constants.PROTOCOL.PHL_SEND)
EventMesh.publish("set_phonebook_list",[1,phonebook])
EventMesh.publish("contact_updata_list_show")
num = 3
else:
num = len(msg_tmp)-1
+ phonebook_data = EventMesh.publish("get_phonebook_list")
+ phonebook = phonebook_data[1]
+
data = []
for i in range(num):
print("sos:send data :{}".format(msg_tmp[i+1]))
if len(msg_tmp[i+1]) != 0:
+ # name = ""
+ # dial_num = str(msg_tmp[i+1])
EventMesh.publish("set_storage_config",["SOS_NUMBER{}".format(i+1),msg_tmp[i+1]])
data.append(str(msg_tmp[i+1]))
count+=1
- print("data:{}".format(data))
+ # if len(phonebook) != 0:
+ # if dial_num in phonebook.values():
+ # name = list(phonebook.keys())[list(phonebook.values()).index(str(dial_num))]
+ # name = name[4:]
+ # print("name",name[4:])
+ # pass
+ # phonebook["00{}:{}SOS_{}".format(count,name,count)] = msg_tmp[i+1]
+ # print("data:{} phonebook:{}".format(data,phonebook))
+
+ # with open("/ext/static/storage_file/phonebook.json","w",encoding="utf-8") as fd:
+ # ujson.dump(phonebook,fd)
+ # print("创建电话簿")
+
+ # EventMesh.publish("set_phonebook_list",[1,phonebook])
+ # EventMesh.publish("contact_updata_list_show")
+
EventMesh.publish("set_dial_sos_number",data)
EventMesh.publish(constants.PROTOCOL.SOS_SEND)
#EventMesh.publish(constants.PROTOCOL.TIME_SEND)
-#拒接模式来电
-class WLKEY_ProtoCol(ProtoCol):
- """"""
- TYPE = "WLKEY"
- def send(self, event, msg):
- # [XT*334588000000156*0005*WLKEY]
- send_data = self.PID+"*%s*0005*WLKEY"%(self.imei)
- MD5_SIGN = self.pack_MD5_head(send_data)
- data = "[%s%s]"%(str(MD5_SIGN),send_data)
- # print("WLKEY:data:%s"%(data))
- # print("WLKEY!!!!!!!!!!!!!")
- # 通过socket发送到服务器端
- EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND,data)
-
- def recv(self, event, msg):
- """
- @param event:
- @param msg: 接收到的下行数据
- """
- # b'[SZKW*867387060319166*000A*KEYBRD]'
- # print("WLKEY!!!!!!!!!!!!!",msg)
- EventMesh.publish(constants.PROTOCOL.WLKEY_SEND)
-
#免打扰
class SILENCETIMEFS_ProtoCol(ProtoCol):#云米
"""上课禁用"""
else:
# [SZKW*YYYYYYYYYYYYYYY*LEN*TK,AMR 格式音频数据]
#[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
- arm_data = msg[1]
- arm_sec = msg[0]
+ arm_data = msg
+
# print("TK_ProtoCol:msgtype:{} arm_sec:{}".format(len(msg[1]),arm_sec))
arm = bytearray()
else :
arm.append(arm_data[i])
- datalen = len(arm) + len("TK")+len(str(arm_sec))+1
+ datalen = len(arm) + len("TK")+1
#Wechat_log("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
send_data = bytearray(self.PID+"*%s*%04X*TK,"%(self.imei,datalen))
send_data.extend(arm)
EventMesh.publish(constants.PROTOCOL.FACTORY_SEND)
# EventMesh.publish("app_factory",None)#app恢复出厂
+class AL_ProtoCol(ProtoCol):
+ """报警数据上报"""
+ TYPE = "AL"
+ timer_repetition_send = None
+ repetition_queue = None
+
+ def send(self, event, msg):
+ if self.timer_repetition_send == None:
+ self.timer_repetition_send = osTimer()
+ if self.repetition_queue == None:
+ self.repetition_queue = Queue(100)
+
+
+ send_data ="AL,"+msg
+ send_len = len(send_data)
+ #wt_data = "%s"%(send_data)
+ send_data = self.PID+"*%s*%04X*%s"%(self.imei,send_len,send_data)
+ MD5_head_data = self.PID+"*%s*%04X*%s"%(self.imei,send_len,"AL")
+
+ MD5_SIGN = self.pack_MD5_head(MD5_head_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #EventMesh.debug_log("AL_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+ self.repetition_queue.put(data)#发送入队
+ self.timer_repetition_send.start(10000, 1, self.repetition_timer_cb)
+ EventMesh.publish("set_dev_state",0)
+ def recv(self, event, msg):
+ """
+
+ @param event: PING
+ @param msg: 接收到的下行数据
+ """
+ #EventMesh.publish(constants.PROTOCOL.CR_SEND)
+ #EventMesh.publish(constants.EVENT.START_LOCATION,constants.PROTOCOL.UD_SEND) #开始ud定位
+ print("报警数据上报:recv:%s"%(msg))
+ #
+ if self.repetition_queue.empty() == False:
+ self.repetition_queue.get()#出队
+ else:
+ self.timer_repetition_send.stop()
+
+ def repetition_timer_cb(self, *args, **kwargs):#每隔10秒发送一次
+ if self.repetition_queue.empty() == False:
+ data = self.repetition_queue.get()#出队
+ self.repetition_queue.put(data)#发送入队
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+ else:
+ self.timer_repetition_send.stop()
+class WLKEY_ProtoCol(ProtoCol):#白名单开关
+ """
+ 白名单开关
+ [XT*YYYYYYYYYYYYYYY*LEN*WLKEY,ONOFF] ONOFF: 1:开启,0:关闭,2:30秒后自动接听。
+ 实例:[XT*334588000000156*0008*WLKEY,1]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*WLKEY]
+ 实例:[XT*334588000000156*0006*WLKEY]
+ """
+ TYPE = "WLKEY"
+
+ def send(self, event, msg):
+ send_data = self.PID+"*%s*00006*WLKEY"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+ print("WLKEY_ProtoCol".format(msg_data[1]))
+ EventMesh.publish("set_storage_config",["WLKEY",str(msg_data[1])])
+
+
+ EventMesh.publish(constants.PROTOCOL.WLKEY_SEND)
+class REMOVE_ProtoCol(ProtoCol):
+ """
+ 取下手环报警开关
+ 平台发送:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMOVE,0或者1]
+ 实例:[XT*334588000000156*0008*REMOVE,1]
+ 终端回复:
+ [XT*YYYYYYYYYYYYYYY*LEN*REMOVE]
+ """
+ TYPE = "REMOVE"
+
+ def send(self, event, msg):
+ send_data = self.PID+"*%s*0006*REMOVE"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+ remove_sw = str(msg_data[1])
+ # EventMesh.debug_log("REMOVE:{}".format(remove_sw))
+ EventMesh.publish("set_storage_config",["remove_sw",remove_sw])
+ EventMesh.publish(constants.PROTOCOL.REMOVE_SEND)
+
+# 自动接听开关
+# [XT*YYYYYYYYYYYYYYY*LEN*GSMANT,ONOFF] ONOFF: 1:开启,0:关闭,2:30秒后自动接听。
+# 实例:[XT*334588000000156*0008*GSMANT,1]
+
+# 终端回复
+# [XT*YYYYYYYYYYYYYYY*LEN*GSMANT]
+# 实例:[XT*334588000000156*0006*GSMANT]
+class GSMANT_ProtoCol(ProtoCol):#自动接听
+ """
+ 白名单开关
+ [XT*YYYYYYYYYYYYYYY*LEN*GSMANT,ONOFF] ONOFF: 1:开启,0:关闭,2:30秒后自动接听。
+ 实例:[XT*334588000000156*0008*GSMANT,1]
+ 终端回复
+ [XT*YYYYYYYYYYYYYYY*LEN*GSMANT]
+ 实例:[XT*334588000000156*0006*GSMANT]
+ """
+ TYPE = "GSMANT"
+
+ def send(self, event, msg):
+ send_data = self.PID+"*%s*00006*GSMANT"%(self.imei)
+ MD5_SIGN = self.pack_MD5_head(send_data)
+ data = "[%s%s]"%(str(MD5_SIGN),send_data)
+ #Wechat_log("POWEROFF_ProtoCol:send:%s"%(data))
+ # 通过socket发送到服务器端
+ EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
+
+ def recv(self, event, msg):
+
+ msg = msg[1:-1]
+ msg_tmp = msg.decode('ascii')
+ msg_data = msg_tmp.split(',')
+ print("GSMANT_ProtoCol".format(msg_data[1]))
+ data = str(msg_data[1])
+ if data == "1":
+ data = "2"
+ EventMesh.publish("set_storage_config",["GSMANT",data])
+
+
+ EventMesh.publish(constants.PROTOCOL.GSMANT_SEND)
class ProtoColResolver(object):
def __init__(self):
import audio
import sms
from machine import Pin
-from lcd import lcd,lcd_ctrl,tp_cst816
+from lcd import lcd,tp_cst816
from misc import PWM
import uos
import gc
hangup_imgbtn = lv.img(dialing_screen)
hangup_imgbtn.set_size(64, 64)
hangup_imgbtn.set_src("E:/static/hang_up.png")
+ hangup_imgbtn.set_pos(80, 240)
hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
- hangup_imgbtn.set_pos(80, 250)
+
+
+ hangup_label_imgbtn = lv.label(dialing_screen)
+ hangup_label_imgbtn.set_pos(40, 200)
+ hangup_label_imgbtn.set_size(160, 120)
+ hangup_label_imgbtn.set_text(" ")
+ hangup_label_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ hangup_label_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.CLICKED, None)
+ lv.EVENT.SHORT_CLICKED, None)
self.meta = dialing_screen
if dialing_name != None:
name = EventMesh.publish("get_phonename")#获取拨打电话名称
def done_return(self):
EventMesh.publish("return_prev_screen")
+
+ def btn1_release(self):
+ EventMesh.publish("return_prev_screen")
+ pass
+ # EventMesh.publish("return_prev_screen")
+ def btn1_press(self):
+ EventMesh.publish("return_prev_screen")
def btn8_press(self):
EventMesh.publish("return_prev_screen")
self.read_call_log = {}
self.number_tmp = {}
self.CALL_LOG_MAX = CALL_LOG_MAX
+ EventMesh.subscribe("voice_call_end",self.voice_call_end)
+
def initialization(self):
EventMesh.publish("set_UI_high_priority", 1)
dialing_popup_hangup_imgbtn.set_src("E:/static/hang_up.png")
dialing_popup_hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
dialing_popup_hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
- dialing_popup_hangup_imgbtn.set_pos(80, 250)
+ dialing_popup_hangup_imgbtn.set_pos(80, 230)
+
+ dialing_popup_hangup_label_imgbtn = lv.label(dialing_popup_screen)
+ dialing_popup_hangup_label_imgbtn.set_pos(40, 200)
+ dialing_popup_hangup_label_imgbtn.set_size(160, 120)
+ dialing_popup_hangup_label_imgbtn.set_text(" ")
+ dialing_popup_hangup_label_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+
dialing_popup_hangup_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
lv.EVENT.CLICKED, None)
+ dialing_popup_hangup_label_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.hangup(e)),
+ lv.EVENT.CLICKED, None)
self.meta = dialing_popup_screen
if dialing_popup_name != None:
name = EventMesh.publish("get_phonename")#获取拨打电话名称
if self.time_count >= 5:#5s内没有打通则不在继续拨打关闭
self.time_count = 0
EventMesh.publish("set_UI_high_priority", 0)
- voiceCall.callEnd()
EventMesh.publish("set_sos_info_call")
EventMesh.publish("load_screen", {"screen": "dial_no_connect_popup"})
+ voiceCall.callEnd()
def hangup(self,e):
+ print("hangup_end")
EventMesh.publish("set_UI_high_priority", 0)
- voiceCall.callEnd()
+
sos_flag = EventMesh.publish("get_sos_flag")
if sos_flag == 1:
EventMesh.publish("close_sos_timer")
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")
+ voiceCall.callEnd()
+
+ def voice_call_end(self,event,msg):
+ voiceCall.callEnd()
+ pass
def Close(self):
self.timer1.stop()
self.timer = osTimer()
self.point = 0
self.heart_value = 0
+ EventMesh.subscribe("show_history_hr_data",self.show_history_hr_data)
def initialization(self):
global heartrate_screen,heartrate_label,heartrate_reset_btn_img,hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7,heartrate_line_bg_img,heartrate_done_img ,heartrate_start_label,heartrate_bpm_label ,heartrate_done_label
def post_processor_after_initialization(self):
self.point = 0
self.heart_value = 0
- self.show_history_data()
+ # self.show_history_data()
+ EventMesh.publish("show_history_hr_data")
self.restart_up(0)
def restart_up(self,e):
EventMesh.publish(constants.EVENT.START_HEART)
- def show_history_data(self):
+ def show_history_hr_data(self):
global hr_line1,hr_line2,hr_line3,hr_line4,hr_line5,hr_line6,hr_line7
read_data = {}
read_data = EventMesh.publish("get_history_hr_value")
# heartrate_done_label.set_text("测量完成")
else:
heartrate_bpm_label.set_text("-- bpm")
- self.show_history_data()
+ # self.show_history_data()
self.point = 0
EventMesh.publish("set_hr_state",0)#0代表关闭测试
print("stop debug9")
self.call_log_value = {}
self.read_call_log = {}
self.number_tmp = {}
-
+ EventMesh.subscribe("answer_auto_event",self.answer_auto_event)
+
def initialization(self):
global incoming_call_screen,incoming_call_img,incoming_call_name_label,incoming_call_answer ,incoming_call_hangup
if incoming_call_screen == None :
EventMesh.publish("set_UI_high_priority",0)
EventMesh.publish("return_prev_screen")
+ def answer_auto_event(self,event,msg):
+ 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)})
+
def btn1_release(self):
pass
self.contact_detail_list.clear_flag(lv.obj.FLAG.HIDDEN)
contact_none_label.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
j =0
- print("self.phonebook sorted :{} len(self.phonebook) :{}".format(sorted(self.phonebook.keys()),len(self.phonebook)))
+ # print("self.phonebook sorted :{} len(self.phonebook) :{}".format(sorted(self.phonebook.keys()),len(self.phonebook)))
phonebook_keys = sorted(self.phonebook.keys())
# self.contact_detail_list.delete()#先删除一次控件
name = self.phonebook[phonebook_keys[j]]
key_tmp = phonebook_keys[j]
- print("name :{} key_tmp:{}".format(name,key_tmp))
+ # print("name :{} key_tmp:{}".format(name,key_tmp))
#contact_btn = lv.btn(self.contact_detail_list)
self.contact_detail_listt_dict[i]["contact_btn"].set_size(230,80)
# phone_num_tmp = int(phone_num)
- "dialing_noplay_popup"
EventMesh.publish("load_screen", {"screen": "dialing_noplay_popup"})
self.timer = osTimer()
self.point = 0
self.temp_value = 0
+ self.temp_data_old = 0
+ EventMesh.subscribe("show_history_temp_data",self.show_history_temp_data)
def initialization(self):
global temperature_screen,temperature_keep_label,temperature_label,temp_reset_btn_img,temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,\
temperature_keep_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
+ #35 246 42
# temperature_degree_img = lv.img(temperature_screen)
# temperature_degree_img.set_pos(156, 242)
# temperature_degree_img.set_size(22, 22)
temperature_bpm_label.set_text("- -℃")
temperature_start_label.set_text("正在测量中.")
+ self.temp_data_old = 0
def post_processor_after_initialization(self):
temperature_start_label.set_text("正在测量中.")
EventMesh.publish("set_temp_state",1)
EventMesh.publish(constants.EVENT.START_TEMP)
- self.show_history_data()
+ EventMesh.publish("show_history_temp_data")
+ self.temp_data_old = 0
self.timer.start(1*500, 1, self.start_measure)
- def show_history_data(self):
+ def show_history_temp_data(self):
global temp_line1,temp_line2,temp_line3,temp_line4,temp_line5,temp_line6,temp_line7
read_data = {}
read_data = EventMesh.publish("get_history_temp_value")
self.point = self.point + 1
EventMesh.publish("system_sleep_rest")#防止黑屏
WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
- temp = EventMesh.publish(constants.EVENT.GET_TEMP)
- temp += 0.5
- tmp = str(temp).split('.')[0] + '.' + str(temp).split('.')[1][:1]#获取小数点后一位 舍去小数点最后一位
- if temp < 25 or temp > 42:
- temp = 0
+ temp_data = EventMesh.publish("optimize_temp")
+ if temp_data == None:
+ temp_data = 0
+
+
# print("self.temp:{}".format(temp))
- if self.point >= 2:
- if temp != 0:
- temperature_bpm_label.set_text("{} ℃".format(tmp))
+ if self.point >= 10 and self.point % 10 == 0:
+ self.temp_data_old = temp_data
+ tmp = temp_data
+ if WEAR == 0:
+ tmp = 0
+ self.temp_data_old = 0
+ if tmp != 0 and WEAR == 1:
+ tmp_data = tmp
+ if str(tmp).find(".") != -1:
+ tmp_data = str(tmp).split('.')[0] + '.' + str(tmp).split('.')[1][:1]#获取小数点后一位 舍去小数点最后一位
+ temperature_bpm_label.set_text("{} ℃".format(tmp_data))
else:
temperature_bpm_label.set_text("- -℃")
-
+ if self.temp_data_old >= 37.3:
+ temperature_keep_label.set_text("体温偏高")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0x00, 0x00), lv.STATE.DEFAULT)
+ elif self.temp_data_old == 0:
+ temperature_keep_label.set_text(" ")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+ else:
+ temperature_keep_label.set_text("体温正常")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+ temp = self.temp_data_old
+
if self.point%4 == 0 :
temperature_start_label.set_text("正在测量中..")
temperature_done_img.set_src("E:/static/temp_gif02.png")
else:
tmp_f_tmp = temp
- if self.point >= 2:
-
- if temp >= 37.3:
- temperature_keep_label.set_text("体温偏高")
- temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0x00, 0x00), lv.STATE.DEFAULT)
- elif temp == 0:
- temperature_keep_label.set_text(" ")
- temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
- else:
- temperature_keep_label.set_text("体温正常")
- temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
-
if self.point > 120 or (WEAR == 0 and self.point > 10): #测2min
self.timer.stop()
if WEAR == 0:
temperature_done_img.set_src("E:/static/temp_gif03.png")
temp_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
- self.show_history_data()
+ # self.show_history_data()
self.point = 0
EventMesh.publish("set_temp_state",0)
self.point = 0
self.spo2_value = 0
#self.Hsensor = None
+ EventMesh.subscribe("show_history_spo2_data",self.show_history_spo2_data)
+
def initialization(self):
global spo2_screen,spo2_label,spo2_value_label,spo2_reset_btn_img,spo2_done_img,spo2_line_bg_img,spo2_line1,spo2_line2,\
spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7,spo2_line_bg_img ,spo2_start_label ,spo2_done_label
def post_processor_after_initialization(self):
self.point = 0
self.spo2_value = 0
- self.show_history_data()
+ EventMesh.publish("show_history_spo2_data")
self.restart_up(0)
def restart_up(self,e):
EventMesh.publish("set_spo2_state",1)#2代表后台进入血氧测试
EventMesh.publish(constants.EVENT.START_BLOOD_OXYGEN)
- def show_history_data(self):
+ def show_history_spo2_data(self):
global spo2_line1,spo2_line2,spo2_line3,spo2_line4,spo2_line5,spo2_line6,spo2_line7
read_data = {}
read_data = EventMesh.publish("get_history_spo2_value")
spo2_value_label.set_text("- - %")
- self.show_history_data()
+ # self.show_history_data()
self.point = 0
EventMesh.publish("set_spo2_state",0)#0代表关闭测试
sos_screen = None
sos_screen_label = None
sos_screen_label_p = None
-
+sos_screen_confirm_label_S = None
+sos_screen_confirm_label = None
+sos_screen_confirm_img = None
#sos求组提示界面
+
class sosScreen(Screen):
NAME = "SOS_POPUP"
def __init__(self):
self.count = 0
def initialization(self):
- global sos_screen ,sos_screen_label
+ global sos_screen ,sos_screen_label ,sos_screen_confirm_label_S
if sos_screen == None :
sos_screen = lv.obj()
print("SOS_POPUP")
sos_screen.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT)
#进入图片
- sos_screen_label = lv.label(sos_screen)
- sos_screen_label.set_pos(0, 20)
- sos_screen_label.set_size(240, 30)
- sos_screen_label.set_text("SOS")
- sos_screen_label.add_style(style_font_youyuan_20_red, lv.PART.MAIN | lv.STATE.DEFAULT)
- sos_screen_label.set_long_mode(lv.label.LONG.WRAP)
- sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ # sos_screen_label = lv.label(sos_screen)
+ # sos_screen_label.set_pos(0, 20)
+ # sos_screen_label.set_size(240, 30)
+ # sos_screen_label.set_text("SOS")
+ # sos_screen_label.add_style(style_font_youyuan_20_red, lv.PART.MAIN | lv.STATE.DEFAULT)
+ # sos_screen_label.set_long_mode(lv.label.LONG.WRAP)
+ # sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+
+ # sos_screen_label = lv.label(sos_screen)
+ # sos_screen_label.set_text("是否拨打紧急\n求助电话?")
+ # sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ # sos_screen_label.set_size(240, 50)
+ # sos_screen_label.set_pos(0,20)
+ # sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
- sos_screen_label = lv.label(sos_screen)
- sos_screen_label.set_text("是否拨打紧急\n求助电话?")
- sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
- sos_screen_label.set_size(240, 50)
- sos_screen_label.set_pos(0,65)
- sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
- sos_screen_label = lv.label(sos_screen)
- sos_screen_label.set_text("无操作10s后\n自动拨打")
- sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
- sos_screen_label.set_size(240, 50)
- sos_screen_label.set_pos(0,140)
- sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # sos_screen_confirm_img = lv.btn(sos_screen)
+ # sos_screen_confirm_img.set_pos(int(20),int(50))
+ # sos_screen_confirm_img.set_size(200,85)
+ # sos_screen_confirm_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # sos_screen_confirm_img.set_style_pad_all(0, lv.STATE.DEFAULT)
+ # sos_screen_confirm_img.add_flag(lv.obj.FLAG.CLICKABLE)
+
+ # sos_screen_confirm_img.add_style(style_screen_btn_1_main_main_red, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+ # sos_screen_confirm_label = lv.label(sos_screen)
+ # sos_screen_confirm_label.set_pos(int(0),int(66))
+ # sos_screen_confirm_label.set_size(240,30)
+ # sos_screen_confirm_label.set_text("确定")
+ # sos_screen_confirm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ # sos_screen_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # sos_screen_confirm_label_S = lv.label(sos_screen)
+ # sos_screen_confirm_label_S.set_pos(int(0),int(101))
+ # sos_screen_confirm_label_S.set_size(240,30)
+ # sos_screen_confirm_label_S.set_text("10S")
+ # sos_screen_confirm_label_S.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ # sos_screen_confirm_label_S.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # screen_btn_1_label = lv.label(sos_screen_confirm_img)
+ # screen_btn_1_label.set_text("确定")
+ # screen_btn_1_label.align(lv.ALIGN.CENTER,0,5)
+ # style_screen_btn_1_main_main_default.set_bg_color(lv.color_make(249,47,104))
+ # # add style for screen_btn_1
+ # sos_screen_confirm_img.add_style(style_screen_btn_1_main_main_default, lv.PART.MAIN|lv.STATE.DEFAULT)
sos_screen_confirm_img = lv.img(sos_screen)
- sos_screen_confirm_img.set_size(176, 46)
- sos_screen_confirm_img.set_pos(32, 210)
- sos_screen_confirm_img.set_src("E:/static/off_icon.png")
+ sos_screen_confirm_img.set_size(200, 85)
+ sos_screen_confirm_img.set_pos(20, 50)
+ sos_screen_confirm_img.set_src("E:/static/off_icon_01.png")
sos_screen_confirm_img.add_flag(lv.obj.FLAG.CLICKABLE)
sos_screen_confirm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
- sos_screen_confirm_label = lv.label(sos_screen_confirm_img)
+ sos_screen_confirm_label = lv.label(sos_screen)
+ sos_screen_confirm_label.set_pos(int(0),int(66))
+ sos_screen_confirm_label.set_size(240,30)
sos_screen_confirm_label.set_text("确定")
- sos_screen_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
+ sos_screen_confirm_label.add_flag(lv.obj.FLAG.CLICKABLE)
+ sos_screen_confirm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
sos_screen_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+ sos_screen_confirm_label_S = lv.label(sos_screen)
+ sos_screen_confirm_label_S.set_pos(int(0),int(101))
+ sos_screen_confirm_label_S.set_size(240,30)
+ sos_screen_confirm_label_S.set_text("10S")
+ sos_screen_confirm_label_S.add_flag(lv.obj.FLAG.CLICKABLE)
+ sos_screen_confirm_label_S.set_style_text_align(lv.TEXT_ALIGN.CENTER,0)
+ sos_screen_confirm_label_S.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # sos_screen_confirm_label = lv.label(sos_screen_confirm_img)
+ # sos_screen_confirm_label.set_text("确定")
+ # sos_screen_confirm_label.align(lv.ALIGN.CENTER, 0, 5)
+ # sos_screen_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ # sos_screen_label = lv.label(sos_screen)
+ # sos_screen_label.set_text("无操作10s后\n自动拨打")
+ # sos_screen_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+ # sos_screen_label.set_size(240, 50)
+ # sos_screen_label.set_pos(0,170)
+ # sos_screen_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
+ # sos_screen_return = lv.btn(sos_screen)
+ # sos_screen_return.set_pos(int(20),int(200))
+ # sos_screen_return.set_size(200,66)
+ # sos_screen_return.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ # sos_screen_return.set_style_pad_all(0, lv.STATE.DEFAULT)
+ # sos_screen_return.add_flag(lv.obj.FLAG.CLICKABLE)
+
+
+ # screen_btn_2_label = lv.label(sos_screen_return)
+ # screen_btn_2_label.set_text("取消")
+ # screen_btn_2_label.align(lv.ALIGN.CENTER,0,5)
+ # sos_screen_return.add_style(style_screen_btn_1_main_main_yellow, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
sos_screen_return = lv.img(sos_screen)
- sos_screen_return.set_size(176, 46)
- sos_screen_return.set_pos(32, 270)
- sos_screen_return.set_src("E:/static/cancel_icon.png")
+ sos_screen_return.set_size(200, 66)
+ sos_screen_return.set_pos(20, 200)
+ sos_screen_return.set_src("E:/static/off_icon_02.png")
sos_screen_return.add_flag(lv.obj.FLAG.CLICKABLE)
sos_screen_return.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
sos_screen_return_label = lv.label(sos_screen_return)
sos_screen_return_label.set_ext_click_area(20)
self.meta = sos_screen
+ sos_screen_confirm_label.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
+ lv.EVENT.CLICKED, None)
+ sos_screen_confirm_label_S.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
+ lv.EVENT.CLICKED, None)
+
sos_screen_confirm_img.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_comfirm_cb(e)),
lv.EVENT.CLICKED, None)
sos_screen_return.add_event_cb(lambda e: EventMesh.callback_wrapper(self.timer_cancel_cb(e)),
lv.EVENT.CLICKED, None)
+
+ self.count = 10
+ if sos_screen_confirm_label_S != None:
+ sos_screen_confirm_label_S.set_text("{}S".format(self.count))
+ self.timer.start(1000,1,self.timer_cb_onescond)
def timer_comfirm_cb(self,e):
+ self.timer.stop()
EventMesh.publish("set_sos_flag", 1)
def timer_cancel_cb(self,e):
EventMesh.publish("return_prev_screen")
- def post_processor_before_initialization(self):
- self.count = 0
- self.timer.start(5000,1,self.timer_cb_onescond)
-
def timer_cb_onescond(self,e):
+ global sos_screen_confirm_label_S
EventMesh.publish("system_sleep_rest")#防止黑屏
- self.count+=1
- if self.count >= 2:
- self.count = 0
+ if self.count > 0:
+ self.count-=1
+ if self.count == 0:
+ self.timer.stop()
EventMesh.publish("set_sos_flag", 1)
+ sos_screen_confirm_label_S.set_text("{}S".format(self.count))
def Close(self):
self.timer.stop()
def timer_cb_onescond(self,e):
EventMesh.publish("system_sleep_rest")#防止黑屏
self.count+=1
- if self.count >= 10:
+ if self.count >= 5:
self.count = 0
+ self.timer.stop()
EventMesh.publish("return_prev_screen")
pass
def btn8_press(self):
-
+ EventMesh.publish("return_prev_screen")
pass
def btn1_press(self):
EventMesh.publish("return_prev_screen")
EventMesh.subscribe("del_prev_screen",self.del_prev_screen)#退出当前界面就删除当前界面 进去需要保存当前界面
EventMesh.subscribe("add_new_screen",self.add_new_screen)#保存新的界面用作返回上一级
+ EventMesh.subscribe("get_old_screen",self.get_old_screen)#保存新的界面用作返回上一级
+
self.system_sleep_timer.start(1000, 1, self.system_sleep_timer_cb)
# if self.screen_prev != None:
# print("self.screen_prev.NAME",self.screen_prev.NAME)
# EventMesh.publish("load_screen", {"screen": self.screen_prev.NAME})
+
+ def get_old_screen(self, event, msg):
+ # print("self.screen_old.NAME",self.screen_old.NAME)
+ if self.screen_old == None:
+ old_screen = "main_menu"
+ return old_screen
+ else:
+ return self.screen_old.NAME
+
+
+
def set_interrup_incall(self, event, msg):
self.set_interrup_flag = msg
screen_NAME = EventMesh.publish("get_screen_NAME")
if screen_NAME == "system_init":
return
- print("btn_press: {}".format(event))
+ print("btn_press: {} self.main_flag:{} self.sleep_flag:{}".format(event,self.main_flag,self.sleep_flag))
#主表盘按电源键,息屏
#息屏状态按按钮都亮屏
self.screen.meta_info = msg.get("meta")
print("load_screen:post_processor_before_initialization")
self.screen.post_processor_before_initialization()
+ self.screen_old = self.screen
print("load_screen:initialization")
self.screen.initialization()
- print("load_screen.load()")
+ print("load_screen.load()1")
self.screen.load()
+ # print("load_screen.load()2")
self.lv.scr_load(self.screen.get_meta())
+ # print("load_screen.load()3")
self.screen.post_processor_after_initialization()
- self.screen_old = self.screen
+ # print("load_screen.load()4")
if self.screen_prev == None:
if self.screen.meta_type != "popup":
self.screen_prev = self.screen
self.__lcd_on()
+ # print("load_screen.load()5")
mem = gc.mem_free()
print('2剩余内存RAM:{} KB'.format(mem / 1024))
import constants
from misc import Power
import pm
-from ui import Screen
+from ui import Screen,style_font_youyuan_20_gray,style_font_youyuan_40
from ui_WatchFaceScreen import WatchFace
style_MainMenu_screen_default = lv.style_t()
style_MainMenu_screen_default.init()
style_font_youyuan_25.set_text_color(lv.color_make(0xff, 0xff, 0xff))
style_font_youyuan_25.set_text_font_v2("font_28.bin",28,0)
+
+
style_btn = lv.style_t()
style_btn.init()
style_btn.set_bg_opa(lv.OPA.TRANSP)
#MainMenu2_num+=1
#MainMenu2x+=1
+#sos
+MainMenu2_setting = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
+#MainMenu2_setting.set_tile_act(0,0,lv.ANIM.ON)
+label_text = lv.label(MainMenu2_setting)
+label_text.set_pos(0, 240)
+label_text.set_size(0, 0)
+label_text.set_text("{}".format(MainMenu2_num))
+MainMenu2_img_sos = lv.img(MainMenu2_setting)
+MainMenu2_img_sos.set_size(160,160)
+MainMenu2_img_sos.set_pos(40,20)
+MainMenu2_img_sos.set_src("U:/static/IMAGE_ONE_PAGE_SOS.png")
+MainMenu2_img_sos.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_sos.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+MainMenu2_img_sos_txt = lv.label(MainMenu2_setting)
+MainMenu2_img_sos_txt.set_pos(int(0),int(210))
+MainMenu2_img_sos_txt.set_size(240,100)
+MainMenu2_img_sos_txt.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_sos_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_sos_txt.set_text("SOS")
+MainMenu2_img_sos_txt.add_style(style_font_youyuan_40, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+MainMenu2_img_sos_txt1 = lv.label(MainMenu2_setting)
+MainMenu2_img_sos_txt1.set_pos(int(0),int(260))
+MainMenu2_img_sos_txt1.set_size(240,60)
+MainMenu2_img_sos_txt1.add_flag(lv.obj.FLAG.CLICKABLE)
+MainMenu2_img_sos_txt1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+MainMenu2_img_sos_txt1.set_text("或长按【SOS键】3秒快速呼叫")
+MainMenu2_img_sos_txt1.add_style(style_font_youyuan_20_gray, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+MainMenu2_num+=1
+MainMenu2x+=1
+
#工具箱
MainMenu2_toolbox = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
label_text = lv.label(MainMenu2_toolbox)
MainMenu2_num+=1
MainMenu2x+=1
+
+
#设置
MainMenu2_setting = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT)
#MainMenu2_setting.set_tile_act(0,0,lv.ANIM.ON)
MainMenu2_img_health.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "health")), lv.EVENT.CLICKED, None)
MainMenu2_img_contacts.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "contacts")), lv.EVENT.CLICKED, None)
MainMenu2_img_wechat.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "wechat")), lv.EVENT.CLICKED, None)
- # MainMenu2_img_spo2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "spo2")), lv.EVENT.CLICKED, None)
+ MainMenu2_img_sos.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "sos")), lv.EVENT.CLICKED, None)
MainMenu2_img_sms.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.CLICKED, None)
+ # MainMenu2_img_sos.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.CLICKED, None)
#MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.CLICKED, None)
EventMesh.subscribe("watch_top_show", self.watch_top_show)
def img_cb(self, e, msg):
print("MainMenu2:img_cb:{}".format(msg))
+ if msg == "sos":
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#有卡时触发sos报警 无卡时自动关机
+ sos_number = EventMesh.publish("get_dial_sos_number")
+ if sos_number != None:
+ if len(sos_number) != 0:
+ screen_NAME = EventMesh.publish("get_screen_NAME")
+ if screen_NAME != None:
+ if screen_NAME != "SOS_POPUP":
+ EventMesh.publish("load_screen", {"screen": "SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "NO_SOS_POPUP"})
+ else:
+ EventMesh.publish("load_screen", {"screen": "no_sim_power_screen"})
+ return
EventMesh.publish("load_screen", {"screen": "{}".format(msg)})
def lcd_on(self):
app_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-# -------------------------------------------volume screen----------------------------------------------------------
-volume_screen = lv.obj()
-print("volume_screen")
-volume_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-volume_phone_btn = lv.btn(volume_screen)
-volume_phone_btn.set_size(240,40)
-volume_phone_btn.set_pos(0,30)
-volume_phone_btn.add_style(style_volume_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-volume_phone_label = lv.label(volume_phone_btn)
-volume_phone_label.set_text("电话铃声")
-volume_phone_label.align(lv.ALIGN.CENTER, 0, 0)
-volume_phone_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-volume_alarm_btn = lv.btn(volume_screen)
-volume_alarm_btn.set_size(240,40)
-volume_alarm_btn.set_pos(0,100)
-volume_alarm_btn.add_style(style_volume_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-volume_alarm_label = lv.label(volume_alarm_btn)
-volume_alarm_label.set_text("闹钟铃声")
-volume_alarm_label.align(lv.ALIGN.CENTER, 0, 0)
-volume_alarm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-volume_message_btn = lv.btn(volume_screen)
-volume_message_btn.set_size(240,40)
-volume_message_btn.set_pos(0,170)
-volume_message_btn.add_style(style_volume_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-volume_message_label = lv.label(volume_message_btn)
-volume_message_label.set_text("消息铃声")
-volume_message_label.align(lv.ALIGN.CENTER, 0, 0)
-volume_message_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-# -------------------------------------------phonering screen----------------------------------------------------------
-phonering_screen = lv.obj()
-print("phonering_screen")
-phonering_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-phonering_title = lv.label(phonering_screen)
-phonering_title.set_pos(0, 10)
-phonering_title.set_size(240, 40)
-phonering_title.set_text("电话铃声")
-phonering_title.set_long_mode(lv.label.LONG.WRAP)
-phonering_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-phonering_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-phonering_label1 = lv.label(phonering_screen)
-phonering_label1.set_pos(10, 70)
-phonering_label1.set_size(230, 40)
-phonering_label1.set_text("电话铃声:")
-phonering_label1.set_long_mode(lv.label.LONG.WRAP)
-phonering_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-phonering_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-phonering_bar = lv.bar(phonering_screen)
-phonering_bar.set_pos(20, 120)
-phonering_bar.set_size(200, 15)
-phonering_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-phonering_bar.set_mode(lv.bar.MODE.NORMAL)
-phonering_bar.set_value(50, lv.ANIM.OFF)
-phonering_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
-phonering_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-
-phonering_reduce_imgbtn = lv.img(phonering_screen)
-phonering_reduce_imgbtn.set_pos(0, 150)
-phonering_reduce_imgbtn.set_size(110, 46)
-phonering_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-phonering_reduce_imgbtn.set_src("E:/static/reduce_btn.png")
-phonering_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-phonering_add_imgbtn = lv.img(phonering_screen)
-phonering_add_imgbtn.set_pos(120, 150)
-phonering_add_imgbtn.set_size(110, 46)
-phonering_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-phonering_add_imgbtn.set_src("E:/static/add_btn.png")
-
-phonering_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-# -------------------------------------------alarmvolume screen----------------------------------------------------------
-alarmvolume_screen = lv.obj()
-print("alarmvolume_screen")
-alarmvolume_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-alarmvolume_title = lv.label(alarmvolume_screen)
-alarmvolume_title.set_pos(0, 10)
-alarmvolume_title.set_size(240, 40)
-alarmvolume_title.set_text("闹钟铃声")
-alarmvolume_title.set_long_mode(lv.label.LONG.WRAP)
-alarmvolume_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-alarmvolume_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-alarmvolume_label1 = lv.label(alarmvolume_screen)
-alarmvolume_label1.set_pos(10, 70)
-alarmvolume_label1.set_size(230, 40)
-alarmvolume_label1.set_text("闹钟铃声:")
-alarmvolume_label1.set_long_mode(lv.label.LONG.WRAP)
-alarmvolume_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-alarmvolume_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-alarmvolume_bar = lv.bar(alarmvolume_screen)
-alarmvolume_bar.set_pos(20, 120)
-alarmvolume_bar.set_size(200, 15)
-alarmvolume_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-alarmvolume_bar.set_mode(lv.bar.MODE.NORMAL)
-alarmvolume_bar.set_value(50, lv.ANIM.OFF)
-alarmvolume_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
-alarmvolume_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-
-alarmvolume_reduce_imgbtn = lv.img(alarmvolume_screen)
-alarmvolume_reduce_imgbtn.set_pos(5, 150)
-alarmvolume_reduce_imgbtn.set_size(110, 46)
-alarmvolume_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-alarmvolume_reduce_imgbtn.set_src("E:/static/reduce_btn.png")
-
-alarmvolume_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-alarmvolume_add_imgbtn = lv.img(alarmvolume_screen)
-alarmvolume_add_imgbtn.set_pos(125, 150)
-alarmvolume_add_imgbtn.set_size(110, 46)
-alarmvolume_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-alarmvolume_add_imgbtn.set_src("E:/static/add_btn.png")
-
-alarmvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-# -------------------------------------------msgvolume screen----------------------------------------------------------
-msgvolume_screen = lv.obj()
-print("msgvolume_screen")
-msgvolume_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-msgvolume_title = lv.label(msgvolume_screen)
-msgvolume_title.set_pos(0, 10)
-msgvolume_title.set_size(240, 40)
-msgvolume_title.set_text("消息铃声")
-msgvolume_title.set_long_mode(lv.label.LONG.WRAP)
-msgvolume_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-msgvolume_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-msgvolume_label1 = lv.label(msgvolume_screen)
-msgvolume_label1.set_pos(10, 70)
-msgvolume_label1.set_size(230, 40)
-msgvolume_label1.set_text("消息铃声:")
-msgvolume_label1.set_long_mode(lv.label.LONG.WRAP)
-msgvolume_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
-msgvolume_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-msgvolume_bar = lv.bar(msgvolume_screen)
-msgvolume_bar.set_pos(20, 120)
-msgvolume_bar.set_size(200, 15)
-msgvolume_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-msgvolume_bar.set_mode(lv.bar.MODE.NORMAL)
-msgvolume_bar.set_value(50, lv.ANIM.OFF)
-msgvolume_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT)
-msgvolume_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT)
-
-msgvolume_reduce_imgbtn = lv.img(msgvolume_screen)
-msgvolume_reduce_imgbtn.set_pos(5, 150)
-msgvolume_reduce_imgbtn.set_size(110, 46)
-msgvolume_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-msgvolume_reduce_imgbtn.set_src("E:/static/reduce_btn.png")
-
-msgvolume_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
-msgvolume_add_imgbtn = lv.img(msgvolume_screen)
-msgvolume_add_imgbtn.set_pos(125, 150)
-msgvolume_add_imgbtn.set_size(110, 46)
-msgvolume_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-
-msgvolume_add_imgbtn.set_src("E:/static/add_btn.png")
-
-msgvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-
# -------------------------------------------restore screen----------------------------------------------------------
restore_screen = lv.obj()
print("restore_screen")
poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
poweroff_confirm_img = lv.img(poweroff_screen)
-poweroff_confirm_img.set_size(176, 46)
+poweroff_confirm_img.set_size(30, 30)
poweroff_confirm_img.set_pos(32, 160)
-poweroff_confirm_img.set_src("E:/static/off_icon.png")
+poweroff_confirm_img.set_src("E:/static/app/wechat/R_3.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.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
poweroff_return = lv.img(poweroff_screen)
-poweroff_return.set_size(176, 46)
+poweroff_return.set_size(30, 30)
poweroff_return.set_pos(32, 240)
-poweroff_return.set_src("E:/static/cancel_icon.png")
+poweroff_return.set_src("E:/static/app/wechat/S_3.png")
+
poweroff_return.add_flag(lv.obj.FLAG.CLICKABLE)
poweroff_return.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
poweroff_return_label = lv.label(poweroff_return)
EventMesh.publish("load_screen", {"screen": "main_menu"})
-class VolumeScreen(Screen):
- NAME = "volume"
-
- 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)
-
- def done_return(self):
- EventMesh.publish("return_prev_screen")
-
- def btn1_release(self):
- EventMesh.publish("return_prev_screen")
-
- def btn8_press(self):
- EventMesh.publish("load_screen", {"screen": "maiin_menu"})
-
-
-
-class PhoneringScreen(Screen):
- NAME = "phonering"
-
- def __init__(self):
- super().__init__()
- self.level = 0
- self.meta = phonering_screen
- phonering_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_level(e)),
- lv.EVENT.CLICKED, None)
- phonering_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_level(e)),
- lv.EVENT.CLICKED, None)
- phonering_add_imgbtn.set_ext_click_area(20)
- phonering_reduce_imgbtn.set_ext_click_area(20)
-
- def add_level(self, e):
- EventMesh.publish("push_add_phonering_level")
- self.level = EventMesh.publish("get_phonering_level")
- self.show_bar()
-
- def reduce_level(self, e):
- EventMesh.publish("push_reduce_phonering_level")
- self.level = EventMesh.publish("get_phonering_level")
- self.show_bar()
-
- def show_bar(self):
- phonering_bar.set_value((100 // 7) * self.level, lv.ANIM.OFF)
-
- def initialization(self):
- self.level = EventMesh.publish("get_phonering_level")
- self.show_bar()
-
- def done_return(self):
- EventMesh.publish("load_screen", {"screen": "volume"})
-
- def done_left_to_right(self):
- pass
-
- def done_right_to_left(self):
- pass
- def btn1_release(self):
- EventMesh.publish("load_screen", {"screen": "main_menu"})
-
- def btn8_press(self):
- EventMesh.publish("load_screen", {"screen": "volume"})
-
-
-
-class AlarmvolumeScreen(Screen):
- NAME = "alarmvolume"
-
- def __init__(self):
- super().__init__()
- self.level = 0
- self.meta = alarmvolume_screen
- alarmvolume_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_level(e)),
- lv.EVENT.CLICKED, None)
- alarmvolume_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_level(e)),
- lv.EVENT.CLICKED, None)
-
- def add_level(self, e):
- EventMesh.publish("push_add_alarmvolume_level")
- self.level = EventMesh.publish("get_alarmvolume_level")
- self.show_bar()
-
- def reduce_level(self, e):
- EventMesh.publish("push_reduce_alarmvolume_level")
- self.level = EventMesh.publish("get_alarmvolume_level")
- self.show_bar()
-
- def show_bar(self):
- alarmvolume_bar.set_value((100 // 7) * self.level, lv.ANIM.OFF)
-
- def initialization(self):
- self.level = EventMesh.publish("get_alarmvolume_level")
- self.show_bar()
-
- def done_return(self):
- EventMesh.publish("load_screen", {"screen": "volume"})
-
- def btn1_release(self):
- EventMesh.publish("load_screen", {"screen": "main_menu"})
-
- def btn8_press(self):
- EventMesh.publish("load_screen", {"screen": "volume"})
-
-
-
-class MsgvolumeScreen(Screen):
- NAME = "msgvolume"
-
- def __init__(self):
- super().__init__()
- self.level = 0
- self.meta = msgvolume_screen
- msgvolume_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_level(e)),
- lv.EVENT.CLICKED, None)
- msgvolume_reduce_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.reduce_level(e)),
- lv.EVENT.CLICKED, None)
-
- def add_level(self, e):
- EventMesh.publish("push_add_msgvolume_level")
- self.level = EventMesh.publish("get_msgvolume_level")
- self.show_bar()
-
- def reduce_level(self, e):
- EventMesh.publish("push_reduce_msgvolume_level")
- self.level = EventMesh.publish("get_msgvolume_level")
- self.show_bar()
-
- def show_bar(self):
- msgvolume_bar.set_value((100 // 7) * self.level, lv.ANIM.OFF)
-
- def initialization(self):
- self.level = EventMesh.publish("get_msgvolume_level")
- self.show_bar()
-
- def done_return(self):
- EventMesh.publish("load_screen", {"screen": "volume"})
-
- def btn1_release(self):
- EventMesh.publish("load_screen", {"screen": "main_menu"})
-
- def btn8_press(self):
- EventMesh.publish("load_screen", {"screen": "volume"})
-
-
-
#-----------------------------------------Total--volum-------------------------------
volume_adjust_screen = lv.obj()