{
static int16_t lp_old[2] = {0};
static int16_t bl_old[2] = {0};
+ static uint8_t cap_wear_flag = 0;
uint8_t ret = 0;
lp[0] = hx3918_read_diff_lp(LP0);
bl[0] = hx3918_read_raw_bl(BL0);
{
if((gdiff[0]>=SLEEPWEARTHRES)&&(wear_detect_mode == SLEEP_WEAR_MODE ))//SLEEPWEARTHRES=9000*0.3
{
- return prox_detect;
+ ret = prox_detect;
}
- return prox_no_detect;
+ ret = prox_no_detect;
}
else
{
- return prox_detect;
+ ret = prox_detect;
}
-
+ if(ret == 1) //检测到已佩戴,置标志
+ cap_wear_flag = 1;
+ if(cap_wear_flag != 1)//没有检测过已佩戴,统一置为已佩戴
+ ret = 1;
+ return ret;
}
/**
static unsigned char s_HX3918_low_blood = 0x0;//血压/低压
static unsigned char s_HX3918_blood_oxygen = 0x0;//血氧
static unsigned char s_HX3918_HRV = 0x0;//hrv
-static unsigned char s_HX3918_wear_status = 0;//佩戴状态
+static unsigned char s_HX3918_wear_status = 1;//佩戴状态
#define HEART_RATE_BUFF_LEN 10
unsigned char s_HX3918_heart_rate_buff[HEART_RATE_BUFF_LEN]={0};
unsigned short s_HX3918_heart_rate_buff_count = 0;
#endif
int ir_wear = 0;//红外佩戴状态
int cap_wear = 0;//电容佩戴状态
+
int wear_time = 0;
// int test_count1 = 0;
// int test_count2 = 0;
if(wear_time > 3)
{
wear_time = 0;
+
//hx3918_prox_factory_hanging_cali();
ir_wear = hx3918_get_wear_ppg_Int_handle();
cap_wear = hx3918_report_prox_status();
-
+
HX3918_LOG("ir_wear:%d cap_wear%d\n",ir_wear,cap_wear);
if(ir_wear == 1 && cap_wear==1)
{
//获取佩戴状态
STATIC mp_obj_t mp_HX3918_get_wear(mp_obj_t self_in)
{
- mp_obj_t coordinate_list[1] = {mp_obj_new_int((int)s_HX3918_wear_status)};
- return mp_obj_new_list(1, coordinate_list);
- //return mp_obj_new_int(s_HX3918_wear_status);
+ //mp_obj_t coordinate_list[1] = {mp_obj_new_int((int)s_HX3918_wear_status)};
+ //return mp_obj_new_list(1, coordinate_list);
+ return mp_obj_new_int(s_HX3918_wear_status);
}
//获取所有数据 心律、血氧、高压、低压、HRV、佩戴状态
STATIC mp_obj_t mp_HX3918_get_all_data(mp_obj_t self_in)
style_btn_1.set_shadow_opa(0)
style_btn_1.set_border_width(0)
style_btn_1.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
+style_btn_1.set_bg_grad_color(lv.color_make(0x00, 0xff, 0x2a))
+style_btn_1.set_bg_grad_dir(lv.GRAD_DIR.NONE)
+
+style_font_W_B_28 = lv.style_t()
+style_font_W_B_28.init()
+style_font_W_B_28.set_text_color(lv.color_make(0xff, 0xff, 0xff))
+style_font_W_B_28.set_text_font_v2("font_28.bin",28,0)
+style_font_W_B_28.set_bg_color(lv.color_make(0x00, 0xff, 0x2a))
factorymode_title = lv.label(factorymode_screen)
factorymode_title.set_pos(0, 10)
factorymode_hsensor_test.set_pos(0, factorymode_cont_y)
factorymode_hsensor_test.set_size(240, 60)
factorymode_hsensor_test_label = lv.label(factorymode_hsensor_test)
-factorymode_hsensor_test_label.set_text("心率血氧测试")
+factorymode_hsensor_test_label.set_text("心率测试")
factorymode_hsensor_test.set_style_pad_all(0, lv.STATE.DEFAULT)
factorymode_hsensor_test_label.align(lv.ALIGN.LEFT_MID, 70, 0)
factorymode_hsensor_test_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
FactoryModeHsensorCali_label = lv.label(FactoryModeHsensorCali_btn)
FactoryModeHsensorCali_label.set_text("活体校准")
FactoryModeHsensorCali_label.align(lv.ALIGN.CENTER, 0, 0)
-FactoryModeHsensorCali_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeHsensorCali_label.add_style(style_font_W_B_28, lv.PART.MAIN | lv.STATE.DEFAULT)
FactoryModeHsensorCali_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
FactoryModeHsensorCali_label.set_style_text_color(lv.color_make(0x16, 0x2c, 0xd4), lv.STATE.DEFAULT)
#FactoryModeHsensorCali_label.set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
FactoryModeHsensorLeakLight_label = lv.label(FactoryModeHsensorLeakLight_btn)
FactoryModeHsensorLeakLight_label.set_text("漏光检测")
FactoryModeHsensorLeakLight_label.align(lv.ALIGN.CENTER, 0, 0)
-FactoryModeHsensorLeakLight_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+FactoryModeHsensorLeakLight_label.add_style(style_font_W_B_28, lv.PART.MAIN | lv.STATE.DEFAULT)
FactoryModeHsensorLeakLight_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
FactoryModeHsensorLeakLight_label.set_style_text_color(lv.color_make(0x16, 0x2c, 0xd4), lv.STATE.DEFAULT)
#FactoryModeHsensorLeakLight_label.set_style_bg_color(lv.color_make(0x00, 0xff, 0x2a), lv.PART.MAIN | lv.STATE.DEFAULT)
try:
c_data = self.Hsensor.get_test_data()#校准数据和工厂数据
FactoryModeHsensorTest_label.set_text(" 佩戴状态\n红外:{}活体:{}佩戴:{}\n{},{} \n{},{} \n{},{}\n校准数据:{},{},{},{}\n漏光数据:{},{},{}"
- .format(c_data[3],c_data[4],w_data[0],c_data[5],c_data[6],c_data[7],c_data[8],c_data[9],c_data[10],
+ .format(c_data[3],c_data[4],w_data,c_data[5],c_data[6],c_data[7],c_data[8],c_data[9],c_data[10],
c_data[11],c_data[12],c_data[13],c_data[14],c_data[0],c_data[1],c_data[2],))
except Exception as e:
FactoryModeHsensorTest_label.set_text("佩戴状态:\n{}".format(w_data))
self.aud = audio.Audio(0)
# self.aud.set_pa(Pin.GPIO29)
- # read_data = EventMesh.publish("get_storage_data")
- # if read_data != None:
- # b = str("volum") in read_data.keys()
- # if b == True:
- # self.volum_size = read_data["volum"]
- # else:
- # self.volum_size = 8
- # else:
- # self.volum_size = 8
-
-
- # # check_volum = ql_fs.path_exists("/ext/static/storage_file/config.json")
- # # if check_volum == True :
- # # with open("/ext/static/storage_file/config.json","r") as fd:#音频文件编号
- # # self.read_data = ujson.load(fd)
- # # if self.read_data != {}:
- # # b = str("volum") in self.read_data.keys()
- # # if b == True:
- # # self.volum_size = self.read_data["volum"]
- # # else:
- # # self.volum_size = 8
- # # else:
- # # self.volum_size = 8
- # # else:
- # # self.volum_size = 8
- # self.aud.setVolume(self.volum_size)
+
+
+
+
self.meta = wechat_screen
wechat_press_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.talking_cb(e)),
lv.EVENT.LONG_PRESSED, None)
import EventMesh
from machine import Pin
from machine import ExtInt
+from misc import Power
import constants
class BtnDevice(Abstract):
if self.GPIO26_status == 1:#松开
if(self.pwk_count >= 1): #防抖100ms
self.__pwk_timer.stop()
+ if self.pwk_count > (self.__PowerDownTimeOut//100): #长按
+ EventMesh.publish("btn8_long_press")
+ else :
+ EventMesh.publish("btn8_press")
self.pwk_count = 0
self.pwk_press = 0
- EventMesh.publish("btn8_press")
- if self.pwk_count > (self.__PowerDownTimeOut//100): #长按
+
+ # if self.pwk_count > (self.__PowerDownTimeOut//100): #长按
+ # # self.__pwk_timer.stop()
+ # # self.pwk_count = 0
+ # # self.pwk_press = 0
+ # EventMesh.publish("btn8_long_press")
+ if self.pwk_count > (10000//100): #长按
self.__pwk_timer.stop()
self.pwk_count = 0
self.pwk_press = 0
- EventMesh.publish("btn8_long_press")
+ Power.powerDown()
def __ui_callback(self, para):
# print("para = {}".format(para))
# from ui_WatchFaceScreen import WatchFaceScreen
from appFactoryMode import FactoryModeLocationScreen,FactoryModeScreen ,FactoryModeAlipayInitScreen,FactoryModeBatTestScreen,FactoryModeHsensorTestScreen
+ from mgr import setSmsIndexManager,ConfigStoreManager,testSmsSetIPManager,playPowerAudioManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
+ AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
+
import ui as _ui
# import ui as _ui
print("init4:{}".format(utime.localtime()))
ui = _ui.UI()
ui.post_processor_after_instantiation()
+ app = watchApp()
+ app.set_ui(ui)
+ app.append_manager(getStorageDataManager())
ui.add_screen(_ui.SystemInitScreen())
EventMesh.publish("load_screen", {"screen": "system_init"})
print("init5:{}".format(utime.localtime()))
import mgr as mgr
print("init7:{}".format(utime.localtime()))
- from mgr import setSmsIndexManager,ConfigStoreManager,testSmsSetIPManager,playPowerAudioManager,sosInfoCallManager,getBootOffManager,getSosFlagManager,CountdownManager, LocationManager, getVolumSizeManager,gethistoryDataManager,getUpLoadDataManager, getplayAudiodStateManager,\
- AddrBookManager,MsgdetailManager,PhoneCallingManager,getOldTimeManager,getStorageDataManager,getBrightnessManager,getHrTimeManager,getTempTimeManager,getLowBatManager
print("init8:{}".format(utime.localtime()))
print("init10:{}".format(utime.localtime()))
- app = watchApp()
- app.set_ui(ui)
- app.append_manager(getStorageDataManager())
+
app.append_manager(mgr.AlarmVolumeLevelManager()) \
.append_manager(mgr.MsgVolumeLevelManager()) \
.append_manager(mgr.PhoneVolumeLevelManager()) \
def gsensor_cb(self, para):
print("gsensor_cb:{}".format(para))
+ flip_sw = EventMesh.publish("get_storage_key_data","flip_sw")
+
if para == 0: #跌倒报警
pass
#EventMesh.publish("load_screen", {"screen": "FIND"})
elif para == 1: #抬腕
- EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
+ if flip_sw == 1:
+ EventMesh.publish(constants.EVENT.SYSTEM_UP)
+
elif para == 2: #放手
pass
- # EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
+ # if flip_sw == 1:
+ # EventMesh.publish(constants.EVENT.SYSTEM_SLEEP)
def publish_event_cb(self, *args, **kwargs):
EventMesh.publish("publish_message_event_DeviceInfo",{"func":self.publish_event,"data":0})
spo2 = EventMesh.publish("get_old_spo2_data")
if spo2 != 0:
EventMesh.publish("set_old_spo2_data", 0)
- EventMesh.publish("set_old_time_data",time_tmp)
+ EventMesh.publish("set_old_time_data",time_tmp)
if hour == 0:#清步数
if min <= 1:
if self.clear_step == 0:
step = EventMesh.publish("get_old_step_value")
+ EventMesh.publish("set_old_time_data",time_tmp)
if step > 0:
EventMesh.publish("set_old_step_value",0)
self.gsensor.reset_step()
else:
self.sms_full_flag = 0
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
get_temp_time = EventMesh.publish("get_temp_time")
get_temp_state = EventMesh.publish("get_temp_state")
hr_time = {}
hr_time = EventMesh.publish("get_time_hr_spo2")#获取时间是否大于0
- if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1":
+ if get_temp_state != None : #突然脱腕
+ if get_temp_state > 1 and WEAR != 1:
+ EventMesh.publish(constants.EVENT.STOP_TEMP)
+ EventMesh.publish("set_temp_state",0)
+ if (self.get_hr_state > 1 or self.get_spo2_state > 1) and WEAR != 1:
+ if self.get_hr_state > 1 :
+ EventMesh.publish("set_hr_state",0)#2代表后台进入测试,定时测心率 1ui界面测试洗心率
+ EventMesh.publish(constants.EVENT.STOP_HEART)
+ elif self.get_spo2_state > 1:
+ EventMesh.publish("set_spo2_state",0)#2代表后台进入测试
+ EventMesh.publish(constants.EVENT.STOP_BLOOD_OXYGEN)
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 and battery[0] != "1" and WEAR == 1:
+
# print("get_temp_time:{} self.temp_one_state:{}".format(get_temp_time,self.temp_one_state))
if get_temp_time != None:#定时测量体温
if get_temp_time > 0:
step = 0
step = EventMesh.publish("get_old_step_value")
if step != 0:
- read_data = EventMesh.publish("get_storage_data")
- b = str("old_step_new") in read_data.keys()
- if b == True:
- old_step = read_data["old_step_new"]
- else:
- old_step = 0
+
+
+ tmp_data = EventMesh.publish("get_storage_key_data","old_step_new")
+ if tmp_data != None:
+ old_step = tmp_data
+
if old_step != step:
- read_data["old_step"] = step
- read_data["old_step_new"] = step
- EventMesh.publish("set_storage_data", read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
+ EventMesh.publish("set_storage_key_data",["old_step",step])
+ EventMesh.publish("set_storage_key_data",["old_step_new",step])
+
old_step = step
# step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0])
#翻转次数
self.read_histroy_temp_data = []
self.read_histroy_spo2_data = []
- read_data = EventMesh.publish("get_storage_data")
- if read_data != None:
- b = str("old_hr") in read_data.keys()
- if b == True:
- self.oldHr = read_data["old_hr"]
+ oldHr = EventMesh.publish("get_storage_key_data","old_hr")
+ if oldHr != None:
+ self.oldHr = oldHr
+ old_spo2 = EventMesh.publish("get_storage_key_data","old_spo2")
+ if old_spo2 != None:
+ self.oldspo2 = old_spo2
+ old_step = EventMesh.publish("get_storage_key_data","old_step")
+ if old_step != None:
+ self.oldstep = old_step
+
- old_spo2 = str("old_spo2") in read_data.keys()
- if old_spo2 == True:
- self.oldspo2 = read_data["old_spo2"]
-
- old_step = str("old_step") in read_data.keys()
- if old_step == True:
- self.oldstep = read_data["old_step"]
-
- # check_json= ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check_json == True :
- # with open("/ext/static/storage_file/config.json","r") as fd:#音频文件编号
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b = str("old_hr") in self.read_data.keys()
- # if b == True:
- # self.oldHr = self.read_data["old_hr"]
- # else:
- # self.oldHr = 0
- # old_spo2 = str("old_spo2") in self.read_data.keys()
- # if old_spo2 == True:
- # self.oldspo2 = self.read_data["old_spo2"]
- # else:
- # self.oldspo2 = 0
- # old_step = str("old_step") in self.read_data.keys()
- # if old_step == True:
- # self.oldstep = self.read_data["old_step"]
- # else:
- # self.oldstep = 0
- # else:
- # self.oldHr = 0
- # self.oldspo2 = 0
- # self.oldstep = 0
check_hr= ql_fs.path_exists("/ext/static/storage_file/history_hr.json")
if check_hr == True :
with open("/ext/static/storage_file/history_hr.json","r") as fd:#音频文件编号
def save_hr_value(self, event, msg):
if msg >= 50:
-
- read_data_hr = EventMesh.publish("get_storage_data")
- read_data_hr["old_hr"] = msg
+ EventMesh.publish("set_storage_key_data",["old_hr",msg])
self.oldHr = msg
- EventMesh.publish("set_storage_data", read_data_hr)
+
date_tmp = utime.localtime()
time_tmp = utime.mktime(date_tmp)
else:
self.read_histroy_hr_data.append({"timeSec": time_tmp, "hr": self.oldHr})
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data_hr,fd)
with open("/ext/static/storage_file/history_hr.json","w",encoding="utf-8") as fd:
ujson.dump(self.read_histroy_hr_data,fd)
def save_spo2_value(self, event, msg):
if msg >= 85:
- read_data_spo2 = EventMesh.publish("get_storage_data")
- read_data_spo2["old_spo2"] = msg
+ EventMesh.publish("set_storage_key_data",["old_spo2",msg])
self.oldspo2 = msg
- EventMesh.publish("set_storage_data", read_data_spo2)
+
date_tmp = utime.localtime()
time_tmp = utime.mktime(date_tmp)
else:
self.read_histroy_spo2_data.append({"timeSec": time_tmp, "spo2": self.oldspo2})
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data_spo2,fd)
-
with open("/ext/static/storage_file/history_spo2.json","w",encoding="utf-8") as fd:
ujson.dump(self.read_histroy_spo2_data,fd)
#print(self.read_histroy_spo2_data)
# 获取天气数据
def __init__(self):
self.time_sec = 0
- read_data = EventMesh.publish("get_storage_data")
- if read_data != None:
- b = str("old_time") in read_data.keys()
- if b == True:
- self.time_sec = read_data["old_time"]
-
- # check_json= ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check_json == True :
- # with open("/ext/static/storage_file/config.json","r") as fd:#音频文件编号
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b = str("old_time") in self.read_data.keys()
- # if b == True:
- # self.time_sec = self.read_data["old_time"]
-
+ tmp_data = EventMesh.publish("get_storage_key_data","old_time")
+ if tmp_data !=None :
+ self.time_sec = tmp_data
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("get_old_time_data", self.get_old_time_data)
EventMesh.subscribe("set_old_time_data", self.set_old_time_data)
def set_old_time_data(self, event, msg):
self.time_sec = msg
- read_data_time = EventMesh.publish("get_storage_data")
- read_data_time["old_time"] = msg
- EventMesh.publish("set_storage_data", read_data_time)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data_time,fd)
+ EventMesh.publish("set_storage_key_data",["old_time",msg])
+
+
self.set_hr = 0 #0关闭 1手动 2 自动测量按照时间间隔测试心率
self.set_spo2 = 0
self.open_btn = 0
- self.get_temp = 0
- read_data = EventMesh.publish("get_storage_data")
+ read_data = EventMesh.publish("get_storage_key_data","measure_time")
if read_data != None:
- b = str("measure_time") in read_data.keys()
- if b == True:
- self.set_time = read_data["measure_time"]
- btn = str("open_hr_btn") in read_data.keys()
- if btn == True:
- self.open_btn = read_data["measure_time"]
-
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b = str("measure_time") in self.read_data.keys()
- # if b == True:
- # self.set_time = self.read_data["measure_time"]
- # btn = str("open_hr_btn") in self.read_data.keys()
- # if btn == True:
- # self.open_btn = self.read_data["measure_time"]
+ self.set_time = read_data
+ read_data = EventMesh.publish("get_storage_key_data","open_hr_btn")
+
+ if read_data != None:
+ self.open_btn = read_data
+
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_time_hr_spo2", self.set_time_hr_spo2)
def set_time_hr_spo2(self, event, msg):
self.open_btn = msg[0]
self.set_time = msg[1]
+ EventMesh.publish("set_storage_key_data",["measure_time",self.set_time])
+ EventMesh.publish("set_storage_key_data",["open_hr_btn",self.open_btn])
def get_time_hr_spo2(self, event, msg):
-
return [self.open_btn,self.set_time]
def set_hr_state(self, event, msg):
def __init__(self):
self.set_time = 0
self.get_temp = 0
- read_data = EventMesh.publish("get_storage_data")
+ read_data = EventMesh.publish("get_storage_key_data","temp_time")
+
if read_data != None:
- b = str("temp_time") in read_data.keys()
- if b == True:
- self.set_time = read_data["temp_time"]
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b = str("temp_time") in self.read_data.keys()
- # if b == True:
- # self.set_time = self.read_data["temp_time"]
+ self.set_time = read_data
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_temp_time", self.set_temp_time)
def set_temp_time(self, event, msg):
self.set_time = msg
+ EventMesh.publish("set_storage_key_data",["set_temp_time",self.set_time])
def get_temp_time(self, event, msg):
-
return self.set_time
def set_temp_state(self, event, msg):
# self.read_data = {}
self.time = 5
self.PWM_backlight = None
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("get_brightness_level", self.get_brightness_level)
def set_brightness_level(self, event, msg):
self.level = msg
-
+ EventMesh.publish("set_storage_key_data", ["brightness_level",self.level])
+
def get_brightness_level(self, event, msg):
- read_data = EventMesh.publish("get_storage_data")
- if read_data != {}:
- b = str("brightness_level") in read_data.keys()
- if b == True:
- self.level = read_data["brightness_level"]
+ tmp = EventMesh.publish("get_storage_key_data","brightness_level")
+ if tmp != None:
+ self.level = tmp
return self.level
def set_brightness_time(self, event, msg):
self.time = msg
+ EventMesh.publish("set_storage_key_data", ["brightness_time",self.time])
def get_brightness_time(self, event, msg):
- # print("get_brightness_time self.read_data:{} self.time:{}".format(self.read_data,self.time))
- read_data = EventMesh.publish("get_storage_data")
- if read_data != {}:
- b = str("brightness_time") in read_data.keys()
- if b == True:
- self.time = read_data["brightness_time"]
+ tmp = EventMesh.publish("get_storage_key_data","brightness_time")
+ if tmp != None:
+ self.time = tmp
return self.time
self.level = self.level + 2
self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS, self.level, 10)
self.PWM_backlight.open()
-
- read_data = EventMesh.publish("get_storage_data")
- read_data["brightness_level"] = self.level
+ EventMesh.publish("set_storage_key_data", ["brightness_level",self.level])
- EventMesh.publish("set_storage_data", read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
def reduce(self, event, msg):
if self.level > 0:
self.PWM_backlight = PWM(PWM.PWM1, PWM.ABOVE_MS,self.level, 10)
self.PWM_backlight.open()
- read_data = EventMesh.publish("get_storage_data")
- read_data["brightness_level"] = self.level
- EventMesh.publish("set_storage_data", read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
+ EventMesh.publish("set_storage_key_data", ["brightness_level",self.level])
+
class getStorageDataManager(Abstract):#获取内存数据
def __init__(self):
- self.read_data = {}
+ self.config_data = {}
check = ql_fs.path_exists("/ext/static/storage_file/config.json")
if check == True:
with open("/ext/static/storage_file/config.json","r") as fd:
- self.read_data = ujson.load(fd)
+ self.config_data = ujson.load(fd)
+ else :
+ self.config_data = {'old_time': 0, 'flip_sw': 0}
+ pass
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_storage_data", self.set_storage_data)
+ EventMesh.subscribe("set_storage_key_data", self.set_storage_key_data)
EventMesh.subscribe("get_storage_data", self.get_storage_data)
+ EventMesh.subscribe("get_storage_key_data", self.get_storage_key_data)
def set_storage_data(self, event, msg):
+ print("set_storage_data:{}".format(msg))
if msg != None:
- self.read_data = msg
-
+ self.config_data = msg
+ with open("/ext/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
+ ujson.dump(self.config_data,fd)
+ def set_storage_key_data(self, event, msg):
+ print("set_storage_key_data1:{}".format(msg))
+ if len(msg) >= 2:
+ self.config_data[msg[0]]=msg[1]
+ print("set_storage_key_data2:{}".format(self.config_data[msg[0]]))
+ with open("/ext/static/storage_file/config.json",'w+',encoding="utf-8") as fd:
+ ujson.dump(self.config_data,fd)
def get_storage_data(self, event, msg):
- return self.read_data
-
-
+ print("get_storage_data:{}".format(self.config_data))
+ return self.config_data
+ def get_storage_key_data(self,event,msg):
+ print("get_storage_key_data1:{}".format(msg))
+ b = msg in self.config_data.keys()
+ if b == True:
+ print("get_storage_key_data2:{}".format(self.config_data[msg]))
+ return self.config_data[msg]
+ else :
+ return None
+ # try:
+ # return self.config_data[msg]
+ # except:
+ # print("get_storage_key_data:none key:{}",msg)
+ # return None
#定位频率
class getUpLoadDataManager(Abstract):#
def __init__(self):
self.upload_time = 1800
- read_data = EventMesh.publish("get_storage_data")
+ read_data = EventMesh.publish("get_storage_key_data","upload_time")
if read_data != None:
- b = str("upload_time") in read_data.keys()
- if b == True:
- self.upload_time = read_data["upload_time"]
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b = str("upload_time") in self.read_data.keys()
- # if b == True:
- # self.upload_time = self.read_data["upload_time"]
+ self.upload_time = read_data
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_upload_data", self.set_upload_data)
class getVolumSizeManager(Abstract):#设置或获取音量大小数据
def __init__(self):
self.volume_size = 8
- read_data = EventMesh.publish("get_storage_data")
+ read_data = EventMesh.publish("get_storage_key_data","volum")
if read_data != None:
- b = str("volum") in read_data.keys()
- if b == True:
- self.volume_size = read_data["volum"]
- # self.read_data = {}
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
-
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b = str("volum") in self.read_data.keys()
- # if b == True:
- # self.volume_size = self.read_data["volum"]
- # else:
- # self.volume_size = 8
- # else:
- # self.volume_size = 8
- # print("self.volume_size:{}".format(self.volume_size))
+ self.volume_size = read_data
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_volum_size", self.set_volum_size)
EventMesh.subscribe("get_volum_size", self.get_volum_size)
def set_volum_size(self, event, msg):
self.volume_size = msg
+ EventMesh.publish("set_storage_key_data", ["volum",self.volume_size])
def get_volum_size(self, event, msg):
return self.volume_size
self.call_timer = osTimer()
self.sos_numer1 = []
self.callnumer =""
- read_data = EventMesh.publish("get_storage_data")
- if read_data != None:
- b1 = str("SOS_NUMBER1") in read_data.keys()
- if b1 == True:
- self.sos_numer1 = [read_data["SOS_NUMBER1"]]
- b2 = str("SOS_NUMBER2") in read_data.keys()
- if b2 == True:
- self.sos_numer1 = [read_data["SOS_NUMBER1"], read_data["SOS_NUMBER2"]]
-
- b3 = str("SOS_NUMBER3") in read_data.keys()
- if b3 == True:
- self.sos_numer1 = [read_data["SOS_NUMBER1"], read_data["SOS_NUMBER2"],read_data["SOS_NUMBER3"]]
- # self.read_data = {}
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
-
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b1 = str("SOS_NUMBER1") in self.read_data.keys()
- # if b1 == True:
- # self.sos_numer1 = [self.read_data["SOS_NUMBER1"]]
- # b2 = str("SOS_NUMBER2") in self.read_data.keys()
- # if b2 == True:
- # self.sos_numer1 = [self.read_data["SOS_NUMBER1"], self.read_data["SOS_NUMBER2"]]
-
- # b3 = str("SOS_NUMBER3") in self.read_data.keys()
- # if b3 == True:
- # self.sos_numer1 = [self.read_data["SOS_NUMBER1"], self.read_data["SOS_NUMBER2"],self.read_data["SOS_NUMBER3"]]
-
- # print("self.sos_numer1:{} self.read_data:{}".format(self.sos_numer1,self.read_data))
+ SOS_NUMBER1 = EventMesh.publish("get_storage_key_data","SOS_NUMBER1")
+ if SOS_NUMBER1 != None:
+ self.sos_numer1 = SOS_NUMBER1
+ SOS_NUMBER2 = EventMesh.publish("get_storage_key_data","SOS_NUMBER2")
+ if SOS_NUMBER1 != None:
+ self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2]
+
+ SOS_NUMBER3 = EventMesh.publish("get_storage_key_data","SOS_NUMBER3")
+ if SOS_NUMBER3 != None:
+ self.sos_numer1 = [SOS_NUMBER1, SOS_NUMBER2,SOS_NUMBER3]
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_sos_flag", self.set_sos_flag)#设置sos拨打标识
def __init__(self):
self.low_btn = 0
- read_data = EventMesh.publish("get_storage_data")
+ read_data = EventMesh.publish("get_storage_key_data","low_on")
if read_data != None:
- b1 = str("low_on") in read_data.keys()
- if b1 == True:
- self.low_btn = read_data["low_on"]
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
-
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b1 = str("low_on") in self.read_data.keys()
- # if b1 == True:
- # self.low_btn = self.read_data["low_on"]
+ self.low_btn = read_data
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_low_bat_btn", self.set_low_bat_btn)#
def set_low_bat_btn(self, event, msg):
self.low_btn = msg
+ EventMesh.publish("set_storage_key_data",["low_on",self.low_btn])
def get_low_bat_btn(self, event, msg):
return self.low_btn
-class getCountDownManager(Abstract):#倒计时
- def __init__(self):
- self.read_data = {}
- self.low_btn = 0
-
-
- def post_processor_after_instantiation(self):
- EventMesh.subscribe("set_low_bat_btn", self.set_low_bat_btn)#
- EventMesh.subscribe("get_low_bat_btn", self.get_low_bat_btn)
- def set_low_bat_btn(self, event, msg):
- self.low_btn = msg
-
- def get_low_bat_btn(self, event, msg):
- return self.low_btn
class playPowerAudioManager(Abstract):#播放开关机音频文件
def __init__(self):
self.off_msg = {}
self.off_flag = 0
self.rtc = RTC()
- read_data = EventMesh.publish("get_storage_data")
+
+ read_data = EventMesh.publish("get_storage_key_data","off_on")
if read_data != None:
- b1 = str("off_on") in read_data.keys()
- if b1 == True:
- self.off_on = read_data["off_on"]
- b2 = str("off_start") in read_data.keys()
- if b2 == True:
- self.off_start= read_data["off_start"]
-
- b3 = str("off_end") in read_data.keys()
- if b3 == True:
- self.off_end = read_data["off_end"]
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b1 = str("off_on") in self.read_data.keys()
- # if b1 == True:
- # self.off_on = self.read_data["off_on"]
- # b2 = str("off_start") in self.read_data.keys()
- # if b2 == True:
- # self.off_start= self.read_data["off_start"]
-
- # b3 = str("off_end") in self.read_data.keys()
- # if b3 == True:
- # self.off_end = self.read_data["off_end"]
-
- # print("self.sos_numer1:{} self.read_data:{}".format(self.sos_numer1,self.read_data))
+ self.off_on = read_data
+ read_data = EventMesh.publish("get_storage_key_data","off_start")
+ if read_data != None:
+ self.off_start= read_data
+ read_data = EventMesh.publish("get_storage_key_data","off_end")
+ if read_data != None:
+ self.off_end = read_data
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("set_boot_off_time", self.set_boot_off_time)#设置关机时间
EventMesh.subscribe("get_boot_off_time", self.get_boot_off_time)
def set_boot_off_time(self, event, msg):
- read_data = EventMesh.publish("get_storage_data")
- read_data["off_on"] = msg[0]
- read_data["off_start"] = msg[1]
- read_data["off_end"] = msg[2]
- with open("/ext/static/storage_file/config.json", 'w+',encoding='utf-8') as fd:
- ujson.dump(read_data,fd)
+ EventMesh.publish("get_storage_key_data",["off_on",msg[0]])
+ EventMesh.publish("get_storage_key_data",["off_start",msg[1]])
+ EventMesh.publish("get_storage_key_data",["off_end",msg[2]])
self.off_msg = msg
- # print("read_data:{} self.off_msg:{}".format(read_data,self.off_msg))
+
def get_boot_off_time(self, event, msg):
flag = 0
def set_sms_index(self, event, msg):
self.index = msg
- # print("read_data:{} self.off_msg:{}".format(read_data,self.off_msg))
def get_sms_index(self, event, msg):
class testSmsSetIPManager(Abstract):#
def __init__(self):
self.timer = osTimer()
- self.newip = ""#默认防走丢协议
- self.newcom = 0
+ self.newip = "api.xcloudtech.com"#默认防走丢协议
+ self.newcom = 9000
+ self.newmd5 = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
+ tmp_data = EventMesh.publish("get_storage_key_data","set_new_ip_addr")
+ if tmp_data != None:
+ self.newip = tmp_data
+ tmp_data = EventMesh.publish("get_storage_key_data","set_new_com")
+ if tmp_data != None:
+ self.newcom = tmp_data
+ tmp_data = EventMesh.publish("get_storage_key_data","set_new_md5")
+ if tmp_data != None:
+ self.newmd5 = tmp_data
- read_data = EventMesh.publish("get_storage_data")
- if read_data != None:
- b1 = str("set_new_ip_addr") in read_data.keys()
- if b1 == True:
- self.newip = read_data["set_new_ip_addr"]
- else:
- self.newip = "api.xcloudtech.com"
-
- b2 = str("set_new_com") in read_data.keys()
- if b2 == True:
- self.newcom = read_data["set_new_com"]
- else:
- self.newcom = 9000
-
- b3 = str("set_new_md5") in read_data.keys()
- if b3 == True:
- self.newmd5 = read_data["set_new_md5"]
- else:
- self.newmd5 = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
-
- # check = ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check == True:
- # with open("/ext/static/storage_file/config.json","r") as fd:
- # self.read_data = ujson.load(fd)
- # print("config.json:{}".format(self.read_data))
- # b1 = str("set_new_ip_addr") in self.read_data.keys()
- # if b1 == True:
- # self.newip = self.read_data["set_new_ip_addr"]
- # else:
- # self.newip = "api.xcloudtech.com"
-
- # b2 = str("set_new_com") in self.read_data.keys()
- # if b2 == True:
- # self.newcom = self.read_data["set_new_com"]
- # else:
- # self.newcom = 9000
-
- # b3 = str("set_new_md5") in self.read_data.keys()
- # if b3 == True:
- # self.newmd5 = self.read_data["set_new_md5"]
- # else:
- # self.newmd5 = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
-
- # self.read_data["set_new_ip_addr"] = self.newip
- # self.read_data["set_new_com"] = self.newcom
- # # self.read_data["set_new_md5"] = self.newmd5
-
-
- # with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- # ujson.dump(self.read_data,fd)
- # else:
- # self.newip = "api.xcloudtech.com"#默认防走丢协议
- # self.newcom = 9000
- # # self.newmd5 = "bZld0ALsZTt15tKEZhOlLPgbsO75BLTP"
- # print("config.json:{}".format(self.read_data))
- # server_addr = "tcptest.tx.kidxin.com"
- # #SETIP:api.xcloudtech.com:9000
- # server_port = 11500
def post_processor_after_instantiation(self):
self.newcom = int(msg[1])
# self.newmd5 = str(msg[2])
#短信格式:SETIP:api.xcloudtech.com:9000:bZld0ALsZTt15tKEZhOlLPgbsO75BLTP 以冒号分隔 SETIP:ip地址:ip端口号:ip密钥key
- read_data = EventMesh.publish("get_storage_data")
- read_data["set_new_ip_addr"] = self.newip #通过短信设置ip地址
- read_data["set_new_com"]= self.newcom #通过短信设置ip端口号
+
# self.read_data["set_new_md5"] = self.newmd5 #通过短信设置ip的key密钥
-
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
- with open("/ext/static/storage_file/config.json","r") as fd:
- read_data = ujson.load(fd)
- print("config.json:{}".format(read_data))
- # print("msg:{} self.read_data:{}".format(msg,self.read_data))
+
+ EventMesh.publish("set_storage_key_data",["set_new_ip_addr",self.newip])
+ EventMesh.publish("set_storage_key_data",["set_new_com",self.newcom])
+
number = str(msg[2])
sms.sendPduMsg(number, 'set ok', 'UCS2')
- self.timer.start(5*1000,0,self.fun)
+ self.timer.start(10*1000,0,self.fun)
def fun(self,*argc):
Power.powerRestart()
step = 0
step = EventMesh.publish("get_old_step_value")
if step != 0:
- read_data = EventMesh.publish("get_storage_data")
- b = str("old_step_new") in read_data.keys()
- if b == True:
- old_step = read_data["old_step_new"]
- else:
- old_step = 0
+ read_data = EventMesh.publish("get_storage_key_data","old_step_new")
+ if read_data != None:
+ old_step = read_data
+
if old_step != step:
# print("old_step:send:%d %d"%(old_step,step))
- read_data["old_step"] = step
- read_data["old_step_new"] = step+10
- EventMesh.publish("set_storage_data", read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
+ EventMesh.publish("set_storage_key_data",["old_step_new",step+10])
+ EventMesh.publish("set_storage_key_data",["old_step_new",step])
old_step = step
# step = EventMesh.publish(constants.EVENT.GET_STEP)[0]
elif hrTotal >= 65536:
hrTotal = 65536
print("HRSTART_ 3".format(hrTotal))
- storage_tmp = EventMesh.publish("get_storage_data")
- storage_tmp["measure_time"] = hrTotal
- storage_tmp["open_hr_btn"] = 1
-
- EventMesh.publish("set_storage_data", storage_tmp)
EventMesh.publish("set_time_hr_spo2",[1,hrTotal])
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(storage_tmp,fd)
+
EventMesh.publish(constants.PROTOCOL.HRTSTART_SEND)
tempTotal = 300
elif tempTotal >= 65536:
tempTotal = 65536
- storage_tmp = EventMesh.publish("get_storage_data")
- storage_tmp["temp_time"] = tempTotal
- EventMesh.publish("set_storage_data", storage_tmp)
+
EventMesh.publish("set_temp_time",tempTotal)
- print("storage_tmp:{}".format(storage_tmp))
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(storage_tmp,fd)
+
+
EventMesh.publish(constants.PROTOCOL.WDSTART_SEND)
#解绑
msg_tmp = msg_tmp.split(',')
msg_tmp = msg_tmp[1]
upload_time = int(msg_tmp)
- storage_tmp = EventMesh.publish("get_storage_data")
- storage_tmp["upload_time"] = upload_time
- EventMesh.publish("set_storage_data", storage_tmp)
+ EventMesh.publish("set_storage_key_data",["upload_time",upload_time])
+
EventMesh.publish("set_upload_data", upload_time)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(storage_tmp,fd)
EventMesh.publish(constants.PROTOCOL.UPLOAD_SEND)
#设置快捷号码
msg_tmp = msg_tmp[1]
print("CENTER_ProtoCol RECV msg:{} msg_:{}".format(msg,msg_tmp))
center_dial = str(msg_tmp)
- storage_tmp = EventMesh.publish("get_storage_data")
- storage_tmp["center_dial"] = center_dial
- EventMesh.publish("set_storage_data", storage_tmp)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(storage_tmp,fd)
+ EventMesh.publish("set_storage_key_data",["center_dial",center_dial])
EventMesh.publish(constants.PROTOCOL.CENTER_SEND)
#呼叫快捷电话号码
@param msg: 接收到的下行数据
"""
# b'[SZKW*867387060319166*000A*MONITOR]'
- self.read_data = {}
- self.read_data = EventMesh.publish("get_storage_data")
- if self.read_data != {}:
- b = str("center_dial") in self.read_data.keys()
- if b == True:
- contact = self.read_data["center_dial"]
- if len(contact) > 0:
- print("MONITOR RECV msg:{} {}".format(contact,type(contact)))
- EventMesh.publish("save_phonename", contact)
- EventMesh.publish("save_phonenum", contact)
- voiceCall.callStart(contact)
+ read_data = EventMesh.publish("set_storage_key_data","center_dial")
+
+ if read_data != None:
+ contact = read_data
+ if len(contact) > 0:
+ print("MONITOR RECV msg:{} {}".format(contact,type(contact)))
+ EventMesh.publish("save_phonename", contact)
+ EventMesh.publish("save_phonenum", contact)
+ voiceCall.callStart(contact)
EventMesh.publish(constants.PROTOCOL.MONITOR_SEND)
#定时开关机
"""
# b'[SZKW*867387060319166*000A*SOS_SEND]'
- read_data = {}
- read_data = EventMesh.publish("get_storage_data")
msg = msg[1:-1]
msg_tmp = msg.decode('ascii')
msg_tmp = msg_tmp.split(',')
for i in range(len(msg_tmp)-1):
# print("sos:send data :{}".format(msg_tmp[i+1]))
if len(msg_tmp[i+1]) != 0:
- read_data["SOS_NUMBER{}".format(i+1)] = msg_tmp[i+1]
+ EventMesh.publish("set_storage_key_data",["SOS_NUMBER{}".format(i+1),msg_tmp[i+1]])
# print("read_data:{} msg_tmp:{}".format(read_data,msg_tmp[i+1]))
if (len(msg_tmp)-1) == 3:
EventMesh.publish("set_dial_sos_number",[msg_tmp[1],msg_tmp[2]])
elif (len(msg_tmp)-1) == 1:
EventMesh.publish("set_dial_sos_number",[msg_tmp[1]])
-
-
- if (len(msg_tmp)-1) != 0:
- EventMesh.publish("set_storage_data",read_data)
- # print("read_data:{}".format(read_data))
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
+
EventMesh.publish(constants.PROTOCOL.SOS_SEND)
# 低电提醒
@param msg: 接收到的下行数据
"""
# b'[SZKW*867387060319166*000A*LOWBAT]'
- read_data = {}
- read_data = EventMesh.publish("get_storage_data")
+
msg = msg[1:-1]
msg_tmp = msg.decode('ascii')
msg_tmp = msg_tmp.split(',')
on_bt = msg_tmp[1]
print("LOWBAT:send data:{}".format(on_bt))
#b'[SZKW*860132060006970*0015*LOWBAT,1,06:00,23:59]'
-
- read_data["low_on"] = on_bt
- EventMesh.publish("set_storage_data",read_data)
EventMesh.publish("set_low_bat_btn",on_bt)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
EventMesh.publish(constants.PROTOCOL.LOWBAT_SEND)
# 低电提醒
self.point = self.point + 1
EventMesh.publish("system_sleep_rest")#防止黑屏
self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ #print("heart WEAR:{}".format(WEAR))
# print("self.heart_value:{}".format(self.heart_value))
if self.point >= 2:
if self.heart_value < 40:
- if self.point > 120: #测20s
+ if self.point > 120 or (WEAR == 0 and self.point > 10): #测60s或没佩戴
self.timer.stop()
heartrate_done_img.set_src("E:/static/hr_gif_03.png")
+
self.heart_value = EventMesh.publish(constants.EVENT.GET_HEART)
+ if WEAR == 0:
+ self.heart_value = 0
+ heartrate_start_label.set_text("佩戴异常,点击重测")
+ else :
+ heartrate_start_label.set_text("测量结束,点击重测")
+
if self.heart_value > 50:
EventMesh.publish("set_old_hr_data",self.heart_value)
EventMesh.publish("set_history_hr_value",self.heart_value)
EventMesh.publish(constants.PROTOCOL.HEART_SEND,self.heart_value)
heartrate_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
- heartrate_start_label.set_text("测量结束,点击重测")
+
if self.heart_value != 0:
heartrate_bpm_label.set_text("{} bpm".format(self.heart_value))
# heartrate_done_label.set_text("测量完成")
def __init__(self):
super().__init__()
self.CALL_LOG_MAX = CALL_LOG_MAX
- # self.read_data = {}
- # self.volum_size = 8
- # check_volum = ql_fs.path_exists("/ext/static/storage_file/config.json")
- # if check_volum == True :
- # with open("/ext/static/storage_file/config.json","r") as fd:#音频文件编号
- # self.read_data = ujson.load(fd)
- # if self.read_data != {}:
- # b = str("volum") in self.read_data.keys()
- # if b == True:
- # self.volum_size = self.read_data["volum"]
- # else:
- # self.volum_size = 8
- # else:
- # self.volum_size = 8
- # else:
- # self.volum_size = 8
+
self.aud = audio.Audio(0)
self.call_timer = osTimer()
def show_bar(self,msg):
on_call_bar.set_value((100 // 11) * self.volum_size, lv.ANIM.OFF)
if msg == 1:
- read_data = EventMesh.publish("get_storage_data")
- read_data["volum"] = self.volum_size
+
+
self.aud.setVolume(self.volum_size)
- EventMesh.publish("set_storage_data", read_data)
+
EventMesh.publish("set_volum_size",self.volum_size)
- # print("self.read_data:size :{}".format(self.read_data))
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
+
def post_processor_after_initialization(self):
global on_call_screen_tab,on_call_obj
# lv.EVENT.CLICKED, None)
#contact_btn_label_1 = lv.label(contact_btn)
- self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_pos(0, 5)
- self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_size(180, 25)
+ self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_pos(0, 0)
+ self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_size(180, 30)
self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_text(key_tmp[4:])
self.contact_detail_listt_dict[i]["contact_btn_label_1"].set_long_mode(lv.label.LONG.DOT)
self.contact_detail_listt_dict[i]["contact_btn_label_1"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
#contact_btn_label_3 = lv.label(contact_btn)
- self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_pos(0, 30)
+ self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_pos(0, 35)
self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_size(220, 35)
self.contact_detail_listt_dict[i]["contact_btn_label_3"].set_text(name)
self.contact_detail_listt_dict[i]["contact_btn_label_3"].add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
global temperature_label,temperature_keep_label,temperature_done_img ,temp_reset_btn_img,temperature_start_label,temperature_bpm_label ,temperature_done_label
self.point = self.point + 1
EventMesh.publish("system_sleep_rest")#防止黑屏
-
+ 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
tmp_d = str(temp).split('.')[1][:1]
tmp_d_tmp = int(tmp_d)
if self.point >= 2:
- if temp != 0:
- if temp >= 37.3:
- temperature_keep_label.set_text("体温偏高")
- temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0x00, 0x00), lv.STATE.DEFAULT)
- else:
- temperature_keep_label.set_text("体温正常")
- temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
- if self.point > 120 : #测2min
+
+ if temp >= 37.3:
+ temperature_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:
+ temp = 0
+ temperature_start_label.set_text("佩戴异常,点击重测")
+ temperature_bpm_label.set_text("- -")
+ temperature_keep_label.set_text("体温异常")
+ temperature_keep_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+ else :
+ temperature_start_label.set_text("测量结束,点击重测")
+ EventMesh.publish("set_history_temp_value",temp)
+ EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
if temp >= 37.3:
temperature_done_img.set_src("E:/static/temp_high.png")
else:
temperature_done_img.set_src("E:/static/temp_gif03.png")
temp_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
- temperature_start_label.set_text("测量结束,点击重测")
- EventMesh.publish("set_history_temp_value",temp)
self.show_history_data()
self.point = 0
EventMesh.publish("set_temp_state",0)
- EventMesh.publish(constants.PROTOCOL.TEMP_SEND,[tmp_f_tmp,tmp_d_tmp])
+
EventMesh.publish(constants.EVENT.STOP_TEMP)
def restart_up(self,e):
global spo2_value_label,heartrate_bpm_label,spo2_start_label,spo2_reset_btn_img
+ self.point = 0
self.timer.start(1*500, 1, self.start_measure)
if spo2_reset_btn_img != None:
spo2_reset_btn_img.add_flag(lv.obj.FLAG.HIDDEN)
- self.point = 0
+
spo2_value_label.set_text("- -%")
spo2_start_label.set_text("正在测量中.")
global spo2_screen,spo2_label,spo2_start_label,spo2_value_label,spo2_done_img ,spo2_reset_btn_img
self.point = self.point + 1
EventMesh.publish("system_sleep_rest")#防止黑屏
+ WEAR = EventMesh.publish(constants.EVENT.GET_WEAR)#佩戴数据
+ print("sop2:start_measure:point{}".format(self.point))
self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
if self.point >= 2:
if self.spo2_value != 0:
- if self.point > 120: #测20s
+ if self.point > 120 or (WEAR == 0 and self.point > 10): #测60s
self.timer.stop()
spo2_done_img.set_src("E:/static/spo2_gif04.png")
self.spo2_value = EventMesh.publish(constants.EVENT.GET_BLOOD_OXYGEN)
+ if WEAR == 0:
+ self.spo2_value = 0
+ spo2_start_label.set_text("佩戴异常,点击重测")
+ else :
+ spo2_start_label.set_text("测量结束,点击重测")
+
if self.spo2_value >= 85:
EventMesh.publish("set_old_spo2_data",self.spo2_value)
EventMesh.publish("set_history_spo2_value",self.spo2_value)
spo2_reset_btn_img.clear_flag(lv.obj.FLAG.HIDDEN)
+
if self.spo2_value != 0:
- spo2_start_label.set_text("测量结束,点击重测")
spo2_value_label.set_text("{}%".format(self.spo2_value))
# heartrate_done_label.set_text("测量完成")
else:
spo2_value_label.set_text("- - %")
- spo2_start_label.set_text("测量异常,点击重测")
+
self.show_history_data()
self.level = 6
self.aud = audio.Audio(0)
self.level = EventMesh.publish("get_brightness_level")
- read_data = EventMesh.publish("get_storage_data")
self.main_flag = 0
self.main_id = 0
self.set_interrup_flag = 0
self.UI_high_priority_flag = 0 #如果=1,则当前ui不被打断
- # print("read_data:{} self.level:{}".format(read_data,self.level))
- check = ql_fs.path_exists("/ext/static/storage_file/config.json")
- if check == True:
- with open("/ext/static/storage_file/config.json","r") as fd:
- read_data = ujson.load(fd)
- if read_data != {}:
- b = str("brightness_level") in read_data.keys()
- if b == True:
- self.level = read_data["brightness_level"]
- else:
- self.level = 6
- else:
- self.level = 6 #默认是6级别
- print("self.read_data:{} self.level:{}".format(read_data,self.level))
+ print(" self.level:{}".format(self.level))
if self.level == None:
self.level = 6
self.watchface_list = []
self.timer_update = osTimer()
EventMesh.subscribe("set_change_face", self.change_face)
- self.read_data = {}
self.PWM_backlight = None
- check = ql_fs.path_exists("/ext/static/storage_file/config.json")
- if check == True:
- with open("/ext/static/storage_file/config.json","r") as fd:
- self.read_data = ujson.load(fd)
- if self.read_data != {}:
- b = str("watchface") in self.read_data.keys()
- if b == True:
- self.watchface_style_num = self.read_data["watchface"]
- else:
- self.watchface_style_num = "Watchface1"
- else:
- self.watchface_style_num = "Watchface1"
+ read_data = EventMesh.publish("get_storage_key_data","watchface")
+ if read_data != None:
+ self.watchface_style_num = read_data
+
+
def initialization(self,main_menu):
if self.watchface_list == [] : #第一次初始化
self.aud.set_pa(Pin.GPIO29)
read_data = {}
self.volum_size = 8
- check_volum = ql_fs.path_exists("/ext/static/storage_file/config.json")
- if check_volum == True :
- with open("/ext/static/storage_file/config.json","r") as fd:#音频文件编号
- read_data= ujson.load(fd)
- if read_data != {}:
- b = str("volum") in read_data.keys()
- if b == True:
- self.volum_size = read_data["volum"]
- else:
- self.volum_size = 8
- else:
- self.volum_size = 8
- else:
- self.volum_size = 8
+ check_volum = EventMesh.publish("get_storage_key_data","volum")
+
+ if check_volum != None:
+ self.volum_size = read_data["volum"]
+
+
self.aud.setVolume(self.volum_size)
self.count = 0
super().__init__()
self.meta = poweroff_confirm_screen
self.timer = osTimer()
- self.read_data = {}
self.count = 0
def initialization(self):
step = EventMesh.publish("get_old_step_value")
- self.read_data = EventMesh.publish("get_storage_data")
if step != 0:
- self.read_data["old_step"] = step
+ EventMesh.publish("set_storage_key_data",["old_step",step])
+
date_tmp = utime.localtime()
- self.read_data["old_timesecond"] = date_tmp#关机保存一个是时间
+ EventMesh.publish("set_storage_key_data",["old_timesecond",date_tmp])#关机保存一个是时间
+
#print("self.read_data:{}".format(self.read_data))
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(self.read_data,fd)
EventMesh.publish("play_poewr_off_event")#
self.count = 0
self.timer.start(1*1000,1,self.power_off)
def __init__(self):
super().__init__()
self.power_off_flag = 0
- self.read_data = {}
+
EventMesh.subscribe("get_time_power_off", self.get_time_power_off)
EventMesh.subscribe("power_off_callback", self.power_off_callback)
EventMesh.subscribe("set_time_power_off", self.set_time_power_off)
self.power_off_flag = 0
def set_time_power_off(self,event,msg):
- self.read_data = EventMesh.publish("get_storage_data")
- if self.read_data != {}:
- b = str("off_on") in self.read_data().keys()
- if b == True:
- pass
+
+ pass
def __init__(self):
super().__init__()
self.meta = dialswitch_screen
- self.read_data = {}
self.watchface_style_num = "Watchface1"
dialswitch_img1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.watchface01(e)),
lv.EVENT.CLICKED, None)
def initialization(self):
self.dial_num = 1
self.move = 0
- self.read_data = EventMesh.publish("get_storage_data")
- if self.read_data != {}:
- b = str("watchface") in self.read_data.keys()
- if b == True:
- self.watchface_style_num = self.read_data["watchface"]
+ read_data = EventMesh.publish("get_storage_key_data","watchface")
+
+ if read_data != None:
+ self.watchface_style_num = read_data
if self.watchface_style_num == "Watchface1":
self.dial_num = 1
else:
self.timer.start(50,0,self.enter_main_show)
def enter_main_show(self,e):
- self.read_data = EventMesh.publish("get_storage_data")
- self.read_data["watchface"] = "Watchface{}".format(self.dial_num)
- EventMesh.publish("set_storage_data", self.read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(self.read_data,fd)
+ EventMesh.publish("set_storage_key_data",["watchface","Watchface{}".format(self.dial_num)])
EventMesh.publish("set_change_face", "Watchface{}".format(self.dial_num))
EventMesh.publish("watch_top_show")
EventMesh.publish("load_screen", {"screen": "main_menu"})
brightness_time_add_imgbtn.set_pos(170, 140)
brightness_time_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-
+brightness_flip_label = lv.label(brightness_screen)
+brightness_flip_label.set_pos(0, 260)
+brightness_flip_label.set_size(140, 40)
+brightness_flip_label.set_text("翻腕亮屏")
+#brightness_flip_label.set_long_mode(lv.label.LONG.WRAP)
+brightness_flip_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0)
+brightness_flip_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+brightness_flip_sw = lv.switch(brightness_screen)
+brightness_flip_sw.set_pos(140, 250)
+brightness_flip_sw.set_size(80, 40)
class BrightnessScreen(Screen):
NAME = "brightness"
super().__init__()
self.level = 6
self.time = 10
- self.read_data = {}
self.meta = brightness_screen
brightness_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_level(e)),
lv.EVENT.CLICKED, None)
brightness_time_add_imgbtn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.add_time_level(e)),
lv.EVENT.CLICKED, None)
+ brightness_flip_sw.add_event_cb(lambda e: EventMesh.callback_wrapper(self.flip_sw_cb(e)),lv.EVENT.ALL, None)
def initialization(self):
self.level = EventMesh.publish("get_brightness_level")
self.time = EventMesh.publish("get_brightness_time")
self.level = EventMesh.publish("get_brightness_level")
self.show_bar()
+ def flip_sw_cb(self,e):
+ code = e.get_code()
+ obj = e.get_target()
+ if code == lv.EVENT.VALUE_CHANGED:
+ flip_sw = 0
+ if obj.has_state(lv.STATE.CHECKED):
+ print("flip_sw_cb: on")
+ flip_sw = 1
+ else:
+ print("flip_sw_cb: off")
+ flip_sw = 0
+ EventMesh.publish("set_storage_key_data",["flip_sw",flip_sw])
+
def reduce_time_level(self, e):
if self.time > 5:
self.time-=5
EventMesh.publish("set_brightness_time",self.time)
- self.read_data = EventMesh.publish("get_storage_data")
- self.read_data["brightness_time"] = self.time
-
- EventMesh.publish("set_storage_data", self.read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(self.read_data,fd)
brightness_label_time_text.set_text("{}秒".format(self.time))
- print("reduce_time_level:{}".format(self.read_data))
+
+
def add_time_level(self, e):
self.time+=5
if self.time >= 30:
self.time = 30
- EventMesh.publish("set_brightness_time",self.time)
- self.read_data = EventMesh.publish("get_storage_data")
- self.read_data["brightness_time"] = self.time
-
- EventMesh.publish("set_storage_data", self.read_data)
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(self.read_data,fd)
+ EventMesh.publish("set_brightness_time",self.time)
brightness_label_time_text.set_text("{}秒".format(self.time))
- print("add_time_level:{}".format(self.read_data))
+
def show_bar(self,msg):
totalvolume_bar.set_value((100 // 11) * self.volum_size, lv.ANIM.OFF)
if msg == 1:
- read_data = EventMesh.publish("get_storage_data")
- read_data["volum"] = self.volum_size
self.aud.setVolume(self.volum_size)
- EventMesh.publish("set_storage_data", read_data)
EventMesh.publish("set_volum_size",self.volum_size)
# print("self.read_data:size :{}".format(self.read_data))
- with open("/ext/static/storage_file/config.json","w",encoding="utf-8") as fd:
- ujson.dump(read_data,fd)
+
self.aud.play(1, 1, 'E:/static/audio_audio_haixiu.mp3') #播放声音
def Close(self):