self.MXA_MSG = 10
self.wechat_recode_list = {}
self.wechat_num = 0
- check_txt = ql_fs.path_exists("/ext/static/audio_amr/num.txt")
+ check_txt = ql_fs.path_exists("/ext/static/storage_file/wechat_num.txt")
if check_txt == True :
- with open("/ext/static/audio_amr/num.txt","r") as fd:
+ with open("/ext/static/storage_file/wechat_num.txt","r") as fd:#音频文件编号
num_tmp = fd.read()
if not num_tmp:
self.wechat_num = 0
else:
self.wechat_num = int(num_tmp)#
if self.wechat_num != 0:
- with open("ext/static/audio_amr/record.json","r",encoding="utf-8") as fd:
+ with open("/ext/static/storage_file/wechat_record.json","r",encoding="utf-8") as fd:#音频文件记录
self.wechat_recode_list = ujson.load(fd)#读取每一个amr音频文件的时长
self.record_test = audio.Record()
self.MXA_MSG = msg[0]
self.wechat_num = msg[1]
self.wechat_recode_list = msg[2]
- with open("ext/static/audio_amr/record.json","w",encoding="utf-8") as fd:
+ with open("/ext/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
ujson.dump(self.wechat_recode_list,fd)
#写编号
- with open("/ext/static/audio_amr/num.txt","w") as fd:
+ with open("/ext/static/storage_file/wechat_num.txt","w") as fd:
fd.write("{}".format(self.wechat_num))
#print("self.MXA_MSG:{} self.wechat_num:{} self.wechat_recode_list:{}".format(self.MXA_MSG,self.wechat_num,self.wechat_recode_list))
if self.wechat_num >= self.MXA_MSG:
self.wechat_num = 0
self.wechat_num += 1
- print("talking self.wechat_num ...:{}".format(self.wechat_num))
+ # print("talking self.wechat_num ...:{}".format(self.wechat_num))
#EventMesh.publish("set_wechat_data",[self.MXA_MSG,self.wechat_num,self.wechat_recode_list])
- self.record_test.start("E:/static/audio_amr/amr/{}.amr".format(self.wechat_num),16)
+ self.record_test.start("/ext/static/storage_file/{}.amr".format(self.wechat_num),16)
self.second_timer.start(1000, 1, self.reduce_second)
#松开发送
#写序号
self.record_test.stop() #停止錄音
self.second_timer.stop() #停止计时器
- print("self.countdown :{} self.wechat_num:{}".format(self.countdown,self.wechat_num))
+ # print("self.countdown :{} self.wechat_num:{}".format(self.countdown,self.wechat_num))
self.wechat_recode_list["%02d"%(self.wechat_num)] = "S:{}".format(str(self.countdown))
- with open("ext/static/audio_amr/num.txt","w") as fd:
+ with open("/ext/static/storage_file/wechat_num.txt","w") as fd:
fd.write(str(self.wechat_num))
self.timer.start(2 * 1000, 0, self.hide_label)
#print("self.countdown :{}".format(self.countdown))
#修改或添加词典键值
- with open("ext/static/audio_amr/record.json","w",encoding="utf-8") as fd:
+ with open("/ext/static/storage_file/wechat_record.json","w",encoding="utf-8") as fd:
ujson.dump(self.wechat_recode_list,fd)
# print("WechatScreen:record:{}".format(self.wechat_recode_list))
def play_img_cb(self,*args):
- print("self.count_img :{} self.play_text:{}".format(self.count_img,self.play_text))
+ # print("self.count_img :{} self.play_text:{}".format(self.count_img,self.play_text))
self.count_img+=1
if self.count_img > 3:
self.count_img = 1
self.sec_num+=1
if self.sec_num % 2 == 0:
- print("self.play_sec:{}".format(self.play_sec))
+ # print("self.play_sec:{}".format(self.play_sec))
if self.play_sec > 0:
self.play_sec -= 1
if self.play_sec == 0:
self.play_sec = int(play_img_s)
self.play_timer.start(500, 1, self.play_img_cb)
# print("play_label self.count_img :{} self.play_text:{} play_img_s:{} self.play_sec:{}".format(self.count_img,self.play_text,play_img_s,self.play_sec))
- # #R:04
num_amr = play_img.get_child(1).get_text()
num_amr = num_amr.split(':')
if self.play_text == "R:" or self.play_text == "S:":#过滤掉文字显示 不需要播放音频文件
self.aud = audio.Audio(0)
self.aud.stop()#
- self.aud.play(1, 0, 'E:/static/audio_amr/amr/{}.amr'.format(i)) #文件名前面要加上路径
+ self.aud.play(1, 0, '/ext/static/storage_file/{}.amr'.format(i)) #文件名前面要加上路径
#松手2秒后发送数据
def hide_label(self,*args):
#读音频amr二进制数据
- path = "/ext/static/audio_amr/amr/{}.amr".format(self.wechat_num)
+ path = "/ext/static/storage_file/{}.amr".format(self.wechat_num)
with open(path,"rb") as fd:
buf = bytearray(ql_fs.path_getsize(path))
fd.readinto(buf)
wechat_recode_list["%02d"%(wechat_num)] = "R:{}".format(3)
EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_num,wechat_recode_list])
#写语音文件数据
- path = "/ext/static/audio_amr/amr/{}.amr".format(wechat_num)
+ # path = "/ext/static/storage_file/audio_amr/amr/{}.amr".format(wechat_num)
+ path = "/ext/static/storage_file/{}.amr".format(wechat_num)
with open(path,"w") as fd:
arm = bytearray()
j = 0
if j >= len(arm_data):
break
fd.write(arm)
-
- #print("TK_ProtoCol end:wechat_num :{} wechat_recode_list:{} self.MXA_MSG:{}".format(wechat_num,wechat_recode_list,MXA_MSG))
-
- #EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_num,wechat_recode_list])
EventMesh.publish("wechat_updata_list_show")
msg_s = msg.decode('ascii')
msg_s = msg_s.split(',')
msg_s = msg_s[1]
- print("msg_tmp:len:{}\r\n data:{}".format(len(msg_s),msg_s))
+ # print("msg_tmp:len:{}\r\n data:{}".format(len(msg_s),msg_s))
get_wechat_data = EventMesh.publish("get_wechat_data")
wechat_num += 1
msg_txt = {}
# 0 1 2 3
- print("msg_tmp:init {}".format(msg_s))
+ # print("msg_tmp:init {}".format(msg_s))
msg_txt = UnicodeHexStr_To_Utf8Str(msg_s)
- print("msg_txt:{}".format(msg_txt))
+ # print("msg_txt:{}".format(msg_txt))
wechat_recode_list["%02d"%(wechat_num)] = "T:{}".format(msg_txt)
EventMesh.publish("set_wechat_data",[MXA_MSG,wechat_num,wechat_recode_list])
- print("wechat_recode_list:len data:{}".format(wechat_recode_list))
+ # print("wechat_recode_list:len data:{}".format(wechat_recode_list))
EventMesh.publish(constants.PROTOCOL.MESSAGE_SEND)
EventMesh.publish("wechat_updata_list_show")
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 PopupScreen,CallLogScreen,DialingScreen
+ # from usr.test_sms import DialingScreen
#from usr.ui_wechat import WechatScreen,TK_ProtoCol
btn_device = BtnDevice(tp_cst816)
ui = _ui.UI(gpio_backlight)
ui.add_screen(WatchFaceScreen())
- ui.add_screen(PopupScreen())
+ ui.add_screen(_ui.PopupScreen())
ui.add_screen(_ui.PhoneScreen())
ui.add_screen(MainMenuScreen())
ui.add_screen(_ui.HeartrateScreen())
ui.add_screen(_ui_setting.AlarmvolumeScreen())
ui.add_screen(_ui_setting.MsgvolumeScreen())
ui.add_screen(_ui_setting.PhoneringScreen())
- ui.add_screen(DialingScreen())
- ui.add_screen(CallLogScreen())
+ ui.add_screen(_ui.DialingScreen())
+ ui.add_screen(_ui.CallLogScreen())
ui.add_screen(AlipayOpenScreen())
ui.add_screen(Alipay_1_1())
ui.add_screen(Alipay_invite())
app.append_manager(AddrBookManager())
app.append_manager(mgr.MsgManager())
app.append_manager(MsgdetailManager())
- app.append_manager(CallLogManager())
+ app.append_manager(mgr.CallLogManager())
app.append_manager(PhoneCallingManager())
pcr = ProtoColResolver()
ql_fs.touch(self.file_name, self.map)
def voice_callback(args):
+ print('voicecall iinfo:{}'.format(args))
if args[0] == 10:
print('voicecall incoming call, PhoneNO.: ', args[6])
EventMesh.publish("load_screen", {"screen": "incoming_call","meta":str(args[6])})
print('voicecall is waiting, PhoneNO.: ', args[6])
elif args[0] == 14:
print('voicecall dialing, PhoneNO.: ', args[6])
+ EventMesh.publish("load_screen", {"screen": "dialing"})
+
elif args[0] == 15:
print('voicecall alerting, PhoneNO.: ', args[6])
+
elif args[0] == 16:
print('voicecall holding, PhoneNO.: ', args[6])
EventMesh.publish(constants.EVENT.CLOSE_LOCATION)#关闭定位
+# class AddrBookManager(Abstract):
+# # 通讯录
+# def post_processor_after_instantiation(self):
+# EventMesh.subscribe("get_addr_book_list", self.get)
+# # 可通过此push_addr_book_list主动推送
+
+# def get(self, event, msg):
+# print("phonebook %s"%(msg))
+# return {
+# "张三": "15692025051",
+# "李四": "15692025051",
+# "崔崔": "15692025051",
+# "鱼鱼": "15692025051",
+# "坤坤": "15692025051",
+# }
+# def set(self, event, msg):
+# print("phonebook %s"%(msg))
class AddrBookManager(Abstract):
# 通讯录
+ def __init__(self):
+ self.read_phonebook = {}
+ self.check_json = 0
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/phonebook.json")
+
+ if self.check_json == True:
+ with open("/ext/static/storage_file/phonebook.json","r",encoding="utf-8") as fd:
+ self.read_phonebook = ujson.load(fd)
+ print("读取电话本")
+
def post_processor_after_instantiation(self):
- EventMesh.subscribe("get_addr_book_list", self.get)
- # 可通过此push_addr_book_list主动推送
+ EventMesh.subscribe("get_phonebook_list", self.get)
+ EventMesh.subscribe("set_phonebook_list", self.set)
def get(self, event, msg):
- print("phonebook %s"%(msg))
- return {
- "张三": "15692025051",
- "李四": "15692025051",
- "崔崔": "15692025051",
- "鱼鱼": "15692025051",
- "坤坤": "15692025051",
- }
- def done_return(self):
- EventMesh.publish("load_screen", {"screen": "main_menu"})
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/phonebook.json")
+ return [self.check_json,self.read_phonebook]
+
+ def set(self, event, msg):
+ self.check_json = msg[0]
+ self.read_phonebook = msg[1]
+
import sms
class MsgManager(Abstract):
# 短信
class CallLogManager(Abstract):
# 通话记录
def __init__(self):
- self.log = [
- #电话 次数 时间 姓名
- ["554592025051","2","12:59","哥gd考"],
- ["15521469561","3","12:49","爸"],
- ["156525051","4","12:39","妈"],
- ["15692025051","4","12:39","姐"],
- ["15521469561","1","12:39","哥"],
- ["5666051","2","12:35","嫂子"],
- ["15521469561","6","12:59","妹"],
- ]
- a = {"15692025051":{"mane":"baba","time":"12:49","count":"6"}}
- b = a["15692025051"]
- b ={"mane":"baba","time":"12:49","count":"6"}
+ self.read_call_log = {}
+ self.check_json = ql_fs.path_exists("//ext/static/storage_fileCall_log.json")
+
+ if self.check_json == True:
+ with open("/ext/static/storage_file/Call_log.json","r",encoding="utf-8") as fd:
+ self.read_call_log = ujson.load(fd)
+ print("读取通话记录")
+
def post_processor_after_instantiation(self):
EventMesh.subscribe("get_call_log_list", self.get)
+ EventMesh.subscribe("set_call_log_list", self.set)
def get(self, event, msg):
- return self.log
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/Call_log.json")
+ return [self.check_json,self.read_call_log]
+
+ def set(self, event, msg):
+ self.check_json = msg[0]
+ self.read_call_log = msg[1]
- def call_usr(self,event,msg):
- content = self.log[msg]
- # 参数1 姓名 参数2 电话 参数3 1/主动呼叫 0别人呼叫
- EventMesh.publish("call_in", [content[2], content[0], 1])
+ # 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 PhoneCallingManager(Abstract):
def __init__(self):
phonebook_oldtmp = phonebook_tmp
# print("phonebook_oldtmp!!!:{}".format(str(phonebook_oldtmp)))
# print("phonebook!!!:{}".format(str(phonebook)))
- with open("ext/phonebook.json","w",encoding="utf-8") as fd:
+ 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 TK_ProtoCol(ProtoCol):
- """微聊"""
- TYPE = "TK"
- global wechat_num
-
- def send(self, event, msg):
- # [SZKW*YYYYYYYYYYYYYYY*LEN*TK,AMR 格式音频数据]
- #[XT*YYYYYYYYYYYYYYY*LEN*TKS,秒数(十进制),AMR 格式音频数据]
- arm_data = msg[1]
- arm_sec = msg[0]
- print("TK_ProtoCol:msgtype:",type(msg))
-
- arm = bytearray()
- for i in range(len(arm_data)):
- if arm_data[i] == 0x7d:
- arm.extend(b'\x7d\x01')
- elif arm_data[i] == 0x5b :
- arm.extend(b'\x7d\x02')
- elif arm_data[i] == 0x5d :
- arm.extend(b'\x7d\x03')
- elif arm_data[i] == 0x2c :
- arm.extend(b'\x7d\x04')
- elif arm_data[i] == 0x2a :
- arm.extend(b'\x7d\x05')
- else :
- arm.append(arm_data[i])
-
- datalen = len(arm) + 4+len(str(arm_sec))+1
- print("len(str(arm_sec)):{}".format(len(str(arm_sec))+1))
- send_data = bytearray("SZKW*%s*%04X*TKS,%d,"%(self.imei,datalen,arm_sec))
- send_data.extend(arm)
- MD5_SIGN = self.pack_MD5_head(send_data)
- data = bytearray('[')
- data.extend(MD5_SIGN)
- data.extend(send_data)
- data.extend(']')
- EventMesh.publish(constants.EVENT.CHANNEL_SOCKET_SEND, data)
-
- def recv(self, event, msg):
- """
-
-
- @param event: 微聊
- @param msg: 接收到的下行数据
- [SZKW*860132060004322*20BD*TK,#!AMR...]
- """
- #print("K_ProtoCol:recv:data:{}".format(msg))
-
- print("TK_ProtoCol:wechat_num :{} wechat_recode_list:{} MXA_MSG:{}".format(wechat_num,wechat_recode_list,MXA_MSG))
- msg_tmp = msg.decode('ascii')
- str = msg_tmp.split('TK,')
- print("TK_ProtoCol:recv:len:{} {} {}".format(len(msg),len(str),msg_tmp.find("#!AMR")))
- if msg_tmp.find("#!AMR") != -1: #是否是服务器下发音频数据
- # print("TK_ProtoCol:recv:datalen{}".format(len(msg)))
- arm_data = bytearray(str[1])#获取amr输出
-
- if wechat_num >= MXA_MSG:
- wechat_num = 0
- wechat_num += 1
- #写语音文件数据
- path = "/ext/static/audio_amr/amr/{}.amr".format(wechat_num)
- with open(path,"w") as fd:
- arm = bytearray()
- j = 0
- for i in range(len(arm_data)):
- if arm_data[j] == 0x7d and arm_data[j+1] == 0x01:
- arm.extend(b'\x7d')
- j+=1
- elif arm_data[j] == 0x7d and arm_data[j+1] == 0x02:
- arm.extend(b'\x5b')
- j+=1
- elif arm_data[j] == 0x7d and arm_data[j+1] == 0x03:
- arm.extend(b'\x5d')
- j+=1
- elif arm_data[j] == 0x7d and arm_data[j+1] == 0x04:
- arm.extend(b'\x2c')
- j+=1
- elif arm_data[j] == 0x7d and arm_data[j+1] == 0x05:
- arm.extend(b'\x2a')
- j+=1
- else :
- arm.append(arm_data[j])
- j+=1
- if j >= len(arm_data):
- break
- fd.write(arm)
- #写记录列表
- wechat_recode_list["%02d"%(wechat_num)] = "R:{}".format(3)
- print("TK_ProtoCol end:wechat_num :{} wechat_recode_list:{} MXA_MSG:{}".format(wechat_num,wechat_recode_list,MXA_MSG))
- with open("ext/static/audio_amr/record.json","w",encoding="utf-8") as fd:
- ujson.dump(wechat_recode_list,fd)
- #写编号
- with open("/ext/static/audio_amr/num.txt","w") as fd:
- fd.write("{}".format(wechat_num))
- EventMesh.publish("wechat_updata_list_show")
class ProtoColResolver(object):
import osTimer
import utime
+
+"""
+
MSG_FLAG = 0
MSG_MAX = 10 #最大显示短信内容条数
def btn8_press(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
-
+"""
# -------------------------------------------call_log screen----------------------------------------------------------
call_log_screen = lv.obj()
call_log.set_size(240, 320)
call_log.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-call_log_screen = lv.obj()
-call_log = lv.obj(call_log_screen)
-call_log.center()
-call_log.set_size(240, 320)
-call_log.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
contacts_cont_list= lv.obj(call_log)
contacts_cont_list.set_pos(0, 50)
contacts_cont_list.set_size(240, 270)
self.meta = call_log_screen
self.log_list = []
self.read_call_log = {}
- self.check_json = ql_fs.path_exists("ext/Call_log.json")
-
- if self.check_json == True:
- with open("ext/Call_log.json","r",encoding="utf-8") as fd:
- self.read_call_log = ujson.load(fd)
- print("读取通话记录")
+ self.check_json = 0
+ self.call_log_detail_list = lv.obj()
+ EventMesh.subscribe("call_log_update_show_list", self.call_log_update_show_list)
+ self.timer = osTimer()
def post_processor_before_initialization(self):
- self.log_list = EventMesh.publish("get_call_log_list")
+ read_call_log = EventMesh.publish("get_call_log_list")
+ self.check_json = read_call_log[0]
+ self.read_call_log = read_call_log[1]
+
+
+
+ def call_log_update_show_list(self, event, msg):
+ read_call_log = EventMesh.publish("get_call_log_list")
+ # print("read_call_log:{}".format(read_call_log))
+ self.check_json = read_call_log[0] #文件是否存在
+ self.read_call_log = read_call_log[1]#通话记录数据
+ self.timer.start(500,0,self.reciving)
+
+ def reciving(self,e):
+ self.btn_create()
def initialization(self):
+ EventMesh.publish("call_log_update_show_list")
self.btn_create()
def btn_create(self):
h = 0
if self.check_json == True:
+ self.call_log_detail_list.delete()#先删除一次控件
+ self.call_log_detail_list = lv.obj(call_log_screen)
+ self.call_log_detail_list.set_pos(0, 50)
+ self.call_log_detail_list.set_size(240, 270)
+ self.call_log_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ self.call_log_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
sort_tmp = self.read_call_log.values()
- # # print("self.call_log :{}\r\n".format(self.read_call_log))
sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
# print("self.call_log :{} \r\n sort_new:{}\r\n".format(self.read_call_log,sort_new))
none_call_log_title.add_flag(lv.obj.FLAG.HIDDEN)
num_time = sort_new_tmp["time"]#获取电话号码
# print("num_count :{} num_name:{} num_time:{}".format(num_count,num_name,num_time))
- _btn = lv.btn(contacts_cont_list)
- _btn.set_size(230,50)
+ _btn = lv.btn(self.call_log_detail_list)
+ _btn.set_size(240,50)
_btn.set_pos(0,52*h)
_btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
_btn.add_event_cb(lambda e: self.calling(e),
_btn_label2 = lv.label(_btn)
_btn_label2.set_pos(0, 5)
- _btn_label2.set_size(100, 25)
+ _btn_label2.set_size(0, 25)
_btn_label2.set_text(num_phonnum)
- _btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ #_btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
#
_btn_label3 = lv.label(_btn)
_btn_label3.set_pos(100, 5)
- _btn_label3.set_size(100, 25)
- _btn_label3.set_text("(" + str(num_count) + ") " + num_name)
+ _btn_label3.set_size(40, 25)
+ _btn_label3.set_text("(" + str(num_count) + ")")
_btn_label3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn_label4 = lv.label(_btn)
+ _btn_label4.set_pos(0, 5)
+ _btn_label4.set_size(100, 25)
+ _btn_label4.set_text(num_phonnum)
+ _btn_label4.set_long_mode(lv.label.LONG.DOT)
+ _btn_label4.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ _btn_label4 = lv.label(_btn)
+ _btn_label4.set_pos(0, 5)
+ _btn_label4.set_size(0, 0)
+ _btn_label4.set_text(num_name)
+ # _btn_label4.set_long_mode(lv.obj.LONG.DOT)
+ # _btn_label4.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ _btn_label5 = lv.label(_btn)
+ _btn_label5.set_pos(135, 5)
+ _btn_label5.set_size(95, 25)
+ _btn_label5.set_text(num_name)
+ _btn_label5.set_long_mode(lv.label.LONG.DOT)
+ _btn_label5.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
h = h + 1
else:
+ self.call_log_detail_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
none_call_log_title.clear_flag(lv.obj.FLAG.HIDDEN)
def calling(self,e):
- print("e.get_text():{} {}".format(e.get_target().get_child(0).get_text(),e.get_target().get_child(1).get_text()))
+ # print("e.get_text():{} {}".format(e.get_target().get_child(0).get_text(),e.get_target().get_child(3).get_text()))
phonnum = int(e.get_target().get_child(0).get_text())
- phnoname = e.get_target().get_child(1).get_text()
- phnoname_tmp = phnoname.split(')')
- phnoname_tmp = phnoname_tmp[1]
-
- print("phonnum :{} _msg:{}".format(phonnum,phnoname_tmp))
- EventMesh.publish("save_phonenum",phonnum)
- EventMesh.publish("save_phonename",phnoname_tmp)
- EventMesh.publish("load_screen", {"screen": "dialing"})
+ phnoname = e.get_target().get_child(3).get_text()
+ # print("phonnum :{} _msg:{}".format(phonnum,phnoname))
+ EventMesh.publish("save_phonenum",phonnum)#保存电话号码用于界面显示获取
+
+ self.name = None
+ self.phonebook = {}
+
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
+
+ data = EventMesh.publish("get_phonebook_list")
+ check = data[0]
+ self.phonebook = data[1]
+ # print("check :{}".format(check))
+ if check == 1:#检查通讯录
+ phonebook_keys = sorted(self.phonebook.keys())
+ b = str(phonnum) in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ j = 0
+ if b == True:
+ for i in range(len(self.phonebook)): #字典 key value
+ #'001:邓雪英':15521469561
+ name = self.phonebook[phonebook_keys[j]]
+ name_value = phonebook_keys[j]
+ number_tmp = str(phonnum)
+ # print("name :{} number_tmp:{}".format(name,number_tmp))
+ if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
+ number_f= name_value
+ name_s = number_f.split(':')
+ name_s = name_s[1]
+ self.name = name_s
+ break
+ j+=1
+ else:
+ self.name = phnoname
+ self.pro_state = 0
+ else:
+ self.name = phnoname
+
+ if self.name == None:
+ self.name = phnoname
+
+ EventMesh.publish("save_phonename",self.name)#
+ voiceCall.callStart(str(phonnum))
def done_return(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
class CallLogManager(Abstract):
# 通话记录
def __init__(self):
- self.log = [
- #电话 次数 时间 姓名
- ["15692025051","2","12:59","哥"],
- ["15692025051","3","12:49","爸"],
- ["15521469561","4","12:39","妈"],
- ["15692025051","4","12:39","姐"],
- ["15521469561","1","12:39","哥"],
- ["15692466051","2","12:35","嫂子"],
- ["15521469561","6","12:59","妹"],
- ]
+ self.read_call_log = {}
+ self.check_json = ql_fs.path_exists("//ext/static/storage_fileCall_log.json")
+
+ if self.check_json == True:
+ with open("/ext/static/storage_file/Call_log.json","r",encoding="utf-8") as fd:
+ self.read_call_log = ujson.load(fd)
+ print("读取通话记录")
def post_processor_after_instantiation(self):
EventMesh.subscribe("get_call_log_list", self.get)
+ EventMesh.subscribe("set_call_log_list", self.set)
def get(self, event, msg):
- return self.log
+ self.check_json = ql_fs.path_exists("/ext/static/storage_file/Call_log.json")
+ return [self.check_json,self.read_call_log]
+
+ def set(self, event, msg):
+ self.check_json = msg[0]
+ self.read_call_log = msg[1]
- def call_usr(self,event,msg):
- content = self.log[msg]
- # 参数1 姓名 参数2 电话 参数3 1/主动呼叫 0别人呼叫
- EventMesh.publish("call_in", [content[2], content[0], 1])
+ # def call_usr(self,event,msg):
+ # content = self.log[msg]
+ # # 参数1 姓名 参数2 电话 参数3 1/主动呼叫 0别人呼叫
+ # EventMesh.publish("call_in", [content[2], content[0], 1])
+
dialing_screen = lv.obj()
dialing = lv.obj(dialing_screen)
def initialization(self):
#获取字符串
- name = EventMesh.publish("get_phonename")
- content = EventMesh.publish("get_phonenum")
- time = EventMesh.publish("screen_get_time")
+ name = EventMesh.publish("get_phonename")#获取拨打电话名称
+ content = EventMesh.publish("get_phonenum")#获取电话号码
+ time = EventMesh.publish("screen_get_time")#获取系统时间
+
# ["15692025051","2","12:59","哥gdh符合双方和开发商开发好看的思考"],
# 格式:{"电话号码":{"timesec":'时间戳',"number":'电话号码',"name":'名字',"time":'时间',"count":'通话次数'}}
dialing_name.set_text(name)#名称
dialing_content.set_text(content)#电话号码
num = 0
- check_json = ql_fs.path_exists("ext/Call_log.json")
date_tmp = utime.localtime()
time_tmp = utime.mktime(date_tmp)
# print("time_tmp:{}".format(time_tmp))
+ read_call_log = EventMesh.publish("get_call_log_list")
+ check_json = read_call_log[0]
if check_json == True:
- with open("ext/Call_log.json","r",encoding="utf-8") as fd:
- self.read_call_log = ujson.load(fd)
- print("读取通话记录")
-
- b = content in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
-
- # print("b:{}".format(b))
-
- if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
- number_tmp = {}
- number_tmp = self.read_call_log[content] #通话次数加一
- num_tmp_t = number_tmp["count"]
- # print("number_tmp:{} self.read_call_log.value:{}".format(number_tmp,self.read_call_log.values()))
- else :
- num_tmp_t = 0
- num = num_tmp_t
+ self.read_call_log = read_call_log[1]
+ b = content in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
+ number_tmp = {}
+ number_tmp = self.read_call_log[content] #通话次数加一
+ num_tmp_t = number_tmp["count"]
+ # print("number_tmp:{} self.read_call_log.value:{}".format(number_tmp,self.read_call_log.values()))
+ else :
+ num_tmp_t = 0
+ num = num_tmp_t
else:
num = 0 #通话次数
sort_tmp = self.read_call_log.values()
sort_new = {}
sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
- print("self.read_call_log:{} sort_new:{}\r\n".format(self.read_call_log,sort_new))
- #popitem
+
i = 0
- if len(self.read_call_log) > CALL_LOG_MAX:
+ # 49 50
+ if len(self.read_call_log) >= CALL_LOG_MAX:
for sort_new_tmp in sort_new: #字典 key value
i+=1 # 1
- if i > CALL_LOG_MAX:#大于50条把最后几条删除掉只保留前面50调最新的数据
+ if i >= CALL_LOG_MAX:#大于50条把最后一条删除掉只保留前面50调最新的数据
key_tmp = sort_new_tmp["number"]
- # print("key :{} value:{} len:{} value_tmp:{} key_tmp:{}\r\n".format(key,value,len(self.read_call_log),value_tmp,key_tmp))
del self.read_call_log[key_tmp]
- # print("delte :{}".format(self.read_call_log))
-
- # print("self.read_call_log end :{}\r\n".format(self.read_call_log))
-
tmp = {}
tmp["count"]= num+1 #通话次数
tmp["time"]= "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通湖时间
tmp["number"] = content
self.read_call_log[content] = tmp
- # sort_tmp = self.read_call_log.values()
- # # print("self.call_log :{}\r\n".format(self.read_call_log))
- # sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
- with open("ext/Call_log.json","w",encoding="utf-8") as fd:
+ with open("/ext/static/storage_file/Call_log.json","w",encoding="utf-8") as fd:
ujson.dump(self.read_call_log,fd)
print("创建通话记录")
+ EventMesh.publish("set_call_log_list", [1,self.read_call_log])
+ EventMesh.publish("call_log_update_show_list")
-
+ def hangup(self,e):
+ voiceCall.callEnd()
def done_return(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
- def hangup(self,e):
- voiceCall.callEnd()
- EventMesh.publish("load_screen", {"screen": "contacts"})
-
def btn1_release(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
-# -------------------------------------------dialing screen----------------------------------------------------------
-dialing_screen = lv.obj()
-dialing = lv.obj(dialing_screen)
-dialing.center()
-dialing.set_size(240, 320)
-dialing.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-dialing_img = lv.img(dialing)
-dialing_img.set_pos(80, 20)
-dialing_img.set_size(64, 64)
-dialing_img.set_src("E:/static/IMAGE_NOTICE_CALL.jpg")
-dialing_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-
-dialing_name = lv.label(dialing)
-dialing_name.set_pos(0, 100)
-dialing_name.set_size(240, 50)
-dialing_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-dialing_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-dialing_content = lv.label(dialing)
-dialing_content.set_pos(0, 160)
-dialing_content.set_size(240, 50)
-dialing_content.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-dialing_content.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.jpg")
-hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
-hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
-hangup_imgbtn.set_pos(80, 220)
# -------------------------------------------incoming_call screen----------------------------------------------------------
incoming_call_screen = lv.obj()
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_pos(80, 20)
incoming_call_img.set_size(64, 64)
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_name_label = lv.label(incoming_call)
+incoming_call_name_label.set_pos(0, 100)
+incoming_call_name_label.set_size(240, 50)
+incoming_call_name_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+incoming_call_name_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
incoming_call_label = lv.label(incoming_call)
-incoming_call_label.set_pos(0, 150)
+incoming_call_label.set_pos(0, 160)
incoming_call_label.set_size(240, 50)
incoming_call_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
incoming_call_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-
incoming_call_answer = lv.img(incoming_call)
incoming_call_answer.set_size(64, 64)
incoming_call_answer.add_flag(lv.obj.FLAG.CLICKABLE)
on_call.set_size(240, 320)
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.jpg")
-on_call_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+on_call_label_name = lv.label(on_call)
+on_call_label_name.set_pos(0, 40)
+on_call_label_name.set_size(240, 50)
+on_call_label_name.set_text(" ")
+on_call_label_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+on_call_label_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
on_call_label = lv.label(on_call)
-on_call_label.set_pos(0, 150)
+on_call_label.set_pos(0, 100)
on_call_label.set_size(240, 50)
+on_call_label.set_text(" ")
on_call_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
on_call_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+on_call_second_label = lv.label(on_call)
+on_call_second_label.set_pos(0, 160)
+on_call_second_label.set_size(240, 50)
+on_call_second_label.set_text("00:00")
+on_call_second_label.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+on_call_second_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+
on_call_hangup = lv.img(on_call)
on_call_hangup.set_size(64, 64)
on_call_hangup.add_flag(lv.obj.FLAG.CLICKABLE)
msg_detail_cont.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
msg_detail_cont.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
-# -------------------------------------------call_log screen----------------------------------------------------------
-call_log_screen = lv.obj()
-call_log = lv.obj(call_log_screen)
-call_log.center()
-call_log.set_size(240, 320)
-call_log.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-call_log_screen = lv.obj()
-call_log = lv.obj(call_log_screen)
-call_log.center()
-call_log.set_size(240, 320)
-call_log.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
-call_log_title = lv.label(call_log)
-call_log_title.set_pos(0, 10)
-call_log_title.set_size(240, 40)
-call_log_title.set_long_mode(lv.label.LONG.WRAP)
-call_log_title.set_text("通话记录")
-call_log_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
-call_log_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
from ext.common import Abstract
def btn8_press(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
+# ----------------------------------通话记录---------call_log screen----------------------------------------------------------
+
+call_log_screen = lv.obj()
+call_log = lv.obj(call_log_screen)
+call_log.center()
+call_log.set_size(240, 320)
+call_log.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+contacts_cont_list= lv.obj(call_log)
+contacts_cont_list.set_pos(0, 50)
+contacts_cont_list.set_size(240, 270)
+contacts_cont_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+contacts_cont_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+call_log_title = lv.label(call_log)
+call_log_title.set_pos(0, 10)
+call_log_title.set_size(240, 40)
+call_log_title.set_long_mode(lv.label.LONG.WRAP)
+call_log_title.set_text("通话记录")
+call_log_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+call_log_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+none_call_log_title = lv.label(contacts_cont_list)
+none_call_log_title.set_pos(0, 120)
+none_call_log_title.set_size(240, 40)
+none_call_log_title.set_long_mode(lv.label.LONG.WRAP)
+none_call_log_title.set_text("暂无记录")
+none_call_log_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+none_call_log_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
CALLLOG_FLAG = 0
class CallLogScreen(Screen):
super().__init__()
self.meta = call_log_screen
self.log_list = []
+ self.read_call_log = {}
+ self.check_json = 0
+ self.call_log_detail_list = lv.obj()
+ EventMesh.subscribe("call_log_update_show_list", self.call_log_update_show_list)
+ self.timer = osTimer()
def post_processor_before_initialization(self):
- self.log_list = EventMesh.publish("get_call_log_list")
+ read_call_log = EventMesh.publish("get_call_log_list")
+ self.check_json = read_call_log[0]
+ self.read_call_log = read_call_log[1]
+
+
+
+ def call_log_update_show_list(self, event, msg):
+ read_call_log = EventMesh.publish("get_call_log_list")
+ # print("read_call_log:{}".format(read_call_log))
+ self.check_json = read_call_log[0] #文件是否存在
+ self.read_call_log = read_call_log[1]#通话记录数据
+ self.timer.start(500,0,self.reciving)
+
+ def reciving(self,e):
+ self.btn_create()
def initialization(self):
- global CALLLOG_FLAG
- if CALLLOG_FLAG == 0:
- self.btn_create()
+ EventMesh.publish("call_log_update_show_list")
+ self.btn_create()
def btn_create(self):
h = 0
- for i ,each in enumerate(self.log_list):
+ if self.check_json == True:
+ self.call_log_detail_list.delete()#先删除一次控件
+ self.call_log_detail_list = lv.obj(call_log_screen)
+ self.call_log_detail_list.set_pos(0, 50)
+ self.call_log_detail_list.set_size(240, 270)
+ self.call_log_detail_list.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF)
+ self.call_log_detail_list.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+ sort_tmp = self.read_call_log.values()
+ sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ # print("self.call_log :{} \r\n sort_new:{}\r\n".format(self.read_call_log,sort_new))
+ none_call_log_title.add_flag(lv.obj.FLAG.HIDDEN)
+ for sort_new_tmp in sort_new: #字典 key value
+ num_count = sort_new_tmp["count"]#获取通话次数
+ num_name = sort_new_tmp["name"]#获取名称
+ num_phonnum = sort_new_tmp["number"]#获取电话号码
+ num_time = sort_new_tmp["time"]#获取电话号码
+
+ # print("num_count :{} num_name:{} num_time:{}".format(num_count,num_name,num_time))
+ _btn = lv.btn(self.call_log_detail_list)
+ _btn.set_size(240,50)
+ _btn.set_pos(0,52*h)
+ _btn.add_style(style_contact_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+ _btn.add_event_cb(lambda e: self.calling(e),
+ lv.EVENT.CLICKED, None)
+
+
+ _btn_label2 = lv.label(_btn)
+ _btn_label2.set_pos(0, 5)
+ _btn_label2.set_size(0, 25)
+ _btn_label2.set_text(num_phonnum)
+ #_btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+ #
+ _btn_label3 = lv.label(_btn)
+ _btn_label3.set_pos(100, 5)
+ _btn_label3.set_size(40, 25)
+ _btn_label3.set_text("(" + str(num_count) + ")")
+ _btn_label3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ _btn_label4 = lv.label(_btn)
+ _btn_label4.set_pos(0, 5)
+ _btn_label4.set_size(100, 25)
+ _btn_label4.set_text(num_phonnum)
+ _btn_label4.set_long_mode(lv.label.LONG.DOT)
+ _btn_label4.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ _btn_label4 = lv.label(_btn)
+ _btn_label4.set_pos(0, 5)
+ _btn_label4.set_size(0, 0)
+ _btn_label4.set_text(num_name)
+ # _btn_label4.set_long_mode(lv.obj.LONG.DOT)
+ # _btn_label4.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ _btn_label5 = lv.label(_btn)
+ _btn_label5.set_pos(135, 5)
+ _btn_label5.set_size(95, 25)
+ _btn_label5.set_text(num_name)
+ _btn_label5.set_long_mode(lv.label.LONG.DOT)
+ _btn_label5.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+ h = h + 1
+ else:
+ self.call_log_detail_list.add_flag(lv.obj.FLAG.HIDDEN)#隐藏空文本
+ none_call_log_title.clear_flag(lv.obj.FLAG.HIDDEN)
- _btn = lv.btn(call_log)
- _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_event_cb(lambda e: self.calling(e),
- lv.EVENT.CLICKED, None)
-
- _btn_label1 = lv.label(_btn)
- _btn_label1.set_pos(0, 0)
- _btn_label1.set_long_mode(lv.label.LONG.DOT)
- _btn_label1.set_size(0, 0)
- _btn_label1.set_text(str(i))
-
- _btn_label2 = lv.label(_btn)
- _btn_label2.set_pos(0, 5)
- _btn_label2.set_size(100, 25)
- _btn_label2.set_text(each[0])
- _btn_label2.set_long_mode(lv.label.LONG.DOT)
- _btn_label2.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
- #
- _btn_label3 = lv.label(_btn)
- _btn_label3.set_pos(100, 5)
- _btn_label3.set_size(100, 25)
- _btn_label3.set_text("(" + each[1] + ") " + each[3])
- _btn_label3.set_long_mode(lv.label.LONG.DOT)
- _btn_label3.add_style(style_font_youyuan_20_black, lv.PART.MAIN | lv.STATE.DEFAULT)
-
- h = h + 1
def calling(self,e):
- _i = int(e.get_target().get_child(0).get_text())
- _msg = self.log_list[_i]
- print("_i :{} _msg:{}".format(_i,_msg))
- EventMesh.publish("save_phonenum",_msg[0])
- EventMesh.publish("save_phonename",_msg[3])
- EventMesh.publish("load_screen", {"screen": "dialing"})
+ # print("e.get_text():{} {}".format(e.get_target().get_child(0).get_text(),e.get_target().get_child(3).get_text()))
+ phonnum = int(e.get_target().get_child(0).get_text())
+ phnoname = e.get_target().get_child(3).get_text()
+ # print("phonnum :{} _msg:{}".format(phonnum,phnoname))
+ EventMesh.publish("save_phonenum",phonnum)#保存电话号码用于界面显示获取
+
+ self.name = None
+ self.phonebook = {}
+
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
+
+ data = EventMesh.publish("get_phonebook_list")
+ check = data[0]
+ self.phonebook = data[1]
+ # print("check :{}".format(check))
+ if check == 1:#检查通讯录
+ phonebook_keys = sorted(self.phonebook.keys())
+ b = str(phonnum) in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ j = 0
+ if b == True:
+ for i in range(len(self.phonebook)): #字典 key value
+ #'001:邓雪英':15521469561
+ name = self.phonebook[phonebook_keys[j]]
+ name_value = phonebook_keys[j]
+ number_tmp = str(phonnum)
+ # print("name :{} number_tmp:{}".format(name,number_tmp))
+ if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
+ number_f= name_value
+ name_s = number_f.split(':')
+ name_s = name_s[1]
+ self.name = name_s
+ break
+ j+=1
+ else:
+ self.name = phnoname
+ self.pro_state = 0
+ else:
+ self.name = phnoname
+
+ if self.name == None:
+ self.name = phnoname
+
+ EventMesh.publish("save_phonename",self.name)#
+ voiceCall.callStart(str(phonnum))
def done_return(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
def btn8_press(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
+# ------------------------------拨打电话-------------dialing screen----------------------------------------------------------
+dialing_screen = lv.obj()
+dialing = lv.obj(dialing_screen)
+dialing.center()
+dialing.set_size(240, 320)
+dialing.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+dialing_img = lv.img(dialing)
+dialing_img.set_pos(80, 20)
+dialing_img.set_size(64, 64)
+dialing_img.set_src("E:/static/IMAGE_NOTICE_CALL.jpg")
+dialing_img.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+dialing_name = lv.label(dialing)
+dialing_name.set_pos(0, 100)
+dialing_name.set_size(240, 50)
+dialing_name.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+dialing_name.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+dialing_content = lv.label(dialing)
+dialing_content.set_pos(0, 160)
+dialing_content.set_size(240, 50)
+dialing_content.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+dialing_content.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.jpg")
+hangup_imgbtn.add_flag(lv.obj.FLAG.CLICKABLE)
+hangup_imgbtn.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT)
+hangup_imgbtn.set_pos(80, 220)
+
+CALL_LOG_MAX = 50
class DialingScreen(Screen):
NAME = "dialing"
self.meta = dialing_screen
hangup_imgbtn.add_event_cb(lambda e: self.hangup(e),
lv.EVENT.CLICKED, None)
-
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
def initialization(self):
#获取字符串
- name = EventMesh.publish("get_phonename")
- content = EventMesh.publish("get_phonenum")
- # print("name %s content %s\r\n"%(name,content))
+ name = EventMesh.publish("get_phonename")#获取拨打电话名称
+ content = EventMesh.publish("get_phonenum")#获取电话号码
+ time = EventMesh.publish("screen_get_time")#获取系统时间
+
+ # ["15692025051","2","12:59","哥gdh符合双方和开发商开发好看的思考"],
+ # 格式:{"电话号码":{"timesec":'时间戳',"number":'电话号码',"name":'名字',"time":'时间',"count":'通话次数'}}
+
dialing_name.set_text(name)#名称
dialing_content.set_text(content)#电话号码
+ num = 0
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ # print("time_tmp:{}".format(time_tmp))
+ read_call_log = EventMesh.publish("get_call_log_list")
+ check_json = read_call_log[0]
+
+ if check_json == True:
+ self.read_call_log = read_call_log[1]
+ b = content in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
+ number_tmp = {}
+ number_tmp = self.read_call_log[content] #通话次数加一
+ num_tmp_t = number_tmp["count"]
+ # print("number_tmp:{} self.read_call_log.value:{}".format(number_tmp,self.read_call_log.values()))
+ else :
+ num_tmp_t = 0
+ num = num_tmp_t
+ else:
+ num = 0 #通话次数
- def done_return(self):
- EventMesh.publish("load_screen", {"screen": "watchface"})
+ sort_tmp = {}
+ sort_tmp = self.read_call_log.values()
+ sort_new = {}
+ sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ i = 0
+ # 49 50
+ if len(self.read_call_log) >= CALL_LOG_MAX:
+ for sort_new_tmp in sort_new: #字典 key value
+ i+=1 # 1
+ if i >= CALL_LOG_MAX:#大于50条把最后一条删除掉只保留前面50调最新的数据
+ key_tmp = sort_new_tmp["number"]
+ del self.read_call_log[key_tmp]
+ tmp = {}
+ tmp["count"]= num+1 #通话次数
+ tmp["time"]= "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通湖时间
+ tmp["name"]= name #名称
+ tmp["timesec"]= time_tmp #时间戳
+ tmp["number"] = content
+
+ self.read_call_log[content] = tmp
+ with open("/ext/static/storage_file/Call_log.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.read_call_log,fd)
+ print("创建通话记录")
+ EventMesh.publish("set_call_log_list", [1,self.read_call_log])
+ EventMesh.publish("call_log_update_show_list")
+
def hangup(self,e):
voiceCall.callEnd()
- EventMesh.publish("load_screen", {"screen": "contacts"})
+
+ 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"})
-
-
############短信###############################
MSG_FLAG = 0
-MSG_FLAG = 0
MSG_MAX = 10 #最大显示短信内容条数
style_sms_bg_btn = lv.style_t()
def sms_create_list(self,event,msg):
self.msg_nums = sms.getMsgNums()
self.btn_create(1)
-
+
+
def btn_create(self,msg):
i = 0
j = 0
-
class MsgDetailScreen(Screen):
NAME = "msg_detail"
EventMesh.publish("load_screen", {"screen": "popup"})
def hangup(self,e):
- voiceCall.callEnd()
EventMesh.publish("load_screen", {"screen": "watchface"})
def btn1_release(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
-
+CALL_LOG_MAX = 50
class IncomingCallScreen(Screen):
NAME = "incoming_call"
def __init__(self):
super().__init__()
+ self.aud = audio.Audio(0)
+ self.aud.set_pa(Pin.GPIO29)
+ self.aud.setVolume(10)
+ self.call_timer = osTimer()
+ self.name = None
+ self.phonebook = {}
+ self.pro_state = 0
self.meta = incoming_call_screen
incoming_call_answer.add_event_cb(lambda e: self.answer(e),
lv.EVENT.CLICKED, None)
incoming_call_hangup.add_event_cb(lambda e: self.hangup(e),
lv.EVENT.CLICKED, None)
+ self.call_log = {}
+ self.call_log_value = {}
+ self.read_call_log = {}
+ self.number_tmp = {}
+
+
+
def post_processor_after_initialization(self):
+
+ data = EventMesh.publish("get_phonebook_list")
+ check = data[0]
+ self.phonebook = data[1]
+ if check == 1:#先检查通讯录
+ phonebook_keys = sorted(self.phonebook.keys())
+ b = self.meta_info in self.phonebook.values()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+ j = 0
+ if b == True:
+ for i in range(len(self.phonebook)): #字典 key value
+ #'001:邓雪英':15521469561
+ name = self.phonebook[phonebook_keys[j]]
+ name_value = phonebook_keys[j]
+ number_tmp = str(self.meta_info)
+ # print("name :{} number_tmp:{}".format(name,number_tmp))
+ if name.find(number_tmp) != -1:#查找电话号码是否在通讯录里面
+ number_f= name_value
+ name_s = number_f.split(':')
+ name_s = name_s[1]
+ self.name = name_s
+ self.pro_state = 1
+ break
+ j+=1
+ else:
+ self.name = str(self.meta_info)
+ self.pro_state = 0
+ else:
+ self.name = str(self.meta_info)
+ self.pro_state = 0
+
+ read_call_log = EventMesh.publish("get_call_log_list")
+ check_call_log_json = read_call_log[0]
+ self.read_call_log = read_call_log[1]
+ if self.pro_state == 0 and check_call_log_json == 1:#电话本没有就在通话记录查找电话号码并且文件存在是查找
+
+ sort_tmp = self.read_call_log.values()
+ for sort_new_tmp in sort_tmp: #字典 key value
+ number = sort_new_tmp["number"]
+ find_ok = self.meta_info in number
+ # print("find_ok:{} sort_tmp :{} self.meta_info:{}\r\n".format(find_ok,number,self.meta_info))
+ if find_ok == True:
+ name_value = sort_new_tmp["name"]#查找到相同的电话号码就退出break
+ self.name = name_value
+ break
+
+ if self.name == None:
+ self.name = str(self.meta_info)
incoming_call_label.set_text(str(self.meta_info))
+ incoming_call_name_label.set_text(self.name)
+ EventMesh.publish("save_phonename",self.name)
+ time = EventMesh.publish("screen_get_time")#获取系统时间
+
+ # ["15692025051","2","12:59","哥gdh符合双方和开发商开发好看的思考"],
+ # 格式:{"电话号码":{"timesec":'时间戳',"number":'电话号码',"name":'名字',"time":'时间',"count":'通话次数'}}
+ num = 0
+
+ date_tmp = utime.localtime()
+ time_tmp = utime.mktime(date_tmp)
+ # print("time_tmp:{}".format(time_tmp))
+ read_call_log = EventMesh.publish("get_call_log_list")
+ check_json = read_call_log[0]
+
+ if check_json == True:
+ self.read_call_log = read_call_log[1]
+ print("读取通话记录")
+ b = str(self.meta_info) in self.read_call_log.keys()#查找key中是否包含content电话号码 True 包含在里面 False不包含在里面
+
+ if b == True:#查找是否有相同的电话号码 有就直接读出来的次数上加一 没有则从1开始加起
+ number_tmp = {}
+ number_tmp = self.read_call_log[str(self.meta_info)] #通话次数加一
+ num_tmp_t = number_tmp["count"]#读取本地保存的通话次数
+ else :
+ num_tmp_t = 0
+ num = num_tmp_t
+ else:
+ num = 0 #通话次数
+
+ sort_tmp = {}
+ sort_tmp = self.read_call_log.values()
+ sort_new = {}
+ sort_new = sorted(sort_tmp, key = lambda i: i['timesec'],reverse = True)#按照时间戳进行排序 去掉最旧的一次数据如果满了五十条
+ i = 0
+ if len(self.read_call_log) >= CALL_LOG_MAX:
+ for sort_new_tmp in sort_new: #字典 key value
+ i+=1 # 1
+ if i >= CALL_LOG_MAX:#大于50条把最后一条删除掉只保留前面50调最新的数据
+ key_tmp = sort_new_tmp["number"]
+ del self.read_call_log[key_tmp]
+
+ tmp = {}
+ tmp["count"]= num+1 #通话次数
+ tmp["time"]= "{}:{}".format("%02d"%(time[0][0]),"%02d"%(time[0][1]))#通话时间
+ tmp["name"]= self.name #名称
+ tmp["timesec"]= time_tmp #时间戳
+ tmp["number"] = self.meta_info
+
+ self.read_call_log[self.meta_info] = tmp
+ with open("/ext/static/storage_file/Call_log.json","w",encoding="utf-8") as fd:
+ ujson.dump(self.read_call_log,fd)
+ print("创建通话记录")
+ EventMesh.publish("set_call_log_list", [1,self.read_call_log])
+ EventMesh.publish("call_log_update_show_list")
+
+ self.call_timer.start(6000, 1, self.call_timer_cb)
+ self.aud.play(1, 0, 'E:/static/R_CALL_mp3.mp3') #播放来电铃声
+
+ def call_timer_cb(self,e):
+ self.aud.play(1, 0, 'E:/static/R_CALL_mp3.mp3') #播放来电铃声
def answer(self,e):
+ self.call_timer.stop()
+ self.aud.stop()
voiceCall.callAnswer()
+ def Close(self):
+ self.call_timer.stop()
+ self.aud.stop()
+
def hangup(self,e):
+ self.aud.stop()
+ self.call_timer.stop()
voiceCall.callEnd()
def btn1_release(self):
- EventMesh.publish("load_screen", {"screen": "watchface"})
+ pass
def btn8_press(self):
- EventMesh.publish("load_screen", {"screen": "watchface"})
+ self.aud.stop()
+ self.call_timer.stop()
+
+
+ def done_left_to_right(self):
+ pass
+
+ def done_right_to_left(self):
+ pass
+
+ def done_bottom_to_top(self):
+ pass
+
+ def done_top_to_bottom(self):
+ pass
+
+ def done_return(self):
+ pass
+
+
+
+
class OnCallScreen(Screen):
- NAME = "oncall"
+ NAME = "on_call"
def __init__(self):
super().__init__()
self.meta = on_call_screen
+ self.count_sec = 0
on_call_hangup.add_event_cb(lambda e: self.hangup(e),
lv.EVENT.CLICKED, None)
+ self.timer = osTimer()
def post_processor_after_initialization(self):
+ self.count_sec = 0
+ self.timer.start(1000,1,self.refresh)
+ name = EventMesh.publish("get_phonename")
+ on_call_label_name.set_text(name)
on_call_label.set_text(str(self.meta_info))
+ def refresh(self,e):
+ min = self.count_sec/60
+ sec = self.count_sec%60
+ if min > 99:
+ total = "%03d:%02d"%(min,sec)
+ else:
+ total = "%02d:%02d"%(min,sec)
+ on_call_second_label.set_text(str(total))
+ self.count_sec+=1
+
+
def hangup(self,e):
voiceCall.callEnd()
- EventMesh.publish("load_screen", {"screen": "watchface"})
-
+
def btn1_release(self):
EventMesh.publish("load_screen", {"screen": "watchface"})
EventMesh.subscribe("contact_updata_list_show", self.btn_create_list)
def post_processor_before_initialization(self):
- self.check_json = ql_fs.path_exists("ext/phonebook.json")
- self.phonebook = EventMesh.publish("get_addr_book_list")
- # print("check_json %d"%(self.check_json))
+ data = EventMesh.publish("get_phonebook_list")
+ self.check_json = data[0]
+ self.phonebook = data[1]
self.count = 0
- if self.check_json == True:
- with open("ext/phonebook.json","r",encoding="utf-8") as fd:
- self.phonebook = ujson.load(fd)
- print("读取电话簿")
-
def initialization(self):
#读取json文件中的字典放到self.phonebook中
i = 0
# print("self.phonebook sorted :{} len(self.phonebook) :{}".format(sorted(self.phonebook.keys()),len(self.phonebook)))
phonebook_keys = sorted(self.phonebook.keys())
- # new_sys1 = sorted(self.phonebook.items(), key=lambda d: d[0], reverse=False)
- # print("new_sys1 :{} ".format(new_sys1))
- # new_sys2 = sorted(self.phonebook.items(), key=lambda d: d[1], reverse=False)
- # print("new_sys2 :{} ".format(new_sys2))
self.contact_detail_list.delete()#先删除一次控件
self.contact_detail_list = lv.obj(contacts_screen)
self.contact_detail_list.set_pos(0, 50)
def calling(self,e):
_msg = e.get_target().get_child(1).get_text()
- print("_msg:{}".format(_msg))
+ # print("_msg:{}".format(_msg))
msg_tmp = _msg.split(':')
msg_tmp = msg_tmp[1]
EventMesh.publish("save_phonename", msg_tmp)
phone_num = self.phonebook[_msg]
EventMesh.publish("save_phonenum", phone_num)
+ # phone_num_tmp = int(phone_num)
voiceCall.callStart(phone_num)
- EventMesh.publish("load_screen", {"screen": "dialing"})
def done_return(self):
+ # print("done_return....\r\n")
EventMesh.publish("load_screen", {"screen": "main_menu"})
def btn1_release(self):
+ # print("btn1_release....\r\n")
EventMesh.publish("load_screen", {"screen": "watchface"})
def btn8_press(self):
+ # print("btn8_press....\r\n")
EventMesh.publish("load_screen", {"screen": "watchface"})
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("/ext/phonebook.json")
- if ret == True :
- ql_fs.rmdirs("ext/phonebook.json")
- else:
- pass
+ ret = ql_fs.path_exists("/ext/static/storage_file")#电话本
+ if ret == True:
+ ql_fs.rmdirs("/ext/static/storage_file")
+ ql_fs.mkdirs("/ext/static/storage_file")
Power.powerRestart()
# EventMesh.publish("load_screen", {"screen": "setting"})