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):
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)
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)
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, ())
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")
+
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)
# 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)
# 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)
# 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)
# 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
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)
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)
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)
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)
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)
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)
#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):
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()
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))
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))
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))
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))
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 !!!!!!!!")