import math
import voiceCall
from misc import PWM
-from machine import I2C
+
class PhoneVolumeLevelManager(Abstract):
def __init__(self):
self.level = 0
print('GNSS init ok.')
else:
print('GNSS init failed.')
- self.i2c0 = I2C(I2C.I2C0, I2C.STANDARD_MODE)
- self.stop_temp( None, None)
-
+
def post_processor_after_instantiation(self):
print("post_processor_after_instantiation:1")
"""订阅此类所有的事件到 EventMesh中"""
EventMesh.subscribe(constants.EVENT.STOP_HEART, self.stop_heart)
EventMesh.subscribe(constants.EVENT.GET_BLOOD_OXYGEN, self.get_blood_oxygen)
EventMesh.subscribe(constants.EVENT.GET_HEART, self.get_heart)
- EventMesh.subscribe(constants.EVENT.START_TEMP, self.start_temp)
- EventMesh.subscribe(constants.EVENT.STOP_TEMP, self.stop_temp)
- EventMesh.subscribe(constants.EVENT.GET_TEMP, self.get_temp)
+
print("post_processor_after_instantiation:2")
self.timer_push_schedule.start(10000, 1, self.publish_event)
# self.battery_push_schedule.start(3000, 1, self.__check_battery)
:param kwargs:
:return:
"""
+
+
self.timer_push = self.timer_push+1
#if self.timer_push > 10 :
if self.bat_time > 5*60:
self.bat_time = 0
- if battery == 20:
+ if battery[1] == 20:
EventMesh.publish("load_screen", {"screen": "LOW_POWER"})
-
+
#消息已满
msg_nums = sms.getMsgNums() #获取短信条数
self.sms_full_flag+=10
EventMesh.publish("load_screen", {"screen": "message_full"})
#print("hr......01....{}\r\n".format(hr_time))
- if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:
+ if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1 or battery[1] != 1:
if hr_time != None:
# print("hr......01....{}\r\n".format(hr_time))
if hr_time > 0:
self.PING = msg
def get_ping(self, topic, msg):
return self.PING
+
def set_connect(self, topic, msg):
#print("set_connect:{}".format(msg))
self.connect = msg
def start_blood_oxygen(self, topic, msg):
print("start_blood_oxygen!!!")
self.hsensor.open_blood_oxygen()
+
def start_heart(self, topic, msg):
print("start_heart!!!")
self.hsensor.open_heart()
+
def stop_blood_oxygen(self, topic, msg):
print("stop_blood_oxygen!!!")
self.hsensor.close()
+
def stop_heart(self, topic, msg):
print("stop_heart!!!")
self.hsensor.close()
+
def get_blood_oxygen(self, topic, msg):
data = self.hsensor.get_all_data()
return data[1]
+
def get_heart(self, topic, msg):
data = self.hsensor.get_all_data()
return data[0]
- def start_temp(self, topic, msg):
- WHO_AM_I = bytearray([0x01, 0])
- I2C_SLAVE_ADDR = 0x49
- r_data = bytearray(2)
- data = bytearray([0x61A0, 0]) # 唤醒
- return self.i2c0.write(I2C_SLAVE_ADDR, WHO_AM_I, 1, data, 2)
- def stop_temp(self, topic, msg):
- WHO_AM_I = bytearray([0x01, 0])
- I2C_SLAVE_ADDR = 0x49
- r_data = bytearray(2)
- data = bytearray([0x60A0, 0]) #休眠
- return self.i2c0.write(I2C_SLAVE_ADDR, WHO_AM_I, 1, data, 2)
-
- def get_temp(self, topic, msg):
- WHO_AM_I = bytearray([0x00, 0])
- I2C_SLAVE_ADDR = 0x49
- r_data = bytearray(2)
- self.i2c0.read(I2C_SLAVE_ADDR, WHO_AM_I, 1, r_data, 2, 0)
- #print("temp_data:{}".format(r_data))
- temp_s = ((r_data[0]<<8) | (r_data[1]))>>4
- #print("temp_s:{}".format(temp_s))
- temp_data = temp_s * 0.0625
- #print("temp_data:{}".format(temp_data))
- return temp_data
data = ""
self.location_timer_count = self.location_timer_count +1
self.location_check_data_timer_count = self.location_check_data_timer_count+1
- match_gga_data = []
- match_gsv_data = []
- if self.location_check_data_timer_count > 2 :#5秒查一次
+ if self.location_check_data_timer_count > 5 :#5秒查一次
self.location_check_data_timer_count = 0
#print(self.location_timer_count)
#检查wifi数据
data = quecgnss.read(4096)
#print(data[1].decode())
if data[0] > 0 : #有数据
- match_gga_data = self.match.GxGGA(data[1]).split(",")
- match_gsv_data = self.match.GxGSV(data[1]).split(",")
if self.gps.__check_gps_valid(data[1].decode()): #数据齐全
match_gmc_data = self.match.GxRMC(data[1]).split(",")
match_vtg_data = self.match.GxVTG(data[1]).split(",")
-
+ match_gga_data = self.match.GxGGA(data[1]).split(",")
data = self.gps.read_coordinates(data[1])
latitude_tmp = str(data[1]).split(".")
if len(latitude_tmp) >= 2 and len(latitude_tmp[1])>=5:
break
if self.location_type == 1: #测试模式
EventMesh.publish("PUSH_LOCATION_DATA", [data,self.wifi_data,self.cell_data])
- elif self.location_type == 0: #正常模式
- #print("(match_gsv_data):{}".format((match_gsv_data)))
- if self.gps_data != [] or self.location_timer_count > 40 : #有gps数据或者超时
+ elif self.location_type == 0: #正常模式
+ if self.gps_data != [] or self.location_timer_count > 60: #or( self.wifi_data != [] and self.cell_data != []):
#print("publish:READ_LOCATION")
EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data])
EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
- if len(match_gsv_data) >= 3:
- #print("match_gsv_data[3]:{}".format(match_gsv_data[3]))
- if (int(match_gsv_data[3]) < 3 and self.wifi_data != [] and self.cell_data != [] and self.location_timer_count > 10): #超过10秒且卫星个数少于3
- #print("publish:READ_LOCATION")
- EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data])
- EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
-
+ # if self.location_timer_count > 60 : #1分钟定位超时,超时发送数据,停止定时器及关闭定位
+ # EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+ # EventMesh.publish(constants.EVENT.READ_LOCATION, [self.gps_data,self.wifi_data,self.cell_data])#发送数据
self.time = msg
def get_brightness_time(self, event, msg):
- #print("get_brightness_time self.read_data:{} self.time:{}".format(self.read_data,self.time))
+ # print("get_brightness_time self.read_data:{} self.time:{}".format(self.read_data,self.time))
if self.read_data != {}:
b = str("brightness_time") in self.read_data.keys()
if b == True:
def __init__(self):
self.meta = MainMenu2
self.watchface = WatchFace()
- self.menu_id = 0
+ self.menu_id = "0"
print("MainMenu1:__init__")
MainMenu2_img_phone.add_event_cb(lambda e: self.img_cb(e, "Phone"), lv.EVENT.CLICKED, None)
MainMenu2_img_toolbox.add_event_cb(lambda e: self.img_cb(e, "toolbox"), lv.EVENT.CLICKED, None)
MainMenu2_img_spo2.add_event_cb(lambda e: self.img_cb(e, "spo2"), lv.EVENT.CLICKED, None)
MainMenu2_img_temperature.add_event_cb(lambda e: self.img_cb(e, "temperature"), lv.EVENT.CLICKED, None)
MainMenu2_img_alipay.add_event_cb(lambda e: self.img_cb(e, "alipay_open"), lv.EVENT.CLICKED, None)
+ EventMesh.subscribe("watch_top_show", self.watch_top_show)
#MainMenu2_img_alipay.add_event_cb(lambda e: img_cb(e, "Watchface_set"), lv.EVENT.CLICKED, None)
- MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
+
def initialization(self):
self.watchface.initialization(MainMenu2_Watchface)
- EventMesh.subscribe("watch_top_show", self.watch_top_show)
+
+ if self.menu_id =="0":
+ MainMenu2_til.set_tile_id(0,1,lv.ANIM.OFF)
# if self.meta_info in globals() :
# MainMenu2_til.set_tile_id(self.meta_info[0],self.meta_info[1],lv.ANIM.OFF)
pass#
id = MainMenu2_til.get_tile_act().get_child(0).get_text()
if id == "0":
EventMesh.publish("load_screen", {"screen": "call_log"})
+ self.menu_id = id
def done_top_to_bottom(self):
id = MainMenu2_til.get_tile_act().get_child(0).get_text()
if id == "0":
EventMesh.publish("load_screen", {"screen": "popup"})
+ self.menu_id = id
def done_left_to_right(self):
id = MainMenu2_til.get_tile_act().get_child(0).get_text()
print("done_left_to_right:ID{}".format(id))