From: d15521469561 Date: Thu, 6 Apr 2023 09:07:37 +0000 (+0800) Subject: 1.添加闹钟 X-Git-Url: http://git.snicker.com.cn/img/static/gitweb.css?a=commitdiff_plain;h=97f6bacf84236d53dbf5b2b53d6be6dce54095b5;p=mirrors%2FASR1603_G5.git 1.添加闹钟 2.修改天气图标名称 --- diff --git a/3.code/1.watch/2.code/main_1.py b/3.code/1.watch/2.code/main_1.py index e0e2efa1..068dda76 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,PHL_ProtoCol + from ext.protocol import LK_ProtoCol,PING_ProtoCol, CR_ProtoCol,KA_ProtoCol,FIND_ProtoCol,POWEROFF_ProtoCol,ProtoColResolver import ext.mgr as mgr import ext.ui as _ui from ext.mgr import ConfigStoreManager, DeviceInfoManager, LocationManager, SockManager, \ @@ -53,10 +53,11 @@ if __name__ == '__main__': from ext.appAlipay import Alipay ,AlipayOpenScreen,Alipay_1_1,Alipay_invite,Alipay_inviting,\ Alipay_success,Alipay_paycode,Alipay_pay_success,Alipay_collect,Alipay_parent from ext.ui_WatchFaceScreen import WatchFaceScreen + from ext.alarm import ClkListScreen,ClockManager,NewEditClk,CLKTimeScreen,ClkPeriod from ext.ui_main_menu import MainMenuScreen from ext.appWechat import WechatScreen,TK_ProtoCol,MESSAGE_ProtoCol import ext.ui_setting as _ui_setting - from usr.test_sms import WeatherScreen,WT_ProtoCol + from usr.test_sms import WT_ProtoCol,UD_ProtoCol,getWeatherDataManager,PHL_ProtoCol #from usr.ui_wechat import WechatScreen,TK_ProtoCol btn_device = BtnDevice(tp_cst816) @@ -74,11 +75,16 @@ if __name__ == '__main__': ui.add_screen(_ui.AlarmScreen()) ui.add_screen(_ui.CountdownScreen()) ui.add_screen(_ui.StopwatchScreen()) - ui.add_screen(WeatherScreen()) + ui.add_screen(_ui.WeatherScreen()) ui.add_screen(_ui.Spo2Screen()) ui.add_screen(_ui.TemperatureScreen()) ui.add_screen(_ui.ContactsScreen()) - ui.add_screen(WechatScreen()) + ui.add_screen(WechatScreen()) + ui.add_screen(ClkListScreen()) + + ui.add_screen(NewEditClk()) + ui.add_screen(CLKTimeScreen()) + ui.add_screen(ClkPeriod()) # ui.add_screen(_ui_setting.LanguageScreen()) ui.add_screen(_ui_setting.DialswitchScreen()) @@ -133,7 +139,9 @@ if __name__ == '__main__': app.append_manager(mgr.MsgManager()) app.append_manager(MsgdetailManager()) app.append_manager(mgr.CallLogManager()) + app.append_manager(getWeatherDataManager()) app.append_manager(PhoneCallingManager()) + app.append_manager(ClockManager()) pcr = ProtoColResolver() pcr.add_support(LK_ProtoCol()) diff --git a/3.code/1.watch/2.code/mgr.py b/3.code/1.watch/2.code/mgr.py index 683b0ad7..41fb8696 100644 --- a/3.code/1.watch/2.code/mgr.py +++ b/3.code/1.watch/2.code/mgr.py @@ -663,7 +663,7 @@ class DeviceInfoManager(Abstract): :return: HH:MM 格式 """ rtc_time = self.rtc.datetime() - print("rtc_time:{}".format(rtc_time)) + # print("rtc_time:{}".format(rtc_time)) date = ("%d月%d日" % (rtc_time[1], rtc_time[2])) year = ("%04då¹´" % (rtc_time[0])) week = ("星期%s"%(self.get_week(rtc_time[3]))) diff --git a/3.code/1.watch/2.code/protocol.py b/3.code/1.watch/2.code/protocol.py index e1c232e7..9ba8d1f2 100644 --- a/3.code/1.watch/2.code/protocol.py +++ b/3.code/1.watch/2.code/protocol.py @@ -453,7 +453,39 @@ class PHL_ProtoCol(ProtoCol): EventMesh.publish("set_phonebook_list",[1,phonebook]) EventMesh.publish("contact_updata_list_show") - + +class WT_ProtoCol(ProtoCol): + pass + # """温度数据""" + # TYPE = "WT" + + + # def send(self, event, msg): + # # [SZKW*867387060319491*0008*PHL] + # print("WT_ProtoCol:msg:%s"%(msg)) + # send_data = "SZKW*%s*0003*WT"%(self.imei) + # MD5_SIGN = self.pack_MD5_head(send_data) + # data = "[%s%s,%s]"%(str(MD5_SIGN),msg) + # print("WT_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("WT_ProtoCol RECV msg:%s"%(msg)) + # # UnicodeHexStr_To_Utf8Str(phonebook_tmp) + + + # # EventMesh.publish(constants.PROTOCOL.WT_SEND) + # # EventMesh.publish("set_phonebook_list",[1,phonebook]) + # # EventMesh.publish("contact_updata_list_show") + + class ProtoColResolver(object): def __init__(self): diff --git a/3.code/1.watch/2.code/static/cloudy.jpg b/3.code/1.watch/2.code/static/cloudy.jpg deleted file mode 100644 index aac5b3c8..00000000 Binary files a/3.code/1.watch/2.code/static/cloudy.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/static/fine.jpg b/3.code/1.watch/2.code/static/fine.jpg deleted file mode 100644 index 7531acb8..00000000 Binary files a/3.code/1.watch/2.code/static/fine.jpg and /dev/null differ 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/snow.jpg b/3.code/1.watch/2.code/static/snow.jpg deleted file mode 100644 index 15ecdc97..00000000 Binary files a/3.code/1.watch/2.code/static/snow.jpg and /dev/null differ diff --git a/3.code/1.watch/2.code/test_sms.py b/3.code/1.watch/2.code/test_sms.py index c7129e7f..dd6baf60 100644 --- a/3.code/1.watch/2.code/test_sms.py +++ b/3.code/1.watch/2.code/test_sms.py @@ -210,17 +210,52 @@ class WeatherScreen(Screen): def btn8_press(self): EventMesh.publish("load_screen", {"screen": "watchface"}) +class getWeatherDataManager(Abstract): + # 通话记录 + def __init__(self): + self.date = ""#日期 + self.time = ""#14:41:41 + self.type = 0#天气类型 + self.temp = 0#当前温度 + self.min_temp = 0#最低温度 + self.max_temp = 0#最高温度 + self.city = ""#城市 + + + + + def post_processor_after_instantiation(self): + EventMesh.subscribe("get_weather_data", self.get) + EventMesh.subscribe("set_weather_data", self.set) + + def get(self, event, msg): + return [self.date,self.time,self.type,self.temp,self.min_temp,self.max_temp,self.city] + + def set(self, event, msg): + self.date = msg[0] + self.time = msg[1] + self.type = msg[2] + self.temp = msg[3] + self.min_temp = msg[4] + self.max_temp = msg[5] + self.city = msg[6] + + # def call_usr(self,event,msg): + # content = self.log[msg] + # # 参数1 姓名 参数2 电话 参数3 1/主动呼叫 0别人呼叫 + # EventMesh.publish("call_in", [content[2], content[0], 1]) + class WT_ProtoCol(ProtoCol): - """温度数据""" + """天气数据""" TYPE = "WT" def send(self, event, msg): - # [SZKW*867387060319491*0008*PHL] - send_data = "SZKW*%s*0003*WT"%(self.imei) + # [SZKW*867387060319491*0008*WT] + send_data = "SZKW*%s*003*WT"%(self.imei) MD5_SIGN = self.pack_MD5_head(send_data) data = "[%s%s]"%(str(MD5_SIGN),send_data) print("WT_ProtoCol:send:%s"%(data)) @@ -230,17 +265,199 @@ class WT_ProtoCol(ProtoCol): def recv(self, event, msg): """ - @param event: 温度数据下发 + @param event: T天气温度数据下发 @param msg: 接收到的下行数据 """ + # b'SZKW*860132060004322*0035*WT,23-04-06,14:41:06,b6e0d4c6,1,27,-1,40,6DF157335E02' msg = msg[1:-1] + msg_tmp = msg.decode('ascii') + msg_tmp = msg_tmp.split('WT,') + # print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp)) + msg_tmp = msg_tmp[1] + + print("msg_tmp :%s"%(msg_tmp)) + + msg_date = msg_tmp.split(',')[0] + + msg_time = msg_tmp.split(',')[1] + msg_weather_content = msg_tmp.split(',')[2] + msg_type = msg_tmp.split(',')[3] + msg_temp = msg_tmp.split(',')[4] + msg_min_temp = msg_tmp.split(',')[5] + msg_max_temp = msg_tmp.split(',')[6] + msg_city = msg_tmp.split(',')[7] + + print("msg_date:{} msg_time:{} msg_type:{} msg_temp:{} msg_min_temp:{} msg_max_temp:{} msg_city:{}".format(msg_date,msg_time,msg_type,msg_temp,msg_min_temp,msg_max_temp,msg_city)) print("WT_ProtoCol RECV msg:%s"%(msg)) + # UnicodeHexStr_To_Utf8Str(phonebook_tmp) - # EventMesh.publish(constants.PROTOCOL.WT_SEND) + EventMesh.publish(constants.PROTOCOL.WT_SEND) # EventMesh.publish("set_phonebook_list",[1,phonebook]) # EventMesh.publish("contact_updata_list_show") +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.decode('ascii') + msg_tmp = msg_tmp.split(',') + # print("phonebook:len:{}\r\n data:{}".format(len(msg_tmp),msg_tmp)) + + phonebook = {} + msg_tmp = msg_tmp[1:] + # print("msg_tmp1:{}".format(msg_tmp)) + j = 0 + i = 0 + phonebook_oldtmp = {} + # 0 1 2 3 + for phonebook_tmp in msg_tmp: + j+=1 + # print("phonebook_tmp:{} msg_tmp:{}".format(phonebook_tmp,msg_tmp)) + + if (j%2) == 0: + i+=1 + phonebook_name = UnicodeHexStr_To_Utf8Str(phonebook_tmp) + phonebook_name = "{}:{}".format("%03d"%i,phonebook_name) + phonebook[phonebook_name] = phonebook_oldtmp + + phonebook_oldtmp = phonebook_tmp + print("phonebook_oldtmp!!!:{}".format(str(phonebook_oldtmp))) + # print("phonebook!!!:{}".format(str(phonebook))) + with open("/ext/static/storage_file/phonebook.json","w",encoding="utf-8") as fd: + ujson.dump(phonebook,fd) + print("创建电话簿") + + EventMesh.publish(constants.PROTOCOL.PHL_SEND) + EventMesh.publish("set_phonebook_list",[1,phonebook]) + EventMesh.publish("contact_updata_list_show") + +class UD_ProtoCol(ProtoCol): + """位置信息""" + TYPE = "UD" + def send(self, event, msg): + #"{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3]) + #[6f62cfc40fc50173f9a7b21e87be3424IS*861217001020120*00f6*UD,220726,211210,A,22.649529,N,114.119165,E,0.28,137.4,100.0,8,24,63,119,0,00000000,2,1,460,11,30472,125667122,24,30472,218944048,19,4, + # wifi0,34:93:44:01:28:b9,-74,wifi1,34:20:03:96:35:ad,-78,wifi2,ea:b5:7b:e8:56:54,-80,wifi3,c4:49:bb:d4:d9:78,-88] + date = "{:04d}{:02d}{:02d},{:02d}{:02d}{:02d}".format(*utime.localtime()[0:6]) + date = date[2:] + GPS_type = "V" + latitude = "0.000000,N" + longitude = "0.000000,E" + speed = "0.00" + direction = "0.0" + high = "100.0" + number = "0" + if msg[0] != [] :#有GPS数据 + GPS_type = "A" + # 纬度 + latitude = msg[0]["latitude"] + # 经度 + longitude = msg[0]["longitude"] + # 速度 + speed = msg[0]["speed"] + # 方向 + direction = "0" + if msg[0]["direction"] : + direction = msg[0]["direction"] + # 高度 + high = msg[0]["high"] + high_tmp = high.split(".") + if len(high_tmp) >= 2 : + high = "%s"%(high_tmp[0]) + # 讯号质量:搜索到的卫星数目 + number = msg[0]["number"] + #gsm 信号强度 + gsm_sig = str((100//31)*EventMesh.publish("screen_get_sig")) + # 电池电量百分比 + bat_tmp = EventMesh.publish("screen_get_battery") + battery_caption = str(bat_tmp[1]) + #步数 + step = str(EventMesh.publish(constants.EVENT.GET_STEP)[0]) + #翻转次数 + turn_count = "0" + #终端状态 + state = "00000000" + #基站数据 + CELL_num = len(msg[2]) + CELL_data = "1," #时延 + if msg[2] != []: + for CELL in msg[2] : + if CELL[0] == 0 : + CELL_data += "%X,"%(int(CELL[2])) #MCC + CELL_data += str(CELL[3]) +","#MNC + CELL_data += str(CELL[5]) +","#tac,区域码 + CELL_data += str(CELL[1]) +","#基站编号 CID + CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi + else : + CELL_data += str(CELL[5]) +","#tac,区域码 + CELL_data += str(CELL[1]) +","#基站编号 CID + CELL_data += str(int(CELL[7]+140)) +","#信号强度 rssi + CELL_data = CELL_data[:(len(CELL_data)-1)] + #WIFI数据 + WIFI_num = 0 + WIFI_data = "" + if msg[1] : + WIFI_num = msg[1][0] + i = 0 + for MAC in msg[1][1] : + WIFI_data += "wifi%d,%s,%d,"%(i,str(MAC[0]),MAC[1]) + i += 1 + WIFI_data = WIFI_data[:(len(WIFI_data)-1)] + WIFI_data = WIFI_data.lower() + #send_data = "UD ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%s ,%d ,%s ,%d ,%s"\ + # %(date,GPS_type,latitude,longitude,speed,direction,high,number,gsm_sig,battery_caption,step,turn_count,state,CELL_num,CELL_data,WIFI_num,WIFI_data) + send_data = "UD,%s,%s,%s"%(date,GPS_type,latitude) + send_data += ",%s,%s,%s"%(longitude,speed,direction) + send_data += ",%s,%s,%s"%(high,number,gsm_sig,) + send_data += ",%s,%s,%s"%(battery_caption,step,turn_count) + send_data += ",%s,%d,%s"%(state,CELL_num,CELL_data) + send_data += ",%d,%s"%(WIFI_num,WIFI_data) + + send_len = len(send_data) + wt_data = "%s"%(send_data) + send_data = "SZKW*%s*%04X*%s"%(self.imei,send_len,send_data) + MD5_SIGN = self.pack_MD5_head(send_data) + data = "[%s%s]"%(str(MD5_SIGN),send_data) + + + #这个是发送WT位置数据到手机端 + msg_tmp = wt_data.split('UD,') + msg_tmp = msg_tmp[1] + # print("WT_ProtoCol:msg_tmp:%s"%(msg_tmp)) + send_data_1 = "SZKW*%s*%04x*WT"%(self.imei,len(msg_tmp)) + MD5_SIGN_1 = self.pack_MD5_head(send_data_1) + data_1 = "[%s%s,%s]"%(str(MD5_SIGN_1),send_data_1,msg_tmp) + # print("WT_ProtoCol:send:%s"%(data_1)) + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data_1) + # 通过socket发送到服务器端 + + EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data) + def recv(self, event, msg): + """ + + @param event: PING + @param msg: 接收到的下行数据 + """ + print("UD_ProtoCol:recv:%s"%(msg)) \ 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 9e94bcda..2dbc9447 100644 --- a/3.code/1.watch/2.code/ui.py +++ b/3.code/1.watch/2.code/ui.py @@ -1850,13 +1850,13 @@ class ToolboxScreen(Screen): self.meta = toolbox_screen toolbox_step.add_event_cb(lambda e: self.load_screen(e, {"screen": "step"}), lv.EVENT.CLICKED, None) toolbox_weather.add_event_cb(lambda e: self.load_screen(e, {"screen": "weather"}), lv.EVENT.CLICKED, None) - toolbox_alarm.add_event_cb(lambda e: self.load_screen(e, {"screen": "alarm"}), lv.EVENT.CLICKED, None) + toolbox_alarm.add_event_cb(lambda e: self.load_screen(e, {"screen": "clk_list"}), lv.EVENT.CLICKED, None) 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) 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_alarm_img.add_event_cb(lambda e: self.load_screen(e, {"screen": "clk_list"}), 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)