JamZYM před 6 měsíci
rodič
revize
d2fba63a42
1 změnil soubory, kde provedl 30 přidání a 30 odebrání
  1. 30 30
      main.py

+ 30 - 30
main.py

@@ -52,36 +52,36 @@ class InfoWidget(Widget):
         #     if num >= 9:
         #         break
 
-    async def connect_and_receive(self, address):
-        async with BleakClient(address) as client:
-            if await client.is_connected():
-                rawdata = await client.read_gatt_char(STM32_UUID)
-                data = rawdata.decode("utf-8")
-                if data.startswith("[") and data.endswith("]"):
-                    list = json.loads(data)
-                    info = "基波频率:" + str(list[0]) + "Hz\n" + \
-                                "THD:" + str(list[6]) + "%\n" + \
-                                "基波幅值:" + str(list[1]) + "V\n" + \
-                                "二次谐波:" + str(list[2]) + "V\n" + \
-                                "三次谐波:" + str(list[3]) + "V\n" + \
-                                "四次谐波:" + str(list[4]) + "V\n" + \
-                                "五次谐波:" + str(list[5]) + "V\n"
-                else:
-                    info = "传输数据出错"
-                label = Label(text=info)
-                self.add_widget(label)
-                return 
-            else:
-                print("Failed to connect to device.")
-    def debug(self):
-        # self.size = (800,480)
-        grid = GridLayout(cols=2,rows=4,width=self.width,height=self.height)
-        self.add_widget(grid)
-        for i in range(8):
-            button = Button(text=str(i))
-            button.width = grid.width / 2
-            button.height = grid.height / 4
-            grid.add_widget(button)
+    # async def connect_and_receive(self, address):
+    #     async with BleakClient(address) as client:
+    #         if await client.is_connected():
+    #             rawdata = await client.read_gatt_char(STM32_UUID)
+    #             data = rawdata.decode("utf-8")
+    #             if data.startswith("[") and data.endswith("]"):
+    #                 list = json.loads(data)
+    #                 info = "基波频率:" + str(list[0]) + "Hz\n" + \
+    #                             "THD:" + str(list[6]) + "%\n" + \
+    #                             "基波幅值:" + str(list[1]) + "V\n" + \
+    #                             "二次谐波:" + str(list[2]) + "V\n" + \
+    #                             "三次谐波:" + str(list[3]) + "V\n" + \
+    #                             "四次谐波:" + str(list[4]) + "V\n" + \
+    #                             "五次谐波:" + str(list[5]) + "V\n"
+    #             else:
+    #                 info = "传输数据出错"
+    #             label = Label(text=info)
+    #             self.add_widget(label)
+    #             return 
+    #         else:
+    #             print("Failed to connect to device.")
+    # def debug(self):
+    #     # self.size = (800,480)
+    #     grid = GridLayout(cols=2,rows=4,width=self.width,height=self.height)
+    #     self.add_widget(grid)
+    #     for i in range(8):
+    #         button = Button(text=str(i))
+    #         button.width = grid.width / 2
+    #         button.height = grid.height / 4
+    #         grid.add_widget(button)
 
 class STI2021A(App):
     def build(self):