Commit f6432dde authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper
Browse files

Added legends and other niceties

parent bf70fa43
from time import sleep
from serial import Serial
class Arduino(object):
def __init__(self, logger, location, channels):
logger("[ARDUINO]", "Opening serial port...")
self.ser = Serial(location, 115200)
except Exception as e:
logger("[ARDUINO]", "ERROR: Could not open serial port")
raise FileNotFoundError("Serial port not found") from e
logger("[ARDUINO]", "Starting board...")
self._reset() # Reset do arduino para reinicio da leitura
self.ser.readline() # Espera o Arduino inicializar
......@@ -19,7 +19,10 @@ class Graph(QThread):
self.config = Config().data
device = self.config["device"]
self.interface = INTERFACES[device["type"]](logger, device["location"], device["channels"])
self.interface = INTERFACES[device["type"]](logger, device["location"], device["channels"])
except FileNotFoundError:
self.running = False
def run(self):
while self.running:
......@@ -37,11 +40,19 @@ class Graph(QThread):
self.running = False
def _configurePlots(self):
first = True
self.logger("[GRAPH]", "Found new device {}".format(self.config["device"]["type"]))
for channel in self.config["device"]["channels"]:
self.logger("[GRAPH]", "Added channel {}".format(channel["name"]))
self.plots.append(self.graph.plot(pen=mkPen(mkColor(channel["color"]), width=2), name=channel["name"]))
self.axis.append(AxisItem("right", channel["color"]))
self.axis[-1].setLabel(channel["name"], channel["unit"])
\ No newline at end of file
plot = self.graph.plot(pen=mkPen(mkColor(channel["color"]), width=2), name=channel["name"])
if first:
self.graph.getPlotItem().setLabel("left", text=channel["name"], units=channel["unit"])
first = False
self.graph.getPlotItem().setLabel("right", text=channel["name"], units=channel["unit"])
self.graph.getPlotItem().setLabel("bottom", text="Tempo", units="s")
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment