Răsfoiți Sursa

fixed imports and doku

subDesTagesMitExtraKaese 4 ani în urmă
părinte
comite
19d3cd1473

+ 21 - 11
software/appWindow.py

@@ -2,24 +2,14 @@
 # License: http://creativecommons.org/licenses/by-sa/3.0/	
 
 from analogPressure.sdpArray import SdpArray
-from digitalPressure.spd610Array import Spd610Array
+from digitalPressure.sdp610Array import Spd610Array
 from wirelessLoadCell.loadCells import LoadCells
 from ui import *
 
-import matplotlib
-from matplotlib.backends.backend_tkagg import (
-    FigureCanvasTkAgg, NavigationToolbar2Tk)
-from matplotlib.figure import Figure
-import matplotlib.animation as animation
-from matplotlib import style
-
 import tkinter as tk
 import tk_tools
 from time import *
 
-LARGE_FONT= ("Verdana", 12)
-style.use("ggplot")
-       
 
 class Main(tk.Tk):
   def __init__(self, *args, **kwargs):
@@ -42,6 +32,26 @@ class Main(tk.Tk):
 
     tk.Tk.config(self, menu=menubar)
 
+    label = tk.Label(self, text="Bedienelemente", font=LARGE_FONT)
+    label.pack(pady=10,padx=10)
+    # top menu
+    top = tk.Frame(self, borderwidth=2, relief="solid")
+    button1 = tk.Button(top, text="Bedienelemente", command=lambda: self.show_frame(Page_1))
+    button1.pack(side=tk.LEFT)
+
+    button2 = tk.Button(top, text="Kräfte", command=lambda: self.show_frame(Page_2))
+    button2.pack(side=tk.LEFT)
+
+    button3 = tk.Button(top, text="Druck", command=lambda: self.show_frame(Page_3))
+    button3.pack(side=tk.LEFT)
+
+    button4 = tk.Button(top,text="Einstellungen",command=lambda: self.show_frame(Page_4))
+    button4.pack(side=tk.LEFT)
+
+    button5 = tk.Button(top, text="QUIT", fg="red",command=quit)
+    button5.pack(side=tk.LEFT)
+    top.pack(side="top", expand=True, fill="both")
+
     self.frames = {}
 
     for F in (Page_1, Page_2, Page_3, Page_4):

+ 15 - 4
software/install.md

@@ -174,28 +174,39 @@ sudo apt autoremove
 
 sudo apt install python3-dev python3-pip
 
-python3 -m pip -U pip setuptools
+python3 -m pip -U pip setuptools matplotlib
 ```
 
 ## 6.1 Install pybluez
 ```bash
 sudo apt-get install bluez bluez-tools python3-bluez
+sudo apt install libbluetooth-dev
 
 python3 -m pip install wheel pybluez
 ```
 
-## 6.2 Install PyQt5
+## 6.2 Install tkinter frontend
 ``` bash
-python3 -m pip install PyQt5 PyQt5-tools
+sudo apt install python3-tk
+python3 -m pip install tk-tools
 ```
 
-## 6.3 Install spidev
+## 6.3 Install SPI support
 Install https://github.com/doceme/py-spidev
 
+``` bash
+python3 -m pip install spidev
+```
+
 Warning: Doesn't work on `Debian 9 with kernel 4.4.55_3`
 
 Workaround: use gpio bitbang instead of spi device
 
+## 6.4 Install I2C support
+```bash
+sudo apt install python3-smbus
+```
+
 # 7. Fix `bluetoothd` service
 Edit `dbus-org.bluez.service`
 ```bash

+ 10 - 19
software/ui/Page_1.py

@@ -1,31 +1,22 @@
 import tkinter as tk
 import tk_tools
+from .Plot import Plot
+from .globals import *
+
+import matplotlib
+from matplotlib.backends.backend_tkagg import (
+    FigureCanvasTkAgg, NavigationToolbar2Tk)
+from matplotlib.figure import Figure
+from matplotlib import style
+
 
 class Page_1(tk.Frame):
   def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)
     self.t = 0
