Commit 74d75898 authored by Alisson Claudino's avatar Alisson Claudino

Implementada pausa na amostragem

parent 53e4a20a
...@@ -21,16 +21,16 @@ void loop(void) ...@@ -21,16 +21,16 @@ void loop(void)
{ {
adc0 = ads0.readADC_SingleEnded(0); adc0 = ads0.readADC_SingleEnded(0);
adc1 = ads0.readADC_SingleEnded(1); adc1 = ads0.readADC_SingleEnded(1);
adc2 = ads0.readADC_SingleEnded(2); /*adc2 = ads0.readADC_SingleEnded(2);
adc3 = ads0.readADC_SingleEnded(3); adc3 = ads0.readADC_SingleEnded(3);
adc4 = ads1.readADC_SingleEnded(0); adc4 = ads1.readADC_SingleEnded(0);
adc5 = ads1.readADC_SingleEnded(1); adc5 = ads1.readADC_SingleEnded(1);
adc6 = ads1.readADC_SingleEnded(2); adc6 = ads1.readADC_SingleEnded(2);
adc7 = ads1.readADC_SingleEnded(3); adc7 = ads1.readADC_SingleEnded(3);*/
Serial.print(adc0); Serial.print(adc0);
Serial.print(" "); Serial.print(" ");
Serial.print(adc1); Serial.print(adc1);
Serial.print(" "); /*Serial.print(" ");
Serial.print(adc2); Serial.print(adc2);
Serial.print(" "); Serial.print(" ");
Serial.print(adc3); Serial.print(adc3);
...@@ -43,7 +43,7 @@ void loop(void) ...@@ -43,7 +43,7 @@ void loop(void)
Serial.print(" "); Serial.print(" ");
Serial.print(adc7); Serial.print(adc7);
Serial.print(" "); Serial.print(" ");
Serial.print(millis()); Serial.print(millis());*/
Serial.print("\n"); Serial.print("\n");
while(millis()%100!=0); while(millis()%100!=0);
......
...@@ -316,4 +316,5 @@ class Ui_MainWindow(object): ...@@ -316,4 +316,5 @@ class Ui_MainWindow(object):
for i in range(0, len(seriaList)): for i in range(0, len(seriaList)):
self.usb.append(QtWidgets.QAction(self.MainWindow)) self.usb.append(QtWidgets.QAction(self.MainWindow))
self.usb[i].setText(seriaList[i].device) self.usb[i].setText(seriaList[i].device)
self.usb[i].setCheckable(True)
self.menuPorta.addAction(self.usb[i]) self.menuPorta.addAction(self.usb[i])
\ No newline at end of file
...@@ -27,7 +27,7 @@ class Graph(pyqtgraph.GraphicsLayout): ...@@ -27,7 +27,7 @@ class Graph(pyqtgraph.GraphicsLayout):
def updateGraph(self,y1,y2): def updateGraph(self,y1,y2):
print(time.time()-self.timeant) #print(time.time()-self.timeant)
self.y1.append(y1) self.y1.append(y1)
self.y2.append(y2) self.y2.append(y2)
if len(self.y1)>self.x_range+1: if len(self.y1)>self.x_range+1:
...@@ -50,6 +50,7 @@ class Graph(pyqtgraph.GraphicsLayout): ...@@ -50,6 +50,7 @@ class Graph(pyqtgraph.GraphicsLayout):
if(y_range==0): if(y_range==0):
y_range=1 y_range=1
self.x_range=x_range self.x_range=x_range
self.y_range=y_range self.y_range=y_range
self.x1=[] self.x1=[]
......
from PyQt5 import QtCore,QtGui,QtWidgets # importação de classes from PyQt5 import QtCore,QtGui,QtWidgets # importação de classes
import pyqtgraph
import serial
import serial.tools.list_ports
import time import time
import sys import sys
from SerialManager import SerialManager
from CalibracaoP import Ui_MainWindow
from SystemEngine import SystemEngine from SystemEngine import SystemEngine
from Graph import Graph
if __name__ == '__main__': if __name__ == '__main__':
engine=SystemEngine() engine=SystemEngine()
timer = QtCore.QTimer() # timer = QtCore.QTimer() #
timer.timeout.connect(engine.updateData) # timer.timeout.connect(engine.updateData) #
......
import serial import serial
import serial.tools.list_ports import serial.tools.list_ports
import time import time
class SerialManager(object): class SerialManager(object):
def __init__(self): def __init__(self):
self.portList = serial.tools.list_ports.comports() self.portList = serial.tools.list_ports.comports()
self.portNum=len(self.portList) self.portNum=len(self.portList)
......
...@@ -14,8 +14,7 @@ class SystemEngine(object): ...@@ -14,8 +14,7 @@ class SystemEngine(object):
self.app = QtWidgets.QApplication(sys.argv) self.app = QtWidgets.QApplication(sys.argv)
self.dialog = QtWidgets.QMainWindow() self.dialog = QtWidgets.QMainWindow()
self.ser1 = SerialManager() self.ser1 = SerialManager()
print(self.ser1.portList[0]) self.ser1.startPort(str(self.ser1.portList[0].device), 115200)
self.ser1.startPort(str(self.ser1.portList[1].device),115200)
self.uiCalibra1 = Ui_MainWindow() self.uiCalibra1 = Ui_MainWindow()
self.uiCalibra1.setupUi(self.dialog) self.uiCalibra1.setupUi(self.dialog)
self.uiCalibra1.serialListPanel(self.ser1.portList) self.uiCalibra1.serialListPanel(self.ser1.portList)
...@@ -28,13 +27,28 @@ class SystemEngine(object): ...@@ -28,13 +27,28 @@ class SystemEngine(object):
self.x_scale=100 self.x_scale=100
def updateData(self): def updateData(self):
readData = self.ser1.read() # Lê o dado da serial if(self.uiCalibra1.usb[0].isChecked()==True):
readData = readData.decode('utf8') readData = self.ser1.read() # Lê o dado da serial
dado = readData.split(' ', 8) readData = readData.decode('utf8')
self.x_scale=int(self.uiCalibra1.t_max.text()) dado = readData.split(' ', 3)
if(self.x_scale != self.prev_x_scale): print(dado)
self.layout.setGraphScale(int(self.x_scale),32700) try:
self.prev_x_scale = self.x_scale self.x_scale=int(self.uiCalibra1.t_max.text())
self.layout.updateGraph(float(dado[0]),float(dado[1])) except ValueError:
\ No newline at end of file self.x_scale=100
if(self.x_scale != self.prev_x_scale):
try:
self.layout.setGraphScale(int(self.x_scale),32700)
except:
print("Err0r")
self.prev_x_scale = self.x_scale
self.uiCalibra1.forcaLabel.setText(str(dado[0])+" Tonf")
self.uiCalibra1.calibranteLabel.setText(str(dado[1].split()[0])+" mV")
self.layout.updateGraph(float(dado[0]),float(dado[1]))
else:
pass
\ 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