From: p15692025051 <846603105@qq.com> Date: Wed, 22 Mar 2023 02:45:02 +0000 (+0800) Subject: 提交代码 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=ffe2798009ed5a6b8dfedea6877108b99c18bd7f;p=mirrors%2FASR1603_G5.git 提交代码 --- diff --git a/3.code/1.watch/2.code/appAlipay.py b/3.code/1.watch/2.code/appAlipay.py index cf513d8d..e0869701 100644 --- a/3.code/1.watch/2.code/appAlipay.py +++ b/3.code/1.watch/2.code/appAlipay.py @@ -15,7 +15,7 @@ from ext.ui import Screen style_font_youyuan_20 = lv.style_t() style_font_youyuan_20.init() style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff)) -style_font_youyuan_20.set_text_font_v2("font.bin",0) +style_font_youyuan_20.set_text_font_v2("font_18.bin",18,0) style_btn_alipay = lv.style_t() style_btn_alipay.init() @@ -115,7 +115,7 @@ class Alipay(Abstract): # 打印获取到的绑定码 print("bindcode[%d]: %s\n"%(result_len, result)) #查询绑定结果 - utime.sleep_ms(5000); + utime.sleep_ms(1000); cmd_t = 2 #UPAY_MSG_GET_BINDING_RESULT; userdata_t = None args = None @@ -137,7 +137,7 @@ class Alipay(Abstract): # 查询付款结果 print("upay_display_notify_cb: get payment result\n") - utime.sleep_ms(5000) + utime.sleep_ms(500) cmd_t = 4 userdata_t = None args = None @@ -147,7 +147,7 @@ class Alipay(Abstract): #打印获取到的收款码 print("upay_display_notify_cb: collectioncode[%d]: %s\n"%(result_len, result)) EventMesh.publish("load_screen", {"screen": "alipay_collect","meta":str(result)}) - utime.sleep_ms(5000) + utime.sleep_ms(500) elif rsp_code == 7: #打印家长控制码 @@ -343,6 +343,8 @@ class AlipayOpenScreen(Screen): print("----init----") EventMesh.publish("alipay_1") pass + def done_return(self): + EventMesh.publish("load_screen", {"screen": "main_menu"}) def Close(self): pass @@ -364,52 +366,41 @@ class Alipay_1_1(Screen): self.meta.add_style(style_alipay_screen_default, lv.PART.MAIN|lv.STATE.DEFAULT) #付款码 - self.alipay_imgbtn_3 = lv.imgbtn(self.meta) - self.alipay_imgbtn_3.set_size(224, 68) - self.alipay_imgbtn_3.set_pos(8, 10) - self.alipay_imgbtn_3.set_src(lv.imgbtn.STATE.RELEASED, "E:/static/APP/alipay/1_13.png", None, None) + self.alipay_imgbtn_3 = lv.img(self.meta) + self.alipay_imgbtn_3.set_pos(8,10) + self.alipay_imgbtn_3.set_size(224,69) + self.alipay_imgbtn_3.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) + self.alipay_imgbtn_3.add_flag(lv.obj.FLAG.CLICKABLE) + self.alipay_imgbtn_3.set_src("E:/static/APP/alipay/1_13.jpg") + self.alipay_imgbtn_3.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.alipay_imgbtn_3.add_event_cb(lambda e: self.alipay_paycode(e), lv.EVENT.PRESSED, None) - self.alipay_imgbtn_3.set_src(lv.imgbtn.STATE.PRESSED, "E:/static/APP/alipay/1_13.png", None, None) - self.alipay_imgbtn_3.set_src(lv.imgbtn.STATE.CHECKED_RELEASED, "E:/static/APP/alipay/1_13.png", None, None) - self.alipay_imgbtn_3.set_src(lv.imgbtn.STATE.CHECKED_PRESSED, "E:/static/APP/alipay/1_13.png", None, None) - self.alipay_imgbtn_3.add_flag(lv.obj.FLAG.CHECKABLE) - self.alipay_imgbtn_3.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.alipay_imgbtn_3.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.PRESSED) - self.alipay_imgbtn_3.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.CHECKED) - + #收钱 - self.alipay_imgbtn_2 = lv.imgbtn(self.meta) - self.alipay_imgbtn_2.set_size(224, 69) - self.alipay_imgbtn_2.set_pos(8, 86) - self.alipay_imgbtn_2.set_src(lv.imgbtn.STATE.RELEASED, "E:/static/APP/alipay/1_12.png", None, None) + self.alipay_imgbtn_2 = lv.img(self.meta) + self.alipay_imgbtn_2.set_pos(8,86) + self.alipay_imgbtn_2.set_size(224,69) + self.alipay_imgbtn_2.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) + self.alipay_imgbtn_2.add_flag(lv.obj.FLAG.CLICKABLE) + self.alipay_imgbtn_2.set_src("E:/static/APP/alipay/1_12.jpg") + self.alipay_imgbtn_2.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.alipay_imgbtn_2.add_event_cb(lambda e: self.alipay_collect(e), lv.EVENT.PRESSED, None) - - self.alipay_imgbtn_2.set_src(lv.imgbtn.STATE.PRESSED, "E:/static/APP/alipay/1_12.png", None, None) - self.alipay_imgbtn_2.set_src(lv.imgbtn.STATE.CHECKED_RELEASED, "E:/static/APP/alipay/1_12.png", None, None) - self.alipay_imgbtn_2.set_src(lv.imgbtn.STATE.CHECKED_PRESSED, "E:/static/APP/alipay/1_12.png", None, None) - self.alipay_imgbtn_2.add_flag(lv.obj.FLAG.CHECKABLE) - self.alipay_imgbtn_2.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.alipay_imgbtn_2.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.PRESSED) - self.alipay_imgbtn_2.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.CHECKED) + #家长设置 - self.alipay_imgbtn_1 = lv.imgbtn(self.meta) - self.alipay_imgbtn_1.set_size(224, 69) - self.alipay_imgbtn_1.set_pos(8, 168) - - self.alipay_imgbtn_1.set_src(lv.imgbtn.STATE.RELEASED, "E:/static/APP/alipay/1_11.png", None, None) + self.alipay_imgbtn_1 = lv.img(self.meta) + self.alipay_imgbtn_1.set_pos(8,168) + self.alipay_imgbtn_1.set_size(224,69) + self.alipay_imgbtn_1.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) + self.alipay_imgbtn_1.add_flag(lv.obj.FLAG.CLICKABLE) + self.alipay_imgbtn_1.set_src("E:/static/APP/alipay/1_11.jpg") + self.alipay_imgbtn_1.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.alipay_imgbtn_1.add_event_cb(lambda e: self.alipay_parent(e), lv.EVENT.PRESSED, None) - self.alipay_imgbtn_1.set_src(lv.imgbtn.STATE.PRESSED, "E:/static/APP/alipay/1_11.png", None, None) - self.alipay_imgbtn_1.set_src(lv.imgbtn.STATE.CHECKED_RELEASED, "E:/static/APP/alipay/1_11.png", None, None) - self.alipay_imgbtn_1.set_src(lv.imgbtn.STATE.CHECKED_PRESSED, "E:/static/APP/alipay/1_11.png", None, None) - self.alipay_imgbtn_1.add_flag(lv.obj.FLAG.CHECKABLE) - self.alipay_imgbtn_1.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.alipay_imgbtn_1.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.PRESSED) - self.alipay_imgbtn_1.add_style(style_alipay_img_default, lv.PART.MAIN | lv.STATE.CHECKED) + + def initialization(self): pass @@ -432,6 +423,9 @@ class Alipay_1_1(Screen): def alipay_parent(self,e): EventMesh.publish("get_parent_code") + def done_return(self): + EventMesh.publish("load_screen", {"screen": "main_menu"}) + def btn1_release(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) @@ -550,7 +544,7 @@ class Alipay_inviting(Screen): # self.bg = lv.img(self.meta) # self.bg.set_pos(56,30) # self.bg.set_size(240,240) -# self.bg.set_src("E:/static/APP/alipay/1_2_2.png") +# self.bg.set_src("E:/static/APP/alipay/1_2_2.jpg") # self.bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) # #提示词 @@ -589,7 +583,7 @@ class Alipay_success(Screen): self.bg = lv.img(self.meta) self.bg.set_pos(56,30) self.bg.set_size(128,127) - self.bg.set_src("E:/static/APP/alipay/1_2_1.png") + self.bg.set_src("E:/static/APP/alipay/1_2_1.jpg") self.bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) #提示词 @@ -694,6 +688,8 @@ class Alipay_paycode(Screen): def Close(self): pass + def done_return(self): + EventMesh.publish("load_screen", {"screen": "alipay_1_1"}) def btn1_release(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) @@ -715,7 +711,7 @@ class Alipay_pay_success(Screen): self.bg = lv.img(self.meta) self.bg.center() self.bg.set_size(240,240) - self.bg.set_src("E:/static/APP/alipay/1_13_1_1.png") + self.bg.set_src("E:/static/APP/alipay/1_13_1_1.jpg") self.bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) #付款金额 @@ -797,6 +793,9 @@ class Alipay_collect(Screen): def Close(self): pass + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "alipay_1_1"}) def btn1_release(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) @@ -819,7 +818,7 @@ class Alipay_parent(Screen): self.bg = lv.img(self.meta) self.bg.set_pos(8,12) self.bg.set_size(81,81) - self.bg.set_src("E:/static/APP/alipay/1_11_1.png") + self.bg.set_src("E:/static/APP/alipay/1_11_1.jpg") self.bg.add_style(style_alipay_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) #提示词 @@ -869,6 +868,9 @@ class Alipay_parent(Screen): def Close(self): pass + def done_return(self): + EventMesh.publish("load_screen", {"screen": "alipay_1_1"}) + def btn1_release(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) diff --git a/3.code/1.watch/2.code/constants.py b/3.code/1.watch/2.code/constants.py index 1c7ca857..fa4cd627 100644 --- a/3.code/1.watch/2.code/constants.py +++ b/3.code/1.watch/2.code/constants.py @@ -20,20 +20,10 @@ class PROTOCOL: POWEROFF_SEND = "POWEROFF_SEND" POWEROFF_RECV = "POWEROFF_RECV" - H10_SEND = "H10_SEND" - H10_RECV = "H10_RECV" + PHL_SEND = "PHL_SEND" + PHL_RECV = "PHL_RECV" - H11_SEND = "H11_SEND" - H11_RECV = "H11_RECV" - H12_SEND = "H12_SEND" - H12_RECV = "H12_RECV" - - H13_SEND = "H13_SEND" - H13_RECV = "H13_RECV" - - H14_SEND = "H14_SEND" - H14_RECV = "H14_RECV" class EVENT: CHANNEL_SOCKET_SEND = "CHANNEL_SOCKET_SEND" diff --git a/3.code/1.watch/2.code/location.py b/3.code/1.watch/2.code/location.py deleted file mode 100644 index dad14903..00000000 --- a/3.code/1.watch/2.code/location.py +++ /dev/null @@ -1,1024 +0,0 @@ -# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import ure -import net -import math -import utime -import osTimer -import _thread -import wifiScan -import cellLocator - -from queue import Queue -from machine import UART, Pin - -try: - from wifilocator import wifilocator -except: - wifilocator = None - -from log import getLogger - -try: - import quecgnss -except ImportError: - quecgnss = None - -log = getLogger(__name__) - -_gps_read_lock = _thread.allocate_lock() -_gps_data_set_lock = _thread.allocate_lock() - -EE = 0.00669342162296594323 -EARTH_RADIUS = 6378.137 # Approximate Earth Radius(km) -M_PI = math.pi - - -class _loc_method(object): - gps = 0x1 - cell = 0x2 - wifi = 0x4 - - -class _gps_mode(object): - none = 0x0 - internal = 0x1 - external = 0x2 - - -def transformLat(x, y): - ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * math.sqrt(math.fabs(x)) - ret += (20.0 * math.sin(6.0 * x * M_PI) + 20.0 * math.sin(2.0 * x * M_PI)) * 2.0 / 3.0 - ret += (20.0 * math.sin(y * M_PI) + 40.0 * math.sin(y / 3.0 * M_PI)) * 2.0 / 3.0 - ret += (160.0 * math.sin(y / 12.0 * M_PI) + 320 * math.sin(y * M_PI / 30.0)) * 2.0 / 3.0 - return ret - - -def transformLon(x, y): - ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * math.sqrt(math.fabs(x)) - ret += (20.0 * math.sin(6.0 * x * M_PI) + 20.0 * math.sin(2.0 * x * M_PI)) * 2.0 / 3.0 - ret += (20.0 * math.sin(x * M_PI) + 40.0 * math.sin(x / 3.0 * M_PI)) * 2.0 / 3.0 - ret += (150.0 * math.sin(x / 12.0 * M_PI) + 300.0 * math.sin(x / 30.0 * M_PI)) * 2.0 / 3.0 - return ret - - -def WGS84ToGCJ02(lon, lat): - dLat = transformLat(lon - 105.0, lat - 35.0) - dLon = transformLon(lon - 105.0, lat - 35.0) - radLat = lat / 180.0 * M_PI - magic = math.sin(radLat) - magic = 1 - magic * magic * EE - sqrtMagic = math.sqrt(magic) - - dLat = (dLat * 180.0) / ((EARTH_RADIUS * 1000 * (1 - EE)) / (magic * sqrtMagic) * M_PI) - dLon = (dLon * 180.0) / (EARTH_RADIUS * 1000 / sqrtMagic * math.cos(radLat) * M_PI) - lon02 = lon + dLon - lat02 = lat + dLat - - return lon02, lat02 - - -class GPSMatch(object): - """This class is match gps NEMA 0183""" - - def GxRMC(self, gps_data): - """Match Recommended Minimum Specific GPS/TRANSIT Data(RMC) - - Args: - gps_data(str): GPS NMEA string. - - Returns: - str: RMC NMEA string. - """ - if gps_data: - rmc_re = ure.search( - r"\$G[NP]RMC,\d*\.*\d*,*[AV],*\d*\.*\d*,*[NS],*\d*\.*\d*,*[EW],*\d*\.*\d*,*\d*\.*\d*,*\d*,*\d*\.*\d*,*[EW]*,*[ADEN]*,*[SCUV]*\**(\d|\w)*", - gps_data) - if rmc_re: - return rmc_re.group(0) - return "" - - def GxGGA(self, gps_data): - """Match Global Positioning System Fix Data(GGA) - - Args: - gps_data(str): GPS NMEA string. - - Returns: - str: GGA NMEA string. - """ - if gps_data: - gga_re = ure.search( - r"\$G[BLPN]GGA,\d*\.*\d*,*\d*\.*\d*,*[NS],*\d*\.*\d*,*[EW],*[0126],*\d*,*\d*\.*\d*,*-*\d*\.*\d*,*M,*-*\d*\.*\d*,*M,*\d*,*\**(\d|\w)*", - gps_data) - if gga_re: - return gga_re.group(0) - return "" - - def GxVTG(self, gps_data): - """Match Track Made Good and Ground Speed(VTG) - - Args: - gps_data(str): GPS NMEA string. - - Returns: - str: VTG NMEA string. - """ - if gps_data: - vtg_re = ure.search(r"\$G[NP]VTG,\d*\.*\d*,*T,*\d*\.*\d*,*M,*\d*\.*\d*,*N,*\d*\.*\d*,*K,*[ADEN]*\*(\d|\w)*", - gps_data) - if vtg_re: - return vtg_re.group(0) - return "" - - def GxGSV(self, gps_data): - """Mactch GPS Satellites in View(GSV) - - Args: - gps_data(str): GPS NMEA string. - - Returns: - str: GSV NMEA string. - """ - if gps_data: - gsv_re = ure.search( - r"\$G[NP]GSV,\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*\**(\d|\w)*", - gps_data) - if gsv_re: - return gsv_re.group(0) - return "" - - def GxGLL(self, gps_data): - """Geographic Position - - Args: - gps_data(str): GPS NMEA string. - - Returns: - str: GLL NMEA string. - """ - if gps_data: - gll_re = ure.search(r"\$G[NP]GLL,\d*\.*\d*,*[NS]*,*\d*\.*\d*,*[EW]*,*\d*\.*\d*,*[AV]*,*[ADEN]*\**(\d|\w)*", - gps_data) - if gll_re: - return gll_re.group(0) - - def GxGSA(self, gps_data): - """GNSS DOP and Active Satellites - - Args: - gps_data(str): GPS NMEA string. - - Returns: - str: GSA NMEA string. - """ - if gps_data: - gsa_re = ure.search( - r"\$G[NP]GSA,[MA]*,*[123]*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*,*\d*\.*\d*,*\d*\.*\d*,*\d*\.*\d*,*(\d|\w)*\**(\d|\w)*", - gps_data) - if gsa_re: - return gsa_re.group(0) - - -class GPSParse(object): - """Parse details from gps data""" - - def GxGGA_satellite_num(self, gga_data): - """Parse satellite num from GGA""" - if gga_data: - satellite_num_re = ure.search(r",[EW],[0126],\d+,", gga_data) - if satellite_num_re: - return satellite_num_re.group(0).split(",")[-2] - return "" - - def GxGGA_latitude(self, gga_data): - """Parse latitude from GGA""" - if gga_data: - latitude_re = ure.search(r",[0-9]+\.[0-9]+,[NS],", gga_data) - if latitude_re: - latitude = latitude_re.group(0)[1:-3] - return str(float(latitude[:2]) + float(latitude[2:]) / 60) - return "" - - def GxGGA_longitude(self, gga_data): - """Parse longitude from GGA""" - if gga_data: - longitude_re = ure.search(r",[0-9]+\.[0-9]+,[EW],", gga_data) - if longitude_re: - longitude = longitude_re.group(0)[1:-3] - return str(float(longitude[:3]) + float(longitude[3:]) / 60) - return "" - - def GxGGA_altitude(self, gga_data): - """Parse altitude from GGA""" - if gga_data: - altitude_re = ure.search(r",-*[0-9]+\.[0-9]+,M,", gga_data) - if altitude_re: - return altitude_re.group(0)[1:-3] - return "" - - def GxVTG_speed(self, vtg_data): - """Parse speed from VTG""" - if vtg_data: - speed_re = ure.search(r",N,\d+\.\d+,K,", vtg_data) - if speed_re: - return speed_re.group(0)[3:-3] - return "" - - def GxGSV_satellite_num(self, gsv_data): - """Parse satellite num from GSV""" - if gsv_data: - satellite_num_re = ure.search(r"\$G[NP]GSV,\d+,\d+,\d+,", gsv_data) - if satellite_num_re: - return satellite_num_re.group(0).split(",")[-2] - return "" - - def GxRMC_loc_status(self, rmc_data): - if rmc_data: - loc_status_re = ure.search(r"\$G[NP]RMC,\d*\.*\d*,[AV],", rmc_data) - if loc_status_re: - loc_status = loc_status_re.group(0).split(",")[-2] - return True if loc_status == "A" else False - return False - - def __nmea_parse(self, nmea): - return tuple(nmea[1:].split("*")[0].split(",")) if nmea else () - - def GxRMC(self, rmc_data): - return self.__nmea_parse(rmc_data) - - def GxGGA(self, gga_data): - return self.__nmea_parse(gga_data) - - def GxGSV(self, gsv_data): - return self.__nmea_parse(gsv_data) - - def GxGSA(self, gsa_data): - return self.__nmea_parse(gsa_data) - - def GxVTG(self, vtg_data): - return self.__nmea_parse(vtg_data) - - def GxGLL(self, gll_data): - return self.__nmea_parse(gll_data) - - -class GPS(object): - """This class if for reading gps data. - - Now support external gps and internal gps. - - Sleep power consumption: - power off < backup < standby - """ - - __RMC = 0 - __GGA = 1 - __GSV = 2 - __GSA = 3 - __VTG = 4 - __GLL = 5 - __NMEA = 0b010111 - - def __init__(self, UARTn, buadrate, databits, parity, stopbits, flowctl, PowerPin, StandbyPin, BackupPin, gps_mode): - """Init GPS module - - [description] - - Args: - UARTn(int): UART No. - buadrate(int): baud rate - databits(int): data bits (5 ~ 8) - parity(int): parity (0 – NONE,1 – EVEN,2 - ODD) - stopbits(int): stop bit - flowctl(int): hardware control flow (0 – FC_NONE, 1 – FC_HW) - PowerPin(int): Power GIPO Pin - StandbyPin(int): Standby GPIO Pin - BackupPin(int): Back GPIO Pin - gps_mode(int): GPS mode - 0 - None - 1 - internal GPS - 2 - external GPS - """ - self.__UARTn = UARTn - self.__buadrate = buadrate - self.__databits = databits - self.__parity = parity - self.__stopbits = stopbits - self.__flowctl = flowctl - self.__PowerPin = PowerPin - self.__StandbyPin = StandbyPin - self.__BackupPin = BackupPin - self.__gps_mode = gps_mode - - self.__external_obj = None - self.__internal_obj = quecgnss - self.__gps_match = GPSMatch() - self.__gps_parse = GPSParse() - self.__gps_power_gpio = None - self.__gps_standby_gpio = None - self.__gps_backup_gpio = None - - self.__external_retrieve_queue = None - self.__queue_size = 2 - self.__first_break = 0 - self.__break = 0 - self.__gps_data = "" - self.__rmc_data = "" - self.__gga_data = "" - self.__vtg_data = "" - self.__gsv_data = "" - self.__gps_timer = osTimer() - self.__gps_data_check_timer = osTimer() - - if self.__gps_mode & _gps_mode.external: - self.__external_init() - elif self.__gps_mode & _gps_mode.internal: - self.__internal_init() - #print("GPS:__init__%d",self.__gps_mode) - def __gps_power_control(self, GPIOn, onoff, method): - if method == "power_switch": - if self.__gps_power_gpio is None: - self.__gps_power_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff) - gpio_obj = self.__gps_power_gpio - elif method == "standby": - if self.__gps_standby_gpio is None: - self.__gps_standby_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff) - gpio_obj = self.__gps_standby_gpio - elif method == "backup": - if self.__gps_backup_gpio is None: - self.__gps_backup_gpio = Pin(GPIOn, Pin.OUT, Pin.PULL_DISABLE, onoff) - gpio_obj = self.__gps_backup_gpio - else: - raise TypeError("Param method %s is not compare." % method) - - if gpio_obj.read() != onoff: - gpio_obj.write(onoff) - if gpio_obj.read() != onoff: - return False - return True - - def __reverse_gps_data(self, this_gps_data): - """Reverse GPS data for regular match get the latest data""" - log.debug("this_gps_data: \n%s" % this_gps_data) - delimiter = "\r\n" - if this_gps_data: - _gps_data = self.__get_gps_data() - if _gps_data: - _gps_data = delimiter.join(_gps_data.split(delimiter)[::-1]) - _gps_data += this_gps_data.strip().replace("\r", "").replace("\n", "").replace("$", delimiter + "$") - _gps_data = delimiter.join(_gps_data.split(delimiter)[::-1]) - self.__set_gps_data(_gps_data) - - def __read_latitude(self, gps_data): - """Read latitude from gps data""" - return self.__gps_parse.GxGGA_latitude(self.__gps_match.GxGGA(gps_data)) - - def __read_longitude(self, gps_data): - """Read longitude from gps data""" - return self.__gps_parse.GxGGA_longitude(self.__gps_match.GxGGA(gps_data)) - - def __read_altitude(self, gps_data): - """Read altitude from gps data""" - return self.__gps_parse.GxGGA_altitude(self.__gps_match.GxGGA(gps_data)) - - def __set_gps_data(self, gps_data): - self.__gps_data = gps_data - - def __get_gps_data(self): - return self.__gps_data - - def __gps_timer_callback(self, args): - """GPS read timer callback - When over time to get uart data, break queue wait - """ - self.__break = 1 - if self.__external_retrieve_queue is not None: - self.__external_retrieve_queue.put(False) - - def __gps_data_check_callback(self, args): - """GPS read old data clean timer callback - When GPS read over time, clean old gps data, wait to read new gps data. - """ - clean = False - if "" in (self.__rmc_data, self.__gga_data, self.__gsv_data): - clean = True - else: - if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data: - clean = True - elif self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data: - clean = True - elif self.__nmea_statement_exist(self.__GLL) and not self.__gll_data: - clean = True - - if clean: - self.__gps_nmea_data_clean() - - def __external_init(self): - """External GPS init""" - self.__external_retrieve_queue = Queue(maxsize=self.__queue_size) - - def __external_open(self): - """External GPS start, UART init""" - self.power_switch(1) - self.__external_obj = UART( - self.__UARTn, - self.__buadrate, - self.__databits, - self.__parity, - self.__stopbits, - self.__flowctl - ) - self.__external_obj.set_callback(self.__external_retrieve_cb) - - def __external_close(self): - """External GPS close, UART close, NOT GPS stop""" - self.__external_obj.close() - - def __external_retrieve_cb(self, args): - """ - GPS data retrieve callback from UART - When data comes, send a message to queue of data length - """ - # log.debug("GPS __external_retrieve_cb args: %s" % str(args)) - if self.__external_retrieve_queue.size() >= self.__queue_size: - self.__external_retrieve_queue.get() - self.__external_retrieve_queue.put(True) - - def __internal_init(self): - """Internal GPS init""" - if self.__internal_obj: - if self.__internal_obj.init() != 0: - self.__internal_open() - log.error("GNSS INIT Failed.") - else: - log.debug("GNSS INIT Success.") - else: - log.error("Module quecgnss Import Error.") - - def __internal_open(self): - """Internal GPS enable""" - if self.__internal_obj.get_state() == 0: - return True if self.__internal_obj.gnssEnable(1) == 0 else False - else: - return True - - def __internal_close(self): - """Internal GPS close""" - return True if self.__internal_obj.gnssEnable(0) == 0 else False - - def __nmea_statement_exist(self, nmea_item): - return (self.__NMEA & (0b1 << nmea_item)) >> nmea_item - - def __gps_nmea_data_clean(self): - self.__set_gps_data("") - self.__rmc_data = "" - self.__gga_data = "" - self.__gsv_data = "" - self.__gsa_data = "" - self.__vtg_data = "" - self.__gll_data = "" - - def __check_gps_valid(self, gps_data): - self.__reverse_gps_data(gps_data) - - if not self.__rmc_data: - self.__rmc_data = self.__gps_match.GxRMC(self.__get_gps_data()) - loc_status = self.__gps_parse.GxRMC_loc_status(self.__rmc_data) - - if self.__rmc_data and loc_status: - if self.__nmea_statement_exist(self.__GGA) and not self.__gga_data: - self.__gga_data = self.__gps_match.GxGGA(self.__get_gps_data()) - if self.__nmea_statement_exist(self.__GSV) and not self.__gsv_data: - self.__gsv_data = self.__gps_match.GxGSV(self.__get_gps_data()) - if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data: - self.__gsa_data = self.__gps_match.GxGSA(self.__get_gps_data()) - if self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data: - self.__vtg_data = self.__gps_match.GxVTG(self.__get_gps_data()) - if self.__nmea_statement_exist(self.__GLL) and not self.__gll_data: - self.__gll_data = self.__gps_match.GxGLL(self.__get_gps_data()) - - if self.__nmea_statement_exist(self.__GGA) and not self.__gga_data: - return False - if self.__nmea_statement_exist(self.__GSV) and not self.__gsv_data: - return False - if self.__nmea_statement_exist(self.__GSA) and not self.__gsa_data: - return False - if self.__nmea_statement_exist(self.__VTG) and not self.__vtg_data: - return False - if self.__nmea_statement_exist(self.__GLL) and not self.__gll_data: - return False - return True - - return False - - def __external_read(self): - """Read external GPS data - - Return: - $GPTXT,01,01,02,ANTSTATUS=OPEN*2B - $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07 - $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22 - $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56 - $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02 - $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03 - $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54 - $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58 - $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B - $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71 - $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71 - $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70 - $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78 - $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72 - $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E - """ - self.__external_open() - log.debug("__external_read start") - - while self.__break == 0: - self.__gps_timer.start(50, 0, self.__gps_timer_callback) - signal = self.__external_retrieve_queue.get() - log.debug("[first] signal: %s" % signal) - if signal: - to_read = self.__external_obj.any() - log.debug("[first] to_read: %s" % to_read) - if to_read > 0: - self.__set_gps_data(self.__external_obj.read(to_read).decode()) - self.__gps_timer.stop() - self.__break = 0 - - self.__gps_nmea_data_clean() - self.__gps_data_check_timer.start(2000, 1, self.__gps_data_check_callback) - cycle = 0 - while self.__break == 0: - self.__gps_timer.start(1500, 0, self.__gps_timer_callback) - signal = self.__external_retrieve_queue.get() - log.debug("[second] signal: %s" % signal) - if signal: - to_read = self.__external_obj.any() - log.debug("[second] to_read: %s" % to_read) - if to_read > 0: - if self.__check_gps_valid(self.__external_obj.read(to_read).decode()): - self.__break = 1 - - self.__gps_timer.stop() - cycle += 1 - if cycle >= self.__retry: - self.__break = 1 - if self.__break != 1: - utime.sleep(1) - self.__gps_data_check_timer.stop() - self.__break = 0 - - # To check GPS data is usable or not. - self.__gps_data_check_callback(None) - self.__external_close() - log.debug("__external_read data: %s" % self.__get_gps_data()) - return self.__get_gps_data() - - def __internal_read(self): - from ext import EventMesh - log.debug("__internal_read start.") - """Read internal GPS data - - Return: - $GPTXT,01,01,02,ANTSTATUS=OPEN*2B - $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07 - $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22 - $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56 - $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02 - $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03 - $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54 - $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58 - $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B - $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71 - $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71 - $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70 - $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78 - $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72 - $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E - """ - - #self.__gps_nmea_data_clean() - - cycle = 0 - #while self.__break == 0: - gnss_data = quecgnss.read(1024*3) - #print("__internal_read") - #print(gnss_data) - if gnss_data and gnss_data[1]: - this_gps_data = gnss_data[1].decode() if len(gnss_data) > 1 and gnss_data[1] else "" - _gps_valid = self.__check_gps_valid(this_gps_data) - log.debug("_gps_valid: %s" % _gps_valid) - - #print("_gps_valid:",_gps_valid) - #print(str(_gps_valid),self.__get_gps_data()) - if _gps_valid == True : - #EventMesh.publish("time", [self.__get_gps_data(),"0",str(_gps_valid),"0"]) - return self.__get_gps_data() - else : - EventMesh.publish("time", [self.__get_gps_data(),"0",str(_gps_valid),"0"]) - return "" - - def read(self, retry=30): - """For user to read gps data - - Return: (res_code, gps_data) - res_code: - - 0: Success - - -1: Failed - gps_data: - $GPTXT,01,01,02,ANTSTATUS=OPEN*2B - $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07 - $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22 - $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56 - $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02 - $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03 - $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54 - $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58 - $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B - $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71 - $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71 - $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70 - $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78 - $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72 - $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E - """ - self.__retry = retry - gps_data = "" - if self.__gps_mode & _gps_mode.external: - gps_data = self.__external_read() - elif self.__gps_mode & _gps_mode.internal: - gps_data = self.__internal_read() - - res = 0 if gps_data else -1 - return (res, gps_data) - - def read_coordinates(self, gps_data): - """Read positioning coordinates. - - Params: - gps_data: read gps data. - map_coordinate_system: `WGS84` or GCJ02 - - Return: - (longitude, latitude, altitude) - """ - latitude = self.__read_latitude(gps_data) - latitude = float(latitude) if latitude else latitude - longitude = self.__read_longitude(gps_data) - longitude = float(longitude) if longitude else longitude - altitude = self.__read_altitude(gps_data) - altitude = float(altitude) if altitude else altitude - return (longitude, latitude, altitude) - - def power_switch(self, onoff): - """GPS module power switch - - Params: - onoff: 0 -- off, 1 -- on - """ - if self.__gps_mode & _gps_mode.external: - if self.__PowerPin is not None: - return self.__gps_power_control(self.__PowerPin, onoff, "power_switch") - else: - return False - elif self.__gps_mode & _gps_mode.internal: - # TODO: Interal GNSS power down will not be used this api. - if onoff == 0: - return self.__internal_close() - else: - return self.__internal_open() - - def backup(self, onoff): - """GPS module low enery mode backup - - Params: - onoff: 0 -- off, 1 -- on - """ - if self.__BackupPin is not None: - return self.__gps_power_control(self.__BackupPin, onoff, "backup") - else: - return False - - def standby(self, onoff): - """GPS module low enery mode standby - - Params: - onoff: 0 -- off, 1 -- on - """ - if self.__StandbyPin is not None: - return self.__gps_power_control(self.__StandbyPin, onoff, "standby") - else: - return False - - def set_nmea_statement(self, nmea_statement): - """Set NMEA statement to check gps info valid - - RMC, GGA, GSV must be required. - - Args: - nmea_statement(int): - RMC - 0b1 << 0 (bit0), 0 - off, 1 - on - GGA - 0b1 << 1 (bit1), 0 - off, 1 - on - GSV - 0b1 << 2 (bit2), 0 - off, 1 - on - GSA - 0b1 << 3 (bit3), 0 - off, 1 - on - VTG - 0b1 << 4 (bit4), 0 - off, 1 - on - GLL - 0b1 << 5 (bit5), 0 - off, 1 - on - - Returns: - bool: True - success, False - falied. - """ - if nmea_statement >= 0b111: - self.__NMEA = nmea_statement - return True - return False - - -class CellLocator(object): - """This class is for reading cell location data""" - - def __init__(self, serverAddr, port, token, timeout, profileIdx): - self.__serverAddr = serverAddr - self.__port = port - self.__token = token - self.__timeout = timeout - self.__profileIdx = profileIdx - - def read(self): - read_loc_res = self.__read_loc() - read_cell_res = self.__read_cell() - res = 0 if read_loc_res[0] == 0 or read_cell_res[0] == 0 else -1 - return (res, read_loc_res[1], read_cell_res[1]) - - def __read_loc(self): - """Read cell location data. - - Return: (res_code, loc_data) - res_code: - - 0: Success - - -1: Initialization failed - - -2: The server address is too long (more than 255 bytes) - - -3: Wrong key length, must be 16 bytes - - -4: The timeout period is out of range, the supported range is (1 ~ 300) s - - -5: The specified PDP network is not connected, please confirm whether the PDP is correct - - -6: Error getting coordinates - loc_data: - (117.1138, 31.82279, 550) - """ - res = -1 - loc_data = cellLocator.getLocation( - self.__serverAddr, - self.__port, - self.__token, - self.__timeout, - self.__profileIdx - ) - if isinstance(loc_data, tuple) and len(loc_data) == 3: - res = 0 - else: - res = loc_data - loc_data = () - - return (res, loc_data) - - def __read_cell(self): - res = -1 - near_cell = [] - server_cell = [] - - near_cells = net.getCi() - if near_cells != -1 and isinstance(near_cells, list): - near_cell = list(map(str, near_cells)) - - server_cells = net.getCellInfo() - if server_cells != -1 and isinstance(server_cells, tuple): - server_cell = server_cells - - res = 0 if near_cell or server_cell else -1 - return (res, {"near_cell": near_cell, "server_cell": server_cell}) - - -class WiFiLocator(object): - """This class is for reading wifi location data""" - - def __init__(self, token): - self.__wifilocator_obj = wifilocator(token) - - def read(self): - read_loc_res = self.__read_loc() - read_mac_res = self.__read_mac() - res = 0 if read_loc_res[0] == 0 or read_mac_res[0] == 0 else -1 - return (res, read_loc_res[1], read_mac_res[1]) - - def __read_loc(self): - """Read wifi location data. - - Return: (res_code, loc_data) - res_code: - - 0: Success - - -1: The current network is abnormal, please confirm whether the dial-up is normal - - -2: Wrong key length, must be 16 bytes - - -3: Error getting coordinates - loc_data: - (117.1138, 31.82279, 550) - """ - res = -1 - loc_data = self.__wifilocator_obj.getwifilocator() - if isinstance(loc_data, tuple) and len(loc_data) == 3: - res = 0 - else: - res = loc_data - loc_data = () - - return (res, loc_data) - - def __read_mac(self): - res = -1 - macs = [] - if wifiScan.support(): - if wifiScan.control(1) == 0: - if wifiScan.getState(): - wifisacn_start = wifiScan.start() - if wifisacn_start != -1 and wifisacn_start[0] > 0: - macs = [i[0] for i in wifisacn_start[1]] - res = 0 - wifiScan.control(0) - return (res, macs) - - -class Location(object): - """This class is for reading location data from gps, cell, wifi""" - gps = None - cellLoc = None - wifiLoc = None - - def __init__(self, loc_method, locator_init_params): - """Init Location module - - 1. If loc_method include gps then init gps module; - 2. If loc_method inculde cell then init cell module; - 3. If loc_method Include wifi then init wifi module; - - Args: - loc_method(int): - 1 - gps - 2 - cell - 3 - cell & gps - 4 - wifi - 5 - wifi & gps - 6 - wifi & cell - 7 - wifi & cell & gps - locator_init_params(dict): - gps_cfg(dict):GPS module init args - cell_cfg(dict):CELL module init args - wifi_cfg(dict):WIFI module init args - """ - self.__loc_method = loc_method - self.__locator_init_params = locator_init_params - self.__locater_init() - - def __locater_init(self): - """Init gps, cell, wifi by loc_method""" - - if self.__loc_method & _loc_method.gps: - if self.gps is None: - _gps_cfg = self.__locator_init_params.get("gps_cfg", {}) - if _gps_cfg: - self.gps = GPS(**_gps_cfg) - if _gps_cfg.get("nmea_cfg") is not None: - self.gps.set_nmea_statement(_gps_cfg.get("nmea_cfg")) - else: - raise ValueError("Invalid gps init parameters.") - else: - self.gps = None - - if self.__loc_method & _loc_method.cell: - if self.cellLoc is None: - _cell_cfg = self.__locator_init_params.get("cell_cfg") - if _cell_cfg: - self.cellLoc = CellLocator(**_cell_cfg) - else: - raise ValueError("Invalid cell-locator init parameters.") - else: - self.cellLoc = None - - if self.__loc_method & _loc_method.wifi: - if self.wifiLoc is None: - _wifi_cfg = self.__locator_init_params.get("wifi_cfg") - if _wifi_cfg: - self.wifiLoc = WiFiLocator(**_wifi_cfg) - else: - raise ValueError("Invalid wifi-locator init parameters.") - else: - self.wifiLoc = None - - def __read_gps(self, retry): - """Read loction data from gps module - - Return: - $GPTXT,01,01,02,ANTSTATUS=OPEN*2B - $GNRMC,073144.000,A,3149.330773,N,11706.946971,E,0.00,337.47,150422,,,D,V*07 - $GNVTG,337.47,T,,M,0.00,N,0.00,K,D*22 - $GNGGA,073144.000,3149.330773,N,11706.946971,E,2,19,0.66,85.161,M,-0.335,M,,*56 - $GNGSA,A,3,01,195,06,03,21,194,19,17,30,14,,,0.94,0.66,0.66,1*02 - $GNGSA,A,3,13,26,07,10,24,25,08,03,22,,,,0.94,0.66,0.66,4*03 - $GPGSV,3,1,12,14,84,210,31,195,67,057,46,17,52,328,28,50,51,161,33,1*54 - $GPGSV,3,2,12,194,49,157,33,03,48,090,37,19,36,305,32,06,34,242,32,1*58 - $GPGSV,3,3,12,01,32,041,35,30,17,204,22,21,07,051,13,07,03,183,,1*6B - $BDGSV,5,1,18,07,86,063,30,10,75,322,30,08,60,211,34,03,52,192,33,1*71 - $BDGSV,5,2,18,24,44,276,33,13,43,215,33,01,43,135,30,26,40,208,37,1*71 - $BDGSV,5,3,18,02,38,230,,04,32,119,,22,26,135,30,19,25,076,,1*70 - $BDGSV,5,4,18,05,17,251,,25,06,322,27,09,02,211,22,21,02,179,,1*78 - $BDGSV,5,5,18,29,02,075,,20,01,035,,1*72 - $GNGLL,3149.330773,N,11706.946971,E,073144.000,A,D*4E - """ - if self.gps: - return self.gps.read(retry)[1] - return "" - - def __read_cell(self): - """Read loction data from cell module - - Return: - (117.1138, 31.82279, 550) or () - """ - if self.cellLoc: - cell_loc_data = self.cellLoc.read() - return (cell_loc_data[1], cell_loc_data[2]) - return () - - def __read_wifi(self): - """Read loction data from wifi module - - Return: - (117.1138, 31.82279, 550) or () - """ - if self.wifiLoc: - wifi_loc_data = self.wifiLoc.read() - return (wifi_loc_data[1], wifi_loc_data[2]) - return () - - def read(self, retry=30): - """Read location data - - args: - retry(int): gps read uart data retry count. - - Returns: - dict: - key: - 1 - GPS data - 2 - CELL data - 4 - WIFI data - .e.g: - { - 1: "$GPGGA,XXX", - 2: (0.00, 0.00, 0.00), - 4: (0.00, 0.00, 0.00), - } - """ - loc_data = {} - - if self.__loc_method & _loc_method.gps: - loc_data[_loc_method.gps] = self.__read_gps(retry) - - if self.__loc_method & _loc_method.cell: - loc_data[_loc_method.cell] = self.__read_cell() - - if self.__loc_method & _loc_method.wifi: - loc_data[_loc_method.wifi] = self.__read_wifi() - - return loc_data - - def wgs84togcj02(self, Longitude, Latitude): - return WGS84ToGCJ02(Longitude, Latitude) - - -if __name__ == '__main__': - _gps_cfg = { - "UARTn": UART.UART1, - "buadrate": 115200, - "databits": 8, - "parity": 0, - "stopbits": 1, - "flowctl": 0, - "PowerPin": Pin.GPIO2, - "StandbyPin": Pin.GPIO3, - "BackupPin": None, - "gps_mode": 0x01, - } - gps = GPS(**_gps_cfg) - print("read {}".format(gps.read(300))) diff --git a/3.code/1.watch/2.code/main_1.py b/3.code/1.watch/2.code/main_1.py index 525ff7d0..c7e55f77 100644 --- a/3.code/1.watch/2.code/main_1.py +++ b/3.code/1.watch/2.code/main_1.py @@ -45,7 +45,7 @@ if __name__ == '__main__': from ext.common import Abstract from ext.lcd import gpio_backlight,tp_cst816 from ext.btn_device_ec800m import BtnDevice - from ext.protocol import LK_ProtoCol,PING_ProtoCol, CR_ProtoCol,UD_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver + from usr.protocol import LK_ProtoCol,PING_ProtoCol, CR_ProtoCol,UD_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver,PHL_ProtoCol import ext.mgr as mgr import ext.ui as _ui from ext.mgr import ConfigStoreManager, DeviceInfoManager, LocationManager, SockManager, \ @@ -54,7 +54,8 @@ if __name__ == '__main__': Alipay_success,Alipay_paycode,Alipay_pay_success,Alipay_collect,Alipay_parent from ext.ui_WatchFaceScreen import WatchFaceScreen from ext.ui_main_menu import MainMenuScreen - + # from usr.test import ContactsScreen + import ext.ui_setting as _ui_setting btn_device = BtnDevice(tp_cst816) btn_device.start() @@ -64,7 +65,7 @@ if __name__ == '__main__': ui.add_screen(_ui.PhoneScreen()) ui.add_screen(MainMenuScreen()) ui.add_screen(_ui.HeartrateScreen()) - ui.add_screen(_ui.SettingScreen()) + ui.add_screen(_ui_setting.SettingScreen()) ui.add_screen(_ui.ToolboxScreen()) ui.add_screen(_ui.StepScreen()) ui.add_screen(_ui.AlarmScreen()) @@ -75,21 +76,21 @@ if __name__ == '__main__': ui.add_screen(_ui.TemperatureScreen()) ui.add_screen(_ui.ContactsScreen()) ui.add_screen(_ui.WechatScreen()) - ui.add_screen(_ui.CountdownScreen()) - ui.add_screen(_ui.LanguageScreen()) - ui.add_screen(_ui.DialswitchScreen()) - ui.add_screen(_ui.ThemeswitchScreen()) - ui.add_screen(_ui.ImeiScreen()) - ui.add_screen(_ui.AppScreen()) - ui.add_screen(_ui.BrightnessScreen()) - ui.add_screen(_ui.VolumeScreen()) - ui.add_screen(_ui.RestoreScreen()) - ui.add_screen(_ui.PoweroffScreen()) - ui.add_screen(_ui.VersionScreen()) - ui.add_screen(_ui.UpdateScreen()) - ui.add_screen(_ui.AlarmvolumeScreen()) - ui.add_screen(_ui.MsgvolumeScreen()) - ui.add_screen(_ui.PhoneringScreen()) + + # ui.add_screen(_ui_setting.LanguageScreen()) + ui.add_screen(_ui_setting.DialswitchScreen()) + # ui.add_screen(_ui.ThemeswitchScreen()) + 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.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.DialingScreen()) ui.add_screen(_ui.CallLogScreen()) ui.add_screen(AlipayOpenScreen()) @@ -139,6 +140,7 @@ if __name__ == '__main__': pcr.add_support(CR_ProtoCol()) pcr.add_support(FIND_ProtoCol()) pcr.add_support(POWEROFF_ProtoCol()) + pcr.add_support(PHL_ProtoCol()) sm = SockManager() sm.add_support_resolver(pcr) app.append_manager(sm) diff --git a/3.code/1.watch/2.code/mgr.py b/3.code/1.watch/2.code/mgr.py index 2ad1eab3..3e9450d0 100644 --- a/3.code/1.watch/2.code/mgr.py +++ b/3.code/1.watch/2.code/mgr.py @@ -719,15 +719,15 @@ class DeviceInfoManager(Abstract): temp = Power.getVbatt() if temp <= 3500: - vbat = 20 #"E:/vbat_20.png" + vbat = 20 #"E:/vbat_20.jpg" elif temp <= 3600: - vbat = 40 #"E:/vbat_40.png" + vbat = 40 #"E:/vbat_40.jpg" elif temp <= 3800: - vbat = 60 #"E:/vbat_60.png" + vbat = 60 #"E:/vbat_60.jpg" elif temp <= 4000: - vbat = 80 #"E:/vbat_80.png" + vbat = 80 #"E:/vbat_80.jpg" else: - vbat = 100 #"E:/vbat_100.png" + vbat = 100 #"E:/vbat_100.jpg" result = [charge_state, vbat] @@ -1124,6 +1124,7 @@ class AddrBookManager(Abstract): # 可通过此push_addr_book_list主动推送 def get(self, event, msg): + print("phonebook %s"%(msg)) return { "张三": "15692025051", "李四": "15692025051", @@ -1131,6 +1132,8 @@ class AddrBookManager(Abstract): "鱼鱼": "15692025051", "坤坤": "15692025051", } + def done_return(self): + EventMesh.publish("load_screen", {"screen": "main_menu"}) class MsgManager(Abstract): # 短信 @@ -1186,6 +1189,10 @@ class CallLogManager(Abstract): ["15692025051","2","12:59","哥"], ["15692025051","3","12:49","爸"], ["15692025051","4","12:39","妈"], + ["15692025051","4","12:39","姐"], + ["15692029951","1","12:39","哥"], + ["15692466051","2","12:35","嫂子"], + ["15692025051","6","12:59","妹"], ] def post_processor_after_instantiation(self): @@ -1197,11 +1204,10 @@ class CallLogManager(Abstract): def call_usr(self,event,msg): content = self.log[msg] # 参数1 姓名 参数2 电话 参数3 1/主动呼叫 0别人呼叫 - EventMesh.publish("call_in", [content[-1], content[0], 1]) + EventMesh.publish("call_in", [content[2], content[0], 1]) class PhoneCallingManager(Abstract): def __init__(self): - self.level = 0 self.phonenum = "" self.phonename = "" @@ -1212,7 +1218,7 @@ class PhoneCallingManager(Abstract): EventMesh.subscribe("save_phonename", self.save_phonename) def get_phonename(self, event, msg): - self.phonename = str(msg) + return self.phonename def save_phonename(self, event, msg): self.phonename = str(msg) diff --git a/3.code/1.watch/2.code/protocol.py b/3.code/1.watch/2.code/protocol.py index d8df86b1..af710f21 100644 --- a/3.code/1.watch/2.code/protocol.py +++ b/3.code/1.watch/2.code/protocol.py @@ -8,6 +8,58 @@ import ubinascii from misc import Power import audio from machine import Pin +import ujson +import ql_fs +def unicode_to_utf8(src): + ref = 0xe08080 + result = ref + + #取最后六位 + a = src & 0x3f + + #将最后六位放在ref最后六位的空位置 + result = result | a + src = src >> 6 + + #取接下来的六位 + a = src & 0x3f + + #放在ref对应的六个位置 + result = result | (a << 8) + + #保留最后四位 + src = src >> 6 + + #放在ref对应的四个位置 + result = result | (src << 16) + return result + +def UnicodeHexStr_To_Utf8Str(str): + odata = 0 + + result = bytes() + su =str.upper() + + i = 0 + for c in su: + tmp=ord(c) + if tmp <= ord('9') : + odata = odata << 4 + odata += tmp - ord('0') + + elif ord('A') <= tmp <= ord('F'): + odata = odata << 4 + odata += tmp - ord('A') + 10 + if(i%4==3): #每2字节获取一个int,拿到转换后的unicode int + #print(odata.to_bytes(2, 'big')) + #result.append(odata) + tmp = unicode_to_utf8(odata)#拿到转换后的utf8 int + tmp2 = tmp.to_bytes(3, 'big') #转ytes + result = result + tmp2 + odata = 0 + i+=1 + return result.decode('utf-8') #返回utf8的str + class ProtoCol(Abstract): TYPE = "" HEADER = "#@{}@#;" @@ -342,6 +394,104 @@ class POWEROFF_ProtoCol(ProtoCol): #print("POWEROFF_ProtoCol:recv:%s"%(msg)) Power.powerDown() +class PHL_ProtoCol(ProtoCol): + """电话本同步""" + TYPE = "PHL" + + + def send(self, event, msg): + # [SZKW*867387060319491*0008*PHL] + send_data = "SZKW*%s*0003*PHL"%(self.imei) + MD5_SIGN = self.pack_MD5_head(send_data) + data = "[%s%s]"%(str(MD5_SIGN),send_data) + #print("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] + # print("phonebook:msg:%s\r\n"%msg) + msg_tmp = msg.split(',') + print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp)) + + #check_json = ql_fs.path_exists("/usr/phonebook.json") + #self.phonebook = EventMesh.publish("get_addr_book_list") + #print("check_json %d"%check_json) + phonebook = {} + msg_tmp = msg_tmp[1:] + # print("msg_tmp1:{}".format(msg_tmp)) + j = 0 + phonebook_oldtmp = {} + # 0 1 2 3 + for phonebook_tmp in msg_tmp: + j+=1 + # print("phonebook_tmp:{}".format(phonebook_tmp)) + if (j%2) == 0: + phonebook[UnicodeHexStr_To_Utf8Str(phonebook_tmp)] = phonebook_oldtmp + phonebook_oldtmp = phonebook_tmp + print("phonebook!!!:{}".format(str(phonebook))) + with open("usr/phonebook.json","w",encoding="utf-8") as fd: + ujson.dump(phonebook,fd) + print("创建电话簿") + + EventMesh.publish(constants.PROTOCOL.PHL_SEND) + + +class REMIND_ProtoCol(ProtoCol): + """闹钟同步""" + TYPE = "REMIND" + + + def send(self, event, msg): + # [SZKW*867387060319491*0008*PHL] + + send_data = "SZKW*%s*0003*REMIND"%(self.imei) + MD5_SIGN = self.pack_MD5_head(send_data) + data = "[%s%s]"%(str(MD5_SIGN),send_data) + #print("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] + # print("phonebook:msg:%s\r\n"%msg) + msg_tmp = msg.split(',') + print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp)) + + #check_json = ql_fs.path_exists("/usr/phonebook.json") + #self.phonebook = EventMesh.publish("get_addr_book_list") + #print("check_json %d"%check_json) + phonebook = {} + msg_tmp = msg_tmp[1:] + # print("msg_tmp1:{}".format(msg_tmp)) + j = 0 + phonebook_oldtmp = {} + # 0 1 2 3 + for phonebook_tmp in msg_tmp: + j+=1 + # print("phonebook_tmp:{}".format(phonebook_tmp)) + if (j%2) == 0: + phonebook[UnicodeHexStr_To_Utf8Str(phonebook_tmp)] = phonebook_oldtmp + phonebook_oldtmp = phonebook_tmp + print("phonebook!!!:{}".format(str(phonebook))) + with open("usr/phonebook.json","w",encoding="utf-8") as fd: + ujson.dump(phonebook,fd) + print("创建电话簿") + + EventMesh.publish(constants.PROTOCOL.PHL_SEND) + + + class ProtoColResolver(object): def __init__(self): @@ -366,5 +516,5 @@ class ProtoColResolver(object): ProtoCol_type = data_tmp.split('*')[3] #拿到协议标识 ProtoCol_type = ProtoCol_type.split(',')[0] ProtoCol_type = "%s_RECV"%(ProtoCol_type) - #print("ProtoCol_type:%s"%(ProtoCol_type)) + print("ProtoColResolver:ProtoCol_type:%s\r\ndata:%s"%(ProtoCol_type,data)) EventMesh.publish(ProtoCol_type, data) #返回协议read diff --git a/3.code/1.watch/2.code/static/APP/alipay/1_11_1.jpg b/3.code/1.watch/2.code/static/APP/alipay/1_11_1.jpg deleted file mode 100644 index 88c0c4b7..00000000 Binary files a/3.code/1.watch/2.code/static/APP/alipay/1_11_1.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/APP/alipay/1_12_1_1.jpg b/3.code/1.watch/2.code/static/APP/alipay/1_12_1_1.jpg deleted file mode 100644 index 3b304a66..00000000 Binary files a/3.code/1.watch/2.code/static/APP/alipay/1_12_1_1.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/APP/alipay/1_1_1.jpg b/3.code/1.watch/2.code/static/APP/alipay/1_1_1.jpg deleted file mode 100644 index 40fdf420..00000000 Binary files a/3.code/1.watch/2.code/static/APP/alipay/1_1_1.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/APP/alipay/1_2_1.jpg b/3.code/1.watch/2.code/static/APP/alipay/1_2_1.jpg deleted file mode 100644 index d54e4b17..00000000 Binary files a/3.code/1.watch/2.code/static/APP/alipay/1_2_1.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_APP_QR_CODE.jpg b/3.code/1.watch/2.code/static/IMAGE_APP_QR_CODE.jpg deleted file mode 100644 index ca88cccf..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_APP_QR_CODE.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_HEART_ONLY_TEST_DONE.jpg b/3.code/1.watch/2.code/static/IMAGE_HEART_ONLY_TEST_DONE.jpg deleted file mode 100644 index 8f30f367..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_HEART_ONLY_TEST_DONE.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY0_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY0_ICON.jpg deleted file mode 100644 index 0a5fbbb4..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY0_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY1_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY1_ICON.jpg deleted file mode 100644 index 35e08c11..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY1_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY2_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY2_ICON.jpg deleted file mode 100644 index 7500ae70..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY2_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY3_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY3_ICON.jpg deleted file mode 100644 index 8783cfa8..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY3_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY4_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY4_ICON.jpg deleted file mode 100644 index 90d2a3ee..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY4_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY5_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY5_ICON.jpg deleted file mode 100644 index c66444d0..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY5_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY6_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY6_ICON.jpg deleted file mode 100644 index 43450ece..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY6_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY7_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY7_ICON.jpg deleted file mode 100644 index c4087a55..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY7_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY8_ICON.jpg b/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY8_ICON.jpg deleted file mode 100644 index e979dc92..00000000 Binary files a/3.code/1.watch/2.code/static/IMAGE_NUMBER_KEY8_ICON.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/audio_amr/num.txt b/3.code/1.watch/2.code/static/audio_amr/num.txt new file mode 100644 index 00000000..e69de29b diff --git a/3.code/1.watch/2.code/static/lightrain.jpg b/3.code/1.watch/2.code/static/lightrain.jpg deleted file mode 100644 index b23ac858..00000000 Binary files a/3.code/1.watch/2.code/static/lightrain.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-1.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu1/4-1.jpg deleted file mode 100644 index ebd1ccc6..00000000 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-1.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-2.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu1/4-2.jpg deleted file mode 100644 index 4b78c8e9..00000000 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-2.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-3.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu1/4-3.jpg deleted file mode 100644 index fbefbce2..00000000 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-3.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-4.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu1/4-4.jpg deleted file mode 100644 index 86e9a902..00000000 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu1/4-4.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu1/IMAGE_MAINMENU_WECHAT.png b/3.code/1.watch/2.code/static/main_menu/main_menu1/IMAGE_MAINMENU_WECHAT.png deleted file mode 100644 index 8414d97c..00000000 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu1/IMAGE_MAINMENU_WECHAT.png and /dev/null differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CALL.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CALL.jpg index 4afb319b..47a5f2e6 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CALL.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CALL.jpg differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CONTACTS.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CONTACTS.jpg index 537e0f5c..75534b35 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CONTACTS.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CONTACTS.jpg differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_HEART_RATE_HEALTH_DETECT.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_HEART_RATE_HEALTH_DETECT.jpg index 6ba5f723..dec91215 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_HEART_RATE_HEALTH_DETECT.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_HEART_RATE_HEALTH_DETECT.jpg differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SETTINGS.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SETTINGS.jpg index 98393c2e..4cd310a1 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SETTINGS.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SETTINGS.jpg differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SPO2_DETECT.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SPO2_DETECT.jpg deleted file mode 100644 index c6f0cbd4..00000000 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SPO2_DETECT.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TEMPERATURE.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TEMPERATURE.jpg index 93ffe9dd..1067b79d 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TEMPERATURE.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TEMPERATURE.jpg differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TOOLS.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TOOLS.jpg index f207090f..c24480ad 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TOOLS.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TOOLS.jpg differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_WECHAT.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_WECHAT.jpg index 740f0a1b..52d2f667 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_WECHAT.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/IMAGE_ONE_PAGE_WECHAT.jpg differ diff --git a/3.code/1.watch/2.code/static/main_menu/main_menu2/alipay_.jpg b/3.code/1.watch/2.code/static/main_menu/main_menu2/alipay_.jpg index aa98ef5f..05de42be 100644 Binary files a/3.code/1.watch/2.code/static/main_menu/main_menu2/alipay_.jpg and b/3.code/1.watch/2.code/static/main_menu/main_menu2/alipay_.jpg differ diff --git a/3.code/1.watch/2.code/static/menu_app_qrcode.jpg b/3.code/1.watch/2.code/static/menu_app_qrcode.jpg deleted file mode 100644 index e4b9eccd..00000000 Binary files a/3.code/1.watch/2.code/static/menu_app_qrcode.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/menu_bright.jpg b/3.code/1.watch/2.code/static/menu_bright.jpg deleted file mode 100644 index d5072f0b..00000000 Binary files a/3.code/1.watch/2.code/static/menu_bright.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/menu_theme_switch.jpg b/3.code/1.watch/2.code/static/menu_theme_switch.jpg deleted file mode 100644 index 55112318..00000000 Binary files a/3.code/1.watch/2.code/static/menu_theme_switch.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/menu_time.jpg b/3.code/1.watch/2.code/static/menu_time.jpg deleted file mode 100644 index 7d4f722c..00000000 Binary files a/3.code/1.watch/2.code/static/menu_time.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/menu_upgrade.jpg b/3.code/1.watch/2.code/static/menu_upgrade.jpg deleted file mode 100644 index 8332b8ce..00000000 Binary files a/3.code/1.watch/2.code/static/menu_upgrade.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/menu_volume.jpg b/3.code/1.watch/2.code/static/menu_volume.jpg deleted file mode 100644 index 064581d3..00000000 Binary files a/3.code/1.watch/2.code/static/menu_volume.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/mpsignal1.jpg b/3.code/1.watch/2.code/static/mpsignal1.jpg deleted file mode 100644 index 520bd7fb..00000000 Binary files a/3.code/1.watch/2.code/static/mpsignal1.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/mpsignal2.jpg b/3.code/1.watch/2.code/static/mpsignal2.jpg deleted file mode 100644 index dd915c88..00000000 Binary files a/3.code/1.watch/2.code/static/mpsignal2.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/mpsignal3.jpg b/3.code/1.watch/2.code/static/mpsignal3.jpg deleted file mode 100644 index 05baf08a..00000000 Binary files a/3.code/1.watch/2.code/static/mpsignal3.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/mpsignal4.jpg b/3.code/1.watch/2.code/static/mpsignal4.jpg deleted file mode 100644 index deeaffa8..00000000 Binary files a/3.code/1.watch/2.code/static/mpsignal4.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/off_icon.jpg b/3.code/1.watch/2.code/static/off_icon.jpg deleted file mode 100644 index 9f019e31..00000000 Binary files a/3.code/1.watch/2.code/static/off_icon.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/reduce_btn.jpg b/3.code/1.watch/2.code/static/reduce_btn.jpg deleted file mode 100644 index 2d76ae23..00000000 Binary files a/3.code/1.watch/2.code/static/reduce_btn.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/stopwatch_reset.jpg b/3.code/1.watch/2.code/static/stopwatch_reset.jpg deleted file mode 100644 index 013ff61f..00000000 Binary files a/3.code/1.watch/2.code/static/stopwatch_reset.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/stopwatch_stop.jpg b/3.code/1.watch/2.code/static/stopwatch_stop.jpg deleted file mode 100644 index 4b4a9982..00000000 Binary files a/3.code/1.watch/2.code/static/stopwatch_stop.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/sunny.jpg b/3.code/1.watch/2.code/static/sunny.jpg deleted file mode 100644 index f49510e5..00000000 Binary files a/3.code/1.watch/2.code/static/sunny.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/time_up.jpg b/3.code/1.watch/2.code/static/time_up.jpg deleted file mode 100644 index 441aa09d..00000000 Binary files a/3.code/1.watch/2.code/static/time_up.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/update.jpg b/3.code/1.watch/2.code/static/update.jpg deleted file mode 100644 index 3ce99f03..00000000 Binary files a/3.code/1.watch/2.code/static/update.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/vbat_0.jpg b/3.code/1.watch/2.code/static/vbat_0.jpg deleted file mode 100644 index 511db7c3..00000000 Binary files a/3.code/1.watch/2.code/static/vbat_0.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/vbat_100.jpg b/3.code/1.watch/2.code/static/vbat_100.jpg deleted file mode 100644 index c8b4259d..00000000 Binary files a/3.code/1.watch/2.code/static/vbat_100.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/vbat_80.jpg b/3.code/1.watch/2.code/static/vbat_80.jpg deleted file mode 100644 index 31bee1df..00000000 Binary files a/3.code/1.watch/2.code/static/vbat_80.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/step.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/step.jpg deleted file mode 100644 index f16ef9cc..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/step.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/0.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/0.jpg deleted file mode 100644 index 62e72ad3..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/0.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/1.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/1.jpg deleted file mode 100644 index 7f84eca3..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/1.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/2.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/2.jpg deleted file mode 100644 index 137d2098..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/2.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/3.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/3.jpg deleted file mode 100644 index b00537d0..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/3.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/4.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/4.jpg deleted file mode 100644 index 00d38374..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/4.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/5.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/5.jpg deleted file mode 100644 index 51870ff3..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/5.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/6.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/6.jpg deleted file mode 100644 index d5bd2f2b..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/6.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/7.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/7.jpg deleted file mode 100644 index 17a9fbc2..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/7.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/8.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/8.jpg deleted file mode 100644 index e06aff66..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/8.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/watch_plate/style_1/time/colon.jpg b/3.code/1.watch/2.code/static/watch_plate/style_1/time/colon.jpg deleted file mode 100644 index 621c9333..00000000 Binary files a/3.code/1.watch/2.code/static/watch_plate/style_1/time/colon.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/test.py b/3.code/1.watch/2.code/test.py new file mode 100644 index 00000000..97d3feb4 --- /dev/null +++ b/3.code/1.watch/2.code/test.py @@ -0,0 +1,198 @@ +import utime +import osTimer +import lvgl as lv +from ext import EventMesh +from machine import Timer +import voiceCall +import osTimer +from ext import constants +from misc import Power +import pm +import ujson +import ql_fs +import audio +from machine import Pin +from ext.lcd import gpio_backlight,lcd,lcd_ctrl,tp_cst816 +from ext.ui import style_btn,ContStyle ,style_font_youyuan_20,style_screen,Screen,style_font_youyuan_20_black +# -------------------------------------------contacts screen---------------------------------------------------------- +style_bar = lv.style_t() +style_bar.init() +style_bar.set_radius(10) +style_bar.set_bg_color(lv.color_make(0xA0, 0xA0, 0xA0)) +style_bar.set_bg_grad_color(lv.color_make(0xA0, 0xA0, 0xA0)) +style_bar.set_bg_grad_dir(lv.GRAD_DIR.VER) +style_bar.set_bg_opa(60) +style_bar.set_pad_left(0) +style_bar.set_pad_right(0) +style_bar.set_pad_top(0) +style_bar.set_pad_bottom(0) + +style_volume_btn = lv.style_t() +style_volume_btn.init() +style_volume_btn.set_shadow_opa(0) +style_volume_btn.set_border_width(0) +style_volume_btn.set_bg_color(lv.color_make(0x80, 0x80, 0x80)) + +style_bar_indic = lv.style_t() +style_bar_indic.init() +style_bar_indic.set_radius(10) +style_bar_indic.set_bg_color(lv.color_make(0xff, 0x61, 0x3a)) +style_bar_indic.set_bg_grad_color(lv.color_make(0xff, 0x61, 0x3a)) +style_bar_indic.set_bg_grad_dir(lv.GRAD_DIR.VER) +style_bar_indic.set_bg_opa(255) + + + + + + + + + +contacts_screen = lv.obj() +contacts = lv.obj(contacts_screen) +contacts.center() +contacts.set_size(240, 320) +contacts.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + + +contact_none_label = lv.label(contacts) +contact_none_label.set_pos(0, 120) +contact_none_label.set_size(240, 60) +contact_none_label.set_text(" ") +contact_none_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +contact_none_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + + + + +contacts_cont = lv.obj(contacts) +contacts_cont.set_pos(0, 0) +contacts_cont.set_size(240, 320) +contacts_cont_style = ContStyle() +contacts_cont.add_style( + contacts_cont_style.style_cont(0, lv.color_make(0x00, 0x00, 0x00), lv.color_make(0x00, 0x00, 0x00), 255), + lv.PART.MAIN | lv.STATE.DEFAULT) +# # create style style_btn +# style_btn = lv.style_t() +# style_btn.init() +# style_btn.set_bg_opa(0) +# style_btn.set_shadow_opa(0) +# style_btn.set_border_width(0) + +# style_contact_btn = lv.style_t() +# style_contact_btn.init() +# style_contact_btn.set_bg_color(lv.color_make(0x1E, 0x26, 0xff)) +# style_contact_btn.set_border_width(0) +# style_contact_btn.set_shadow_opa(0) + +# style_contact_btn_pressed = lv.style_t() +# style_contact_btn_pressed.init() +# style_contact_btn_pressed.set_bg_opa(lv.OPA.TRANSP) +# style_contact_btn_pressed.set_shadow_opa(0) +# style_contact_btn_pressed.set_border_width(0) + +CONTACT_FLAG = 0 + +class ContactsScreen(Screen): + NAME = "contacts" + + def __init__(self): + super().__init__() + self.meta = contacts_screen + self.phonebook = {} + self.count = 0 + self.phone_num_count = 0 + self.phone_num = {} + self.name = [] + self.check_json = 0 + + def post_processor_before_initialization(self): + self.check_json = ql_fs.path_exists("/usr/phonebook.json") + self.phonebook = EventMesh.publish("get_addr_book_list") + print("check_json %d"%(self.check_json)) + self.count = 0 + if self.check_json == True: + with open("usr/phonebook.json","r",encoding="utf-8") as fd: + self.phonebook = ujson.load(fd) + print("读取电话簿") + + + # if check_json == False: + # # with open("usr/phonebook.json","w",encoding="utf-8") as fd: + # # ujson.dump(self.phonebook,fd) + # # print("创建电话簿") + # else: + # with open("usr/phonebook.json","r",encoding="utf-8") as fd: + # self.phonebook = ujson.load(fd) + # print("读取电话簿") + + def initialization(self): + #读取json文件中的字典放到self.phonebook中 + #创建btn + self.btn_create() + + def btn_create(self): + #读取json文件中的键作为label文本; + if self.check_json == 1: + contact_none_label.set_text(" ") + for key,value in dict.items(self.phonebook): #字典 key value + + contact_btn = lv.btn(contacts_cont) + contact_btn.set_pos(0, 82*self.count) + contact_btn.set_size(230,80) + contact_btn_label = lv.label(contact_btn) + contact_btn_label.set_text(key+'\r\n'+ value) + contact_btn.set_style_pad_all(0, lv.STATE.DEFAULT) + contact_btn.set_style_text_align(lv.TEXT_ALIGN.LEFT ,0) + # contact_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0) + contact_btn_label.set_style_text_color(lv.color_make(0x00, 0x00, 0x00), lv.STATE.DEFAULT) + contact_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + contact_btn.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) + contact_btn.add_event_cb(lambda e: self.calling(e), + lv.EVENT.CLICKED, None) + + # contact_btn = lv.btn(contacts_cont) + # contact_btn.set_size(230,80) + # contact_btn.set_pos(0,82*self.count ) + # contact_btn_label = lv.label(contact_btn) + # contact_btn_label.set_text(key+'\r\n'+ value) + # contact_btn.set_style_pad_all(0, lv.STATE.DEFAULT) + + # contact_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT) + # contact_btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) + # contact_btn.add_event_cb(lambda e: self.calling(e), + # lv.EVENT.PRESSED, None) + + + # contact_btn_label.set_text(key+'\r\n'+ value) + # contact_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0) + # contact_btn_label.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT) + + # contact_btn_labe2 = lv.label(contacts) + # contact_btn_labe2.set_text(value) + # contact_btn_labe2.set_pos(10,(82*self.count) + 45) + # contact_btn_labe2.set_style_text_align(lv.TEXT_ALIGN.LEFT, 30) + # # contact_btn_labe2.align(lv.ALIGN.LEFT_MID, 10, 20) + # contact_btn_labe2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT) + self.count += 1 + else: + contact_none_label.set_text("空") + def calling(self,e): + _msg = e.get_target().get_child(0).get_text() + _msg = _msg.split('\r\n') + EventMesh.publish("save_phonenum", _msg[0]) + self.phone_num = self.phonebook[_msg[0]] + # print(_msg,self.phone_num,_msg) + voiceCall.callStart(self.phone_num) + EventMesh.publish("load_screen", {"screen": "dialing"}) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "main_menu"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) \ No newline at end of file diff --git a/3.code/1.watch/2.code/ui.py b/3.code/1.watch/2.code/ui.py index ec3d337f..de3b1b58 100644 --- a/3.code/1.watch/2.code/ui.py +++ b/3.code/1.watch/2.code/ui.py @@ -9,10 +9,12 @@ from ext import constants from misc import Power import pm import ujson +import audio import ql_fs import audio from machine import Pin from ext.lcd import gpio_backlight,lcd,lcd_ctrl,tp_cst816 +import uos # -----------------------------------------style create-------------------------------------- style_screen = lv.style_t() style_screen.init() @@ -24,13 +26,18 @@ style_screen.set_pad_left(0) style_screen.set_pad_right(0) style_screen.set_pad_top(0) style_screen.set_pad_bottom(0) +# 默认白色 style_font_youyuan_20 = lv.style_t() style_font_youyuan_20.init() style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff)) -style_font_youyuan_20.set_text_font_v2("font.bin",0) +style_font_youyuan_20.set_text_font_v2("font_20.bin",20,0) -# 默认白色 +#黑色 +style_font_youyuan_20_black = lv.style_t() +style_font_youyuan_20_black.init() +style_font_youyuan_20_black.set_text_color(lv.color_make(0x00, 0x00, 0x00)) +style_font_youyuan_20_black.set_text_font_v2("font_20.bin",20,0) class LabelStyle(object): @@ -93,18 +100,51 @@ style_btn.set_bg_opa(0) style_btn.set_shadow_opa(0) style_btn.set_border_width(0) +style_wechat_btn = lv.style_t() +style_wechat_btn.init() +style_wechat_btn.set_bg_color(lv.color_make(0x1E, 0x26, 0xff)) +style_wechat_btn.set_border_width(0) +style_wechat_btn.set_shadow_opa(0) + style_contact_btn = lv.style_t() style_contact_btn.init() style_contact_btn.set_bg_color(lv.color_make(0x1E, 0x26, 0xff)) style_contact_btn.set_border_width(0) style_contact_btn.set_shadow_opa(0) -style_contact_btn_pressed = lv.style_t() +style_common_bg_rect_btn_pressed = lv.style_t() +style_common_bg_rect_btn_pressed.init() +style_common_bg_rect_btn_pressed.set_bg_color(lv.color_make(0x1E, 0x26, 0xff)) +style_common_bg_rect_btn_pressed.set_bg_opa(100) +style_common_bg_rect_btn_pressed.set_border_width(0) +style_common_bg_rect_btn_pressed.set_shadow_opa(0) + +style_contact_btn_pressed = lv.style_t() style_contact_btn_pressed.init() -style_contact_btn_pressed.set_bg_color(lv.color_make(0x1E, 0x26, 0xff)) -style_contact_btn_pressed.set_bg_opa(100) +style_contact_btn_pressed.set_radius(5) +style_contact_btn_pressed.set_bg_color(lv.color_make(0xff,0xff,0xff)) +style_contact_btn_pressed.set_bg_grad_color(lv.color_make(0x21,0x95,0xf6)) +style_contact_btn_pressed.set_bg_grad_dir(lv.GRAD_DIR.HOR) +style_contact_btn_pressed.set_bg_opa(217) +style_contact_btn_pressed.set_border_color(lv.color_make(0x21,0x95,0xf6)) style_contact_btn_pressed.set_border_width(0) -style_contact_btn_pressed.set_shadow_opa(0) +style_contact_btn_pressed.set_border_opa(255) +style_contact_btn_pressed.set_text_color(lv.color_make(0x00,0x00,0x00)) + +# style_contact_btn_pressed = lv.style_t() +# style_contact_btn_pressed.init() +# style_contact_btn_pressed.set_bg_color(lv.color_make(0xff, 0xff, 0xff)) +# style_contact_btn_pressed.set_bg_opa(100) +# style_contact_btn_pressed.set_border_width(0) +# style_contact_btn_pressed.set_shadow_opa(0) + +# style_contact_btn_pressed = lv.style_t() +# style_contact_btn_pressed.init() +# style_contact_btn_pressed.set_bg_color(lv.color_make(0xff, 0xff, 0xff)) +# style_contact_btn_pressed.set_bg_opa(100) +# style_contact_btn_pressed.set_border_width(0) +# style_contact_btn_pressed.set_shadow_opa(0) + style_alipay_btn = lv.style_t() style_alipay_btn.init() @@ -113,36 +153,14 @@ style_alipay_btn.set_bg_opa(20) style_alipay_btn.set_border_width(0) style_alipay_btn.set_shadow_opa(0) -style_volume_btn = lv.style_t() -style_volume_btn.init() -style_volume_btn.set_shadow_opa(0) -style_volume_btn.set_border_width(0) -style_volume_btn.set_bg_color(lv.color_make(0x80, 0x80, 0x80)) + style_circle = lv.style_t() style_circle.init() style_circle.set_bg_color(lv.color_make(0xff, 0xff, 0xff)) style_circle.set_radius(0x7FFF) -style_bar = lv.style_t() -style_bar.init() -style_bar.set_radius(10) -style_bar.set_bg_color(lv.color_make(0xA0, 0xA0, 0xA0)) -style_bar.set_bg_grad_color(lv.color_make(0xA0, 0xA0, 0xA0)) -style_bar.set_bg_grad_dir(lv.GRAD_DIR.VER) -style_bar.set_bg_opa(60) -style_bar.set_pad_left(0) -style_bar.set_pad_right(0) -style_bar.set_pad_top(0) -style_bar.set_pad_bottom(0) - -style_bar_indic = lv.style_t() -style_bar_indic.init() -style_bar_indic.set_radius(10) -style_bar_indic.set_bg_color(lv.color_make(0xff, 0x61, 0x3a)) -style_bar_indic.set_bg_grad_color(lv.color_make(0xff, 0x61, 0x3a)) -style_bar_indic.set_bg_grad_dir(lv.GRAD_DIR.VER) -style_bar_indic.set_bg_opa(255) + # -------------------------------------------phone screen---------------------------------------------------------- @@ -152,115 +170,121 @@ phone.center() phone.set_size(240, 320) phone.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) +# line_points = [{"x":0,"y":0},{"x":0,"y":240}] +# phone_line = lv.line(phone) +# phone_line.set_points(line_points,2) +# phone_line.set_pos(230,100) +# phone_line.set_size(4,20) +# phone_line.add_style(style_line,0) phone_label = lv.label(phone) phone_label.set_pos(0, 50) -phone_label.set_size(240, 30) +phone_label.set_size(240, 40) phone_label.set_text("") phone_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) phone_label.set_long_mode(lv.label.LONG.WRAP) -phone_label.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0) +phone_label.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 10) phone_one = lv.img(phone) -phone_one.set_src("E:/static/IMAGE_NUMBER_KEY1_ICON.png") +phone_one.set_src("E:/static/IMAGE_NUMBER_KEY1_ICON.jpg") phone_one.add_flag(lv.obj.FLAG.CLICKABLE) phone_one.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_one.set_pos(3, 100) phone_two = lv.img(phone) phone_two.set_size(76, 40) -phone_two.set_src("E:/static/IMAGE_NUMBER_KEY2_ICON.png") +phone_two.set_src("E:/static/IMAGE_NUMBER_KEY2_ICON.jpg") phone_two.add_flag(lv.obj.FLAG.CLICKABLE) phone_two.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_two.set_pos(82, 100) phone_three = lv.img(phone) phone_three.set_size(76, 40) -phone_three.set_src("E:/static/IMAGE_NUMBER_KEY3_ICON.png") +phone_three.set_src("E:/static/IMAGE_NUMBER_KEY3_ICON.jpg") phone_three.add_flag(lv.obj.FLAG.CLICKABLE) phone_three.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_three.set_pos(161, 100) phone_four = lv.img(phone) phone_four.set_size(76, 40) -phone_four.set_src("E:/static/IMAGE_NUMBER_KEY4_ICON.png") +phone_four.set_src("E:/static/IMAGE_NUMBER_KEY4_ICON.jpg") phone_four.add_flag(lv.obj.FLAG.CLICKABLE) phone_four.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_four.set_pos(3, 142) phone_five = lv.img(phone) phone_five.set_size(76, 40) -phone_five.set_src("E:/static/IMAGE_NUMBER_KEY5_ICON.png") +phone_five.set_src("E:/static/IMAGE_NUMBER_KEY5_ICON.jpg") phone_five.add_flag(lv.obj.FLAG.CLICKABLE) phone_five.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_five.set_pos(82, 142) phone_six = lv.img(phone) phone_six.set_size(76, 40) -phone_six.set_src("E:/static/IMAGE_NUMBER_KEY6_ICON.png") +phone_six.set_src("E:/static/IMAGE_NUMBER_KEY6_ICON.jpg") phone_six.add_flag(lv.obj.FLAG.CLICKABLE) phone_six.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_six.set_pos(161, 142) phone_seven = lv.img(phone) phone_seven.set_size(76, 40) -phone_seven.set_src("E:/static/IMAGE_NUMBER_KEY7_ICON.png") +phone_seven.set_src("E:/static/IMAGE_NUMBER_KEY7_ICON.jpg") phone_seven.add_flag(lv.obj.FLAG.CLICKABLE) phone_seven.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_seven.set_pos(3, 184) phone_eight = lv.img(phone) phone_eight.set_size(76, 40) -phone_eight.set_src("E:/static/IMAGE_NUMBER_KEY8_ICON.png") +phone_eight.set_src("E:/static/IMAGE_NUMBER_KEY8_ICON.jpg") phone_eight.add_flag(lv.obj.FLAG.CLICKABLE) phone_eight.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_eight.set_pos(82, 184) phone_nine = lv.img(phone) phone_nine.set_size(76, 40) -phone_nine.set_src("E:/static/IMAGE_NUMBER_KEY9_ICON.png") +phone_nine.set_src("E:/static/IMAGE_NUMBER_KEY9_ICON.jpg") phone_nine.add_flag(lv.obj.FLAG.CLICKABLE) phone_nine.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_nine.set_pos(161, 184) phone_start = lv.img(phone) phone_start.set_size(76, 40) -phone_start.set_src("E:/static/IMAGE_NUMBER_KEYSTAR_ICON.png") +phone_start.set_src("E:/static/IMAGE_NUMBER_KEYSTAR_ICON.jpg") phone_start.add_flag(lv.obj.FLAG.CLICKABLE) phone_start.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_start.set_pos(3, 226) phone_zero = lv.img(phone) phone_zero.set_size(76, 40) -phone_zero.set_src("E:/static/IMAGE_NUMBER_KEY0_ICON.png") +phone_zero.set_src("E:/static/IMAGE_NUMBER_KEY0_ICON.jpg") phone_zero.add_flag(lv.obj.FLAG.CLICKABLE) phone_zero.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_zero.set_pos(82, 226) phone_hash = lv.img(phone) phone_hash.set_size(76, 40) -phone_hash.set_src("E:/static/IMAGE_NUMBER_KEYSTAR_ICON.png") +phone_hash.set_src("E:/static/IMAGE_NUMBER_KEYSTAR_ICON.jpg") phone_hash.add_flag(lv.obj.FLAG.CLICKABLE) phone_hash.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_hash.set_pos(161, 226) phone_call = lv.img(phone) phone_call.set_size(76, 40) -phone_call.set_src("E:/static/IMAGE_BUTTON_DIAL.png") +phone_call.set_src("E:/static/IMAGE_BUTTON_DIAL.jpg") phone_call.add_flag(lv.obj.FLAG.CLICKABLE) phone_call.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_call.set_pos(3, 268) phone_contact = lv.img(phone) -phone_contact.set_size(76, 40) -phone_contact.set_src("E:/static/IMAGE_BUTTON_DIAL_CONTACT.png") +phone_contact.set_size(64, 40) +phone_contact.set_src("E:/static/IMAGE_BUTTON_DIAL_CONTACT.jpg") phone_contact.add_flag(lv.obj.FLAG.CLICKABLE) phone_contact.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) -phone_contact.set_pos(84, 268) +phone_contact.set_pos(87, 268) phone_delete = lv.img(phone) phone_delete.set_size(76, 40) -phone_delete.set_src("E:/static/IMAGE_BUTTON_DELKEY.png") +phone_delete.set_src("E:/static/IMAGE_BUTTON_DELKEY.jpg") phone_delete.add_flag(lv.obj.FLAG.CLICKABLE) phone_delete.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) phone_delete.set_pos(161, 268) @@ -291,16 +315,16 @@ heartrate_start_label.set_pos(0,160) heartrate_start_label.set_text(" ") heartrate_start_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) heartrate_start_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -heartrate_start_label.set_style_text_color(lv.color_make(0xff, 0x6f, 0x3a), lv.STATE.DEFAULT) +heartrate_start_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) heartrate_bpm_label = lv.label(heartrate) heartrate_bpm_label.set_size(240, 40) -heartrate_bpm_label.set_pos(0, 210) +heartrate_bpm_label.set_pos(0, 200) heartrate_bpm_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) heartrate_bpm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -heartrate_bpm_label.set_style_text_color(lv.color_make(0xff, 0x6f, 0x3f), lv.STATE.DEFAULT) +heartrate_bpm_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) heartrate_mmhg_label = lv.label(heartrate) @@ -309,7 +333,7 @@ heartrate_mmhg_label.set_pos(0, 240) heartrate_mmhg_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) heartrate_mmhg_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -heartrate_mmhg_label.set_style_text_color(lv.color_make(0xff, 0x6f, 0x3f), lv.STATE.DEFAULT) +heartrate_mmhg_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) @@ -350,7 +374,7 @@ toolbox_step_img = lv.img(toolbox_cont) toolbox_step_img.set_pos(10, 0) toolbox_step_img.set_size(47, 47) toolbox_step_img.add_flag(lv.obj.FLAG.CLICKABLE) -toolbox_step_img.set_src("E:/static/IMAGE_SECMENU_STEP.png") +toolbox_step_img.set_src("E:/static/IMAGE_SECMENU_STEP.jpg") toolbox_step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) toolbox_weather = lv.btn(toolbox_cont) @@ -366,7 +390,7 @@ toolbox_weather_img = lv.img(toolbox_cont) toolbox_weather_img.set_pos(10, 60) toolbox_weather_img.set_size(47, 47) toolbox_weather_img.add_flag(lv.obj.FLAG.CLICKABLE) -toolbox_weather_img.set_src("E:/static/IMAGE_SECMENU_WEATHER.png") +toolbox_weather_img.set_src("E:/static/IMAGE_SECMENU_WEATHER.jpg") toolbox_weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) toolbox_alarm = lv.btn(toolbox_cont) @@ -382,7 +406,7 @@ toolbox_alarm_img = lv.img(toolbox_cont) toolbox_alarm_img.set_pos(10, 120) toolbox_alarm_img.set_size(47, 47) toolbox_alarm_img.add_flag(lv.obj.FLAG.CLICKABLE) -toolbox_alarm_img.set_src("E:/static/IMAGE_SECMENU_ALARM.png") +toolbox_alarm_img.set_src("E:/static/IMAGE_SECMENU_ALARM.jpg") toolbox_alarm_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) toolbox_countdown = lv.btn(toolbox_cont) @@ -398,7 +422,7 @@ toolbox_countdown_img = lv.img(toolbox_cont) toolbox_countdown_img.set_pos(10, 180) toolbox_countdown_img.set_size(47, 47) toolbox_countdown_img.add_flag(lv.obj.FLAG.CLICKABLE) -toolbox_countdown_img.set_src("E:/static/IMAGE_SECMENU_COUNTDOWN.png") +toolbox_countdown_img.set_src("E:/static/IMAGE_SECMENU_COUNTDOWN.jpg") toolbox_countdown_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) toolbox_stopwatch = lv.btn(toolbox_cont) @@ -414,219 +438,9 @@ toolbox_stopwatch_img = lv.img(toolbox_cont) toolbox_stopwatch_img.set_pos(10, 240) toolbox_stopwatch_img.set_size(47, 47) toolbox_stopwatch_img.add_flag(lv.obj.FLAG.CLICKABLE) -toolbox_stopwatch_img.set_src("E:/static/IMAGE_SECMENU_STOPWATCH.png") +toolbox_stopwatch_img.set_src("E:/static/IMAGE_SECMENU_STOPWATCH.jpg") toolbox_stopwatch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) -# -------------------------------------------setting screen---------------------------------------------------------- -setting_screen = lv.obj() -setting = lv.obj(setting_screen) -setting.center() -setting.set_size(240, 320) -setting.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_title = lv.label(setting) -setting_title.set_pos(0, 10) -setting_title.set_size(240, 40) -setting_title.set_text("设置") -setting_title.set_long_mode(lv.label.LONG.WRAP) -setting_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -setting_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_cont = lv.obj(setting) -setting_cont.set_pos(0, 50) -setting_cont.set_size(240, 270) -setting_cont_style = ContStyle() -setting_cont.add_style( - setting_cont_style.style_cont(0, lv.color_make(0x00, 0x00, 0x00), lv.color_make(0x00, 0x00, 0x00), 255), - lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_language = lv.btn(setting_cont) -setting_language.set_pos(0, 0) -setting_language.set_size(240, 54) -setting_language_label = lv.label(setting_language) -setting_language_label.set_text("语言设置") -setting_language.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_language_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_language_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_language_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_language.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_language_img = lv.img(setting_cont) -setting_language_img.set_pos(10, 0) -setting_language_img.set_size(47, 47) -setting_language_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_language_img.set_src("E:/static/menu_language.png") -setting_language_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_dialswitch = lv.btn(setting_cont) -setting_dialswitch.set_pos(0, 60) -setting_dialswitch.set_size(240, 54) -setting_dialswitch_label = lv.label(setting_dialswitch) -setting_dialswitch_label.set_text("表盘切换") -setting_dialswitch.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_dialswitch_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_dialswitch_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_dialswitch_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_dialswitch.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_dialswitch_img = lv.img(setting_cont) -setting_dialswitch_img.set_pos(10, 60) -setting_dialswitch_img.set_size(47, 47) -setting_dialswitch_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_dialswitch_img.set_src("E:/static/menu_watch_switch.png") -setting_dialswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_themeswitch = lv.btn(setting_cont) -setting_themeswitch.set_pos(0, 120) -setting_themeswitch.set_size(240, 54) -setting_themeswitch_label = lv.label(setting_themeswitch) -setting_themeswitch_label.set_text("主题切换") -setting_themeswitch.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_themeswitch_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_themeswitch_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_themeswitch_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_themeswitch.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_themeswitch_img = lv.img(setting_cont) -setting_themeswitch_img.set_pos(10, 120) -setting_themeswitch_img.set_size(47, 47) -setting_themeswitch_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_themeswitch_img.set_src("E:/static/menu_theme_switch.png") -setting_themeswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_imei = lv.btn(setting_cont) -setting_imei.set_pos(0, 180) -setting_imei.set_size(240, 54) -setting_imei_label = lv.label(setting_imei) -setting_imei_label.set_text("设备IMEI号") -setting_imei.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_imei_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_imei_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_imei_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_imei.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_imei_img = lv.img(setting_cont) -setting_imei_img.set_pos(10, 180) -setting_imei_img.set_size(47, 47) -setting_imei_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_imei_img.set_src("E:/static/menu_imei_qrcode.png") -setting_imei_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_app = lv.btn(setting_cont) -setting_app.set_pos(0, 240) -setting_app.set_size(240, 54) -setting_app_label = lv.label(setting_app) -setting_app_label.set_text("手机安装APP") -setting_app.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_app_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_app_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_app_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_app.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_app_img = lv.img(setting_cont) -setting_app_img.set_pos(10, 240) -setting_app_img.set_size(47, 47) -setting_app_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_app_img.set_src("E:/static/menu_app_qrcode.png") -setting_app_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_bright = lv.btn(setting_cont) -setting_bright.set_pos(0, 300) -setting_bright.set_size(240, 54) -setting_bright_label = lv.label(setting_bright) -setting_bright_label.set_text("屏幕调节") -setting_bright.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_bright_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_bright_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_bright_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_bright.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_bright_img = lv.img(setting_cont) -setting_bright_img.set_pos(10, 300) -setting_bright_img.set_size(47, 47) -setting_bright_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_bright_img.set_src("E:/static/menu_bright.png") -setting_bright_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_volume = lv.btn(setting_cont) -setting_volume.set_pos(0, 360) -setting_volume.set_size(240, 54) -setting_volume_label = lv.label(setting_volume) -setting_volume_label.set_text("铃声") -setting_volume.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_volume_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_volume_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_volume_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_volume.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_volume_img = lv.img(setting_cont) -setting_volume_img.set_pos(10, 360) -setting_volume_img.set_size(47, 47) -setting_volume_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_volume_img.set_src("E:/static/menu_volume.png") -setting_volume_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_restore = lv.btn(setting_cont) -setting_restore.set_pos(0, 420) -setting_restore.set_size(240, 54) -setting_restore_label = lv.label(setting_restore) -setting_restore_label.set_text("回复出厂设置") -setting_restore.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_restore_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_restore_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_restore_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_restore.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_restore_img = lv.img(setting_cont) -setting_restore_img.set_pos(10, 420) -setting_restore_img.set_size(47, 47) -setting_restore_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_restore_img.set_src("E:/static/menu_restore.png") -setting_restore_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -setting_poweroff = lv.btn(setting_cont) -setting_poweroff.set_pos(0, 480) -setting_poweroff.set_size(240, 54) -setting_poweroff_label = lv.label(setting_poweroff) -setting_poweroff_label.set_text("关机") -setting_poweroff.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_poweroff_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_poweroff_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_poweroff.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_poweroff_img = lv.img(setting_cont) -setting_poweroff_img.set_pos(10, 480) -setting_poweroff_img.set_size(47, 47) -setting_poweroff_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_poweroff_img.set_src("E:/static/menu_poweroff.png") -setting_poweroff_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_version = lv.btn(setting_cont) -setting_version.set_pos(0, 540) -setting_version.set_size(240, 54) -setting_version_label = lv.label(setting_version) -setting_version_label.set_text("关于设备") -setting_version.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_version_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_version_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_version_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_version.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_version_img = lv.img(setting_cont) -setting_version_img.set_pos(10, 540) -setting_version_img.set_size(47, 47) -setting_version_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_version_img.set_src("E:/static/menu_version.png") -setting_version_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - -setting_update = lv.btn(setting_cont) -setting_update.set_pos(0, 600) -setting_update.set_size(240, 54) -setting_update_label = lv.label(setting_update) -setting_update_label.set_text("系统升级") -setting_update.set_style_pad_all(0, lv.STATE.DEFAULT) -setting_update_label.align(lv.ALIGN.LEFT_MID, 70, 0) -setting_update_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) -setting_update_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_update.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -setting_update_img = lv.img(setting_cont) -setting_update_img.set_pos(10, 600) -setting_update_img.set_size(47, 47) -setting_update_img.add_flag(lv.obj.FLAG.CLICKABLE) -setting_update_img.set_src("E:/static/menu_upgrade.png") -setting_update_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) # -------------------------------------------step screen---------------------------------------------------------- step_screen = lv.obj() @@ -654,7 +468,7 @@ step_label_01.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) step_img = lv.img(step) step_img.set_pos(100, 150) step_img.set_size(40, 65) -step_img.set_src("E:/static/IMAGE_STEP.png") +step_img.set_src("E:/static/IMAGE_STEP.jpg") step_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) # -------------------------------------------weather screen---------------------------------------------------------- @@ -667,7 +481,7 @@ weather.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) weather_img = lv.img(weather) weather_img.set_pos(10, 10) weather_img.set_size(135, 120) -weather_img.set_src("E:/static/cloudy.png") +weather_img.set_src("E:/static/cloudy.jpg") weather_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) @@ -705,7 +519,7 @@ alarm.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) # alarm_nodata_img = lv.img(alarm) # alarm_nodata_img.center() # alarm_nodata_img.set_size(113, 152) -# alarm_nodata_img.set_src("E:/static/IMAGE_IDLE_SCREEN_ALARM_ICON_NEW.png") +# alarm_nodata_img.set_src("E:/static/IMAGE_IDLE_SCREEN_ALARM_ICON_NEW.jpg") # alarm_nodata_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) alarm_title = lv.label(alarm) @@ -763,7 +577,7 @@ countdown_sec.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0) countdown_hour_up = lv.img(countdown) countdown_hour_up.set_size(34, 30) countdown_hour_up.set_pos(23, 100) -countdown_hour_up.set_src("E:/static/time_up.png") +countdown_hour_up.set_src("E:/static/time_up.jpg") @@ -773,7 +587,7 @@ countdown_hour_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) countdown_hour_down = lv.img(countdown) countdown_hour_down.set_size(34, 30) countdown_hour_down.set_pos(23, 180) -countdown_hour_down.set_src("E:/static/time_down.png") +countdown_hour_down.set_src("E:/static/time_down.jpg") @@ -783,7 +597,7 @@ countdown_hour_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) countdown_min_up = lv.img(countdown) countdown_min_up.set_size(34, 30) countdown_min_up.set_pos(80, 100) -countdown_min_up.set_src("E:/static/time_up.png") +countdown_min_up.set_src("E:/static/time_up.jpg") @@ -793,7 +607,7 @@ countdown_min_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) countdown_min_down = lv.img(countdown) countdown_min_down.set_size(34, 30) countdown_min_down.set_pos(80, 180) -countdown_min_down.set_src("E:/static/time_down.png") +countdown_min_down.set_src("E:/static/time_down.jpg") @@ -803,7 +617,7 @@ countdown_min_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) countdown_sec_up = lv.img(countdown) countdown_sec_up.set_size(34, 30) countdown_sec_up.set_pos(160, 100) -countdown_sec_up.set_src("E:/static/time_up.png") +countdown_sec_up.set_src("E:/static/time_up.jpg") @@ -813,7 +627,7 @@ countdown_sec_up.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) countdown_sec_down = lv.img(countdown) countdown_sec_down.set_size(34, 30) countdown_sec_down.set_pos(160, 180) -countdown_sec_down.set_src("E:/static/time_down.png") +countdown_sec_down.set_src("E:/static/time_down.jpg") @@ -822,7 +636,7 @@ countdown_sec_down.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) countdown_reset_imgbtn = lv.img(countdown) countdown_reset_imgbtn.set_size(99, 36) -countdown_reset_imgbtn.set_src("E:/static/stopwatch_reset.png") +countdown_reset_imgbtn.set_src("E:/static/stopwatch_reset.jpg") @@ -832,7 +646,7 @@ countdown_reset_imgbtn.set_pos(10, 260) countdown_start_imgbtn = lv.img(countdown) countdown_start_imgbtn.set_size(99, 36) -countdown_start_imgbtn.set_src("E:/static/stopwatch_play.png") +countdown_start_imgbtn.set_src("E:/static/stopwatch_play.jpg") @@ -842,7 +656,7 @@ countdown_start_imgbtn.set_pos(120, 260) countdown_stop_imgbtn = lv.img(countdown) countdown_stop_imgbtn.set_size(99, 36) -countdown_stop_imgbtn.set_src("E:/static/stopwatch_stop.png") +countdown_stop_imgbtn.set_src("E:/static/stopwatch_stop.jpg") @@ -851,6 +665,23 @@ countdown_stop_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) countdown_stop_imgbtn.set_pos(120, 260) countdown_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) +#结束倒计时显示图标 +countdown_end_img = lv.img(countdown) +countdown_end_img.set_size(140, 140) +countdown_end_img.set_pos(50, 20) +countdown_end_img.set_src("E:/static/time_finish.jpg") +countdown_end_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + +countdown_end_label = lv.label(countdown) +countdown_end_label.set_pos(0, 190) +countdown_end_label.set_size(240, 40) +countdown_end_label.set_text("时间到") +countdown_end_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +countdown_end_label.set_long_mode(lv.label.LONG.WRAP) +countdown_end_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +#............................................................................................ + + # -------------------------------------------stopwatch screen---------------------------------------------------------- stopwatch_screen = lv.obj() @@ -898,7 +729,7 @@ stopwatch_label_ms.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFA stopwatch_reset_imgbtn = lv.img(stopwatch) stopwatch_reset_imgbtn.set_size(99, 36) -stopwatch_reset_imgbtn.set_src("E:/static/stopwatch_reset.png") +stopwatch_reset_imgbtn.set_src("E:/static/stopwatch_reset.jpg") stopwatch_reset_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) stopwatch_reset_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) stopwatch_reset_imgbtn.set_pos(10, 210) @@ -906,14 +737,14 @@ stopwatch_reset_imgbtn.set_pos(10, 210) stopwatch_start_imgbtn = lv.img(stopwatch) stopwatch_start_imgbtn.set_size(99, 36) -stopwatch_start_imgbtn.set_src("E:/static/stopwatch_play.png") +stopwatch_start_imgbtn.set_src("E:/static/stopwatch_play.jpg") stopwatch_start_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) stopwatch_start_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) stopwatch_start_imgbtn.set_pos(115, 210) stopwatch_stop_imgbtn = lv.img(stopwatch) stopwatch_stop_imgbtn.set_size(99, 36) -stopwatch_stop_imgbtn.set_src("E:/static/stopwatch_stop.png") +stopwatch_stop_imgbtn.set_src("E:/static/stopwatch_stop.jpg") stopwatch_stop_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) stopwatch_stop_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) stopwatch_stop_imgbtn.set_pos(115, 210) @@ -929,7 +760,7 @@ temperature.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) temperature_bg_img = lv.img(temperature) temperature_bg_img.set_pos(0, 0) temperature_bg_img.set_size(71, 170) -temperature_bg_img.set_src("E:/static/temp_bg.png") +temperature_bg_img.set_src("E:/static/temp_bg.jpg") temperature_bg_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) temperature_body_label = lv.label(temperature) @@ -943,7 +774,7 @@ temperature_body_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE. temperature_degree_img = lv.img(temperature) temperature_degree_img.set_pos(150, 70) temperature_degree_img.set_size(22, 22) -temperature_degree_img.set_src("E:/static/degree.png") +temperature_degree_img.set_src("E:/static/degree.jpg") temperature_degree_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) temperature_value_label = lv.label(temperature) @@ -965,7 +796,7 @@ temperature_wrist_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE temperature_wrist_degree_img = lv.img(temperature) temperature_wrist_degree_img.set_pos(150, 150) temperature_wrist_degree_img.set_size(22, 22) -temperature_wrist_degree_img.set_src("E:/static/degree.png") +temperature_wrist_degree_img.set_src("E:/static/degree.jpg") temperature_wrist_degree_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) temperature_wrist_value_label = lv.label(temperature) @@ -1035,11 +866,18 @@ spo2_label_1.set_text(" ") spo2_label_1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) spo2_label_1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -line_points = [{"x":0,"y":245},{"x":240,"y":245}] + + +line_points = [{"x":0,"y":0},{"x":240,"y":0}] spo2_line = lv.line(spo2) spo2_line.set_points(line_points,2) +spo2_line.set_pos(0,240) +spo2_line.set_size(240,10) spo2_line.add_style(style_line,0) + + + spo2_last_time = lv.label(spo2) spo2_last_time.set_size(240, 15) spo2_last_time.set_pos(0, 250) @@ -1066,8 +904,8 @@ wechat.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) wechat_press_btn = lv.btn(wechat) wechat_press_btn.set_pos(0, 260) wechat_press_btn.set_size(220, 56) -wechat_press_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -wechat_press_btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) +wechat_press_btn.add_style(style_wechat_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +wechat_press_btn.add_style(style_common_bg_rect_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) wechat_press_btn.set_style_radius(30,0) wechat_press_label = lv.label(wechat_press_btn) @@ -1082,576 +920,21 @@ wechat_label.set_long_mode(lv.label.LONG.WRAP) wechat_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) wechat_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +wechat_press_play_btn = lv.btn(wechat) +wechat_press_play_btn.set_pos(0, 120) +wechat_press_play_btn.set_size(60, 40) +wechat_press_play_btn.add_style(style_wechat_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +wechat_press_play_btn.add_style(style_common_bg_rect_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) +wechat_press_play_btn.set_style_radius(30,0) + +wechat_press_label_play = lv.label(wechat_press_play_btn) +wechat_press_label_play.set_text("请点击播放") +wechat_press_label_play.align(lv.ALIGN.CENTER, 40, 20) +wechat_press_label_play.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + -# -------------------------------------------contacts screen---------------------------------------------------------- -contacts_screen = lv.obj() -contacts = lv.obj(contacts_screen) -contacts.center() -contacts.set_size(240, 320) -contacts.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) -# -------------------------------------------language screen---------------------------------------------------------- -language_screen = lv.obj() -language = lv.obj(language_screen) -language.center() -language.set_size(240, 320) -language.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -language_title = lv.label(language) -language_title.set_pos(0, 10) -language_title.set_size(240, 40) -language_title.set_text("语言设置") -language_title.set_long_mode(lv.label.LONG.WRAP) -language_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -language_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -language_english_btn = lv.btn(language) -language_english_btn.set_size(240,50) -language_english_btn.set_pos(0, 60) -language_english_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) -language_english_btn.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -language_english_btn_label = lv.label(language_english_btn) -language_english_btn_label.set_text("English") -language_english_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0) -language_english_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -language_chinese_btn = lv.btn(language) -language_chinese_btn.set_size(240,50) -language_chinese_btn.set_pos(0, 120) -language_chinese_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) -language_chinese_btn.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -language_chinese_btn_label = lv.label(language_chinese_btn) -language_chinese_btn_label.set_text("简体中文") -language_chinese_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0) -language_chinese_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -# -------------------------------------------dialswitch screen---------------------------------------------------------- -dialswitch_screen = lv.obj() -dialswitch = lv.obj(dialswitch_screen) -dialswitch.center() -dialswitch.set_size(240, 320) -dialswitch.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -dialswitch_title = lv.label(dialswitch) -dialswitch_title.set_pos(0, 10) -dialswitch_title.set_size(240, 40) -dialswitch_title.set_text("表盘切换") -dialswitch_title.set_long_mode(lv.label.LONG.WRAP) -dialswitch_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -dialswitch_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -dialswitch_btn1 = lv.btn(dialswitch) -dialswitch_btn1.set_size(240,54) -dialswitch_btn1.set_pos(0, 50) -dialswitch_btn1.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) -dialswitch_btn1.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -dialswitch_btn1_label = lv.label(dialswitch_btn1) -dialswitch_btn1_label.set_text("表盘1") -dialswitch_btn1_label.align(lv.ALIGN.LEFT_MID, 10, 0) -dialswitch_btn1_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -dialswitch_btn2 = lv.btn(dialswitch) -dialswitch_btn2.set_size(240,54) -dialswitch_btn2.set_pos(0, 104) -dialswitch_btn2.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) -dialswitch_btn2.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -dialswitch_btn2_label = lv.label(dialswitch_btn2) -dialswitch_btn2_label.set_text("表盘2") -dialswitch_btn2_label.align(lv.ALIGN.LEFT_MID, 10, 0) -dialswitch_btn2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -btn1_switch = lv.switch(dialswitch_btn1) -btn1_switch.set_pos(185, 3) -btn1_switch.set_size(10, 10) -btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) -btn1_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) -btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) - -btn2_switch = lv.switch(dialswitch_btn2) -btn2_switch.set_pos(185, 3) -btn2_switch.set_size(10, 10) -btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) -btn2_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) -btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) - -# -------------------------------------------menustyle screen---------------------------------------------------------- -menustyle_screen = lv.obj() -menustyle = lv.obj(menustyle_screen) -menustyle.center() -menustyle.set_size(240, 320) -menustyle.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -menustyle_title = lv.label(menustyle) -menustyle_title.set_pos(0, 10) -menustyle_title.set_size(240, 40) -menustyle_title.set_text("主菜单风格") -menustyle_title.set_long_mode(lv.label.LONG.WRAP) -menustyle_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -menustyle_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -menustyle_btn1 = lv.btn(menustyle) -menustyle_btn1.set_size(240,54) -menustyle_btn1.set_pos(0, 50) -menustyle_btn1.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) -menustyle_btn1.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -menustyle_btn1_label = lv.label(menustyle_btn1) -menustyle_btn1_label.set_text("四宫格") -menustyle_btn1_label.align(lv.ALIGN.LEFT_MID, 10, 0) -menustyle_btn1_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -menu_btn1_switch = lv.switch(menustyle_btn1) -menu_btn1_switch.set_pos(185, 3) -menu_btn1_switch.set_size(10, 10) -menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) -menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) -menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) - -menustyle_btn2 = lv.btn(menustyle) -menustyle_btn2.set_size(240,54) -menustyle_btn2.set_pos(0, 104) -menustyle_btn2.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) -menustyle_btn2.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) -menustyle_btn2_label = lv.label(menustyle_btn2) -menustyle_btn2_label.set_text("单页") -menustyle_btn2_label.align(lv.ALIGN.LEFT_MID, 10, 0) -menustyle_btn2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - - -menu_btn2_switch = lv.switch(menustyle_btn2) -menu_btn2_switch.set_pos(185, 3) -menu_btn2_switch.set_size(10, 10) -menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) -menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) -menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) - - -# -------------------------------------------imei screen---------------------------------------------------------- -imei_screen = lv.obj() -imei = lv.obj(imei_screen) -imei.center() -imei.set_size(240, 320) -imei.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5) -fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4) - -imei_qr = lv.qrcode(imei, 150, fg_color, bg_color) -imei_qr.center() -# Add a border with bg_color -imei_qr.set_style_border_color(bg_color, 0) -imei_qr.set_style_border_width(5, 0) -imei_qr_data = str("867387060319145") -imei_qr.update(imei_qr_data,len(imei_qr_data)) - -imei_label = lv.label(imei) -imei_label.set_pos(0, 280) -imei_label.set_size(240, 20) -imei_label.set_text("867387060319145") -imei_label.set_long_mode(lv.label.LONG.WRAP) -imei_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -imei_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - - -# -------------------------------------------app screen---------------------------------------------------------- -app_screen = lv.obj() -app = lv.obj(app_screen) -app.center() -app.set_size(240, 320) -app.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -app_qr = lv.qrcode(imei, 150, fg_color, bg_color) -app_qr.center() -# Add a border with bg_color -app_qr.set_style_border_color(bg_color, 0) -app_qr.set_style_border_width(5, 0) -app_qr_data = str("https://fangzoudiu.xcloudtech.com/xiao_jian") -app_qr.update(app_qr_data,len(app_qr_data)) - -app_label = lv.label(app) -app_label.set_pos(0, 280) -app_label.set_size(240, 20) -app_label.set_text("867387060319145") -app_label.set_long_mode(lv.label.LONG.WRAP) -app_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -app_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -# -------------------------------------------brightness screen---------------------------------------------------------- -brightness_screen = lv.obj() -brightness = lv.obj(brightness_screen) -brightness.center() -brightness.set_size(240, 320) -brightness.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -brightness_title = lv.label(brightness) -brightness_title.set_pos(0, 10) -brightness_title.set_size(240, 40) -brightness_title.set_text("屏幕调节") -brightness_title.set_long_mode(lv.label.LONG.WRAP) -brightness_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -brightness_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -brightness_label1 = lv.label(brightness) -brightness_label1.set_pos(10, 60) -brightness_label1.set_size(50, 40) -brightness_label1.set_text("亮度") -brightness_label1.set_long_mode(lv.label.LONG.WRAP) -brightness_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0) -brightness_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - - -brightness_bar = lv.bar(brightness) -brightness_bar.set_pos(20, 120) -brightness_bar.set_size(200, 15) -brightness_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT) -brightness_bar.set_mode(lv.bar.MODE.NORMAL) -brightness_bar.set_value(50, lv.ANIM.OFF) -brightness_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT) -brightness_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT) - -brightness_add_imgbtn = lv.img(brightness) -brightness_add_imgbtn.set_pos(50, 250) -brightness_add_imgbtn.set_size(34, 30) -brightness_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) -brightness_add_imgbtn.set_src("E:/static/time_up.png") -brightness_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -brightness_reduce_imgbtn = lv.img(brightness) -brightness_reduce_imgbtn.set_pos(150, 250) -brightness_reduce_imgbtn.set_size(34, 30) -brightness_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) -brightness_reduce_imgbtn.set_src("E:/static/time_down.png") -brightness_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -# -------------------------------------------volume screen---------------------------------------------------------- -volume_screen = lv.obj() -volume = lv.obj(volume_screen) -volume.center() -volume.set_size(240, 320) -volume.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -volume_phone_btn = lv.btn(volume) -volume_phone_btn.set_size(200,50) -volume_phone_btn.set_pos(20,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.LEFT_MID, 50, 0) -volume_phone_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -volume_alarm_btn = lv.btn(volume) -volume_alarm_btn.set_size(200,50) -volume_alarm_btn.set_pos(20,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.LEFT_MID, 50, 0) -volume_alarm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -volume_message_btn = lv.btn(volume) -volume_message_btn.set_size(200,50) -volume_message_btn.set_pos(20,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.LEFT_MID, 50, 0) -volume_message_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -# -------------------------------------------phonering screen---------------------------------------------------------- -phonering_screen = lv.obj() -phonering = lv.obj(phonering_screen) -phonering.center() -phonering.set_size(240, 320) -phonering.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -phonering_title = lv.label(phonering) -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) -phonering_label1.set_pos(10, 60) -phonering_label1.set_size(50, 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) -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_add_imgbtn = lv.img(phonering) -phonering_add_imgbtn.set_pos(50, 250) -phonering_add_imgbtn.set_size(34, 30) -phonering_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) -phonering_add_imgbtn.set_src("E:/static/time_up.png") -phonering_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -phonering_reduce_imgbtn = lv.img(phonering) -phonering_reduce_imgbtn.set_pos(150, 250) -phonering_reduce_imgbtn.set_size(34, 30) -phonering_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) - -phonering_reduce_imgbtn.set_src("E:/static/time_down.png") - -phonering_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -# -------------------------------------------alarmvolume screen---------------------------------------------------------- -alarmvolume_screen = lv.obj() -alarmvolume = lv.obj(alarmvolume_screen) -alarmvolume.center() -alarmvolume.set_size(240, 320) -alarmvolume.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -alarmvolume_title = lv.label(alarmvolume) -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) -alarmvolume_label1.set_pos(10, 60) -alarmvolume_label1.set_size(50, 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) -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_add_imgbtn = lv.img(alarmvolume) -alarmvolume_add_imgbtn.set_pos(50, 250) -alarmvolume_add_imgbtn.set_size(34, 30) -alarmvolume_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) - -alarmvolume_add_imgbtn.set_src("E:/static/time_up.png") - -alarmvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -alarmvolume_reduce_imgbtn = lv.img(alarmvolume) -alarmvolume_reduce_imgbtn.set_pos(150, 250) -alarmvolume_reduce_imgbtn.set_size(34, 30) -alarmvolume_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) - -alarmvolume_reduce_imgbtn.set_src("E:/static/time_down.png") - -alarmvolume_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -# -------------------------------------------msgvolume screen---------------------------------------------------------- -msgvolume_screen = lv.obj() -msgvolume = lv.obj(msgvolume_screen) -msgvolume.center() -msgvolume.set_size(240, 320) -msgvolume.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -msgvolume_title = lv.label(msgvolume) -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) -msgvolume_label1.set_pos(10, 60) -msgvolume_label1.set_size(50, 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) -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_add_imgbtn = lv.img(msgvolume) -msgvolume_add_imgbtn.set_pos(50, 250) -msgvolume_add_imgbtn.set_size(34, 30) -msgvolume_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) - -msgvolume_add_imgbtn.set_src("E:/static/time_up.png") - -msgvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -msgvolume_reduce_imgbtn = lv.img(msgvolume) -msgvolume_reduce_imgbtn.set_pos(150, 250) -msgvolume_reduce_imgbtn.set_size(34, 30) -msgvolume_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) - -msgvolume_reduce_imgbtn.set_src("E:/static/time_down.png") - -msgvolume_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) - - -# -------------------------------------------restore screen---------------------------------------------------------- -restore_screen = lv.obj() -restore = lv.obj(restore_screen) -restore.center() -restore.set_size(240, 320) -restore.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -restore_label = lv.label(restore) -restore_label.set_pos(0, 100) -restore_label.set_size(240, 40) -restore_label.set_text("恢复出厂设置?") -restore_label.set_long_mode(lv.label.LONG.WRAP) -restore_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -restore_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -restore_confirm = lv.label(restore) -restore_confirm.set_text("确认") -restore_confirm.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -restore_confirm.set_size(120, 20) -restore_confirm.set_pos(0,280) -restore_confirm.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -restore_confirm.add_flag(lv.obj.FLAG.CLICKABLE) -restore_confirm.set_ext_click_area(20) - -restore_cancel = lv.label(restore) -restore_cancel.set_text("返回") -restore_cancel.set_size(120, 20) -restore_cancel.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -restore_cancel.set_pos(120,280) -restore_cancel.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -restore_cancel.add_flag(lv.obj.FLAG.CLICKABLE) -restore_cancel.set_ext_click_area(20) - - - -# -------------------------------------------poweroff screen---------------------------------------------------------- -poweroff_screen = lv.obj() -poweroff = lv.obj(poweroff_screen) -poweroff.center() -poweroff.set_size(240, 320) -poweroff.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -poweroff_img = lv.img(poweroff) -poweroff_img.set_pos(100, 30) -poweroff_img.set_size(61, 61) -poweroff_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) -poweroff_img.set_src("E:/static/poweroff_icon.png") - -poweroff_label = lv.label(poweroff) -poweroff_label.set_text("是否关机?") -poweroff_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -poweroff_label.set_size(240, 20) -poweroff_label.set_pos(0,120) -poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -poweroff_confirm = lv.img(poweroff) -poweroff_confirm.set_size(176, 46) -poweroff_confirm.set_pos(32, 150) -poweroff_confirm.set_src("E:/static/off_icon.png") -poweroff_confirm.add_flag(lv.obj.FLAG.CLICKABLE) -poweroff_confirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) -poweroff_confirm.set_ext_click_area(20) - -poweroff_confirm_label = lv.label(poweroff_confirm) -poweroff_confirm_label.set_text("关机") -poweroff_confirm_label.align(lv.ALIGN.CENTER, 10, 0) -poweroff_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -poweroff_return = lv.img(poweroff) -poweroff_return.set_size(176, 46) -poweroff_return.set_pos(32, 210) -poweroff_return.set_src("E:/static/cancel_icon.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) -poweroff_return_label.set_text("返回") -poweroff_return_label.align(lv.ALIGN.CENTER, 10, 0) -poweroff_return_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -poweroff_return.set_ext_click_area(20) - -# -------------------------------------------version screen---------------------------------------------------------- -version_screen = lv.obj() -version = lv.obj(version_screen) -version.center() -version.set_size(240, 320) -version.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -version_msg = """Software Version: -MMI -Version:UIX8910_C55_V -1.0_Release -Build Time: -2-17-2023 -9:32:5 -IMEI: -867387060319145 -""" - -version_label = lv.label(version) -version_label.set_pos(0, 0) -version_label.set_size(240, 320) -version_label.set_long_mode(lv.label.LONG.WRAP) -version_label.set_text(version_msg) - -version_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -version_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - - -# -------------------------------------------update screen---------------------------------------------------------- -update_screen = lv.obj() -update = lv.obj(update_screen) -update.center() -update.set_size(240, 320) -update.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - -update_title = lv.label(update) -update_title.set_pos(0, 10) -update_title.set_size(240, 40) -update_title.set_text("系统更新") -update_title.set_long_mode(lv.label.LONG.WRAP) -update_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -update_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -update_label = lv.label(update) -update_label.set_text(" 检查版本更新!/n 请稍后...") -update_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0) -update_label.set_size(240, 50) -update_label.set_pos(0,50) -update_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - -update_return = lv.label(update) -update_return.set_text("返回") -update_return.set_size(120, 20) -update_return.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0) -update_return.set_pos(0,280) -update_return.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) -update_return.add_flag(lv.obj.FLAG.CLICKABLE) # -------------------------------------------dialing screen---------------------------------------------------------- @@ -1664,7 +947,7 @@ dialing.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) dialing_img = lv.img(dialing) dialing_img.set_pos(80, 50) dialing_img.set_size(64, 64) -dialing_img.set_src("E:/static/IMAGE_NOTICE_CALL.png") +dialing_img.set_src("E:/static/IMAGE_NOTICE_CALL.jpg") dialing_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) dialing_label = lv.label(dialing) @@ -1675,7 +958,7 @@ dialing_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) hangup_imgbtn = lv.img(dialing) hangup_imgbtn.set_size(64, 64) -hangup_imgbtn.set_src("E:/static/IMG_CC_HUNGUP1.png") +hangup_imgbtn.set_src("E:/static/IMG_CC_HUNGUP1.jpg") @@ -1693,7 +976,7 @@ incoming_call.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) incoming_call_img = lv.img(incoming_call) incoming_call_img.set_pos(80, 50) incoming_call_img.set_size(64, 64) -incoming_call_img.set_src("E:/static/IMAGE_NOTICE_CALL.png") +incoming_call_img.set_src("E:/static/IMAGE_NOTICE_CALL.jpg") incoming_call_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) incoming_call_label = lv.label(incoming_call) @@ -1708,14 +991,14 @@ incoming_call_answer.set_size(64, 64) incoming_call_answer.add_flag(lv.obj.FLAG.CLICKABLE) incoming_call_answer.set_pos(30, 220) incoming_call_answer.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) -incoming_call_answer.set_src("E:/static/answer.png") +incoming_call_answer.set_src("E:/static/answer.jpg") incoming_call_hangup = lv.img(incoming_call) incoming_call_hangup.set_size(64, 64) incoming_call_hangup.add_flag(lv.obj.FLAG.CLICKABLE) incoming_call_hangup.set_pos(150, 220) incoming_call_hangup.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) -incoming_call_hangup.set_src("E:/static/hang_up.png") +incoming_call_hangup.set_src("E:/static/hang_up.jpg") # -------------------------------------------on_call screen---------------------------------------------------------- on_call_screen = lv.obj() @@ -1727,7 +1010,7 @@ on_call.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) on_call_img = lv.img(on_call) on_call_img.set_pos(80, 50) on_call_img.set_size(64, 64) -on_call_img.set_src("E:/static/IMAGE_NOTICE_CALL.png") +on_call_img.set_src("E:/static/IMAGE_NOTICE_CALL.jpg") on_call_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) on_call_label = lv.label(on_call) @@ -1741,7 +1024,7 @@ on_call_hangup.set_size(64, 64) on_call_hangup.add_flag(lv.obj.FLAG.CLICKABLE) on_call_hangup.set_pos(85, 220) on_call_hangup.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) -on_call_hangup.set_src("E:/static/hang_up.png") +on_call_hangup.set_src("E:/static/hang_up.jpg") # -------------------------------------------sms_detail screen---------------------------------------------------------- @@ -1873,53 +1156,75 @@ class PhoneScreen(Screen): lv.EVENT.CLICKED, None) phone_delete.add_event_cb(lambda e: self.delete(e), lv.EVENT.CLICKED, None) - + def post_processor_after_instantiation(self): + self.phone_num='' + self.phone_list = [] def one(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("1") self.phone_num = ''.join(self.phone_list) self.show_num() def two(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("2") self.phone_num = ''.join(self.phone_list) self.show_num() def three(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("3") self.phone_num = ''.join(self.phone_list) self.show_num() def four(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("4") self.phone_num = ''.join(self.phone_list) self.show_num() def five(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("5") self.phone_num = ''.join(self.phone_list) self.show_num() def six(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("6") self.phone_num = ''.join(self.phone_list) self.show_num() def seven(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("7") self.phone_num = ''.join(self.phone_list) self.show_num() def eight(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("8") self.phone_num = ''.join(self.phone_list) self.show_num() def nine(self,e): + if(len(self.phone_list) >= 20): + return self.phone_list.append("9") self.phone_num = ''.join(self.phone_list) self.show_num() def zero(self,e): + if(len(self.phone_list) >= 20):#限制拨号数量20个数字 + return self.phone_list.append("0") self.phone_num = ''.join(self.phone_list) self.show_num() @@ -1934,6 +1239,7 @@ class PhoneScreen(Screen): EventMesh.publish("load_screen", {"screen": "contacts"}) def call(self,e): + EventMesh.publish("save_phonenum",self.phone_num) EventMesh.publish("load_screen", {"screen": "dialing"}) voiceCall.callStart(self.phone_num) @@ -1972,12 +1278,12 @@ class CallLogScreen(Screen): for i ,each in enumerate(self.log_list): _btn = lv.btn(call_log) - _btn.set_size(240,50) + _btn.set_size(230,50) _btn.set_pos(0,52*h + 50) _btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT) - _btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) + _btn.add_style(style_common_bg_rect_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) _btn.add_event_cb(lambda e: self.calling(e), - lv.EVENT.PRESSED, None) + lv.EVENT.CLICKED, None) _btn_label1 = lv.label(_btn) _btn_label1.set_pos(0, 0) @@ -2004,11 +1310,12 @@ class CallLogScreen(Screen): def calling(self,e): _i = int(e.get_target().get_child(0).get_text()) _msg = self.log_list[_i] - EventMesh.publish("save_phonenum",_msg[1]) + print("_i..........%d",_i) + EventMesh.publish("save_phonenum",_msg[0]) EventMesh.publish("load_screen", {"screen": "dialing"}) def done_return(self): - EventMesh.publish("load_screen", {"screen": "tilemenu"}) + EventMesh.publish("load_screen", {"screen": "watchface"}) def btn1_release(self): EventMesh.publish("load_screen", {"screen": "watchface"}) @@ -2032,6 +1339,7 @@ class DialingScreen(Screen): def initialization(self): #获取字符串 self.value = EventMesh.publish("get_phonenum") + print("dialing %s\r\n"%self.value) dialing_label.set_text(self.value) def done_return(self): @@ -2099,7 +1407,7 @@ class PopupScreen(Screen): msg_btn.set_size(240,50) msg_btn.set_pos(0,52*i) msg_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT) - msg_btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) + msg_btn.add_style(style_common_bg_rect_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) msg_btn.add_event_cb(lambda e: self.calling(e), lv.EVENT.PRESSED, None) @@ -2237,37 +1545,11 @@ class ToolboxScreen(Screen): toolbox_countdown.add_event_cb(lambda e: self.load_screen(e, {"screen": "countdown"}), lv.EVENT.CLICKED, None) toolbox_stopwatch.add_event_cb(lambda e: self.load_screen(e, {"screen": "stopwatch"}), lv.EVENT.CLICKED, None) - def done_return(self): - EventMesh.publish("load_screen", {"screen": "main_menu"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class SettingScreen(Screen): - NAME = "setting" - - def __init__(self): - super().__init__() - self.meta = setting_screen - setting_language.add_event_cb(lambda e: self.load_screen(e, {"screen": "language"}), lv.EVENT.CLICKED, None) - setting_dialswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "dialswitch"}), lv.EVENT.CLICKED, None) - setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.CLICKED, None) - setting_imei.add_event_cb(lambda e: self.load_screen(e, {"screen": "imei"}), lv.EVENT.CLICKED, None) - setting_app.add_event_cb(lambda e: self.load_screen(e, {"screen": "app"}), lv.EVENT.CLICKED, None) - setting_bright.add_event_cb(lambda e: self.load_screen(e, {"screen": "brightness"}), lv.EVENT.CLICKED, None) - setting_volume.add_event_cb(lambda e: self.load_screen(e, {"screen": "volume"}), lv.EVENT.CLICKED, None) - setting_restore.add_event_cb(lambda e: self.load_screen(e, {"screen": "restore"}), lv.EVENT.CLICKED, None) - setting_poweroff.add_event_cb(lambda e: self.load_screen(e, {"screen": "poweroff"}), lv.EVENT.CLICKED, None) - setting_update.add_event_cb(lambda e: self.load_screen(e, {"screen": "update"}), lv.EVENT.CLICKED, None) - setting_version.add_event_cb(lambda e: self.load_screen(e, {"screen": "version"}), lv.EVENT.CLICKED, None) - - def done_bottom_to_top(self): - #上滑添加动画切屏:动画类型,时间,延迟,auto_del - EventMesh.publish("load_screen", {"screen": "setting2"}) + toolbox_step_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "step"}), lv.EVENT.CLICKED, None) + toolbox_weather_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "weather"}), lv.EVENT.CLICKED, None) + toolbox_alarm_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "alarm"}), lv.EVENT.CLICKED, None) + toolbox_countdown_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "countdown"}), lv.EVENT.CLICKED, None) + toolbox_stopwatch_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "stopwatch"}), lv.EVENT.CLICKED, None) def done_return(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) @@ -2278,394 +1560,10 @@ class SettingScreen(Screen): def btn8_press(self): EventMesh.publish("load_screen", {"screen": "watchface"}) -class RestoreScreen(Screen): - NAME = "restore" - - def __init__(self): - super().__init__() - self.meta = restore_screen - restore_confirm.add_event_cb(lambda e: self.confirm(e),lv.EVENT.CLICKED, None) - restore_cancel.add_event_cb(lambda e: self.concel(e),lv.EVENT.CLICKED, None) - - def confirm(self, e): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def concel(self, e): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class UpdateScreen(Screen): - NAME = "update" - - def __init__(self): - super().__init__() - self.meta = update_screen - update_return.add_event_cb(lambda e: self.back(e),lv.EVENT.CLICKED, None) - - def back(self,e): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class VersionScreen(Screen): - NAME = "version" - - def __init__(self): - super().__init__() - self.meta = version_screen - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class PoweroffScreen(Screen): - NAME = "poweroff" - - def __init__(self): - super().__init__() - self.meta = poweroff_screen - poweroff_confirm.add_event_cb(lambda e: self.confirm(e),lv.EVENT.CLICKED, None) - poweroff_return.add_event_cb(lambda e: self.concel(e),lv.EVENT.CLICKED, None) - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def confirm(self, e): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def concel(self, e): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class LanguageScreen(Screen): - NAME = "language" - - def __init__(self): - super().__init__() - self.meta = language_screen - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class DialswitchScreen(Screen): - NAME = "dialswitch" - - def __init__(self): - super().__init__() - self.meta = dialswitch_screen - dialswitch_btn1.add_event_cb(lambda e: self.watchface01(e), - lv.EVENT.PRESSED, None) - - dialswitch_btn2.add_event_cb(lambda e: self.watchface02(e), - lv.EVENT.PRESSED, None) - - def watchface01(self,e): - #watchface2.add_flag(lv.obj.FLAG.HIDDEN) - #watchface01.clear_flag(lv.obj.FLAG.HIDDEN) - btn1_switch.add_state(lv.STATE.CHECKED) - btn2_switch.clear_state(lv.STATE.CHECKED) - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def watchface02(self,e): - #watchface01.add_flag(lv.obj.FLAG.HIDDEN) - #watchface2.clear_flag(lv.obj.FLAG.HIDDEN) - btn1_switch.clear_state(lv.STATE.CHECKED) - btn2_switch.add_state(lv.STATE.CHECKED) - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class ThemeswitchScreen(Screen): - NAME = "themeswitch" - - def __init__(self): - super().__init__() - self.meta = menustyle_screen - menustyle_btn1.add_event_cb(lambda e: self.fun1(e), - lv.EVENT.PRESSED, None) - - menustyle_btn2.add_event_cb(lambda e: self.fun2(e), - lv.EVENT.PRESSED, None) - - def fun1(self,e): - menu_btn1_switch.add_state(lv.STATE.CHECKED) - menu_btn2_switch.clear_state(lv.STATE.CHECKED) - EventMesh.publish("change_style", "MainMenu1") - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def fun2(self,e): - menu_btn1_switch.clear_state(lv.STATE.CHECKED) - menu_btn2_switch.add_state(lv.STATE.CHECKED) - EventMesh.publish("change_style", "MainMenu2") - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class ImeiScreen(Screen): - NAME = "imei" - - def __init__(self): - super().__init__() - self.meta = imei_screen - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class AppScreen(Screen): - NAME = "app" - - def __init__(self): - super().__init__() - self.meta = app_screen - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - -class BrightnessScreen(Screen): - NAME = "brightness" - - def __init__(self): - super().__init__() - self.level = 0 - self.meta = brightness_screen - brightness_add_imgbtn.add_event_cb(lambda e: self.add_level(e), - lv.EVENT.CLICKED, None) - brightness_reduce_imgbtn.add_event_cb(lambda e: self.reduce_level(e), - lv.EVENT.CLICKED, None) - - def add_level(self, e): - EventMesh.publish("push_add_brightness_level") - self.level = EventMesh.publish("get_brightness_level") - self.show_bar() - - def reduce_level(self, e): - EventMesh.publish("push_reduce_brightness_level") - self.level = EventMesh.publish("get_brightness_level") - self.show_bar() - - def show_bar(self): - brightness_bar.set_value((100 // 7) * self.level, lv.ANIM.OFF) - - def initialization(self): - self.level = EventMesh.publish("get_brightness_level") - self.show_bar() - - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) -class VolumeScreen(Screen): - NAME = "volume" - def __init__(self): - super().__init__() - self.meta = volume_screen - volume_phone_btn.add_event_cb(lambda e: self.load_screen(e, {"screen": "phonering"}), lv.EVENT.CLICKED, None) - volume_message_btn.add_event_cb(lambda e: self.load_screen(e, {"screen": "msgvolume"}), lv.EVENT.CLICKED, None) - volume_alarm_btn.add_event_cb(lambda e: self.load_screen(e, {"screen": "alarmvolume"}), lv.EVENT.CLICKED, None) - def done_return(self): - EventMesh.publish("load_screen", {"screen": "setting"}) - - def btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - - -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: self.add_level(e), - lv.EVENT.CLICKED, None) - phonering_reduce_imgbtn.add_event_cb(lambda e: 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 btn1_release(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - - -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: self.add_level(e), - lv.EVENT.CLICKED, None) - alarmvolume_reduce_imgbtn.add_event_cb(lambda e: 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": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) - - - -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: self.add_level(e), - lv.EVENT.CLICKED, None) - msgvolume_reduce_imgbtn.add_event_cb(lambda e: 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): - alarmvolume_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": "watchface"}) - - def btn8_press(self): - EventMesh.publish("load_screen", {"screen": "watchface"}) class IncomingCallScreen(Screen): NAME = "incoming_call" @@ -2752,38 +1650,87 @@ class WeatherScreen(Screen): def btn8_press(self): EventMesh.publish("load_screen", {"screen": "watchface"}) +import audio +from machine import Pin +# from functools import reduce +# DIGITS = {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9} +# def str2int(str): +# def char2num(s): +# return DIGITS[s] +# return reduce(lambda x,y:x*10+y,map(char2num,str)) class WechatScreen(Screen): NAME = "wechat" def __init__(self): super().__init__() + + self.record_test = audio.Record() + + self.aud = audio.Audio(0) + self.aud.set_pa(Pin.GPIO29) + self.aud.setVolume(10) self.meta = wechat_screen + self.count = 0 wechat_press_btn.add_event_cb(lambda e: self.talking(e), lv.EVENT.PRESSING, None) wechat_press_btn.add_event_cb(lambda e: self.sending(e), - lv.EVENT.PRESS_LOST, None) + lv.EVENT.RELEASED, None) + wechat_press_play_btn.add_event_cb(lambda e: self.play_label(e), + lv.EVENT.CLICKED, None) self.timer = osTimer() wechat_label.set_text(" ") + self.num = 0 + def initialization(self): + wechat_label.add_flag(lv.obj.FLAG.HIDDEN) + # self.check_json = ql_fs.path_exists("/ext/static/audio_amr/num.txt") + # print("self.check_json %d"%self.check_json) + # if self.check_json == True: + # with open("/ext/static/audio_amr/num.txt","r") as fd: + # num_str = fd.read() + # print("fd.read %s"%(num_str)) + # self.num = len(num_str) + # if self.num >= 10: + # self.num = 0 + # self.num+=1 + # else: + # self.num = 0 + # self.record_test.start("E:/static/audio_amr/{}.amr".format(self.num),15) def talking(self,e): - wechat_label.set_text("松开发送,上滑取消") - + self.check_json = ql_fs.path_exists("/ext/static/audio_amr/num.txt") + print("self.check_json %d"%self.check_json) + if self.check_json == True: + with open("/ext/static/audio_amr/num.txt","r") as fd: + num_str = fd.read() + print("num_str %s \r\n"%(num_str)) + self.num = int(str(num_str)) + print("self.num %d .......\r\n"%self.num) + if self.num >= 10: + self.num = 0 + self.num += 1 + print("fd.read %s \r\n"%(fd.read())) + print("self.num %d \r\n"%self.num) + # else: + # self.num = 0 + self.record_test.start("E:/static/audio_amr/{}.amr".format(self.num),15) + wechat_label.clear_flag(lv.obj.FLAG.HIDDEN) + wechat_label.set_text("松开发送") + def sending(self,e): - wechat_label.set_text("发送中") + self.record_test.stop() + with open("/ext/static/audio_amr/num.txt","w") as fd: + print("write data txt.........%s.....\r\n"%(str(self.num))) + fd.write(str(self.num)) self.timer.start(2 * 1000, 0, self.hide_label) - + def play_label(self,e): + a = audio.Audio(0) + a.play(1, 0, 'E:/static/audio_amr/{}.amr'.format(self.num)) #文件名前面要加上路径 + def hide_label(self,*args): - wechat_label.add_flag(lv.obj.FLAG.HIDDEN) + wechat_label.clear_flag(lv.obj.FLAG.HIDDEN) + wechat_label.set_text("发送中") # self.make_btn() - - # def make_btn(self): - # _btn = lv.btn(alarm) - # _btn.set_size(60,50) - # _btn.set_pos(, 52*i + 50) - # _btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT) - # _btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) - def done_return(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) @@ -2811,8 +1758,34 @@ class StepScreen(Screen): def btn8_press(self): EventMesh.publish("load_screen", {"screen": "watchface"}) +# -------------------------------------------contacts screen---------------------------------------------------------- + +contacts_screen = lv.obj() +contacts = lv.obj(contacts_screen) +contacts.center() +contacts.set_size(240, 320) +contacts.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) +contacts.set_scrollbar_mode(0) + + + +contacts_cont = lv.obj(contacts_screen) +contacts_cont.set_pos(0, 0) +contacts_cont.set_size(240, 320) +contacts_cont_style = ContStyle() +contacts_cont.add_style( + contacts_cont_style.style_cont(0, lv.color_make(0x00, 0x00, 0x00), lv.color_make(0x00, 0x00, 0x00), 255), + lv.PART.MAIN | lv.STATE.DEFAULT) + +contact_none_label = lv.label(contacts_cont) +contact_none_label.set_pos(0, 120) +contact_none_label.set_size(240, 60) +contact_none_label.set_text("空") +contact_none_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +contact_none_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) CONTACT_FLAG = 0 + class ContactsScreen(Screen): NAME = "contacts" @@ -2821,58 +1794,75 @@ class ContactsScreen(Screen): self.meta = contacts_screen self.phonebook = {} self.count = 0 - self.phone_num = "" + self.phone_num_count = 0 + self.phone_num = {} self.name = [] + self.check_json = 0 def post_processor_before_initialization(self): - check_json = ql_fs.path_exists("/usr/phonebook.json") + self.check_json = ql_fs.path_exists("/usr/phonebook.json") self.phonebook = EventMesh.publish("get_addr_book_list") - if check_json == False: - with open("usr/phonebook.json","w",encoding="utf-8") as fd: - ujson.dump(self.phonebook,fd) - print("创建电话簿") - else: + print("check_json %d"%(self.check_json)) + self.count = 0 + if self.check_json == True: with open("usr/phonebook.json","r",encoding="utf-8") as fd: self.phonebook = ujson.load(fd) print("读取电话簿") + + # if check_json == False: + # # with open("usr/phonebook.json","w",encoding="utf-8") as fd: + # # ujson.dump(self.phonebook,fd) + # # print("创建电话簿") + # else: + # with open("usr/phonebook.json","r",encoding="utf-8") as fd: + # self.phonebook = ujson.load(fd) + # print("读取电话簿") + def initialization(self): #读取json文件中的字典放到self.phonebook中 - global CONTACT_FLAG #创建btn - if CONTACT_FLAG == 0: - self.btn_create() + self.btn_create() def btn_create(self): + #读取json文件中的键作为label文本; - global CONTACT_FLAG - CONTACT_FLAG = 1 - for key in self.phonebook.keys(): + if self.check_json == True: + contact_none_label.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本 + for key,value in dict.items(self.phonebook): #字典 key value + + print("self.phonebook value %s \r\n %s"%(key,value)) + contact_btn = lv.btn(contacts_cont) + contact_btn.set_size(230,80) + contact_btn.set_pos(0,82*self.count ) + contact_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT) + # contact_btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) + contact_btn.add_event_cb(lambda e: self.calling(e), + lv.EVENT.CLICKED, None) + + contact_btn_label = lv.label(contact_btn) + contact_btn_label.set_text(key+'\r\n'+ value) + contact_btn.set_style_text_align(lv.TEXT_ALIGN.LEFT ,0) + # contact_btn_label.align(lv.ALIGN.LEFT, 10, 0) + contact_btn_label.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT) + + self.count += 1 + else: + contact_none_label.clear_flag(lv.obj.FLAG.HIDDEN) #显示空文本 - contact_btn = lv.btn(contacts) - contact_btn.set_size(240,50) - contact_btn.set_pos(0,52*self.count ) - contact_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT) - contact_btn.add_style(style_contact_btn_pressed, lv.PART.MAIN | lv.STATE.PRESSED) - contact_btn.add_event_cb(lambda e: self.calling(e), - lv.EVENT.PRESSED, None) - contact_btn_label = lv.label(contact_btn) - contact_btn_label.set_text(key) - contact_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0) - contact_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) - self.count += 1 def calling(self,e): _msg = e.get_target().get_child(0).get_text() - EventMesh.publish("save_phonenum", _msg) - self.phone_num = self.phonebook[_msg] - print(_msg,self.phone_num,_msg) + _msg = _msg.split('\r\n') + EventMesh.publish("save_phonenum", _msg[0]) + self.phone_num = self.phonebook[_msg[0]] + # print(_msg,self.phone_num,_msg) voiceCall.callStart(self.phone_num) EventMesh.publish("load_screen", {"screen": "dialing"}) def done_return(self): - EventMesh.publish("load_screen", {"screen": "tilemenu"}) + EventMesh.publish("load_screen", {"screen": "main_menu"}) def btn1_release(self): EventMesh.publish("load_screen", {"screen": "watchface"}) @@ -2985,8 +1975,8 @@ class Spo2Screen(Screen): self.point = 0 def done_return(self): - spo2_start_btn.clear_flag(lv.obj.FLAG.HIDDEN) - spo2_now_value.add_flag(lv.obj.FLAG.HIDDEN) + # spo2_start_btn.clear_flag(lv.obj.FLAG.HIDDEN) + # spo2_now_value.add_flag(lv.obj.FLAG.HIDDEN) self.timer.stop() EventMesh.publish("load_screen", {"screen": "main_menu"}) @@ -3000,7 +1990,7 @@ class Spo2Screen(Screen): class CountdownScreen(Screen): NAME = "countdown" - + def __init__(self): super().__init__() self.meta = countdown_screen @@ -3010,6 +2000,15 @@ class CountdownScreen(Screen): self.hour = 0 self.total = 0 self.flag = 1 + self.g_state = 0 + self.g_end = 0 + self.total = 0 + countdown_end_label.add_flag(lv.obj.FLAG.HIDDEN) + countdown_end_img.add_flag(lv.obj.FLAG.HIDDEN) + countdown_start_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_reset_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_up.add_event_cb(lambda e: self.sec_up(e), lv.EVENT.CLICKED, None) countdown_sec_down.add_event_cb(lambda e: self.sec_down(e), @@ -3027,7 +2026,26 @@ class CountdownScreen(Screen): countdown_reset_imgbtn.add_event_cb(lambda e: self.reset(e), lv.EVENT.CLICKED, None) countdown_stop_imgbtn.add_event_cb(lambda e: self.stop(e), - lv.EVENT.CLICKED, None) + lv.EVENT.CLICKED, None) + + def post_processor_before_initialization(self): + if self.g_state == 0: + countdown_end_label.add_flag(lv.obj.FLAG.HIDDEN) + countdown_end_img.add_flag(lv.obj.FLAG.HIDDEN) + countdown_start_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_reset_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_up.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_down.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_min_up.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_min_down.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_up.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_down.clear_flag(lv.obj.FLAG.HIDDEN) + self.g_end = 0 + self.total = 0 + self.hour = 0 + self.min = 0 + self.sec = 0 def sec_up(self,e): if self.sec < 59: @@ -3068,54 +2086,115 @@ class CountdownScreen(Screen): def start(self,e): self.total = self.hour*60*60 + self.min*60 + self.sec print("--00:",self.total,self.hour,self.min,self.sec) - self.timer.start(period=1000, mode=self.timer.PERIODIC, callback=self.fun) - countdown_stop_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) - countdown_start_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + if self.total > 0: + self.g_state = 1 + self.g_end = 0 + self.show_value() + self.timer.start(period=1000, mode=self.timer.PERIODIC, callback=self.fun) + countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN) + countdown_min_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_min_down.add_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_down.add_flag(lv.obj.FLAG.HIDDEN) + countdown_start_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_stop_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_reset_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) def stop(self,e): print("in stop") - countdown_start_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) - countdown_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) - self.timer.stop() - self.show_value() + if self.g_state == 1: + countdown_start_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_reset_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + self.g_state = 0 + self.g_end = 0 + self.timer.stop() + self.show_value() def fun(self,e): - self.show_value() - self.total = self.total - 1 - if self.total < 1: + + + self.hour = self.total//3600 + self.min = self.total%3600//60 + + self.show_value() + + if self.total <= 0: + countdown_end_label.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_end_img.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_start_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_reset_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_down.add_flag(lv.obj.FLAG.HIDDEN) + countdown_min_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_min_down.add_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_up.add_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_down.add_flag(lv.obj.FLAG.HIDDEN) + self.g_state = 0 + self.g_end = 1 self.timer.stop() - self.sec = self.sec - 1 + self.total = self.total - 1 + + self.sec = self.sec - 1 if self.sec < 0: self.sec = 59 - self.min = self.min -1 - + def reset(self,e): - print("in reset") + # print("in reset") self.timer.stop() self.hour = 0 self.min = 0 self.sec = 0 + self.g_state = 0 + self.g_end = 0 + countdown_start_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + countdown_reset_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + + countdown_end_label.add_flag(lv.obj.FLAG.HIDDEN) + countdown_end_img.add_flag(lv.obj.FLAG.HIDDEN) + + countdown_hour_up.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_hour_down.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_min_up.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_min_down.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_up.clear_flag(lv.obj.FLAG.HIDDEN) + countdown_sec_down.clear_flag(lv.obj.FLAG.HIDDEN) self.show_value() def show_value(self): - print(" in show value :",str(self.sec),str(self.min),str(self.hour)) + # print(" in show value :",str(self.sec),str(self.min),str(self.hour)) countdown_sec.set_text(str(self.sec)) countdown_min.set_text(str(self.min)) countdown_hour.set_text(str(self.hour)) + def done_return(self): - EventMesh.publish("load_screen", {"screen": "toolbox"}) + if self.g_state == 0: + self.timer.stop() + if self.g_end == 1: + EventMesh.publish("load_screen", {"screen": "countdown"}) + else: + EventMesh.publish("load_screen", {"screen": "toolbox"}) def btn1_release(self): + if self.g_state == 0: + self.timer.stop() EventMesh.publish("load_screen", {"screen": "watchface"}) - self.timer.stop() def btn8_press(self): + if self.g_state == 0: + self.timer.stop() EventMesh.publish("load_screen", {"screen": "watchface"}) - self.timer.stop() class StopwatchScreen(Screen): @@ -3127,6 +2206,7 @@ class StopwatchScreen(Screen): self.ms_value = 0 self.sec_value = 0 self.min_value = 0 + self.s_state = 0 self.timer = Timer(Timer.Timer1) stopwatch_start_imgbtn.add_event_cb(lambda e: self.start(e), lv.EVENT.CLICKED, None) @@ -3139,6 +2219,7 @@ class StopwatchScreen(Screen): def start(self, e): #self.timer.start(100, 1, self._fun) self.timer.start(period=100, mode=self.timer.PERIODIC, callback=self._fun) + self.s_state = 1 stopwatch_stop_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) stopwatch_start_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) @@ -3147,14 +2228,19 @@ class StopwatchScreen(Screen): print("stopwatch pause") stopwatch_start_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) stopwatch_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) + self.s_state = 0 self.timer.stop() self.show_value() def reset(self, e): print("stopwatch reset") + self.sec_value = 0 self.min_value = 0 self.ms_value = 0 + self.s_state = 0 + stopwatch_start_imgbtn.clear_flag(lv.obj.FLAG.HIDDEN) + stopwatch_stop_imgbtn.add_flag(lv.obj.FLAG.HIDDEN) self.timer.stop() self.show_value() @@ -3166,7 +2252,7 @@ class StopwatchScreen(Screen): if self.sec_value > 60: self.sec_value = 0 self.min_value += 1 - if self.min_value > 60: + if self.min_value > 99: self.timer.stop() self.show_value() @@ -3177,16 +2263,19 @@ class StopwatchScreen(Screen): stopwatch_label_min.set_text(str(self.min_value)) def done_return(self): - self.timer.stop() + if self.s_state == 0: + self.timer.stop() EventMesh.publish("load_screen", {"screen": "toolbox"}) def btn1_release(self): + if self.s_state == 0: + self.timer.stop() EventMesh.publish("load_screen", {"screen": "watchface"}) - self.timer.stop() def btn8_press(self): + if self.s_state == 0: + self.timer.stop() EventMesh.publish("load_screen", {"screen": "watchface"}) - self.timer.stop() @@ -3207,11 +2296,11 @@ class UIFINDScreen(Screen): self.meta.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT) #进入图片 self.watchface_mpsignal_img = lv.img(self.meta) - self.watchface_mpsignal_img.set_pos(int(0),int(80)) + self.watchface_mpsignal_img.set_pos(int(50),int(80)) self.watchface_mpsignal_img.set_size(140,140) self.watchface_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface_mpsignal_img.set_src("E:/static/time_finish.png") + self.watchface_mpsignal_img.set_src("E:/static/time_finish.jpg") self.watchface_mpsignal_img.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT) def initialization(self): @@ -3327,9 +2416,12 @@ class UI(object): self.__lcd_off() return #息屏状态按按钮都亮屏 - + if event == "btn8_press" and self.sleep_flag == 0: + self.__lcd_on() + return self.__lcd_on() + # if event == "btn1_press": # self.screen.btn1_press() @@ -3358,7 +2450,8 @@ class UI(object): lcd.lcd_display_on() lv.autoSleep(0) pm.autosleep(0) - + utime.sleep_ms(100) + def publish_call_in(self, event, msg): EventMesh.publish("load_screen", {"screen": "dialing", "meta": msg}) @@ -3373,6 +2466,7 @@ class UI(object): lcd.lcd_display_off() lv.autoSleep(1) pm.autosleep(1) + utime.sleep_ms(300) def system_sleep(self, event, msg) : self.__lcd_off() diff --git a/3.code/1.watch/2.code/ui_WatchFaceScreen.py b/3.code/1.watch/2.code/ui_WatchFaceScreen.py index ac50e44c..cb9cd918 100644 --- a/3.code/1.watch/2.code/ui_WatchFaceScreen.py +++ b/3.code/1.watch/2.code/ui_WatchFaceScreen.py @@ -11,6 +11,11 @@ from misc import Power import pm from ext.ui import Screen +style_font_youyuan_20 = lv.style_t() +style_font_youyuan_20.init() +style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff)) +style_font_youyuan_20.set_text_font_v2("font_18.bin",18,0) + class Watchface2(): NAME = "Watchface2" # # #表盘1 @@ -40,7 +45,7 @@ class Watchface2(): self.watchface_mpsignal_img.set_size(24,17) self.watchface_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface_mpsignal_img.set_src("E:/static/mpsignal5.png") + self.watchface_mpsignal_img.set_src("E:/static/mpsignal5.jpg") self.watchface_mpsignal_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface_res_stat_battery_img = lv.img(self.meta) @@ -48,7 +53,7 @@ class Watchface2(): self.watchface_res_stat_battery_img.set_size(30,18) self.watchface_res_stat_battery_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface_res_stat_battery_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface_res_stat_battery_img.set_src("E:/static/vbat_100.png") + self.watchface_res_stat_battery_img.set_src("E:/static/vbat_100.jpg") self.watchface_res_stat_battery_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface_res_stat_charge_in_img = lv.img(self.meta) @@ -56,7 +61,7 @@ class Watchface2(): self.watchface_res_stat_charge_in_img.set_size(10,18) self.watchface_res_stat_charge_in_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface_res_stat_charge_in_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in.png") + self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in.jpg") # add style for watchface_res_stat_charge_in_img self.watchface_res_stat_charge_in_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) @@ -68,7 +73,7 @@ class Watchface2(): self.watchface1_time1_img.set_size(56,56) self.watchface1_time1_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time1_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time1_img.set_src("E:/static/watch_plate/style_2/time/1.png") + self.watchface1_time1_img.set_src("E:/static/watch_plate/style_2/time/1.jpg") self.watchface1_time1_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_time2_img = lv.img(self.meta) @@ -76,7 +81,7 @@ class Watchface2(): self.watchface1_time2_img.set_size(56,56) self.watchface1_time2_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time2_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time2_img.set_src("E:/static/watch_plate/style_2/time/3.png") + self.watchface1_time2_img.set_src("E:/static/watch_plate/style_2/time/3.jpg") self.watchface1_time2_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_time4_img = lv.img(self.meta) @@ -84,7 +89,7 @@ class Watchface2(): self.watchface1_time4_img.set_size(56,56) self.watchface1_time4_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time4_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time4_img.set_src("E:/static/watch_plate/style_2/time/2.png") + self.watchface1_time4_img.set_src("E:/static/watch_plate/style_2/time/2.jpg") self.watchface1_time4_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_time5_img = lv.img(self.meta) @@ -92,7 +97,7 @@ class Watchface2(): self.watchface1_time5_img.set_size(56,56) self.watchface1_time5_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time5_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time5_img.set_src("E:/static/watch_plate/style_2/time/3.png") + self.watchface1_time5_img.set_src("E:/static/watch_plate/style_2/time/3.jpg") self.watchface1_time5_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) #星期 @@ -102,7 +107,7 @@ class Watchface2(): self.weekday.set_size(56,56) self.weekday.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.weekday.add_flag(lv.obj.FLAG.CLICKABLE) - self.weekday.set_src("E:/static/watch_plate/style_2/week/fri.png") + self.weekday.set_src("E:/static/watch_plate/style_2/week/fri.jpg") self.weekday.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) #日期 @@ -157,11 +162,11 @@ class Watchface1(): #状态栏 self.watchface_mpsignal_img = lv.img(self.meta) - self.watchface_mpsignal_img.set_pos(int(0),int(0)) + self.watchface_mpsignal_img.set_pos(int(40),int(0)) self.watchface_mpsignal_img.set_size(24,17) self.watchface_mpsignal_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface_mpsignal_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface_mpsignal_img.set_src("E:/static/mpsignal5.png") + self.watchface_mpsignal_img.set_src("E:/static/mpsignal5.jpg") self.watchface_mpsignal_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface_res_stat_battery_img = lv.img(self.meta) @@ -169,15 +174,15 @@ class Watchface1(): self.watchface_res_stat_battery_img.set_size(30,18) self.watchface_res_stat_battery_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface_res_stat_battery_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface_res_stat_battery_img.set_src("E:/static/vbat_100.png") + self.watchface_res_stat_battery_img.set_src("E:/static/vbat_100.jpg") self.watchface_res_stat_battery_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface_res_stat_charge_in_img = lv.img(self.meta) - self.watchface_res_stat_charge_in_img.set_pos(int(190),int(0)) - self.watchface_res_stat_charge_in_img.set_size(10,18) + self.watchface_res_stat_charge_in_img.set_pos(int(180),int(0)) + self.watchface_res_stat_charge_in_img.set_size(6,16) self.watchface_res_stat_charge_in_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface_res_stat_charge_in_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in.png") + self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in.jpg") # add style for watchface_res_stat_charge_in_img self.watchface_res_stat_charge_in_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) @@ -187,7 +192,7 @@ class Watchface1(): self.watchface1_bg_img.set_size(240,280) self.watchface1_bg_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_bg_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_bg_img.set_src("E:/static/watch_plate/style_1/bg.png") + self.watchface1_bg_img.set_src("E:/static/watch_plate/style_1/bg.jpg") self.watchface1_bg_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) #时间 x = 40 @@ -197,7 +202,7 @@ class Watchface1(): self.watchface1_time1_img.set_size(36,44) self.watchface1_time1_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time1_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time1_img.set_src("E:/static/watch_plate/style_1/time/1.png") + self.watchface1_time1_img.set_src("E:/static/watch_plate/style_1/time/1.jpg") self.watchface1_time1_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_time2_img = lv.img(self.meta) @@ -205,47 +210,32 @@ class Watchface1(): self.watchface1_time2_img.set_size(36,44) self.watchface1_time2_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time2_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time2_img.set_src("E:/static/watch_plate/style_1/time/3.png") + self.watchface1_time2_img.set_src("E:/static/watch_plate/style_1/time/3.jpg") self.watchface1_time2_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_time3_img = lv.img(self.meta) - self.watchface1_time3_img.set_pos(int(x+36+36+4),int(y+2)) + self.watchface1_time3_img.set_pos(int(x+36+36+4),int(y+11)) self.watchface1_time3_img.set_size(8,24) self.watchface1_time3_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time3_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time3_img.set_src("E:/static/watch_plate/style_1/time/colon.png") + self.watchface1_time3_img.set_src("E:/static/watch_plate/style_1/time/colon.jpg") self.watchface1_time3_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_time4_img = lv.img(self.meta) - self.watchface1_time4_img.set_pos(int(x+36+36+16),int(y)) + self.watchface1_time4_img.set_pos(int(x+36+36+4+12),int(y)) self.watchface1_time4_img.set_size(36,44) self.watchface1_time4_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time4_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time4_img.set_src("E:/static/watch_plate/style_1/time/2.png") + self.watchface1_time4_img.set_src("E:/static/watch_plate/style_1/time/2.jpg") self.watchface1_time4_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_time5_img = lv.img(self.meta) - self.watchface1_time5_img.set_pos(int(x+36+36+16+36),int(y)) + self.watchface1_time5_img.set_pos(int(x+36+36+4+12+36),int(y)) self.watchface1_time5_img.set_size(36,44) self.watchface1_time5_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_time5_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_time5_img.set_src("E:/static/watch_plate/style_1/time/3.png") + self.watchface1_time5_img.set_src("E:/static/watch_plate/style_1/time/3.jpg") self.watchface1_time5_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) - #日期 - self.watchface1_date = lv.spangroup(self.meta) - self.watchface1_date.set_pos(int(24),int(131)) - self.watchface1_date.set_size(84,17) - self.watchface1_date.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) - self.watchface1_date.set_align(lv.TEXT_ALIGN.LEFT) - self.watchface1_date.set_overflow(lv.SPAN_OVERFLOW.CLIP) - self.watchface1_date.set_mode(lv.SPAN_MODE.BREAK) - self.watchface1_date_span = self.watchface1_date.new_span() - self.watchface1_date_span.set_text("12月9日") - self.watchface1_date_span.style.set_text_color(lv.color_make(0xe0,0xd7,0xd7)) - self.watchface1_date_span.style.set_text_decor(lv.TEXT_DECOR.NONE) - self.watchface1_date_span.style.set_size(100) - #main_style_1_spangroup_date_span.style.set_text_font(lv.font_harmony_19) - self.watchface1_date.refr_mode() # create style self.watchface1_style_default self.watchface1_style_default = lv.style_t() self.watchface1_style_default.init() @@ -261,7 +251,22 @@ class Watchface1(): self.watchface1_style_default.set_pad_right(0) self.watchface1_style_default.set_pad_top(0) self.watchface1_style_default.set_pad_bottom(0) - self.watchface1_style_default.set_text_font_v2("font.bin",0) #将外部字体库与该style对象绑定 + self.watchface1_style_default.set_text_font_v2("font_18.bin",18,0) #将外部字体库与该style对象绑定 + #日期 + self.watchface1_date = lv.spangroup(self.meta) + self.watchface1_date.set_pos(int(24),int(131)) + self.watchface1_date.set_size(84,17) + self.watchface1_date.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) + self.watchface1_date.set_align(lv.TEXT_ALIGN.LEFT) + self.watchface1_date.set_overflow(lv.SPAN_OVERFLOW.CLIP) + self.watchface1_date.set_mode(lv.SPAN_MODE.BREAK) + self.watchface1_date_span = self.watchface1_date.new_span() + self.watchface1_date_span.set_text("12月9日") + self.watchface1_date_span.style.set_text_color(lv.color_make(0xe0,0xd7,0xd7)) + self.watchface1_date_span.style.set_text_decor(lv.TEXT_DECOR.NONE) + self.watchface1_date_span.style.set_size(100) + self.watchface1_date.refr_mode() + # add style for main_style_1_spangroup_date self.watchface1_date.add_style(self.watchface1_style_default, lv.PART.MAIN|lv.STATE.DEFAULT) #星期 @@ -276,27 +281,25 @@ class Watchface1(): self.watchface1_week_span.set_text("星期四") self.watchface1_week_span.style.set_text_color(lv.color_make(0xee,0xe7,0xe7)) self.watchface1_week_span.style.set_text_decor(lv.TEXT_DECOR.NONE) - #self.watchface1_week_week_span.style.set_text_font(lv.font_harmony_19) self.watchface1_week.refr_mode() # add style for main_style_1_spangroup_week self.watchface1_week.add_style(self.watchface1_style_default, lv.PART.MAIN|lv.STATE.DEFAULT) - #阴历 - self.watchface1_lunar_calendar = lv.spangroup(self.meta) - self.watchface1_lunar_calendar.set_pos(int(124),int(131)) - self.watchface1_lunar_calendar.set_size(110,17) - self.watchface1_lunar_calendar.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) - self.watchface1_lunar_calendar.set_align(lv.TEXT_ALIGN.LEFT) - self.watchface1_lunar_calendar.set_overflow(lv.SPAN_OVERFLOW.CLIP) - self.watchface1_lunar_calendar.set_mode(lv.SPAN_MODE.BREAK) - self.watchface1_lunar_calendar_span = self.watchface1_lunar_calendar.new_span() - self.watchface1_lunar_calendar_span.set_text("三月初三") - self.watchface1_lunar_calendar_span.style.set_text_color(lv.color_make(0xee,0xe7,0xe7)) - self.watchface1_lunar_calendar_span.style.set_text_decor(lv.TEXT_DECOR.NONE) - #self.watchface1_lunar_calendar_span.style.set_text_font(lv.font_harmony_19) - self.watchface1_lunar_calendar.refr_mode() - # add style for main_style_1_spangroup_week - self.watchface1_lunar_calendar.add_style(self.watchface1_style_default, lv.PART.MAIN|lv.STATE.DEFAULT) + # #阴历 + # self.watchface1_lunar_calendar = lv.spangroup(self.meta) + # self.watchface1_lunar_calendar.set_pos(int(124),int(131)) + # self.watchface1_lunar_calendar.set_size(110,17) + # self.watchface1_lunar_calendar.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) + # self.watchface1_lunar_calendar.set_align(lv.TEXT_ALIGN.LEFT) + # self.watchface1_lunar_calendar.set_overflow(lv.SPAN_OVERFLOW.CLIP) + # self.watchface1_lunar_calendar.set_mode(lv.SPAN_MODE.BREAK) + # self.watchface1_lunar_calendar_span = self.watchface1_lunar_calendar.new_span() + # self.watchface1_lunar_calendar_span.set_text("三月初三") + # self.watchface1_lunar_calendar_span.style.set_text_color(lv.color_make(0xee,0xe7,0xe7)) + # self.watchface1_lunar_calendar_span.style.set_text_decor(lv.TEXT_DECOR.NONE) + # self.watchface1_lunar_calendar.refr_mode() + # # add style for main_style_1_spangroup_week + # self.watchface1_lunar_calendar.add_style(self.watchface1_style_default, lv.PART.MAIN|lv.STATE.DEFAULT) #计步 self.watchface1_step_img = lv.img(self.meta) @@ -304,7 +307,7 @@ class Watchface1(): self.watchface1_step_img.set_size(26,24) self.watchface1_step_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_step_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_step_img.set_src("E:/static/watch_plate/style_1/step.png") + self.watchface1_step_img.set_src("E:/static/watch_plate/style_1/step.jpg") self.watchface1_step_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_step_txt = lv.spangroup(self.meta) @@ -329,7 +332,7 @@ class Watchface1(): self.watchface1_HB_img.set_size(30,27) self.watchface1_HB_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_HB_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_HB_img.set_src("E:/static/watch_plate/style_1/heart.png") + self.watchface1_HB_img.set_src("E:/static/watch_plate/style_1/heart.jpg") self.watchface1_HB_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_HB_txt = lv.spangroup(self.meta) @@ -354,7 +357,7 @@ class Watchface1(): self.watchface1_SPO2_img.set_size(23,32) self.watchface1_SPO2_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) self.watchface1_SPO2_img.add_flag(lv.obj.FLAG.CLICKABLE) - self.watchface1_SPO2_img.set_src("E:/static/watch_plate/style_1/blood.png") + self.watchface1_SPO2_img.set_src("E:/static/watch_plate/style_1/blood.jpg") self.watchface1_SPO2_img.add_style(self.style_watchface_img_default, lv.PART.MAIN|lv.STATE.DEFAULT) self.watchface1_SPO2_txt = lv.spangroup(self.meta) @@ -409,10 +412,10 @@ class Watchface1(): hour2_chose = (msg[0][0])%10 min1_chose = (msg[0][1])//10%10 min2_chose = (msg[0][1])%10 - self.watchface1_time1_img.set_src("E:/static/watch_plate/style_1/time/%d.png"%(hour1_chose)) - self.watchface1_time2_img.set_src("E:/static/watch_plate/style_1/time/%d.png"%(hour2_chose)) - self.watchface1_time4_img.set_src("E:/static/watch_plate/style_1/time/%d.png"%(min1_chose)) - self.watchface1_time5_img.set_src("E:/static/watch_plate/style_1/time/%d.png"%(min2_chose)) + self.watchface1_time1_img.set_src("E:/static/watch_plate/style_1/time/%d.jpg"%(hour1_chose)) + self.watchface1_time2_img.set_src("E:/static/watch_plate/style_1/time/%d.jpg"%(hour2_chose)) + self.watchface1_time4_img.set_src("E:/static/watch_plate/style_1/time/%d.jpg"%(min1_chose)) + self.watchface1_time5_img.set_src("E:/static/watch_plate/style_1/time/%d.jpg"%(min2_chose)) self.watchface1_date_span.set_text(msg[2])#日期 self.watchface1_week_span.set_text(msg[3]) #星期 @@ -422,20 +425,21 @@ class Watchface1(): #print("__signal_cb:{}".format(msg//8)) if msg: if msg >= 0 and msg<=31 : - self.watchface_mpsignal_img.set_src("E:/static/mpsignal{}.png".format(msg//8)) + self.watchface_mpsignal_img.set_src("E:/static/mpsignal{}.jpg".format(msg//8)) else : - self.watchface_mpsignal_img.set_src("E:/static/mpsignal5.png") + self.watchface_mpsignal_img.set_src("E:/static/mpsignal5.jpg") def __battery(self, event, msg): #print("__battery_cb:",str(msg)) #print(msg) if msg[0] == '1': - self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in.png") + self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in.jpg") else: - self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in1.png") + self.watchface_res_stat_charge_in_img.set_src("E:/static/charge_in1.jpg") - self.watchface_res_stat_battery_img.set_src("E:/static/vbat_%d.png"%(msg[1]))#"E:/vbat_60.png" + self.watchface_res_stat_battery_img.set_src("E:/static/vbat_%d.jpg"%(msg[1]))#"E:/vbat_60.jpg" pass + class WatchFaceScreen(Screen): @@ -450,6 +454,7 @@ class WatchFaceScreen(Screen): self.timer_update = osTimer() + def initialization(self): print("watchface INIT !!!!!!!!") if self.watchface_list == [] : #第一次初始化 diff --git a/3.code/1.watch/2.code/ui_main_menu.py b/3.code/1.watch/2.code/ui_main_menu.py index a75b11eb..cb5df5b4 100644 --- a/3.code/1.watch/2.code/ui_main_menu.py +++ b/3.code/1.watch/2.code/ui_main_menu.py @@ -30,7 +30,7 @@ style_MainMenu_img_default.set_img_opa(255) style_font_youyuan_20 = lv.style_t() style_font_youyuan_20.init() style_font_youyuan_20.set_text_color(lv.color_make(0xff, 0xff, 0xff)) -style_font_youyuan_20.set_text_font_v2("font.bin",0) +style_font_youyuan_20.set_text_font_v2("font_20.bin",20,0) style_btn = lv.style_t() style_btn.init() @@ -73,8 +73,8 @@ class MainMenuScreen(Screen): print("main_menu Close !!!!!!!!") return - # def done_return(self): - # EventMesh.publish("load_screen", {"screen": "watchface"}) + def done_return(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) def btn1_release(self): EventMesh.publish("load_screen", {"screen": "watchface"}) def btn8_press(self): @@ -258,7 +258,7 @@ class MainMenu1(): self.MainMenu1_img_wechat = lv.img(self.MainMenu1_5) self.MainMenu1_img_wechat.set_size(70, 70) self.MainMenu1_img_wechat.set_pos(30,60) - self.MainMenu1_img_wechat.set_src("E:/static/main_menu/main_menu1/IMAGE_MAINMENU_WECHAT.png") + self.MainMenu1_img_wechat.set_src("E:/static/main_menu/main_menu1/IMAGE_MAINMENU_WECHAT.jpg") self.MainMenu1_img_wechat.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu1_img_wechat.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) self.MainMenu1_img_wechat.add_event_cb(lambda e: self.img_cb(e, "wechat"), lv.EVENT.CLICKED, None) @@ -285,145 +285,145 @@ class MainMenu2(): #支付宝 self.MainMenu2_alipay = self.MainMenu2.add_tile(0, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_alipay = lv.img(self.MainMenu2_alipay) - self.MainMenu2_img_alipay.set_size(126, 126) + self.MainMenu2_img_alipay.set_size(160,160) self.MainMenu2_img_alipay.center() self.MainMenu2_img_alipay.set_src("E:/static/main_menu/main_menu2/alipay_.jpg") self.MainMenu2_img_alipay.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_alipay.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_alipay) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("支付宝") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_alipay) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("支付宝") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #拨号盘 self.MainMenu2_phone = self.MainMenu2.add_tile(1, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_phone = lv.img(self.MainMenu2_phone) - self.MainMenu2_img_phone.set_size(128, 128) + self.MainMenu2_img_phone.set_size(160,160) self.MainMenu2_img_phone.center() self.MainMenu2_img_phone.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CALL.jpg") self.MainMenu2_img_phone.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_phone.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_phone) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("通话") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_phone) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("通话") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #通讯录 self.MainMenu2_contacts = self.MainMenu2.add_tile(2, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_contacts = lv.img(self.MainMenu2_contacts) - self.MainMenu2_img_contacts.set_size(128, 128) + self.MainMenu2_img_contacts.set_size(160,160) self.MainMenu2_img_contacts.center() self.MainMenu2_img_contacts.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_CONTACTS.jpg") self.MainMenu2_img_contacts.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_contacts.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_contacts) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("通讯录") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_contacts) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("通讯录") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #心律检测 self.MainMenu2_heartrate = self.MainMenu2.add_tile(3, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_heartrate = lv.img(self.MainMenu2_heartrate) - self.MainMenu2_img_heartrate.set_size(128, 128) + self.MainMenu2_img_heartrate.set_size(160,160) self.MainMenu2_img_heartrate.center() self.MainMenu2_img_heartrate.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_HEART_RATE_HEALTH_DETECT.jpg") self.MainMenu2_img_heartrate.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_heartrate.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_heartrate) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("心率") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_heartrate) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("心率") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #血样检测 self.MainMenu2_spo2 = self.MainMenu2.add_tile(4, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_spo2 = lv.img(self.MainMenu2_spo2) - self.MainMenu2_img_spo2.set_size(128, 128) + self.MainMenu2_img_spo2.set_size(160,160) self.MainMenu2_img_spo2.center() self.MainMenu2_img_spo2.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SPO2_DETECT.jpg") self.MainMenu2_img_spo2.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_spo2.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_spo2) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("血氧") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_spo2) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("血氧") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #工具箱 self.MainMenu2_toolbox = self.MainMenu2.add_tile(5, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_toolbox = lv.img(self.MainMenu2_toolbox) - self.MainMenu2_img_toolbox.set_size(128, 128) + self.MainMenu2_img_toolbox.set_size(160,160) self.MainMenu2_img_toolbox.center() self.MainMenu2_img_toolbox.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TOOLS.jpg") self.MainMenu2_img_toolbox.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_toolbox.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_toolbox) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("工具箱") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_toolbox) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("工具箱") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #设置 self.MainMenu2_setting = self.MainMenu2.add_tile(6, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_setting = lv.img(self.MainMenu2_setting) - self.MainMenu2_img_setting.set_size(128, 128) + self.MainMenu2_img_setting.set_size(160,160) self.MainMenu2_img_setting.center() self.MainMenu2_img_setting.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_SETTINGS.jpg") self.MainMenu2_img_setting.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_setting.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_setting) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("设置") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_setting) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("设置") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #体温测量 self.MainMenu2_temperature = self.MainMenu2.add_tile(7, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_temperature = lv.img(self.MainMenu2_temperature) - self.MainMenu2_img_temperature.set_size(128, 128) + self.MainMenu2_img_temperature.set_size(160,160) self.MainMenu2_img_temperature.center() self.MainMenu2_img_temperature.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_TEMPERATURE.jpg") self.MainMenu2_img_temperature.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_temperature.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_temperature) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("体温") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_temperature) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("体温") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) #微聊 self.MainMenu2_wechat = self.MainMenu2.add_tile(8, 0, lv.DIR.LEFT | lv.DIR.RIGHT) self.MainMenu2_img_wechat = lv.img(self.MainMenu2_wechat) - self.MainMenu2_img_wechat.set_size(128, 128) + self.MainMenu2_img_wechat.set_size(160,160) self.MainMenu2_img_wechat.center() self.MainMenu2_img_wechat.set_src("E:/static/main_menu/main_menu2/IMAGE_ONE_PAGE_WECHAT.jpg") self.MainMenu2_img_wechat.add_flag(lv.obj.FLAG.CLICKABLE) self.MainMenu2_img_wechat.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) - self.label = lv.label(self.MainMenu2_wechat) - self.label.set_pos(0, 280) - self.label.set_size(240, 40) - self.label.set_text("微聊") - self.label.set_long_mode(lv.label.LONG.WRAP) - self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) - self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + # self.label = lv.label(self.MainMenu2_wechat) + # self.label.set_pos(0, 280) + # self.label.set_size(240, 40) + # self.label.set_text("微聊") + # self.label.set_long_mode(lv.label.LONG.WRAP) + # self.label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + # self.label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) @@ -441,7 +441,7 @@ class MainMenu2(): def img_cb(self, e, msg): print("MainMenu2:img_cb:{}".format(msg)) EventMesh.publish("load_screen", {"screen": "{}".format(msg)}) - + diff --git a/3.code/1.watch/2.code/ui_setting.py b/3.code/1.watch/2.code/ui_setting.py new file mode 100644 index 00000000..1dfac3d8 --- /dev/null +++ b/3.code/1.watch/2.code/ui_setting.py @@ -0,0 +1,1272 @@ + +import lvgl as lv +import ql_fs +from ext import EventMesh +from misc import Power +from ext.ui import style_screen,style_font_youyuan_20,ContStyle,style_btn,style_img,Screen,style_contact_btn + +# -------------------------------------------setting screen---------------------------------------------------------- + +style_bar = lv.style_t() +style_bar.init() +style_bar.set_radius(10) +style_bar.set_bg_color(lv.color_make(0xA0, 0xA0, 0xA0)) +style_bar.set_bg_grad_color(lv.color_make(0xA0, 0xA0, 0xA0)) +style_bar.set_bg_grad_dir(lv.GRAD_DIR.VER) +style_bar.set_bg_opa(60) +style_bar.set_pad_left(0) +style_bar.set_pad_right(0) +style_bar.set_pad_top(0) +style_bar.set_pad_bottom(0) + +style_volume_btn = lv.style_t() +style_volume_btn.init() +style_volume_btn.set_shadow_opa(0) +style_volume_btn.set_border_width(0) +style_volume_btn.set_bg_color(lv.color_make(0x80, 0x80, 0x80)) + +style_bar_indic = lv.style_t() +style_bar_indic.init() +style_bar_indic.set_radius(10) +style_bar_indic.set_bg_color(lv.color_make(0xff, 0x61, 0x3a)) +style_bar_indic.set_bg_grad_color(lv.color_make(0xff, 0x61, 0x3a)) +style_bar_indic.set_bg_grad_dir(lv.GRAD_DIR.VER) +style_bar_indic.set_bg_opa(255) + +setting_cont_y = 0 +setting_screen = lv.obj() +setting = lv.obj(setting_screen) +setting.center() +setting.set_size(240, 320) +setting.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +setting_title = lv.label(setting) +setting_title.set_pos(0, 10) +setting_title.set_size(240, 40) +setting_title.set_text("设置") +setting_title.set_long_mode(lv.label.LONG.WRAP) +setting_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +setting_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +setting_cont = lv.obj(setting) +setting_cont.set_pos(0, 50) +setting_cont.set_size(240, 270) +setting_cont_style = ContStyle() +setting_cont.add_style( + setting_cont_style.style_cont(0, lv.color_make(0x00, 0x00, 0x00), lv.color_make(0x00, 0x00, 0x00), 255), + lv.PART.MAIN | lv.STATE.DEFAULT) + +# setting_language = lv.btn(setting_cont) +# setting_language.set_pos(0, setting_cont_y) +# setting_language.set_size(240, 54) +# setting_language_label = lv.label(setting_language) +# setting_language_label.set_text("语言设置") +# setting_language.set_style_pad_all(0, lv.STATE.DEFAULT) +# setting_language_label.align(lv.ALIGN.LEFT_MID, 70, 0) +# setting_language_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +# setting_language_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +# setting_language.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +# setting_language_img = lv.img(setting_cont) +# setting_language_img.set_pos(10, setting_cont_y) +# setting_language_img.set_size(47, 47) +# setting_language_img.add_flag(lv.obj.FLAG.CLICKABLE) +# setting_language_img.set_src("E:/static/menu_language.jpg") +# setting_language_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +#setting_cont_y += 60 + +setting_dialswitch = lv.btn(setting_cont) +setting_dialswitch.set_pos(0, setting_cont_y) +setting_dialswitch.set_size(240, 60) +setting_dialswitch_label = lv.label(setting_dialswitch) +setting_dialswitch_label.set_text("表盘切换") +setting_dialswitch.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_dialswitch_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_dialswitch_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_dialswitch_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_dialswitch.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_dialswitch_img = lv.img(setting_cont) +setting_dialswitch_img.set_pos(10, setting_cont_y) +setting_dialswitch_img.set_size(47, 47) +setting_dialswitch_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_dialswitch_img.set_src("E:/static/menu_watch_switch.jpg") +setting_dialswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+=60 + + +# setting_themeswitch = lv.btn(setting_cont) +# setting_themeswitch.set_pos(0, 120) +# setting_themeswitch.set_size(240, 54) +# setting_themeswitch_label = lv.label(setting_themeswitch) +# setting_themeswitch_label.set_text("主题切换") +# setting_themeswitch.set_style_pad_all(0, lv.STATE.DEFAULT) +# setting_themeswitch_label.align(lv.ALIGN.LEFT_MID, 70, 0) +# setting_themeswitch_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +# setting_themeswitch_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +# setting_themeswitch.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +# setting_themeswitch_img = lv.img(setting_cont) +# setting_themeswitch_img.set_pos(10, 120) +# setting_themeswitch_img.set_size(47, 47) +# setting_themeswitch_img.add_flag(lv.obj.FLAG.CLICKABLE) +# setting_themeswitch_img.set_src("E:/static/menu_theme_switch.jpg") +# setting_themeswitch_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +#setting_cont_y+=60 + +setting_imei = lv.btn(setting_cont) +setting_imei.set_pos(0, setting_cont_y) +setting_imei.set_size(240, 60) +setting_imei_label = lv.label(setting_imei) +setting_imei_label.set_text("设备IMEI号") +setting_imei.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_imei_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_imei_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_imei_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_imei.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_imei_img = lv.img(setting_cont) +setting_imei_img.set_pos(10, setting_cont_y) +setting_imei_img.set_size(47, 47) +setting_imei_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_imei_img.set_src("E:/static/menu_imei_qrcode.jpg") +setting_imei_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+=60 + +setting_app = lv.btn(setting_cont) +setting_app.set_pos(0, setting_cont_y) +setting_app.set_size(240, 60) +setting_app_label = lv.label(setting_app) +setting_app_label.set_text("手机安装APP") +setting_app.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_app_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_app_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_app_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_app.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_app_img = lv.img(setting_cont) +setting_app_img.set_pos(10, setting_cont_y) +setting_app_img.set_size(47, 47) +setting_app_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_app_img.set_src("E:/static/menu_app_qrcode.jpg") +setting_app_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+=60 + +setting_bright = lv.btn(setting_cont) +setting_bright.set_pos(0, setting_cont_y) +setting_bright.set_size(240, 60) +setting_bright_label = lv.label(setting_bright) +setting_bright_label.set_text("屏幕调节") +setting_bright.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_bright_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_bright_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_bright_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_bright.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_bright_img = lv.img(setting_cont) +setting_bright_img.set_pos(10, setting_cont_y) +setting_bright_img.set_size(47, 47) +setting_bright_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_bright_img.set_src("E:/static/menu_bright.jpg") +setting_bright_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+60 + +setting_volume = lv.btn(setting_cont) +setting_volume.set_pos(0, setting_cont_y) +setting_volume.set_size(240, 60) +setting_volume_label = lv.label(setting_volume) +setting_volume_label.set_text("铃声") +setting_volume.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_volume_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_volume_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_volume_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_volume.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_volume_img = lv.img(setting_cont) +setting_volume_img.set_pos(10, setting_cont_y) +setting_volume_img.set_size(47, 47) +setting_volume_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_volume_img.set_src("E:/static/menu_volume.jpg") +setting_volume_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+=60 + +setting_restore = lv.btn(setting_cont) +setting_restore.set_pos(0, setting_cont_y) +setting_restore.set_size(240, 60) +setting_restore_label = lv.label(setting_restore) +setting_restore_label.set_text("恢复出厂设置") +setting_restore.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_restore_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_restore_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_restore_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_restore.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_restore_img = lv.img(setting_cont) +setting_restore_img.set_pos(10, setting_cont_y) +setting_restore_img.set_size(47, 47) +setting_restore_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_restore_img.set_src("E:/static/menu_restore.jpg") +setting_restore_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+=60 + +setting_poweroff = lv.btn(setting_cont) +setting_poweroff.set_pos(0, setting_cont_y) +setting_poweroff.set_size(240, 60) +setting_poweroff_label = lv.label(setting_poweroff) +setting_poweroff_label.set_text("关机") +setting_poweroff.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_poweroff_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_poweroff_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_poweroff.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_poweroff_img = lv.img(setting_cont) +setting_poweroff_img.set_pos(10, setting_cont_y) +setting_poweroff_img.set_size(47, 47) +setting_poweroff_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_poweroff_img.set_src("E:/static/menu_poweroff.jpg") +setting_poweroff_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+=60 + +setting_version = lv.btn(setting_cont) +setting_version.set_pos(0, setting_cont_y) +setting_version.set_size(240, 60) +setting_version_label = lv.label(setting_version) +setting_version_label.set_text("关于设备") +setting_version.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_version_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_version_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_version_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_version.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_version_img = lv.img(setting_cont) +setting_version_img.set_pos(10, setting_cont_y) +setting_version_img.set_size(47, 47) +setting_version_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_version_img.set_src("E:/static/menu_version.jpg") +setting_version_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_cont_y+=60 + +setting_update = lv.btn(setting_cont) +setting_update.set_pos(0, setting_cont_y) +setting_update.set_size(240, 60) +setting_update_label = lv.label(setting_update) +setting_update_label.set_text("系统升级") +setting_update.set_style_pad_all(0, lv.STATE.DEFAULT) +setting_update_label.align(lv.ALIGN.LEFT_MID, 70, 0) +setting_update_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT) +setting_update_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_update.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +setting_update_img = lv.img(setting_cont) +setting_update_img.set_pos(10, setting_cont_y) +setting_update_img.set_size(47, 47) +setting_update_img.add_flag(lv.obj.FLAG.CLICKABLE) +setting_update_img.set_src("E:/static/menu_upgrade.jpg") +setting_update_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + +class SettingScreen(Screen): + NAME = "setting" + + def __init__(self): + super().__init__() + self.meta = setting_screen + # setting_language.add_event_cb(lambda e: self.load_screen(e, {"screen": "language"}), lv.EVENT.CLICKED, None) + setting_dialswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "dialswitch"}), lv.EVENT.CLICKED, None) + # setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.CLICKED, None) + setting_imei.add_event_cb(lambda e: self.load_screen(e, {"screen": "imei"}), lv.EVENT.CLICKED, None) + setting_app.add_event_cb(lambda e: self.load_screen(e, {"screen": "app"}), lv.EVENT.CLICKED, None) + setting_bright.add_event_cb(lambda e: self.load_screen(e, {"screen": "brightness"}), lv.EVENT.CLICKED, None) + setting_volume.add_event_cb(lambda e: self.load_screen(e, {"screen": "volume"}), lv.EVENT.CLICKED, None) + setting_restore.add_event_cb(lambda e: self.load_screen(e, {"screen": "restore"}), lv.EVENT.CLICKED, None) + setting_poweroff.add_event_cb(lambda e: self.load_screen(e, {"screen": "poweroff"}), lv.EVENT.CLICKED, None) + setting_update.add_event_cb(lambda e: self.load_screen(e, {"screen": "update"}), lv.EVENT.CLICKED, None) + setting_version.add_event_cb(lambda e: self.load_screen(e, {"screen": "version"}), lv.EVENT.CLICKED, None) + + # img regist btton + # setting_language.add_event_cb(lambda e: self.load_screen(e, {"screen": "language"}), lv.EVENT.CLICKED, None) + setting_dialswitch_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "dialswitch"}), lv.EVENT.CLICKED, None) + # setting_themeswitch.add_event_cb(lambda e: self.load_screen(e, {"screen": "themeswitch"}), lv.EVENT.CLICKED, None) + setting_imei_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "imei"}), lv.EVENT.CLICKED, None) + setting_app_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "app"}), lv.EVENT.CLICKED, None) + setting_bright_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "brightness"}), lv.EVENT.CLICKED, None) + setting_volume_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "volume"}), lv.EVENT.CLICKED, None) + setting_restore_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "restore"}), lv.EVENT.CLICKED, None) + setting_poweroff_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "poweroff"}), lv.EVENT.CLICKED, None) + setting_update_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "update"}), lv.EVENT.CLICKED, None) + setting_version_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "version"}), lv.EVENT.CLICKED, None) + + def done_bottom_to_top(self): + #上滑添加动画切屏:动画类型,时间,延迟,auto_del + EventMesh.publish("load_screen", {"screen": "setting2"}) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "main_menu"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) +################################################################## +# -------------------------------------------language screen---------------------------------------------------------- +language_screen = lv.obj() +language = lv.obj(language_screen) +language.center() +language.set_size(240, 320) +language.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +language_title = lv.label(language) +language_title.set_pos(0, 10) +language_title.set_size(240, 40) +language_title.set_text("语言设置") +language_title.set_long_mode(lv.label.LONG.WRAP) +language_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +language_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +language_english_btn = lv.btn(language) +language_english_btn.set_size(240,50) +language_english_btn.set_pos(0, 60) +language_english_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) +language_english_btn.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +language_english_btn_label = lv.label(language_english_btn) +language_english_btn_label.set_text("English") +language_english_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0) +language_english_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +language_chinese_btn = lv.btn(language) +language_chinese_btn.set_size(240,50) +language_chinese_btn.set_pos(0, 120) +language_chinese_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) +language_chinese_btn.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +language_chinese_btn_label = lv.label(language_chinese_btn) +language_chinese_btn_label.set_text("简体中文") +language_chinese_btn_label.align(lv.ALIGN.LEFT_MID, 10, 0) +language_chinese_btn_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +# -------------------------------------------dialswitch screen---------------------------------------------------------- +dialswitch_screen = lv.obj() +dialswitch = lv.obj(dialswitch_screen) +dialswitch.center() +dialswitch.set_size(240, 320) +dialswitch.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +dialswitch_title = lv.label(dialswitch) +dialswitch_title.set_pos(0, 10) +dialswitch_title.set_size(240, 40) +dialswitch_title.set_text("表盘切换") +dialswitch_title.set_long_mode(lv.label.LONG.WRAP) +dialswitch_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +dialswitch_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +dialswitch_btn1 = lv.btn(dialswitch) +dialswitch_btn1.set_size(240,54) +dialswitch_btn1.set_pos(0, 50) +dialswitch_btn1.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) +dialswitch_btn1.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +dialswitch_btn1_label = lv.label(dialswitch_btn1) +dialswitch_btn1_label.set_text("表盘1") +dialswitch_btn1_label.align(lv.ALIGN.LEFT_MID, 10, 0) +dialswitch_btn1_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +dialswitch_btn2 = lv.btn(dialswitch) +dialswitch_btn2.set_size(240,54) +dialswitch_btn2.set_pos(0, 104) +dialswitch_btn2.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) +dialswitch_btn2.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +dialswitch_btn2_label = lv.label(dialswitch_btn2) +dialswitch_btn2_label.set_text("表盘2") +dialswitch_btn2_label.align(lv.ALIGN.LEFT_MID, 10, 0) +dialswitch_btn2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +btn1_switch = lv.switch(dialswitch_btn1) +btn1_switch.set_pos(185, 3) +btn1_switch.set_size(10, 10) +btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) +btn1_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) +btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) + +btn2_switch = lv.switch(dialswitch_btn2) +btn2_switch.set_pos(185, 3) +btn2_switch.set_size(10, 10) +btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) +btn2_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) +btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) + +# -------------------------------------------menustyle screen---------------------------------------------------------- +menustyle_screen = lv.obj() +menustyle = lv.obj(menustyle_screen) +menustyle.center() +menustyle.set_size(240, 320) +menustyle.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +menustyle_title = lv.label(menustyle) +menustyle_title.set_pos(0, 10) +menustyle_title.set_size(240, 40) +menustyle_title.set_text("主菜单风格") +menustyle_title.set_long_mode(lv.label.LONG.WRAP) +menustyle_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +menustyle_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +menustyle_btn1 = lv.btn(menustyle) +menustyle_btn1.set_size(240,54) +menustyle_btn1.set_pos(0, 50) +menustyle_btn1.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) +menustyle_btn1.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +menustyle_btn1_label = lv.label(menustyle_btn1) +menustyle_btn1_label.set_text("四宫格") +menustyle_btn1_label.align(lv.ALIGN.LEFT_MID, 10, 0) +menustyle_btn1_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +menu_btn1_switch = lv.switch(menustyle_btn1) +menu_btn1_switch.set_pos(185, 3) +menu_btn1_switch.set_size(10, 10) +menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) +menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) +menu_btn1_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) + +menustyle_btn2 = lv.btn(menustyle) +menustyle_btn2.set_size(240,54) +menustyle_btn2.set_pos(0, 104) +menustyle_btn2.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.PRESSED) +menustyle_btn2.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT) +menustyle_btn2_label = lv.label(menustyle_btn2) +menustyle_btn2_label.set_text("单页") +menustyle_btn2_label.align(lv.ALIGN.LEFT_MID, 10, 0) +menustyle_btn2_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + +menu_btn2_switch = lv.switch(menustyle_btn2) +menu_btn2_switch.set_pos(185, 3) +menu_btn2_switch.set_size(10, 10) +menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.MAIN | lv.PART.INDICATOR) +menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0x00, 0x00),lv.PART.KNOB | lv.STATE.CHECKED) +menu_btn2_switch.set_style_bg_color(lv.color_make(0xff, 0xff, 0xff),lv.PART.KNOB) + + +# -------------------------------------------imei screen---------------------------------------------------------- +imei_screen = lv.obj() +imei = lv.obj(imei_screen) +imei.center() +imei.set_size(240, 320) +imei.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +bg_color = lv.palette_lighten(lv.PALETTE.LIGHT_BLUE, 5) +fg_color = lv.palette_darken(lv.PALETTE.BLUE, 4) + +imei_qr = lv.qrcode(imei, 150, fg_color, bg_color) +imei_qr.center() +# Add a border with bg_color +imei_qr.set_style_border_color(bg_color, 0) +imei_qr.set_style_border_width(5, 0) +imei_qr_data = str("867387060319145") +imei_qr.update(imei_qr_data,len(imei_qr_data)) + +imei_label = lv.label(imei) +imei_label.set_pos(0, 280) +imei_label.set_size(240, 20) +imei_label.set_text("867387060319145") +imei_label.set_long_mode(lv.label.LONG.WRAP) +imei_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +imei_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + +# -------------------------------------------app screen---------------------------------------------------------- +#app_screen = lv.obj() +app_screen = lv.obj() +app_screen.center() +app_screen.set_size(240, 320) +app_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +app_img = lv.img(app_screen) +app_img.set_pos(int(20),int(40)) +app_img.set_size(200,200) +app_img.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) +app_img.add_flag(lv.obj.FLAG.CLICKABLE) +app_img.set_src("E:/static/IMAGE_APP_QR_CODE.jpg") +app_img.add_style(style_screen, lv.PART.MAIN|lv.STATE.DEFAULT) +# app_qr = lv.qrcode(imei, 150, fg_color, bg_color) +# app_qr.center() +# Add a border with bg_color +# app_qr.set_style_border_color(bg_color, 0) +# app_qr.set_style_border_width(5, 0) +# app_qr_data = str("https://fangzoudiu.xcloudtech.com/xiao_jian") +# app_qr.update(app_qr_data,len(app_qr_data)) + +app_label = lv.label(app_screen) +app_label.set_pos(0, 280) +app_label.set_size(240, 20) +app_label.set_text("867387060319145") +app_label.set_long_mode(lv.label.LONG.WRAP) +app_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +app_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +# -------------------------------------------brightness screen---------------------------------------------------------- +brightness_screen = lv.obj() +brightness = lv.obj(brightness_screen) +brightness.center() +brightness.set_size(240, 320) +brightness.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +brightness_title = lv.label(brightness) +brightness_title.set_pos(0, 10) +brightness_title.set_size(240, 40) +brightness_title.set_text("屏幕调节") +brightness_title.set_long_mode(lv.label.LONG.WRAP) +brightness_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +brightness_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +brightness_label1 = lv.label(brightness) +brightness_label1.set_pos(10, 60) +brightness_label1.set_size(50, 40) +brightness_label1.set_text("亮度") +brightness_label1.set_long_mode(lv.label.LONG.WRAP) +brightness_label1.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0) +brightness_label1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + +brightness_bar = lv.bar(brightness) +brightness_bar.set_pos(20, 120) +brightness_bar.set_size(200, 15) +brightness_bar.set_style_anim_time(1000, lv.PART.INDICATOR | lv.STATE.DEFAULT) +brightness_bar.set_mode(lv.bar.MODE.NORMAL) +brightness_bar.set_value(50, lv.ANIM.OFF) +brightness_bar.add_style(style_bar, lv.PART.MAIN | lv.STATE.DEFAULT) +brightness_bar.add_style(style_bar_indic, lv.PART.INDICATOR | lv.STATE.DEFAULT) + +brightness_add_imgbtn = lv.img(brightness) +brightness_add_imgbtn.set_pos(50, 250) +brightness_add_imgbtn.set_size(34, 30) +brightness_add_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) +brightness_add_imgbtn.set_src("E:/static/time_up.jpg") +brightness_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +brightness_reduce_imgbtn = lv.img(brightness) +brightness_reduce_imgbtn.set_pos(150, 250) +brightness_reduce_imgbtn.set_size(34, 30) +brightness_reduce_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE) +brightness_reduce_imgbtn.set_src("E:/static/time_down.jpg") +brightness_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +# -------------------------------------------volume screen---------------------------------------------------------- +volume_screen = lv.obj() +volume = lv.obj(volume_screen) +volume.center() +volume.set_size(240, 320) +volume.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +volume_phone_btn = lv.btn(volume) +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) +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) +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() +phonering = lv.obj(phonering_screen) +phonering.center() +phonering.set_size(240, 320) +phonering.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +phonering_title = lv.label(phonering) +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) +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) +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) +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.jpg") +phonering_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +phonering_add_imgbtn = lv.img(phonering) +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.jpg") + +phonering_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +# -------------------------------------------alarmvolume screen---------------------------------------------------------- +alarmvolume_screen = lv.obj() +alarmvolume = lv.obj(alarmvolume_screen) +alarmvolume.center() +alarmvolume.set_size(240, 320) +alarmvolume.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +alarmvolume_title = lv.label(alarmvolume) +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) +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) +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) +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.jpg") + +alarmvolume_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +alarmvolume_add_imgbtn = lv.img(alarmvolume) +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.jpg") + +alarmvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +# -------------------------------------------msgvolume screen---------------------------------------------------------- +msgvolume_screen = lv.obj() +msgvolume = lv.obj(msgvolume_screen) +msgvolume.center() +msgvolume.set_size(240, 320) +msgvolume.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +msgvolume_title = lv.label(msgvolume) +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) +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) +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) +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.jpg") + +msgvolume_reduce_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +msgvolume_add_imgbtn = lv.img(msgvolume) +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.jpg") + +msgvolume_add_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + +# -------------------------------------------restore screen---------------------------------------------------------- +restore_screen = lv.obj() +restore = lv.obj(restore_screen) +restore.center() +restore.set_size(240, 320) +restore.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +restore_label = lv.label(restore) +restore_label.set_pos(0, 100) +restore_label.set_size(240, 40) +restore_label.set_text("恢复出厂设置?") +restore_label.set_long_mode(lv.label.LONG.WRAP) +restore_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +restore_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +restore_confirm = lv.label(restore) +restore_confirm.set_text("确认") +restore_confirm.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +restore_confirm.set_size(120, 40) +restore_confirm.set_pos(0,180) +restore_confirm.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +restore_confirm.add_flag(lv.obj.FLAG.CLICKABLE) +restore_confirm.set_ext_click_area(20) + +restore_cancel = lv.label(restore) +restore_cancel.set_text("返回") +restore_cancel.set_size(120, 40) +restore_cancel.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +restore_cancel.set_pos(120,180) +restore_cancel.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +restore_cancel.add_flag(lv.obj.FLAG.CLICKABLE) +restore_cancel.set_ext_click_area(20) + + + +# -------------------------------------------poweroff screen---------------------------------------------------------- +poweroff_screen = lv.obj() +poweroff = lv.obj(poweroff_screen) +poweroff.center() +poweroff.set_size(240, 320) +poweroff.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +poweroff_img = lv.img(poweroff) +poweroff_img.set_pos(100, 30) +poweroff_img.set_size(61, 61) +poweroff_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +poweroff_img.set_src("E:/static/poweroff_icon.jpg") + +poweroff_label = lv.label(poweroff) +poweroff_label.set_text("是否关机?") +poweroff_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +poweroff_label.set_size(240, 20) +poweroff_label.set_pos(0,120) +poweroff_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +poweroff_confirm = lv.img(poweroff) +poweroff_confirm.set_size(176, 46) +poweroff_confirm.set_pos(32, 150) +poweroff_confirm.set_src("E:/static/off_icon.jpg") +poweroff_confirm.add_flag(lv.obj.FLAG.CLICKABLE) +poweroff_confirm.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) +poweroff_confirm.set_ext_click_area(20) + +poweroff_confirm_label = lv.label(poweroff_confirm) +poweroff_confirm_label.set_text("关机") +poweroff_confirm_label.align(lv.ALIGN.CENTER, 0, 0) +poweroff_confirm_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +poweroff_return = lv.img(poweroff) +poweroff_return.set_size(176, 46) +poweroff_return.set_pos(32, 210) +poweroff_return.set_src("E:/static/cancel_icon.jpg") +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) +poweroff_return_label.set_text("返回") +poweroff_return_label.align(lv.ALIGN.CENTER, 0, 0) +poweroff_return_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +poweroff_return.set_ext_click_area(20) + +# -------------------------------------------version screen---------------------------------------------------------- +version_screen = lv.obj() +version = lv.obj(version_screen) +version.center() +version.set_size(240, 320) +version.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +version_msg = """Software Version: +MMI +Version:UIX8910_C55_V +1.0_Release +Build Time: +2-17-2023 +9:32:5 +IMEI: +867387060319145 +""" + +version_label = lv.label(version) +version_label.set_pos(0, 0) +version_label.set_size(240, 320) +version_label.set_long_mode(lv.label.LONG.WRAP) +version_label.set_text(version_msg) + +version_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +version_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + +# -------------------------------------------update screen---------------------------------------------------------- +update_screen = lv.obj() +update = lv.obj(update_screen) +update.center() +update.set_size(240, 320) +update.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + +update_title = lv.label(update) +update_title.set_pos(0, 10) +update_title.set_size(240, 40) +update_title.set_text("系统更新") +update_title.set_long_mode(lv.label.LONG.WRAP) +update_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +update_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +update_label = lv.label(update) +update_label.set_text(" 检查版本更新!/n 请稍后...") +update_label.set_style_text_align(lv.TEXT_ALIGN.LEFT, 0) +update_label.set_size(240, 50) +update_label.set_pos(0,50) +update_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + +update_return = lv.label(update) +update_return.set_text("返回") +update_return.set_size(240, 40) +update_return.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +update_return.set_pos(0,240) +update_return.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) +update_return.add_flag(lv.obj.FLAG.CLICKABLE) + +class RestoreScreen(Screen): + NAME = "restore" + + def __init__(self): + super().__init__() + self.meta = restore_screen + restore_confirm.add_event_cb(lambda e: self.confirm(e),lv.EVENT.CLICKED, None) + restore_cancel.add_event_cb(lambda e: self.concel(e),lv.EVENT.CLICKED, None) + + def confirm(self, e): + global ret + ret = 0 + ret = ql_fs.path_exists("/usr/phonebook.json") + if ret == True : + ql_fs.rmdirs("/usr/phonebook.json") + else: + pass + Power.powerRestart() + # EventMesh.publish("load_screen", {"screen": "setting"}) + + def concel(self, e): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class UpdateScreen(Screen): + NAME = "update" + + def __init__(self): + super().__init__() + self.meta = update_screen + update_return.add_event_cb(lambda e: self.back(e),lv.EVENT.CLICKED, None) + + def back(self,e): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class VersionScreen(Screen): + NAME = "version" + + def __init__(self): + super().__init__() + self.meta = version_screen + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class PoweroffScreen(Screen): + NAME = "poweroff" + + def __init__(self): + super().__init__() + self.meta = poweroff_screen + poweroff_confirm.add_event_cb(lambda e: self.confirm(e),lv.EVENT.CLICKED, None) + poweroff_return.add_event_cb(lambda e: self.concel(e),lv.EVENT.CLICKED, None) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def confirm(self, e): + Power.powerDown() + # EventMesh.publish("load_screen", {"screen": "setting"}) + + def concel(self, e): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class LanguageScreen(Screen): + NAME = "language" + + def __init__(self): + super().__init__() + self.meta = language_screen + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class DialswitchScreen(Screen): + NAME = "dialswitch" + + def __init__(self): + super().__init__() + self.meta = dialswitch_screen + dialswitch_btn1.add_event_cb(lambda e: self.watchface01(e), + lv.EVENT.PRESSED, None) + + dialswitch_btn2.add_event_cb(lambda e: self.watchface02(e), + lv.EVENT.PRESSED, None) + + def watchface01(self,e): + #watchface2.add_flag(lv.obj.FLAG.HIDDEN) + #watchface01.clear_flag(lv.obj.FLAG.HIDDEN) + btn1_switch.add_state(lv.STATE.CHECKED) + btn2_switch.clear_state(lv.STATE.CHECKED) + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def watchface02(self,e): + #watchface01.add_flag(lv.obj.FLAG.HIDDEN) + #watchface2.clear_flag(lv.obj.FLAG.HIDDEN) + btn1_switch.clear_state(lv.STATE.CHECKED) + btn2_switch.add_state(lv.STATE.CHECKED) + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class ThemeswitchScreen(Screen): + NAME = "themeswitch" + + def __init__(self): + super().__init__() + self.meta = menustyle_screen + menustyle_btn1.add_event_cb(lambda e: self.fun1(e), + lv.EVENT.PRESSED, None) + + menustyle_btn2.add_event_cb(lambda e: self.fun2(e), + lv.EVENT.PRESSED, None) + + def fun1(self,e): + menu_btn1_switch.add_state(lv.STATE.CHECKED) + menu_btn2_switch.clear_state(lv.STATE.CHECKED) + EventMesh.publish("change_style", "MainMenu1") + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def fun2(self,e): + menu_btn1_switch.clear_state(lv.STATE.CHECKED) + menu_btn2_switch.add_state(lv.STATE.CHECKED) + EventMesh.publish("change_style", "MainMenu2") + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class ImeiScreen(Screen): + NAME = "imei" + + def __init__(self): + super().__init__() + self.meta = imei_screen + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class AppScreen(Screen): + NAME = "app" + + def __init__(self): + super().__init__() + self.meta = app_screen + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class BrightnessScreen(Screen): + NAME = "brightness" + + def __init__(self): + super().__init__() + self.level = 0 + self.meta = brightness_screen + brightness_add_imgbtn.add_event_cb(lambda e: self.add_level(e), + lv.EVENT.CLICKED, None) + brightness_reduce_imgbtn.add_event_cb(lambda e: self.reduce_level(e), + lv.EVENT.CLICKED, None) + + def add_level(self, e): + EventMesh.publish("push_add_brightness_level") + self.level = EventMesh.publish("get_brightness_level") + self.show_bar() + + def reduce_level(self, e): + EventMesh.publish("push_reduce_brightness_level") + self.level = EventMesh.publish("get_brightness_level") + self.show_bar() + + def show_bar(self): + brightness_bar.set_value((100 // 7) * self.level, lv.ANIM.OFF) + + def initialization(self): + self.level = EventMesh.publish("get_brightness_level") + self.show_bar() + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + +class VolumeScreen(Screen): + NAME = "volume" + + def __init__(self): + super().__init__() + self.meta = volume_screen + volume_phone_btn.add_event_cb(lambda e: self.load_screen(e, {"screen": "phonering"}), lv.EVENT.CLICKED, None) + volume_message_btn.add_event_cb(lambda e: self.load_screen(e, {"screen": "msgvolume"}), lv.EVENT.CLICKED, None) + volume_alarm_btn.add_event_cb(lambda e: self.load_screen(e, {"screen": "alarmvolume"}), lv.EVENT.CLICKED, None) + + def done_return(self): + EventMesh.publish("load_screen", {"screen": "setting"}) + + def btn1_release(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + + +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: self.add_level(e), + lv.EVENT.CLICKED, None) + phonering_reduce_imgbtn.add_event_cb(lambda e: 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": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + + +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: self.add_level(e), + lv.EVENT.CLICKED, None) + alarmvolume_reduce_imgbtn.add_event_cb(lambda e: 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": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) + + + +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: self.add_level(e), + lv.EVENT.CLICKED, None) + msgvolume_reduce_imgbtn.add_event_cb(lambda e: 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": "watchface"}) + + def btn8_press(self): + EventMesh.publish("load_screen", {"screen": "watchface"}) \ No newline at end of file