-    label = tk.Label(self, text="Bedienelemente", font=LARGE_FONT)
-    label.pack(pady=10,padx=10)
-    # top menu
-    top = tk.Frame(self, borderwidth=2, relief="solid")
-    button1 = tk.Button(top, text="Bedienelemente", command=lambda: controller.show_frame(Page_0))
-    button1.pack(side=tk.LEFT)
-
-    button2 = tk.Button(top, text="Kräfte", command=lambda: controller.show_frame(Page_2))
-    button2.pack(side=tk.LEFT)
-
-    button3 = tk.Button(top, text="Druck", command=lambda: controller.show_frame(Page_2))
-    button3.pack(side=tk.LEFT)
-
-    button4 = tk.Button(top,text="Einstellungen",command=lambda: controller.show_frame(Page_2))
-    button4.pack(side=tk.LEFT)
 
-    button5 = tk.Button(top, text="QUIT", fg="red",command=quit)
-    button5.pack(side=tk.LEFT)
-    top.pack(side="top", expand=True, fill="both")
     # graph
-    self.serialPlot = Plot()
+    self.serialPlot = Plot(20)
     canvas = FigureCanvasTkAgg(self.serialPlot.fig, self)
     canvas.draw()
     canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)

+ 2 - 0
software/ui/Page_2.py

@@ -1,6 +1,8 @@
 import tkinter as tk
 import tk_tools
 
+from .globals import *
+
 class Page_2(tk.Frame):
   def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)

+ 2 - 0
software/ui/Page_3.py

@@ -1,6 +1,8 @@
 import tkinter as tk
 import tk_tools
 
+from .globals import *
+
 class Page_3(tk.Frame):
   def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)

+ 1 - 0
software/ui/Page_4.py

@@ -1,6 +1,7 @@
 import tkinter as tk
 import tk_tools
 
+from .globals import *
 class Page_4(tk.Frame):
   def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)

+ 5 - 0
software/ui/Plot.py

@@ -3,6 +3,11 @@ from matplotlib.figure import Figure
 from matplotlib import style
 
 
+from .globals import *
+
+style.use("ggplot")
+       
+
 class Plot():
   def __init__(self, n):
     self.fig = Figure()

+ 7 - 6
software/ui/__init__.py

@@ -1,7 +1,8 @@
-from Page_1 import Page_1
-from Page_2 import Page_2
-from Page_3 import Page_3
-from Page_4 import Page_4
-from Plot import Plot
+from .Page_1 import Page_1
+from .Page_2 import Page_2
+from .Page_3 import Page_3
+from .Page_4 import Page_4
+from .Plot import Plot
+from .globals import *
 
-__all__ = ["Page_1", "Page_2", "Page_3", "Page_4", "Plot"]
+__all__ = ["Page_1", "Page_2", "Page_3", "Page_4", "Plot", "LARGE_FONT"]

+ 3 - 0
software/ui/globals.py

@@ -0,0 +1,3 @@
+
+
+LARGE_FONT= ("Verdana", 12)

+ 0 - 0
software/ui/read_i²c.py


+ 0 - 25
software/ui/read_serial.py

@@ -1,25 +0,0 @@
-import serial
-import io
-import time
-
-class my_serial():
-    def __init__(self, port, baud_rate):
-        self.serial = serial.Serial(port, baud_rate, timeout=1)
-        self.serial_io_wrapped = io.TextIOWrapper(io.BufferedRWPair(self.serial, self.serial))
-
-    # receive message via serial
-    def read(self):
-        read_out = None
-        timeout = time.time() + 0.1
-        while ((self.serial.in_waiting > 0) and (timeout > time.time())):
-            pass
-        if self.serial.in_waiting > 0:
-            read_out = self.serial_io_wrapped.readline()
-        return read_out
-
-ser = my_serial('/dev/ttyUSB0', 9600)
-
-while True:
-    incomingMessage = ser.read()
-    if incomingMessage is not None:
-        print(incomingMessage)

+ 0 - 0
software/ui/read_spi.py


+ 1 - 1
software/wirelessLoadCell/loadCells.py

@@ -1,4 +1,4 @@
-from GSV4BT import GSV4BT
+from .GSV4BT import GSV4BT
 import time
 import bluetooth