BATTERY_OCV_TABLE = {
"nix_coy_mnzo2": {
55: {
- 4152: 100, 4083: 95, 4023: 90, 3967: 85, 3915: 80, 3864: 75, 3816: 70, 3773: 65, 3737: 60, 3685: 55,
- 3656: 50, 3638: 45, 3625: 40, 3612: 35, 3596: 30, 3564: 25, 3534: 20, 3492: 15, 3457: 10, 3410: 5, 3380: 0,
+ 4331: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
},
20: {
- 4143: 100, 4079: 95, 4023: 90, 3972: 85, 3923: 80, 3876: 75, 3831: 70, 3790: 65, 3754: 60, 3720: 55,
- 3680: 50, 3652: 45, 3634: 40, 3621: 35, 3608: 30, 3595: 25, 3579: 20, 3548: 15, 3511: 10, 3468: 5, 3430: 0,
+ 4331: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
},
0: {
- 4147: 100, 4089: 95, 4038: 90, 3990: 85, 3944: 80, 3899: 75, 3853: 70, 3811: 65, 3774: 60, 3741: 55,
- 3708: 50, 3675: 45, 3651: 40, 3633: 35, 3620: 30, 3608: 25, 3597: 20, 3585: 15, 3571: 10, 3550: 5, 3500: 0,
+ 4331: 100, 4237: 95, 4179: 90, 4123: 85, 4070: 80, 4020: 75, 3963: 70, 3919: 65, 3882: 60, 3847: 55,
+ 3818: 50, 3794: 45, 3772: 40, 3752: 35, 3733: 30, 3716: 25, 3699: 20, 3677: 15, 3652: 10, 3629: 5, 3355: 0,
},
},
}
break
else:
pre_volt = volt
+ # print("__get_soc_from_dict:{}".format(soc2 - (soc2 - soc1) * (pre_volt - volt_arg) // (pre_volt - volt)))
if pre_volt == 0: # Input Voltarg > Highest Voltarg
return soc1
elif volt_not_under == 0:
else:
return self.__get_adc_vbatt()
- def get_energy(self):
+ def get_energy(self,volt_arg ):
"""Get battery energy"""
- self.__energy = self.__get_soc(self.__temp, self.get_voltage())
+ if( volt_arg == None) :
+ volt_arg = self.get_voltage()
+ self.__energy = self.__get_soc(self.__temp, volt_arg)
+ # print("get_energy:volt_arg {} __energy{}".format(volt_arg,self.__energy))
return self.__energy
def set_charge_callback(self, charge_callback):
EventMesh.subscribe("get_battery", self.get_battery)
def get_battery(self, event=None, msg=None):
- battery = self.battery.get_energy()
+ battery = self.battery.get_energy(msg)
return battery
def get_voltage(self, event=None, msg=None):
EventMesh.publish(constants.EVENT.PUSH_STEP, self.get_step_count())
temp = Power.getVbatt()
- self.bat_count+=1
- self.vbat_buf.append(temp)
+
+ if self.bat_count < 10:
+ self.vbat_buf.append(temp)
+ self.bat_count += 1
+ else:
+ for i in range(9):
+ self.vbat_buf[i] = self.vbat_buf[i+1]
+ self.vbat_buf[9] = temp
curr_count = len(self.vbat_buf)
bat_total_value = 0
bat_total_value = bat_total_value//curr_count#一分钟更新一次电量 10个平均值
EventMesh.publish("set_curr_battery_level",bat_total_value)
- # print("self.vbat_buf:{} curr_count :{} bat_total_value:{}".format(self.vbat_buf,curr_count,bat_total_value))
- if self.bat_count >= 10:
- self.bat_count = 0
- self.vbat_buf = []
+ # print("self.vbat_buf:{} curr_count :{} bat_total_value:{} temp:{}".format(self.vbat_buf,curr_count,bat_total_value,temp))
+
bat_tmp = EventMesh.publish("screen_get_battery")
self.vbat_count+=10
voiceCall.setCallback(voice_callback)
if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:#未插卡提示关机
if battery[0] == "0":
- self.no_smi_count+=1
- if self.no_smi_count > 6 and self.no_smi_state == 0:
+ self.no_smi_count+=10
+ if self.no_smi_count > (15*60) and self.no_smi_state == 0:
self.no_smi_count = 0
self.no_smi_state = 1
EventMesh.publish("load_screen", {"screen": "no_sim_auto_screen"})
#temp = Power.getVbatt()
temp = EventMesh.publish("get_curr_battery_level")
- if temp != None :
- if temp <= 3505:
- vbat = 0
- elif temp <= 3699:
- vbat = 20 #"E:/vbat_20.jpg"
- elif temp <= 3772:
- vbat = 40 #"E:/vbat_40.jpg"
- elif temp <= 3882:
- vbat = 60 #"E:/vbat_60.jpg"
- elif temp <= 4070:
- vbat = 80 #"E:/vbat_80.jpg"
- else:
- vbat = 100 #"E:/vbat_100.jpg"
- else:
+ vbat = EventMesh.publish("get_battery",temp)
+ if vbat == None:
vbat = 100
+ # print("vbat",vbat)
+ # if temp != None :
+ # if temp <= 3505:
+ # vbat = 0
+ # elif temp <= 3699:
+ # vbat = 20 #"E:/vbat_20.jpg"
+ # elif temp <= 3772:
+ # vbat = 40 #"E:/vbat_40.jpg"
+ # elif temp <= 3882:
+ # vbat = 60 #"E:/vbat_60.jpg"
+ # elif temp <= 4070:
+ # vbat = 80 #"E:/vbat_80.jpg"
+ # elif temp <= 4200:
+ # vbat = 90 #
+ # else:
+ # vbat = 100 #"E:/vbat_100.jpg"
+ # else:
+ # vbat = 100
result = [charge_state, vbat]
style_font_youyuan_28.set_text_color(lv.color_make(0xFF, 0xFF, 0xFF))
style_font_youyuan_28.set_text_font(lv.font_28_dial)
+power_line_points = [{"x":0,"y":0},{"x":0,"y":16}]
+power_line_red = lv.style_t()
+power_line_red.init()
+power_line_red.set_line_width(0)#23 宽度
+power_line_red.set_line_color(lv.color_make(0xff, 0xff, 0xff))
+
Watchface = lv.obj()
print("Watchface")
Watchface1 = lv.obj(Watchface)
#状态栏
watchface1_mpsignal_img = lv.img(Watchface1)
-watchface1_mpsignal_img.set_pos(int(20),int(0))
-watchface1_mpsignal_img.set_size(24,17)
+watchface1_mpsignal_img.set_pos(int(20),int(5))
+watchface1_mpsignal_img.set_size(30,22)
watchface1_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
watchface1_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE)
watchface1_mpsignal_img.set_src("E:/static/mpsignal5.png")
watchface1_mpsignal_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
watchface1_res_stat_battery_img = lv.img(Watchface1)
-watchface1_res_stat_battery_img.set_pos(int(200),int(0))
-watchface1_res_stat_battery_img.set_size(30,18)
+watchface1_res_stat_battery_img.set_pos(int(196),int(5))
+watchface1_res_stat_battery_img.set_size(40,22)
watchface1_res_stat_battery_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
watchface1_res_stat_battery_img.add_flag(lv.obj.FLAG.CLICKABLE)
-watchface1_res_stat_battery_img.set_src("E:/static/vbat_100.png")
+watchface1_res_stat_battery_img.set_src("E:/static/vbat_0.png")
watchface1_res_stat_battery_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+
+
+watchface1_res_stat_battery_line = lv.line(Watchface1)
+watchface1_res_stat_battery_line.set_points(power_line_points,2)
+watchface1_res_stat_battery_line.set_pos(int(203),int(3))
+watchface1_res_stat_battery_line.set_size(0,16)#高度12
+watchface1_res_stat_battery_line.add_style(power_line_red,0)
+
watchface1_res_stat_charge_in_img = lv.img(Watchface1)
watchface1_res_stat_charge_in_img.set_pos(int(180),int(0))
watchface1_res_stat_charge_in_img.set_size(10,18)
#print("__battery_cb:",str(msg))
#print(msg)
if msg[0] == '1':
+
+ watchface1_res_stat_battery_line.set_pos(int(0),int(8))
+ watchface1_res_stat_battery_line.set_size(0,0)
+ watchface1_res_stat_battery_line.set_style_line_width(0,lv.PART.MAIN)
watchface1_res_stat_battery_img.set_src("E:/static/charge_ing.png")
else:
- # watchface1_res_stat_charge_in_img.set_src("E:/static/charge_in1.png")
- watchface1_res_stat_battery_img.set_src("E:/static/vbat_%d.png"%(msg[1]))#"E:/vbat_60.png"
+ watchface1_res_stat_battery_img.set_src("E:/static/vbat_0.png")
+ level = msg[1]
+ if level >= 100:
+ level = 100
+ line_len = int(level*(30/100))
+ # print("__battery_cb:",level,line_len,30/100)
+ if line_len >= 30:
+ line_len = 30
+ if line_len <= 6:
+ line_len = 6
+ set_x = int(199+line_len//2)
+ watchface1_res_stat_battery_line.set_pos(int(set_x),int(8))
+ watchface1_res_stat_battery_line.set_size(line_len,15)
+ watchface1_res_stat_battery_line.set_style_line_width(line_len,lv.PART.MAIN)
+ if line_len <= 6:
+ watchface1_res_stat_battery_line.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ watchface1_res_stat_battery_line.set_style_line_color(lv.color_make(0x00,0xff,0x00),0)
+ # watchface2_res_stat_battery_img.set_src("E:/static/vbat_%d.png"%(msg[1]))#"E:/vbat_60.png"
pass
def __oldHrValue(self, event, msg):
#状态栏
watchface2_mpsignal_img = lv.img(Watchface2)
-watchface2_mpsignal_img.set_pos(int(20),int(0))
-watchface2_mpsignal_img.set_size(24,17)
+watchface2_mpsignal_img.set_pos(int(20),int(5))
+watchface2_mpsignal_img.set_size(30,22)
watchface2_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
watchface2_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE)
watchface2_mpsignal_img.set_src("E:/static/mpsignal5.png")
watchface2_mpsignal_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
watchface2_res_stat_battery_img = lv.img(Watchface2)
-watchface2_res_stat_battery_img.set_pos(int(200),int(0))
-watchface2_res_stat_battery_img.set_size(30,18)
+watchface2_res_stat_battery_img.set_pos(int(196),int(5))
+watchface2_res_stat_battery_img.set_size(40,22)
watchface2_res_stat_battery_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
watchface2_res_stat_battery_img.add_flag(lv.obj.FLAG.CLICKABLE)
-watchface2_res_stat_battery_img.set_src("E:/static/vbat_100.png")
+watchface2_res_stat_battery_img.set_src("E:/static/vbat_0.png")
watchface2_res_stat_battery_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
-watchface2_res_stat_charge_in_img = lv.img(Watchface2)
-watchface2_res_stat_charge_in_img.set_pos(int(180),int(0))
-watchface2_res_stat_charge_in_img.set_size(10,18)
-watchface2_res_stat_charge_in_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
-watchface2_res_stat_charge_in_img.add_flag(lv.obj.FLAG.CLICKABLE)
-watchface2_res_stat_charge_in_img.set_src("E:/static/charge_in.png")
-# add style for watchface_res_stat_charge_in_img
-watchface2_res_stat_charge_in_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
+
+watchface2_res_stat_battery_line = lv.line(Watchface2)
+watchface2_res_stat_battery_line.set_points(power_line_points,2)
+watchface2_res_stat_battery_line.set_pos(int(203),int(3))
+watchface2_res_stat_battery_line.set_size(0,16)#高度12
+watchface2_res_stat_battery_line.add_style(power_line_red,0)
+
+
+# watchface2_res_stat_charge_in_img = lv.img(Watchface2)
+# watchface2_res_stat_charge_in_img.set_pos(int(180),int(0))
+# watchface2_res_stat_charge_in_img.set_size(10,18)
+# watchface2_res_stat_charge_in_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+# watchface2_res_stat_charge_in_img.add_flag(lv.obj.FLAG.CLICKABLE)
+# watchface2_res_stat_charge_in_img.set_src("E:/static/charge_ing.png")
+# # add style for watchface_res_stat_charge_in_img
+# watchface2_res_stat_charge_in_img.add_style(style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT)
style_font_youyuan_70_red = lv.style_t()
style_font_youyuan_70_red.init()
#print("__battery_cb:",str(msg))
#print(msg)
if msg[0] == '1':
+
+ watchface2_res_stat_battery_line.set_pos(int(0),int(0))
+ watchface2_res_stat_battery_line.set_size(0,0)
+ watchface2_res_stat_battery_line.set_style_line_width(0,lv.PART.MAIN)
watchface2_res_stat_battery_img.set_src("E:/static/charge_ing.png")
else:
- # watchface2_res_stat_charge_in_img.set_src("E:/static/charge_in1.png")
- watchface2_res_stat_battery_img.set_src("E:/static/vbat_%d.png"%(msg[1]))#"E:/vbat_60.png"
+ watchface2_res_stat_battery_img.set_src("E:/static/vbat_0.png")
+ level = msg[1]
+ if level >= 100:
+ level = 100
+ line_len = int(level*(30/100))
+ # print("__battery_cb:",level,line_len,30/100)
+ if line_len >= 30:
+ line_len = 30
+ if line_len <= 6:
+ line_len = 6
+ set_x = int(199+line_len//2)
+ watchface2_res_stat_battery_line.set_pos(int(set_x),int(8))
+ watchface2_res_stat_battery_line.set_size(line_len,16)
+ watchface2_res_stat_battery_line.set_style_line_width(line_len,lv.PART.MAIN)
+ if line_len <= 6:
+ watchface2_res_stat_battery_line.set_style_line_color(lv.color_make(0xff,0x00,0x00),0)
+ else:
+ watchface2_res_stat_battery_line.set_style_line_color(lv.color_make(0x00,0xff,0x00),0)
+ # watchface2_res_stat_battery_img.set_src("E:/static/vbat_%d.png"%(msg[1]))#"E:/vbat_60.png"
pass
def __stepValue(self, event, msg):
if msg == None: