From: dxy15521469561 <1731678236@qq.com> Date: Fri, 4 Aug 2023 12:27:02 +0000 (+0800) Subject: 1.优化表盘 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=96805fd998b65375e8a37ed090726fbee8772dfd;p=mirrors%2FASR1603_G5.git 1.优化表盘 2.修复bug --- diff --git a/2.sdk/project/K5/ext/static/charge_ing.png b/2.sdk/project/K5/ext/static/charge_ing.png index 1e4a346c..070a502c 100644 Binary files a/2.sdk/project/K5/ext/static/charge_ing.png and b/2.sdk/project/K5/ext/static/charge_ing.png differ diff --git a/2.sdk/project/K5/ext/static/mpsignal1.png b/2.sdk/project/K5/ext/static/mpsignal1.png index ba1c2c57..2691f718 100644 Binary files a/2.sdk/project/K5/ext/static/mpsignal1.png and b/2.sdk/project/K5/ext/static/mpsignal1.png differ diff --git a/2.sdk/project/K5/ext/static/mpsignal2.png b/2.sdk/project/K5/ext/static/mpsignal2.png index 16d8b5a6..7afdd947 100644 Binary files a/2.sdk/project/K5/ext/static/mpsignal2.png and b/2.sdk/project/K5/ext/static/mpsignal2.png differ diff --git a/2.sdk/project/K5/ext/static/mpsignal3.png b/2.sdk/project/K5/ext/static/mpsignal3.png index 16fe72e7..10a5ef1e 100644 Binary files a/2.sdk/project/K5/ext/static/mpsignal3.png and b/2.sdk/project/K5/ext/static/mpsignal3.png differ diff --git a/2.sdk/project/K5/ext/static/mpsignal4.png b/2.sdk/project/K5/ext/static/mpsignal4.png index 30a13b17..51d49628 100644 Binary files a/2.sdk/project/K5/ext/static/mpsignal4.png and b/2.sdk/project/K5/ext/static/mpsignal4.png differ diff --git a/2.sdk/project/K5/ext/static/mpsignal5.png b/2.sdk/project/K5/ext/static/mpsignal5.png index 6d14ff2b..53352ab5 100644 Binary files a/2.sdk/project/K5/ext/static/mpsignal5.png and b/2.sdk/project/K5/ext/static/mpsignal5.png differ diff --git a/2.sdk/project/K5/ext/static/vbat_0.png b/2.sdk/project/K5/ext/static/vbat_0.png index 89ae5248..a830107c 100644 Binary files a/2.sdk/project/K5/ext/static/vbat_0.png and b/2.sdk/project/K5/ext/static/vbat_0.png differ diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py index f6048e4c..5053204c 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/mgr.py @@ -255,16 +255,16 @@ class CountdownManager(Abstract): 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, }, }, } @@ -356,6 +356,7 @@ class Battery(object): 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: @@ -404,9 +405,12 @@ class Battery(object): 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): @@ -430,7 +434,7 @@ class BatteryManager(Abstract): 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): @@ -810,8 +814,14 @@ class DeviceInfoManager(Abstract): 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 @@ -821,10 +831,8 @@ class DeviceInfoManager(Abstract): 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 @@ -1348,8 +1356,8 @@ class DeviceInfoManager(Abstract): 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"}) @@ -1493,21 +1501,27 @@ class DeviceInfoManager(Abstract): #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] diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py index 0b25bf5d..8a23d387 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/protocol.py @@ -1373,7 +1373,7 @@ class ProtoColResolver(object): def handler(self, data): # 这里接收数据 - print("handler -> {}".format(data)) + # print("handler -> {}".format(data)) # if data.startswith('Init;'): # data = data[5:] # EventMesh.publish(constants.EVENT.SET_KEY, {"value": ujson.loads(data)['KEY']}) diff --git a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui_WatchFaceScreen.py b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui_WatchFaceScreen.py index 9e472e74..5ce82317 100644 --- a/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui_WatchFaceScreen.py +++ b/2.sdk/project/K5/sdk/services/microPython/ports/quectel/core/ui_WatchFaceScreen.py @@ -27,6 +27,12 @@ style_font_youyuan_28.init() 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) @@ -49,21 +55,30 @@ style_watchface_img_default.set_img_opa(255) #状态栏 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) @@ -258,10 +273,31 @@ class WatchFace1(): #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): @@ -309,29 +345,37 @@ Watchface2.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT) #状态栏 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() @@ -481,10 +525,31 @@ class WatchFace2(): #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: diff --git a/2.sdk/project/K5/usr/static/DIAL_PREV01.png b/2.sdk/project/K5/usr/static/DIAL_PREV01.png index ea14d899..3e6567e9 100644 Binary files a/2.sdk/project/K5/usr/static/DIAL_PREV01.png and b/2.sdk/project/K5/usr/static/DIAL_PREV01.png differ diff --git a/2.sdk/project/K5/usr/static/DIAL_PREV02.png b/2.sdk/project/K5/usr/static/DIAL_PREV02.png index 62cca412..a7c9c0ba 100644 Binary files a/2.sdk/project/K5/usr/static/DIAL_PREV02.png and b/2.sdk/project/K5/usr/static/DIAL_PREV02.png differ