From: dxy15521469561 <1731678236@qq.com> Date: Fri, 7 Jun 2024 01:41:29 +0000 (+0800) Subject: AI语音界面 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=0251a1c495d37d32584d96694f28dfee9e94d664;p=mirrors%2FASR1603_G5.git AI语音界面 --- diff --git a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ai.py b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ai.py index f34bae66..198298e9 100644 --- a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ai.py +++ b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ai.py @@ -4,13 +4,19 @@ from machine import Pin import osTimer import _thread from queue import Queue -from ui import style_font_youyuan_20,style_screen,Screen,style_font_youyuan_20_black,style_img,LCD_SIZE_H,LCD_SIZE_W import uwebsocket import usys import EventMesh import constants import ujson import lvgl as lv +from ui import style_font_youyuan_20,style_screen,Screen,style_img,LCD_SIZE_H,LCD_SIZE_W +style_font_youyuan_ai_20 = lv.style_t() +style_font_youyuan_ai_20.init() +style_font_youyuan_ai_20.set_text_color(lv.color_make(253, 82, 19)) +style_font_youyuan_ai_20.set_text_font_v2("font_28.bin",28,0) + + def sub_utf8_String(string,length): if length >= len(string): @@ -99,7 +105,12 @@ AI_screen_list_screen.set_size(LCD_SIZE_W, LCD_SIZE_H-60) AI_screen_list_screen.set_scrollbar_mode(lv.SCROLLBAR_MODE.OFF) AI_screen_list_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) - +al_success_title1 = lv.label(AI_screen) +al_success_title1.set_pos(0, 10) +al_success_title1.set_size(LCD_SIZE_W, 40) +al_success_title1.set_text("AI智能助手") +al_success_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +al_success_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) AI_press_btn = lv.btn(AI_screen) AI_press_btn.set_pos(10, (LCD_SIZE_H-60)+4) @@ -117,15 +128,15 @@ AI_press_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) AI_press_label_countdown = lv.label(AI_screen_list_screen) -AI_press_label_countdown.set_pos(30, 20) -AI_press_label_countdown.set_size(LCD_SIZE_W-30, 80) +AI_press_label_countdown.set_pos(30, 40) +AI_press_label_countdown.set_size(LCD_SIZE_W-30, 66) AI_press_label_countdown.set_text(" ") AI_press_label_countdown.set_long_mode(lv.label.LONG.WRAP) AI_press_label_countdown.set_style_text_align(lv.TEXT_ALIGN.RIGHT, 0) AI_press_label_countdown.add_style(style_font_20_ai_green, lv.PART.MAIN | lv.STATE.DEFAULT) AI_label = lv.label(AI_screen_list_screen) -AI_label.set_pos(0, 130) +AI_label.set_pos(0, 135) AI_label.set_size(LCD_SIZE_W-30, 80) AI_label.set_text(" ") AI_label.set_long_mode(lv.label.LONG.WRAP) @@ -177,6 +188,7 @@ class AIScreen(Screen):#AI_GUI AI_press_btn.add_event_cb(lambda e: EventMesh.callback_wrapper(self.talking_cb(e)), lv.EVENT.RELEASED, None) def initialization(self): + self.aud.setVolume(11)#设置最大声录音 self.AI_audio_queue = Queue(100) self.AI_audio_queue_thread_id = _thread.start_new_thread(self.AI_audio_queue_thread, ()) @@ -623,4 +635,386 @@ class AIScreen(Screen):#AI_GUI def btn8_press(self): EventMesh.publish("load_screen", {"screen": "main_menu"}) - pass \ No newline at end of file + pass + +al_no_sim_popup_screen = None +al_no_sim_popup_screen_title1 = None +al_no_sim_popup_screen_title2 = None +al_no_sim_popup_screen_title3 = None +al_no_sim_popup_screen_title4 =None +al_no_sim_popup_screen_icon = None +al_no_sim_popup_screen_icon1 = None +#启动失败 请先开启移动数据 +class AINoSimScreen(Screen):# + NAME = "ai_no_sim_popup" + def __init__(self): + super().__init__() + self.meta = None + self.meta_type = "popup" + self.checkMode = "0" + + def initialization(self): + self.checkMode = "0" + global al_no_sim_popup_screen,al_no_sim_popup_screen_title4,al_no_sim_popup_screen_icon1,al_no_sim_popup_screen_title1,al_no_sim_popup_screen_icon,al_no_sim_popup_screen_title2,al_no_sim_popup_screen_title3 + if al_no_sim_popup_screen == None : + al_no_sim_popup_screen = lv.obj() + print("no_sim_popup_screen") + al_no_sim_popup_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_no_sim_popup_screen_title1 = lv.label(al_no_sim_popup_screen) + al_no_sim_popup_screen_title1.set_pos(0, 20) + al_no_sim_popup_screen_title1.set_size(LCD_SIZE_W, 40) + al_no_sim_popup_screen_title1.set_text("AI智能助手") + al_no_sim_popup_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_no_sim_popup_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_no_sim_popup_screen_icon = lv.img(al_no_sim_popup_screen) + al_no_sim_popup_screen_icon.set_size(42,42) + al_no_sim_popup_screen_icon.set_pos((240-42)//2,60) + al_no_sim_popup_screen_icon.set_src("E:/static/ai_warning.png") + al_no_sim_popup_screen_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + + al_no_sim_popup_screen_title2 = lv.label(al_no_sim_popup_screen) + al_no_sim_popup_screen_title2.set_pos(0, 125) + al_no_sim_popup_screen_title2.set_size(LCD_SIZE_W, 40) + al_no_sim_popup_screen_title2.set_text("启动失败") + al_no_sim_popup_screen_title2.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_no_sim_popup_screen_title2.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_no_sim_popup_screen_title3 = lv.label(al_no_sim_popup_screen) + al_no_sim_popup_screen_title3.set_pos(0, 165) + al_no_sim_popup_screen_title3.set_size(LCD_SIZE_W, 40) + al_no_sim_popup_screen_title3.set_text("请先开启移动数据") + al_no_sim_popup_screen_title3.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_no_sim_popup_screen_title3.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + + al_no_sim_popup_screen_icon1 = lv.img(al_no_sim_popup_screen) + al_no_sim_popup_screen_icon1.set_size(230,58) + al_no_sim_popup_screen_icon1.set_pos((240-230)//2,210) + al_no_sim_popup_screen_icon1.set_src("E:/static/ai_confirm_bt.png") + al_no_sim_popup_screen_icon1.add_flag(lv.obj.FLAG.CLICKABLE) + al_no_sim_popup_screen_icon1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_no_sim_popup_screen_title4 = lv.label(al_no_sim_popup_screen_icon1) + al_no_sim_popup_screen_title4.set_pos(0, 18) + al_no_sim_popup_screen_title4.set_size(230, 58) + al_no_sim_popup_screen_title4.set_text("确定") + al_no_sim_popup_screen_title4.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_no_sim_popup_screen_title4.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + self.meta = al_no_sim_popup_screen + + if al_no_sim_popup_screen_icon1 != None: + al_no_sim_popup_screen_icon1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e)), lv.EVENT.SHORT_CLICKED, None) + self.checkMode = str(self.meta_info) + if self.checkMode =="1": #连接超时 请重新对话 + al_no_sim_popup_screen_title2.set_text("连接超时") + al_no_sim_popup_screen_title3.set_text("请重新对话") + else: + al_no_sim_popup_screen_title2.set_text("启动失败") + al_no_sim_popup_screen_title3.set_text("请先开启移动数据") + pass + def img_cb(self,e): + if self.checkMode == "0": + EventMesh.publish("load_screen", {"screen": "ai_talk_popup"}) + else: + EventMesh.publish("load_screen", {"screen": "ai_listen_popup"}) + + def done_return(self): + EventMesh.publish("return_prev_screen") + + + def btn1_release(self): + EventMesh.publish("return_prev_screen") + + def done_left_to_right(self): + EventMesh.publish("return_prev_screen") + + def done_right_to_left(self): + EventMesh.publish("return_prev_screen") + + def done_bottom_to_top(self): + EventMesh.publish("return_prev_screen") + + def done_top_to_bottom(self): + EventMesh.publish("return_prev_screen") + + def btn8_press(self): + EventMesh.publish("return_prev_screen") +al_talk_screen = None +al_talk_screen_title1 = None +al_talk_screen_title2 = None +al_talk_screen_title3 = None +al_talk_screen_title4 =None +al_talk_screen_icon = None +al_talk_screen_icon1 = None +#AI对话界面 +class AITalkScreen(Screen):# + NAME = "ai_talk_popup" + def __init__(self): + super().__init__() + self.meta = None + + def initialization(self): + global al_talk_screen,al_talk_screen_title4,al_talk_screen_icon1,al_talk_screen_title1,al_talk_screen_icon,al_talk_screen_title2,al_talk_screen_title3 + if al_talk_screen == None : + al_talk_screen = lv.obj() + print("no_sim_popup_screen") + al_talk_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_talk_screen_title1 = lv.label(al_talk_screen) + al_talk_screen_title1.set_pos(0, 20) + al_talk_screen_title1.set_size(LCD_SIZE_W, 40) + al_talk_screen_title1.set_text("AI智能助手") + al_talk_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_talk_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + + al_talk_screen_icon1 = lv.img(al_talk_screen) + al_talk_screen_icon1.set_size(32,32) + al_talk_screen_icon1.set_pos((240-32)//2,110) + al_talk_screen_icon1.set_src("E:/static/ai_listen.png") + al_talk_screen_icon1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_talk_screen_icon = lv.img(al_talk_screen) + al_talk_screen_icon.set_size(230,58) + al_talk_screen_icon.set_pos((240-230)//2,210) + al_talk_screen_icon.set_src("E:/static/ai_talk_bt.png") + al_talk_screen_icon.add_flag(lv.obj.FLAG.CLICKABLE) + al_talk_screen_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_talk_screen_title4 = lv.label(al_talk_screen_icon) + al_talk_screen_title4.set_pos(0, 18) + al_talk_screen_title4.set_size(230, 58) + al_talk_screen_title4.set_text("开始对话") + al_talk_screen_title4.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_talk_screen_title4.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + self.meta = al_talk_screen + + if al_talk_screen_icon != None: + al_talk_screen_icon.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e)), lv.EVENT.SHORT_CLICKED, None) + def img_cb(self,e): + # EventMesh.publish("load_screen", {"screen": "AI_success"}) + if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#网络不正常 + EventMesh.publish("load_screen", {"screen": "ai_listen_popup"}) + else: + EventMesh.publish("load_screen", {"screen": "ai_no_sim_popup","meta":str("0")}) + + def done_return(self): + EventMesh.publish("return_prev_screen") + + + def btn1_release(self): + EventMesh.publish("return_prev_screen") + + def done_left_to_right(self): + EventMesh.publish("return_prev_screen") + + def done_right_to_left(self): + EventMesh.publish("return_prev_screen") + + def done_bottom_to_top(self): + EventMesh.publish("return_prev_screen") + + def done_top_to_bottom(self): + EventMesh.publish("return_prev_screen") + + def btn8_press(self): + EventMesh.publish("return_prev_screen") + + +al_listen_screen = None +al_listen_screen_title1 = None +al_listen_screen_title2 = None +al_listen_screen_title3 = None +al_listen_screen_title4 =None +al_listen_screen_icon = None +al_listen_screen_icon1 = None +#AI聆听界面 +class AIListenScreen(Screen):# + NAME = "ai_listen_popup" + def __init__(self): + super().__init__() + self.meta = None + self.meta_type = "popup" + self.listeTimerCount = 0 + + self.listeTimer = osTimer() + + def initialization(self): + global al_listen_screen,al_listen_screen_title4,al_listen_screen_icon1,al_listen_screen_title1,al_listen_screen_icon,al_listen_screen_title2,al_listen_screen_title3 + if al_listen_screen == None : + al_listen_screen = lv.obj() + print("al_listen_screen") + al_listen_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_listen_screen_title1 = lv.label(al_listen_screen) + al_listen_screen_title1.set_pos(0, 20) + al_listen_screen_title1.set_size(LCD_SIZE_W, 40) + al_listen_screen_title1.set_text("正在聆听...") + al_listen_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_listen_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + + al_listen_screen_icon1 = lv.img(al_listen_screen) + al_listen_screen_icon1.set_size(32,32) + al_listen_screen_icon1.set_pos((240-32)//2,110) + al_listen_screen_icon1.set_src("E:/static/ai_listen.png") + al_listen_screen_icon1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_listen_screen_icon = lv.img(al_listen_screen) + al_listen_screen_icon.set_size(230,58) + al_listen_screen_icon.set_pos((240-230)//2,210) + al_listen_screen_icon.set_src("E:/static/ai_confirm_bt.png") + al_listen_screen_icon.add_flag(lv.obj.FLAG.CLICKABLE) + al_listen_screen_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_listen_screen_title4 = lv.label(al_listen_screen_icon) + al_listen_screen_title4.set_pos(0, 18) + al_listen_screen_title4.set_size(230, 58) + al_listen_screen_title4.set_text("说话完成") + al_listen_screen_title4.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_listen_screen_title4.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + self.meta = al_listen_screen + + if al_listen_screen_icon != None: + al_listen_screen_icon.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e)), lv.EVENT.SHORT_CLICKED, None) + self.listeTimerCount = 0 + self.listeTimer.start(500,1,self.text_show_cb) + def text_show_cb(self,*argc): + EventMesh.publish("system_sleep_rest")#防止黑屏 + if al_listen_screen_title1 != None: + self.listeTimerCount+=1 + if self.listeTimerCount > 3: + self.listeTimerCount = 0 + if self.listeTimerCount == 1: + al_listen_screen_title1.set_text("正在聆听.") + elif self.listeTimerCount == 2: + al_listen_screen_title1.set_text("正在聆听..") + else: + al_listen_screen_title1.set_text("正在聆听...") + + def Close(self): + self.listeTimerCount = 0 + self.listeTimer.stop() + + def img_cb(self,e): + if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#网络不正常 + EventMesh.publish("load_screen", {"screen": "ai_think_popup"}) + else: + EventMesh.publish("load_screen", {"screen": "ai_no_sim_popup","meta":str("1")}) + + + def done_return(self): + pass + # EventMesh.publish("return_prev_screen") + + + def btn1_release(self): + pass + # EventMesh.publish("return_prev_screen") + + def btn8_press(self): + pass + # EventMesh.publish("return_prev_screen") + + +al_think_screen = None +al_think_screen_title1 = None +al_think_screen_title2 = None +al_think_screen_title3 = None +al_think_screen_title4 =None +al_think_screen_icon = None +al_think_screen_icon1 = None +#AI思考界面 +class AIThinkScreen(Screen):# + NAME = "ai_think_popup" + def __init__(self): + super().__init__() + self.meta = None + self.meta_type = "popup" + self.listeTimerCount = 0 + self.listeTimer = osTimer() + + def initialization(self): + global al_think_screen,al_think_screen_title4,al_think_screen_icon,al_think_screen_title1,al_think_screen_icon1,al_think_screen_title2,al_think_screen_title3 + if al_think_screen == None : + al_think_screen = lv.obj() + print("al_think_screen") + al_think_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_think_screen_title1 = lv.label(al_think_screen) + al_think_screen_title1.set_pos(0, 20) + al_think_screen_title1.set_size(LCD_SIZE_W, 40) + al_think_screen_title1.set_text("正在思考...") + al_think_screen_title1.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_think_screen_title1.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + + al_think_screen_icon = lv.img(al_think_screen) + al_think_screen_icon.set_size(63,63) + al_think_screen_icon.set_pos((240-63)//2,90) + al_think_screen_icon.set_src("E:/static/ai_listen_gif.png") + al_think_screen_icon.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_think_screen_icon1 = lv.img(al_think_screen) + al_think_screen_icon1.set_size(230,58) + al_think_screen_icon1.set_pos((240-230)//2,210) + al_think_screen_icon1.set_src("E:/static/ai_confirm_bt.png") + al_think_screen_icon1.add_flag(lv.obj.FLAG.CLICKABLE) + al_think_screen_icon1.add_style(style_img, lv.PART.MAIN | lv.STATE.DEFAULT) + + al_think_screen_title4 = lv.label(al_think_screen_icon1) + al_think_screen_title4.set_pos(0, 18) + al_think_screen_title4.set_size(230, 58) + al_think_screen_title4.set_text("取消") + al_think_screen_title4.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) + al_think_screen_title4.add_style(style_font_youyuan_ai_20, lv.PART.MAIN | lv.STATE.DEFAULT) + + self.meta = al_think_screen + + if al_think_screen_icon1 != None: + al_think_screen_icon1.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e)), lv.EVENT.SHORT_CLICKED, None) + self.listeTimerCount = 0 + self.listeTimer.start(500,1,self.text_show_cb) + def text_show_cb(self,*argc): + EventMesh.publish("system_sleep_rest")#防止黑屏 + if al_think_screen_title1 != None: + self.listeTimerCount+=1 + if self.listeTimerCount > 3: + self.listeTimerCount = 0 + if self.listeTimerCount == 1: + al_think_screen_title1.set_text("正在思考.") + elif self.listeTimerCount == 2: + al_think_screen_title1.set_text("正在思考..") + else: + al_think_screen_title1.set_text("正在思考...") + if EventMesh.publish(constants.EVENT.GET_CONNECT) == 0:#网络不正常 + EventMesh.publish("load_screen", {"screen": "ai_no_sim_popup","meta":str("1")}) + else: + EventMesh.publish("load_screen", {"screen": "AI_success"}) + pass + def Close(self): + self.listeTimerCount = 0 + self.listeTimer.stop() + + def img_cb(self,e): + EventMesh.publish("load_screen", {"screen": "ai_talk_popup"}) + + def done_return(self): + pass + # EventMesh.publish("return_prev_screen") + + + def btn1_release(self): + pass + # EventMesh.publish("return_prev_screen") + + def btn8_press(self): + pass + # EventMesh.publish("return_prev_screen") + diff --git a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/main_init.py b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/main_init.py index ba9af7cb..a7083721 100644 --- a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/main_init.py +++ b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/main_init.py @@ -220,8 +220,20 @@ def main_init(): #AI try: - from usr.ai import AIScreen + from usr.ai import AIScreen,AINoSimScreen,AITalkScreen,AIListenScreen,AIThinkScreen + + # import ai + # ui.add_screen(ai.AIScreen()) + # ui.add_screen(ai.AINoSimScreen()) + # ui.add_screen(ai.AITalkScreen()) + # ui.add_screen(ai.AIListenScreen()) + # ui.add_screen(ai.AIThinkScreen()) + ############################################## ui.add_screen(AIScreen()) + ui.add_screen(AINoSimScreen()) + ui.add_screen(AITalkScreen()) + ui.add_screen(AIListenScreen()) + ui.add_screen(AIThinkScreen()) except Exception as e: usys.print_exception(e) diff --git a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/mgr.py b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/mgr.py index ea276674..fdac57f6 100644 --- a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/mgr.py +++ b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/mgr.py @@ -1117,14 +1117,15 @@ class DeviceInfoManager(Abstract): msg_nums = sms.getMsgNums() #获取短信条数 if(msg_nums != -1): sms_data = sms.getSaveLoc() - sms_max = sms_data[0][2] - if msg_nums >= sms_max-1: - self.sms_full_flag+=10 - if self.sms_full_flag >= 120: - self.sms_full_flag=0 - EventMesh.publish("load_screen", {"screen": "message_full"}) - else: - self.sms_full_flag = 0 + if sms_data != -1: + sms_max = sms_data[0][2] + if msg_nums >= sms_max-1: + self.sms_full_flag+=10 + if self.sms_full_flag >= 120: + self.sms_full_flag=0 + EventMesh.publish("load_screen", {"screen": "message_full"}) + else: + self.sms_full_flag = 0 except Exception as e: usys.print_exception(e) EventMesh.txt_log("publish_event3:".format(e)) diff --git a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui.py b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui.py index f0b1c81c..304ddf35 100644 --- a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui.py +++ b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui.py @@ -2166,6 +2166,8 @@ def msg_cb(args): storage = args[2] print("index:{}".format(index)) sms_data = sms.getSaveLoc() + if sms_data == -1: + return sms_max = sms_data[0][2] if index != -1: tmp = sms.searchTextMsg(index) diff --git a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui_main_menu.py b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui_main_menu.py index 12f7eb6b..fd5fd63c 100644 --- a/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui_main_menu.py +++ b/2.sdk/project/W8/sdk/services/microPython/ports/quectel/core/ui_main_menu.py @@ -244,6 +244,29 @@ MainMenu2_img_sms_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STAT MainMenu2_num+=1 MainMenu2x+=1 +#AI助手 +MainMenu2_ai = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT) +label_text = lv.label(MainMenu2_ai) +label_text.set_pos(0, LCD_SIZE_H) +label_text.set_size(0, 0) +label_text.set_text("{}".format(MainMenu2_num)) +MainMenu2_img_ai = lv.img(MainMenu2_ai) +MainMenu2_img_ai.set_size(MAIN_ICON_SZIE,MAIN_ICON_SZIE) +MainMenu2_img_ai.set_pos(MAIN_ICON_X,MAIN_ICON_Y) +MainMenu2_img_ai.set_src("U:/static/IMAGE_ONE_PAGE_AI.png") +MainMenu2_img_ai.add_flag(lv.obj.FLAG.CLICKABLE) +MainMenu2_img_ai.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) + +MainMenu2_img_ai_txt = lv.label(MainMenu2_ai) +MainMenu2_img_ai_txt.set_pos(int(0),int(MAIN_LABEL_Y)) +MainMenu2_img_ai_txt.set_size(LCD_SIZE_W,LCD_SIZE_H-MAIN_LABEL_Y) +MainMenu2_img_ai_txt.add_flag(lv.obj.FLAG.CLICKABLE) +MainMenu2_img_ai_txt.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +MainMenu2_img_ai_txt.set_text("AI助手") +MainMenu2_img_ai_txt.add_style(style_font_youyuan_font_60, lv.PART.MAIN|lv.STATE.DEFAULT) +MainMenu2_num+=1 +MainMenu2x+=1 + #微聊 MainMenu2_wechat = MainMenu2_til.add_tile(MainMenu2x, 0, lv.DIR.LEFT | lv.DIR.RIGHT) label_text = lv.label(MainMenu2_wechat) @@ -550,8 +573,17 @@ MainMenu1_img_wechat.set_src("U:/static/theme1/THEME1_WECHAT.png") # MainMenu1_img_wechat.add_flag(lv.obj.FLAG.CLICKABLE) MainMenu1_img_wechat.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) +MainMenu1_img_ai_text = lv.label(MainMenu1_three) +MainMenu1_img_ai_text.set_pos(MAIN1_ICON_X,MAIN1_ICON_Y+5) +MainMenu1_img_ai_text.set_size(THEME1_ICON_X,THEME1_ICON_X) +MainMenu1_img_ai_text.add_flag(lv.obj.FLAG.CLICKABLE) +MainMenu1_img_ai_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +MainMenu1_img_ai_text.set_text(" ") +MainMenu1_img_ai_text.add_style(style_font_youyuan_20_black, lv.PART.MAIN|lv.STATE.DEFAULT) + + MainMenu1_img_wechat_text = lv.label(MainMenu1_three) -MainMenu1_img_wechat_text.set_pos(MAIN1_ICON_X,MAIN1_ICON_Y+5) +MainMenu1_img_wechat_text.set_pos(MAIN1_ICON_X*2+85,MAIN1_ICON_Y+5) MainMenu1_img_wechat_text.set_size(THEME1_ICON_X,THEME1_ICON_X) MainMenu1_img_wechat_text.add_flag(lv.obj.FLAG.CLICKABLE) MainMenu1_img_wechat_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) @@ -566,7 +598,7 @@ MainMenu1_img_wechat_text.add_style(style_font_youyuan_20_black, lv.PART.MAIN|lv # MainMenu1_img_alarm.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) MainMenu1_img_alarm_text = lv.label(MainMenu1_three) -MainMenu1_img_alarm_text.set_pos(MAIN1_ICON_X*2+85,MAIN1_ICON_Y+5) +MainMenu1_img_alarm_text.set_pos(MAIN1_ICON_X,140+5) MainMenu1_img_alarm_text.set_size(THEME1_ICON_X,THEME1_ICON_X) MainMenu1_img_alarm_text.add_flag(lv.obj.FLAG.CLICKABLE) MainMenu1_img_alarm_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) @@ -581,7 +613,7 @@ MainMenu1_img_alarm_text.add_style(style_font_youyuan_20_black, lv.PART.MAIN|lv. # MainMenu1_img_stopwatch.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) MainMenu1_img_stopwatch_text = lv.label(MainMenu1_three) -MainMenu1_img_stopwatch_text.set_pos(MAIN1_ICON_X,140+5) +MainMenu1_img_stopwatch_text.set_pos(MAIN1_ICON_X*2+85,140+5) MainMenu1_img_stopwatch_text.set_size(THEME1_ICON_X,THEME1_ICON_Y) MainMenu1_img_stopwatch_text.add_flag(lv.obj.FLAG.CLICKABLE) MainMenu1_img_stopwatch_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) @@ -595,13 +627,7 @@ MainMenu1_img_stopwatch_text.add_style(style_font_youyuan_20_black, lv.PART.MAIN # MainMenu1_img_countdown.add_flag(lv.obj.FLAG.CLICKABLE) # MainMenu1_img_countdown.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) -MainMenu1_img_countdown_text = lv.label(MainMenu1_three) -MainMenu1_img_countdown_text.set_pos(MAIN1_ICON_X*2+85,140+5) -MainMenu1_img_countdown_text.set_size(THEME1_ICON_X,THEME1_ICON_Y) -MainMenu1_img_countdown_text.add_flag(lv.obj.FLAG.CLICKABLE) -MainMenu1_img_countdown_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) -MainMenu1_img_countdown_text.set_text(" ") -MainMenu1_img_countdown_text.add_style(style_font_youyuan_20_black, lv.PART.MAIN|lv.STATE.DEFAULT) + MainMenu1_num+=1 MainMenu1x+=1 @@ -662,14 +688,22 @@ label_text.set_size(0, 0) label_text.set_text("{}".format(MainMenu1_num)) MainMenu1_img_setting = lv.img(MainMenu1_setting) -MainMenu1_img_setting.set_size(240,140) +MainMenu1_img_setting.set_size(240,282) MainMenu1_img_setting.set_pos(0,0) MainMenu1_img_setting.set_src("U:/static/theme1/THEME1_SETING.png") # MainMenu1_img_setting.add_flag(lv.obj.FLAG.CLICKABLE) MainMenu1_img_setting.add_style(style_MainMenu_img_default, lv.PART.MAIN | lv.STATE.DEFAULT) +MainMenu1_img_countdown_text = lv.label(MainMenu1_setting) +MainMenu1_img_countdown_text.set_pos(MAIN1_ICON_X,MAIN1_ICON_Y+5) +MainMenu1_img_countdown_text.set_size(THEME1_ICON_X,THEME1_ICON_Y) +MainMenu1_img_countdown_text.add_flag(lv.obj.FLAG.CLICKABLE) +MainMenu1_img_countdown_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) +MainMenu1_img_countdown_text.set_text(" ") +MainMenu1_img_countdown_text.add_style(style_font_youyuan_20_black, lv.PART.MAIN|lv.STATE.DEFAULT) + MainMenu1_img_toolbox_text = lv.label(MainMenu1_setting) -MainMenu1_img_toolbox_text.set_pos(int(MAIN1_ICON_X),int(MAIN1_ICON_Y+5)) +MainMenu1_img_toolbox_text.set_pos(int(MAIN1_ICON_X*2+85),int(MAIN1_ICON_Y+5)) MainMenu1_img_toolbox_text.set_size(THEME1_ICON_X,THEME1_ICON_X) MainMenu1_img_toolbox_text.add_flag(lv.obj.FLAG.CLICKABLE) MainMenu1_img_toolbox_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) @@ -677,7 +711,7 @@ MainMenu1_img_toolbox_text.set_text(" ") MainMenu1_img_toolbox_text.add_style(style_font_youyuan_20_black, lv.PART.MAIN|lv.STATE.DEFAULT) MainMenu1_img_setting_text = lv.label(MainMenu1_setting) -MainMenu1_img_setting_text.set_pos(int(MAIN1_ICON_X*2+85),int(MAIN1_ICON_Y+5)) +MainMenu1_img_setting_text.set_pos(int(MAIN1_ICON_X),int(140+5)) MainMenu1_img_setting_text.set_size(THEME1_ICON_X,THEME1_ICON_X) MainMenu1_img_setting_text.add_flag(lv.obj.FLAG.CLICKABLE) MainMenu1_img_setting_text.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0) @@ -784,6 +818,10 @@ class MainMenuScreen(Screen): MainMenu1_img_temp_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "temperature")), lv.EVENT.SHORT_CLICKED, None) MainMenu1_img_temp_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "temperature")), lv.EVENT.PRESSING, None) + MainMenu1_img_ai_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.SHORT_CLICKED, None) + MainMenu1_img_ai_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.PRESSING, None) + + MainMenu1_img_wechat_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "wechat")), lv.EVENT.SHORT_CLICKED, None) MainMenu1_img_wechat_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "wechat")), lv.EVENT.PRESSING, None) @@ -804,8 +842,8 @@ class MainMenuScreen(Screen): MainMenu1_img_video_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "videolist")), lv.EVENT.PRESSING, None) # MainMenu1_img_alipay_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.SHORT_CLICKED, None) # MainMenu1_img_alipay_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.PRESSING, None) - MainMenu1_img_alipay_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.SHORT_CLICKED, None) - MainMenu1_img_alipay_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.PRESSING, None) + MainMenu1_img_alipay_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.SHORT_CLICKED, None) + MainMenu1_img_alipay_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.PRESSING, None) MainMenu1_img_toolbox_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "toolbox")), lv.EVENT.SHORT_CLICKED, None) MainMenu1_img_toolbox_text.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "toolbox")), lv.EVENT.PRESSING, None) @@ -824,11 +862,13 @@ class MainMenuScreen(Screen): MainMenu2_img_setting.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "setting")), lv.EVENT.SHORT_CLICKED, None) MainMenu2_img_health.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "health")), lv.EVENT.SHORT_CLICKED, None) MainMenu2_img_contacts.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "contacts")), lv.EVENT.SHORT_CLICKED, None) + MainMenu2_img_ai.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.SHORT_CLICKED, None) + MainMenu2_img_wechat.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "wechat")), lv.EVENT.SHORT_CLICKED, None) # MainMenu2_img_spo2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "spo2")), lv.EVENT.SHORT_CLICKED, None) MainMenu2_img_sms.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.SHORT_CLICKED, None) #MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.SHORT_CLICKED, None) - MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.SHORT_CLICKED, None) + MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.SHORT_CLICKED, None) MainMenu2_img_camera_video.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "videolist")), lv.EVENT.SHORT_CLICKED, None) MainMenu2_img_camera.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "camera")), lv.EVENT.SHORT_CLICKED, None) MainMenu2_img_camera_album.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "camera_album")), lv.EVENT.SHORT_CLICKED, None) @@ -838,11 +878,12 @@ class MainMenuScreen(Screen): MainMenu2_img_setting.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "setting")), lv.EVENT.PRESSING, None) MainMenu2_img_health.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "health")), lv.EVENT.PRESSING, None) MainMenu2_img_contacts.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "contacts")), lv.EVENT.PRESSING, None) + MainMenu2_img_ai.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.PRESSING, None) MainMenu2_img_wechat.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "wechat")), lv.EVENT.PRESSING, None) # MainMenu2_img_spo2.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "spo2")), lv.EVENT.CLICKED, None) MainMenu2_img_sms.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "popup")), lv.EVENT.PRESSING, None) #MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.PRESSING, None) - MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "AI_success")), lv.EVENT.PRESSING, None) + MainMenu2_img_alipay.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "alipay_open")), lv.EVENT.PRESSING, None) MainMenu2_img_camera_video.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "videolist")), lv.EVENT.PRESSING, None) MainMenu2_img_camera.add_event_cb(lambda e: EventMesh.callback_wrapper(self.img_cb(e, "camera")), lv.EVENT.PRESSING, None) @@ -946,15 +987,24 @@ class MainMenuScreen(Screen): #utime.sleep_ms(10) print("1self.is_sliding",self.is_sliding) if self.is_sliding <= 5 and self.is_sliding != 0:#如果是在滑动中则不需要点击事件 + self.is_sliding = 0 print("img_cb:{}".format(msg)) + if msg == "AI_success":#ai语音界面需要判断网络是不是正常 + # if EventMesh.publish(constants.EVENT.GET_CONNECT) == 1:#网络不正常 + EventMesh.publish("load_screen", {"screen": "{}".format("ai_talk_popup")}) + return + EventMesh.publish("load_screen", {"screen": "{}".format(msg)}) - self.is_sliding = 0 + else: + self.is_sliding = 0 def lcd_on(self): + self.is_sliding = 0 self.watchface.watchface_style.timerout_update() self.watchface.timer_update.start(10000, 1, self.watchface.timerout_update) def lcd_off(self): + self.is_sliding = 0 self.watchface.timer_update.stop() def done_return(self): @@ -981,6 +1031,7 @@ class MainMenuScreen(Screen): def btn8_press(self): + self.is_sliding = 0 flag = EventMesh.publish("get_lcd_state") if self.MainMenu_til.get_tile_act() != None: id = self.MainMenu_til.get_tile_act().get_child(0).get_text() @@ -1001,16 +1052,20 @@ class MainMenuScreen(Screen): EventMesh.publish(constants.EVENT.SYSTEM_UP) def done_bottom_to_top(self): + id = self.MainMenu_til.get_tile_act().get_child(0).get_text() if id == "0": EventMesh.publish("load_screen", {"screen": "call_log"}) self.menu_id = id + self.is_sliding = 0 def done_top_to_bottom(self): id = self.MainMenu_til.get_tile_act().get_child(0).get_text() if id == "0": EventMesh.publish("load_screen", {"screen": "popup"}) self.menu_id = id + self.is_sliding = 0 + def done_left_to_right(self): id = self.MainMenu_til.get_tile_act().get_child(0).get_text() print("done_left_to_right:ID{} menu_id{}".format(id,self.menu_id)) @@ -1021,6 +1076,8 @@ class MainMenuScreen(Screen): elif self.menu_id == id : self.menu_action = 1 self.menu_id = id + self.is_sliding = 0 + def done_right_to_left(self): id = self.MainMenu_til.get_tile_act().get_child(0).get_text() print("done_right_to_left:ID{} menu_id{}".format(id,self.menu_id)) @@ -1030,7 +1087,9 @@ class MainMenuScreen(Screen): self.MainMenu_til.set_tile_id(0,0,lv.ANIM.OFF) else : self.menu_action = 2 - self.menu_id = id + self.menu_id = id + self.is_sliding = 0 + def done_DOWN(self):#下滑 id = self.MainMenu_til.get_tile_act().get_child(0).get_text() print("done_right_to_left: {} {} {}".format(id,self.menu_id,self.MainMenu_num)) @@ -1044,6 +1103,8 @@ class MainMenuScreen(Screen): else : self.MainMenu_til.set_tile_id(int(id)-2,0,lv.ANIM.OFF) self.menu_id = id + self.is_sliding = 0 + def done_UP(self):#上滑 id = self.MainMenu_til.get_tile_act().get_child(0).get_text() print("done_right_to_left: {} {} {}".format(id,self.menu_id,self.MainMenu_num)) @@ -1058,6 +1119,7 @@ class MainMenuScreen(Screen): self.MainMenu_til.set_tile_id(int(id),0,lv.ANIM.OFF) self.menu_id = id + self.is_sliding = 0 def Close(self): self.watchface.Close() print("main_menu Close !!!!!!!!") diff --git a/2.sdk/project/W8/usr/static/theme1/THEME1_SETING.png b/2.sdk/project/W8/usr/static/theme1/THEME1_SETING.png index 82a1ee46..2604bd34 100644 Binary files a/2.sdk/project/W8/usr/static/theme1/THEME1_SETING.png and b/2.sdk/project/W8/usr/static/theme1/THEME1_SETING.png differ diff --git a/2.sdk/project/W8/usr/static/theme1/THEME1_WECHAT.png b/2.sdk/project/W8/usr/static/theme1/THEME1_WECHAT.png index 802f3810..9c57a032 100644 Binary files a/2.sdk/project/W8/usr/static/theme1/THEME1_WECHAT.png and b/2.sdk/project/W8/usr/static/theme1/THEME1_WECHAT.png differ