添加文件
authorp15692025051 <846603105@qq.com>
Tue, 11 Apr 2023 03:33:10 +0000 (11:33 +0800)
committerp15692025051 <846603105@qq.com>
Tue, 11 Apr 2023 03:33:10 +0000 (11:33 +0800)
3.code/1.watch/2.code/appFactoryMode.py [new file with mode: 0644]
3.code/1.watch/2.code/mgr.py

diff --git a/3.code/1.watch/2.code/appFactoryMode.py b/3.code/1.watch/2.code/appFactoryMode.py
new file mode 100644 (file)
index 0000000..c2ec6d0
--- /dev/null
@@ -0,0 +1,159 @@
+import osTimer
+import lvgl as lv
+from ext import EventMesh
+import osTimer
+from ext import constants
+import ujson
+import ql_fs
+import audio
+from machine import Pin
+from ext.ui import style_screen,style_font_youyuan_20,ContStyle,style_btn,style_img,Screen,style_contact_btn
+import audio
+factorymode_cont_y = 0
+factorymode_screen = lv.obj()
+factorymode_screen.center()
+factorymode_screen.set_size(240, 320)
+factorymode_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_title = lv.label(factorymode_screen)
+factorymode_title.set_pos(0, 10)
+factorymode_title.set_size(240, 40)
+factorymode_title.set_text("-工厂模式-")
+factorymode_title.set_long_mode(lv.label.LONG.WRAP)
+factorymode_title.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
+factorymode_title.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_cont = lv.obj(factorymode_screen)
+factorymode_cont.set_pos(0, 50)
+factorymode_cont.set_size(240, 270)
+factorymode_cont_style = ContStyle()
+factorymode_cont.add_style(
+    factorymode_cont_style.style_cont(0, lv.color_make(0x00, 0x00, 0x00), lv.color_make(0x00, 0x00, 0x00), 255),
+    lv.PART.MAIN | lv.STATE.DEFAULT)
+
+factorymode_location = lv.btn(factorymode_cont)
+factorymode_location.set_pos(0, factorymode_cont_y)
+factorymode_location.set_size(240, 60)
+factorymode_location_label = lv.label(factorymode_location)
+factorymode_location_label.set_text("定位测试")
+factorymode_location.set_style_pad_all(0, lv.STATE.DEFAULT)
+factorymode_location_label.align(lv.ALIGN.LEFT_MID, 70, 0)
+factorymode_location_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+factorymode_location_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+factorymode_location.add_style(style_btn, lv.PART.MAIN | lv.STATE.DEFAULT)
+factorymode_cont_y+=60
+
+class FactoryModeScreen(Screen):
+    NAME = "factorymode"
+    def __init__(self):
+        super().__init__()
+        self.meta = factorymode_screen
+        factorymode_location.add_event_cb(lambda e: self.load_screen(e, {"screen": "FactoryModeLocation"}), lv.EVENT.CLICKED, None)
+    
+
+    def done_return(self):
+        EventMesh.publish("load_screen", {"screen": "main_menu"})
+
+    def btn1_release(self):
+        EventMesh.publish("load_screen", {"screen": "main_menu"})
+        
+    def btn8_press(self):
+        EventMesh.publish("load_screen", {"screen": "watchface"})
+
+
+FactoryModeLocation_screen = lv.obj()
+FactoryModeLocation_screen.center()
+FactoryModeLocation_screen.set_size(240, 320)
+FactoryModeLocation_screen.add_style(style_screen, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeLocation_WIFI_label = lv.label(FactoryModeLocation_screen)
+FactoryModeLocation_WIFI_label.set_text("WIFI:\n")
+FactoryModeLocation_WIFI_label.set_size(240, 80)
+FactoryModeLocation_WIFI_label.set_pos(0, 0)
+FactoryModeLocation_WIFI_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+FactoryModeLocation_WIFI_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeLocation_CALL_label = lv.label(FactoryModeLocation_screen)
+FactoryModeLocation_CALL_label.set_text("CALL:\n")
+FactoryModeLocation_CALL_label.set_size(240, 40)
+FactoryModeLocation_CALL_label.set_pos(0, 80)
+FactoryModeLocation_CALL_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+FactoryModeLocation_CALL_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+FactoryModeLocation_GNSS_label = lv.label(FactoryModeLocation_screen)
+FactoryModeLocation_GNSS_label.set_text("GNSS:\n")
+FactoryModeLocation_GNSS_label.set_size(240, 200)
+FactoryModeLocation_GNSS_label.set_pos(0, 120)
+FactoryModeLocation_GNSS_label.set_style_text_color(lv.color_make(0xff, 0xff, 0xff), lv.STATE.DEFAULT)
+FactoryModeLocation_GNSS_label.add_style(style_font_youyuan_20, lv.PART.MAIN | lv.STATE.DEFAULT)
+
+class FactoryModeLocationScreen(Screen):
+    NAME = "FactoryModeLocation"
+    def __init__(self):
+        super().__init__()
+        self.meta = FactoryModeLocation_screen
+
+    def post_processor_after_initialization(self):
+        EventMesh.subscribe("PUSH_LOCATION_DATA",self.GET_LOCATION_DATA)
+        EventMesh.publish(constants.EVENT.START_LOCATION, 1) #测试模式
+        FactoryModeLocation_GNSS_label.set_text("GNSS:\n") 
+        FactoryModeLocation_WIFI_label.set_text("WIFI:\n")
+        FactoryModeLocation_CALL_label.set_text("CALL:")
+    def GET_LOCATION_DATA(self, event, msg):
+        #print("GPS:{}".format(msg[0]))
+        print("WIFI:{}".format(msg[1]))
+        print("CALL:{}".format(msg[2]))
+        EventMesh.publish("system_sleep_rest")#防止黑屏
+        if msg[1] != [] : #WIFI
+            WIFI_len = len(msg[1][1])
+            WIFI_DATA = "WIFI:\n"
+            if WIFI_len > 3:
+                WIFI_len = 3
+            for i in range(WIFI_len) :
+                WIFI_DATA += "{}\n".format(msg[1][1][i])
+            FactoryModeLocation_WIFI_label.set_text(WIFI_DATA)
+        
+        if len(msg[0]) > 1 : #GPS
+            GNSS_DATA = "GNSS:\n"
+
+            gsv_data = msg[0][1].split("GSV")
+            if len(gsv_data) < 2 :
+                return
+            gsv_data = gsv_data[1:]
+            
+            GSV_dict= {}
+            for i in range(len(gsv_data)) :
+                gsv_data[i] = gsv_data[i].split("\r\n")[0]
+                gsv_tmp = gsv_data[i].split(",")
+                if len(gsv_tmp) < 7 :
+                    break
+                gsv_tmp = gsv_tmp[4:]
+                #print("gsv_tmp:{}".format(gsv_tmp))
+                for i in range(len(gsv_tmp)) :
+                    if i % 4 == 0:
+                        GSV_dict[gsv_tmp[i]] = gsv_tmp[i+3]
+                        #print("GSV_dict:{}:[{}]".format(gsv_tmp[i],gsv_tmp[i+3]))
+                    if len(gsv_tmp)-i < 4:
+                        break 
+            count = 0
+            for key in GSV_dict :
+                GNSS_DATA+="        {}:[{}]\n".format(key,GSV_dict[key])
+                count+=1
+                if count > 9:
+                    break
+            print("GxGSV:{}".format(GNSS_DATA))
+            FactoryModeLocation_GNSS_label.set_text(GNSS_DATA)  
+        if msg[2] != [] :#基站
+            if len(msg[2]) > 2 :
+                FactoryModeLocation_CALL_label.set_text("CALL:{}".format(msg[2][0]))      
+    def Close(self):
+        EventMesh.publish(constants.EVENT.CLOSE_LOCATION) 
+
+    def done_return(self):
+        EventMesh.publish("load_screen", {"screen": "factorymode"})
+
+    def btn1_release(self):
+        EventMesh.publish("load_screen", {"screen": "factorymode"})
+        
+    def btn8_press(self):
+        EventMesh.publish("load_screen", {"screen": "watchface"})
\ No newline at end of file
index 2e41896..f3e76ea 100644 (file)
@@ -902,7 +902,6 @@ class DeviceInfoManager(Abstract):
     def stop_heart(self, topic, msg):
         print("stop_heart!!!")
         self.hsensor.close()
-        
 
     def get_blood_oxygen(self, topic, msg):
         data = self.hsensor.get_all_data()
@@ -1071,6 +1070,7 @@ class LocationManager(Abstract):
         self.cell_data = []
         self.location_timer_count = 0
         self.location_check_data_timer_count = 0
+        self.location_type = 0 #定位类型,0:正常定位,有gps数据或60秒关闭;1:测试模式,只有发CLOSE_LOCATION消息才关闭
     @staticmethod
     def get_date():
         return "{:04d}-{:02d}-{:02d}".format(*utime.localtime()[0:3])
@@ -1189,9 +1189,7 @@ class LocationManager(Abstract):
                             "high": high,
                             "direction": match_vtg_data[1],
                             "speed": match_vtg_data[5],
-                            "number": match_gga_data[7],
-
-                            
+                            "number": match_gga_data[7],   
                         }
             #检查基站数据
             if self.cell_data == []: