Commit dd3a5da6 authored by Alisson Claudino's avatar Alisson Claudino

ADD: Interface controls number of stream channels

parent eff5560d
#include <Wire.h>
#include <ADS1115.h>
#include <ThermoCouple.h>
#include <string.h>
ADS1115 ads0(0x48);
ADS1115 ads1(0x49);
Thermocouple term1;
ThermoCouple term1;
int16_t adc0, adc1, adc2, adc3, adc4, adc5, adc6, adc7;
String interface;
int channelNr = 0;
void setup(void)
{
Serial.begin(115200);
......@@ -17,13 +23,31 @@ void setup(void)
ads0.begin();
ads1.begin();
Serial.println("");
while(!Serial.available());
interface = Serial.readString();
if(interface.startsWith("press"))
{
channelNr = 2;
}
else if(interface.startsWith("temp"))
{
channelNr = 3;
}
}
void loop(void)
{
adc0 = ads0.readADC_SingleEnded(0);
adc1 = ads0.readADC_SingleEnded(1);
adc2 = ads0.readADC_SingleEnded(2);
if(channelNr == 3)
{
adc2 = ads0.readADC_SingleEnded(2);
}
/*adc3 = ads0.readADC_SingleEnded(3);
adc4 = ads1.readADC_SingleEnded(0);
adc5 = ads1.readADC_SingleEnded(1);
......@@ -32,8 +56,11 @@ void loop(void)
Serial.print(adc0);
Serial.print(" ");
Serial.print(adc1);
Serial.print(" ");
Serial.print(adc2);
if(channelNr == 3)
{
Serial.print(" ");
Serial.print(adc2);
}
/*Serial.print(" ");
Serial.print(adc3);
Serial.print(" ");
......
......@@ -24,7 +24,9 @@ from PyQt5 import QtWidgets
class SerialManager(object):
def __init__(self): #Construtor da classe
def __init__(self, type): #Construtor da classe
self.type = type
self.portList = serial.tools.list_ports.comports() #Armazena a lista de portas em um array
self.portNum=len(self.portList) #Imprime no stdout a lista de portas disponíveis
......@@ -36,7 +38,18 @@ class SerialManager(object):
self.ser.setDTR(False) # Reset do arduino para reinicio da leitura
time.sleep(0.022)
self.ser.setDTR(True)
self.ser.readline() # Primeiro valor da serial sai com lixo
print(self.ser.readline())
if(self.type == 0):
#while(self.ser.inWaiting()==0):
self.ser.write(bytes("press",'utf-8'))
elif(self.type == 1):
self.ser.write(bytes("temp",'utf-8'))
elif(self.type==2):
self.ser.write(bytes("proc",'utf-8'))
if(self.ser.inWaiting() > 0):
print(self.ser.readline()) # Primeiro valor da serial sai com lixo
def read(self): #Função para realizar a leitura do valor atual na serial.
if(self.ser.inWaiting()==0):
......
......@@ -32,16 +32,17 @@ class SystemEngine(object):
self.timer=QtCore.QTimer()
self.ser1 = SerialManager()
self.ser1.startPort(str(self.ser1.portList[1].device), 115200)
self.ser1.serialListPanel(self.ui)
self.ser1 = SerialManager(interType)
self.ySize = 500
if self.interType==0:
self.x_scale=10
self.nCurves = 2
self.y_min=[0,0]
self.y_max=[32700,10000]
self.xSize = 780
self.color = ['r','g']
......@@ -54,10 +55,13 @@ class SystemEngine(object):
self.y_min = [0, 0, 0]
self.y_max = [32700, 10000, 5000]
self.color = ['r', 'g','w']
self.color = ['r', 'g','y']
self.name = ["Temperatura", "Força","Potência"]
self.unit = ["ºC","N","W"]
self.xSize = 735
self.ser1.startPort(str(self.ser1.portList[1].device), 115200)
self.ser1.serialListPanel(self.ui)
self.layout=GraphicsLayout()
......@@ -121,7 +125,9 @@ class SystemEngine(object):
self.ui.menuPlay_Pause.setText("Play")
def sceneSelector(self, scene):
scene.setSceneRect(0, 0, 1000, 600)
self.ui.CentralGraph.setScene(scene)
self.ui.CentralGraph.setSceneRect(scene.sceneRect())
self.ui.CentralGraph.setBackgroundBrush(QtCore.Qt.black)
self.ui.CentralGraph.setInteractive(False)
......@@ -196,7 +202,7 @@ class SystemEngine(object):
self.layout.clear()
self.layout.setMinimumSize(500, 600)
self.layout.setMaximumSize(500, 600)
self.graph = Graph(self.time[0] / 1000, self.x_scale, self.nCurves, self.y_min, self.y_max, 700, 500,
self.graph = Graph(self.time[0] / 1000, self.x_scale, self.nCurves, self.y_min, self.y_max, self.xSize, self.ySize,
self.color, self.name, self.unit)
self.layout.addItem(self.graph.axis[0], row=1, col=1, rowspan=1, colspan=1)
......
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