فهرست منبع

准备移动到笔记本上进行开发

JamZYM 6 ماه پیش
والد
کامیت
7d1fe49ab7
5فایلهای تغییر یافته به همراه222 افزوده شده و 10 حذف شده
  1. 2 1
      .gitignore
  2. 3 3
      buildozer.spec
  3. 153 0
      environment.yml
  4. 51 6
      main.py
  5. 13 0
      sti2021a.kv

+ 2 - 1
.gitignore

@@ -1,3 +1,4 @@
 .buildozer/*
 bin/*
-pong.kv
+pong.kv
+test.py

+ 3 - 3
buildozer.spec

@@ -1,10 +1,10 @@
 [app]
 
 # (str) Title of your application
-title = PongApp
+title = STI2021A
 
 # (str) Package name
-package.name = pongapp
+package.name = debug
 
 # (str) Package domain (needed for android/ios packaging)
 package.domain = org.test
@@ -37,7 +37,7 @@ version = 1.0
 
 # (list) Application requirements
 # comma separated e.g. requirements = sqlite3,kivy
-requirements = python3,kivy
+requirements = python3,kivy,bleak,asyncio
 
 # (str) Custom source folders for requirements
 # Sets custom source for any requirements with recipes

+ 153 - 0
environment.yml

@@ -0,0 +1,153 @@
+name: kivy
+channels:
+  - conda-forge
+  - defaults
+dependencies:
+  - _libgcc_mutex=0.1=conda_forge
+  - _openmp_mutex=4.5=2_gnu
+  - alsa-lib=1.2.12=h4ab18f5_0
+  - aom=3.9.1=hac33072_0
+  - attr=2.5.1=h166bdaf_1
+  - brotli-python=1.1.0=py311hb755f60_1
+  - bzip2=1.0.8=hd590300_5
+  - ca-certificates=2024.7.4=hbcca054_0
+  - cairo=1.18.0=hbb29018_2
+  - certifi=2024.7.4=pyhd8ed1ab_0
+  - cffi=1.16.0=py311hb3a22ac_0
+  - charset-normalizer=3.3.2=pyhd8ed1ab_0
+  - cython=3.0.10=py311h5eee18b_0
+  - dav1d=1.2.1=hd590300_0
+  - dbus=1.13.6=h5008d03_3
+  - docutils=0.21.2=pyhd8ed1ab_0
+  - expat=2.6.2=h59595ed_0
+  - fluidsynth=2.3.5=h8b45d9c_0
+  - font-ttf-dejavu-sans-mono=2.37=hab24e00_0
+  - font-ttf-inconsolata=3.000=h77eed37_0
+  - font-ttf-source-code-pro=2.038=h77eed37_0
+  - font-ttf-ubuntu=0.83=h77eed37_2
+  - fontconfig=2.14.2=h14ed4e7_0
+  - fonts-conda-ecosystem=1=0
+  - fonts-conda-forge=1=0
+  - freetype=2.12.1=h267a509_2
+  - gettext=0.22.5=h59595ed_2
+  - gettext-tools=0.22.5=h59595ed_2
+  - glib=2.80.3=h8a4344b_1
+  - glib-tools=2.80.3=h73ef956_1
+  - graphite2=1.3.13=h59595ed_1003
+  - gst-plugins-base=1.24.5=hbaaba92_0
+  - gstreamer=1.24.5=haf2f30d_0
+  - h2=4.1.0=pyhd8ed1ab_0
+  - harfbuzz=9.0.0=hfac3d4d_0
+  - hpack=4.0.0=pyh9f0ad1d_0
+  - hyperframe=6.0.1=pyhd8ed1ab_0
+  - icu=73.2=h59595ed_0
+  - idna=3.7=pyhd8ed1ab_0
+  - jack=1.9.22=h7c63dc7_2
+  - kivy=2.3.0=py311he512489_1
+  - lame=3.100=h166bdaf_1003
+  - lcms2=2.16=hb7c19ff_0
+  - ld_impl_linux-64=2.40=hf3520f5_7
+  - lerc=4.0.0=h27087fc_0
+  - libasprintf=0.22.5=h661eb56_2
+  - libasprintf-devel=0.22.5=h661eb56_2
+  - libavif16=1.0.4=h9b56c87_5
+  - libcap=2.69=h0f662aa_0
+  - libdb=6.2.32=h9c3ff4c_0
+  - libdeflate=1.20=hd590300_0
+  - libexpat=2.6.2=h59595ed_0
+  - libffi=3.4.2=h7f98852_5
+  - libflac=1.4.3=h59595ed_0
+  - libgcc-ng=14.1.0=h77fa898_0
+  - libgcrypt=1.11.0=h4ab18f5_0
+  - libgettextpo=0.22.5=h59595ed_2
+  - libgettextpo-devel=0.22.5=h59595ed_2
+  - libglib=2.80.3=h8a4344b_1
+  - libgomp=14.1.0=h77fa898_0
+  - libgpg-error=1.50=h4f305b6_0
+  - libiconv=1.17=hd590300_2
+  - libjpeg-turbo=3.0.0=hd590300_1
+  - libmad=0.15.1b=h0b41bf4_1001
+  - libnsl=2.0.1=hd590300_0
+  - libogg=1.3.5=h4ab18f5_0
+  - libopus=1.3.1=h7f98852_1
+  - libpng=1.6.43=h2797004_0
+  - libsndfile=1.2.2=hc60ed4a_1
+  - libsqlite=3.46.0=hde9e2c9_0
+  - libstdcxx-ng=14.1.0=hc0a3c3a_0
+  - libsystemd0=255=h3516f8a_1
+  - libtiff=4.6.0=h1dd3fc0_3
+  - libuuid=2.38.1=h0b41bf4_0
+  - libvorbis=1.3.7=h9c3ff4c_0
+  - libwebp-base=1.4.0=hd590300_0
+  - libxcb=1.16=hd590300_0
+  - libxcrypt=4.4.36=hd590300_1
+  - libzlib=1.3.1=h4ab18f5_1
+  - lz4-c=1.9.4=hcb278e6_0
+  - mpg123=1.32.6=h59595ed_0
+  - ncurses=6.5=h59595ed_0
+  - openjpeg=2.5.2=h488ebb8_0
+  - openssl=3.3.1=h4ab18f5_1
+  - opusfile=0.12=h3358134_2
+  - pcre2=10.44=h0f59acf_0
+  - pillow=10.4.0=py311h82a398c_0
+  - pip=24.0=pyhd8ed1ab_0
+  - pixman=0.43.2=h59595ed_0
+  - portaudio=19.6.0=h7c63dc7_9
+  - pthread-stubs=0.4=h36c2ea0_1001
+  - pulseaudio-client=17.0=hb77b528_0
+  - pycparser=2.22=pyhd8ed1ab_0
+  - pygments=2.18.0=pyhd8ed1ab_0
+  - pysocks=1.7.1=pyha2e5f31_6
+  - python=3.11.9=hb806964_0_cpython
+  - python_abi=3.11=4_cp311
+  - rav1e=0.6.6=he8a937b_2
+  - readline=8.2=h8228510_1
+  - requests=2.32.3=pyhd8ed1ab_0
+  - sdl2=2.30.5=hef7aa77_0
+  - sdl2_image=2.8.2=h06ee604_1
+  - sdl2_mixer=2.6.3=h8830914_1
+  - sdl2_ttf=2.22.0=h08b1b5d_2
+  - setuptools=70.1.1=pyhd8ed1ab_0
+  - svt-av1=2.1.2=hac33072_0
+  - tk=8.6.13=noxft_h4845f30_101
+  - tzdata=2024a=h0c530f3_0
+  - urllib3=2.2.2=pyhd8ed1ab_1
+  - wheel=0.43.0=pyhd8ed1ab_1
+  - xorg-kbproto=1.0.7=h7f98852_1002
+  - xorg-libice=1.1.1=hd590300_0
+  - xorg-libsm=1.2.4=h7391055_0
+  - xorg-libx11=1.8.9=hb711507_1
+  - xorg-libxau=1.0.11=hd590300_0
+  - xorg-libxdmcp=1.1.3=h7f98852_0
+  - xorg-libxext=1.3.4=h0b41bf4_2
+  - xorg-libxrender=0.9.11=hd590300_0
+  - xorg-renderproto=0.11.1=h7f98852_1002
+  - xorg-xextproto=7.3.0=h0b41bf4_1003
+  - xorg-xproto=7.0.31=h7f98852_1007
+  - xz=5.2.6=h166bdaf_0
+  - zlib=1.3.1=h4ab18f5_1
+  - zstandard=0.22.0=py311hb6f056b_1
+  - zstd=1.5.6=ha6fb4c9_0
+  - pip:
+      - appdirs==1.4.4
+      - bleak==0.22.2
+      - build==1.2.1
+      - buildozer==1.5.0
+      - colorama==0.4.6
+      - dbus-fast==2.22.1
+      - distlib==0.3.8
+      - filelock==3.15.4
+      - jinja2==3.1.4
+      - kivy-garden==0.1.5
+      - kivymd==1.2.0
+      - markupsafe==2.1.5
+      - packaging==24.1
+      - pexpect==4.9.0
+      - platformdirs==4.2.2
+      - ptyprocess==0.7.0
+      - pyproject-hooks==1.1.0
+      - sh==1.14.3
+      - toml==0.10.2
+      - typing-extensions==4.12.2
+      - virtualenv==20.26.3
+prefix: /home/jam/anaconda3/envs/kivy

+ 51 - 6
main.py

@@ -1,17 +1,62 @@
 from kivy.app import App
 from kivy.uix.widget import Widget
+from kivy.uix.button import Button
 from kivy.properties import (
-    NumericProperty, ReferenceListProperty, ObjectProperty
+    StringProperty,NumericProperty,
 )
-
 from kivy.clock import Clock
 
+import asyncio
+from bleak import BleakClient,BleakScanner
+
+import json
+
+STM32_UUID = "00001101-0000-1000-8000-00805F9B34FB"
+
+class InfoWidget(Widget): 
+    info = StringProperty("")
+
+    def __init__(self, **kwargs):
+        super(InfoWidget, self).__init__(**kwargs)
+
+    #     asyncio.run(self.discover_devices())
+
+    # async def discover_devices(self):
+    #     devices = await BleakScanner.discover()
+    #     for d in devices:
+    #         button = Button(text=f"{d.address}: {d.name}")
+    #         button.bind(on_press=lambda instance, d=d: asyncio.run(self.connect_and_receive(d.address)))
+    #         self.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()
+    #             data = rawdata.decode("utf-8")
+    #             if data.startswith("[") and data.endswith("]"):
+    #                 list = json.loads(data)
+    #                 self.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:
+    #                 self.info = "传输数据出错"
+    #                 return 
+    #         else:
+    #             print("Failed to connect to device.")
+    def debug(self):
+        for i in range(6):
+            button = Button(text=str(i) + "!!!!!!")
+            self.add_widget(button)
+
 class STI2021A(App):
     def build(self):
-        game = PongGame()
-        game.serve_ball()
-        Clock.schedule_interval(game.update, 1.0 / 60.0)
-        return game
+        info = InfoWidget()
+        info.debug()
+        return info
 
 
 if __name__ == '__main__':

+ 13 - 0
sti2021a.kv

@@ -0,0 +1,13 @@
+<InfoWidget>:
+    orientation: 'vertical'
+    Button:
+        size_hint_y: None
+        width: root.width / 2
+        height: 100
+        font_size: 50
+    Label:
+        font_size: 100 
+        center_x: root.width / 2
+        top: root.top - 50
+        text: str(root.info)
+