subDesTagesMitExtraKaese il y a 4 ans
Parent
commit
e46ecef618
3 fichiers modifiés avec 20 ajouts et 5 suppressions
  1. 10 2
      software/appWindow.py
  2. 9 2
      software/database.py
  3. 1 1
      software/wirelessLoadCell/loadCells.py

+ 10 - 2
software/appWindow.py

@@ -21,12 +21,13 @@ class Main(tk.Tk, Table):
     self.adc = MCP3008(0,0)
     self.pressureSensors = Spd610Array()
     self.forceSensors = LoadCells()
+    self.forceSensors.start()
     self.motorController = None
     
     Table.__init__(self, 
     ["time", "windspeed", "motor_pwm"] + 
     [f"pressure_{i}" for i in range(8)] + 
-    [f"adc_{i}" for i in range(8)] + 
+    [f"adc_{i}" for i in range(1)] + 
     [f"force_X_1", f"force_Y_1", f"force_Z_1"] +
     [f"force_X_2", f"force_Y_2", f"force_Z_2"] + 
     [f"force_X_3", f"force_Y_3", f"force_Z_3"])
@@ -96,7 +97,14 @@ class Main(tk.Tk, Table):
   def interval(self):
     adcValues = self.adc.read()
 
-    self.addRow([time.time()] + adcValues)
+    self.addRow(
+      [time.time(), 0, 0] + 
+      self.pressureSensors.getValues() +
+      [self.adc.getVoltage(0)] +
+      self.forceSensors.getForces(0) +
+      self.forceSensors.getForces(1) +
+      self.forceSensors.getForces(2)
+    )
     for frame in self.frames:
       frame.update()
 

+ 9 - 2
software/database.py

@@ -12,7 +12,7 @@ class Table:
 
   def getLastRow(self):
     if len(self.rows) > 0:
-      return rows[len(self.rows)-1]
+      return self.rows[len(self.rows)-1]
     else:
       return [0] * len(self.columnNames)
 
@@ -24,4 +24,11 @@ class Table:
     with open(filename,"w+", newline='') as my_csv:
       csvWriter = csv.writer(my_csv,delimiter=',')
       csvWriter.writerow(self.columnNames)
-      csvWriter.writerows(self.rows)
+      csvWriter.writerows(self.rows)
+
+if __name__ == "__main__":
+  t = Table(["time", "col1", "col2"])
+  t.addRow([time.time(), 1, 2])
+  t.addRow([time.time(), 3, 4])
+  print(len(t.rows))
+  print(t.getLastRow())

+ 1 - 1
software/wirelessLoadCell/loadCells.py

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