summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpyk8055/pyplotA.py17
-rwxr-xr-xpyk8055/pyplotD.py21
2 files changed, 23 insertions, 15 deletions
diff --git a/pyk8055/pyplotA.py b/pyk8055/pyplotA.py
index e520c40..7f8799a 100755
--- a/pyk8055/pyplotA.py
+++ b/pyk8055/pyplotA.py
@@ -23,21 +23,24 @@ class DataPlot(QwtPlot):
self.a2 = zeros(len(self.x), Float)
self.setTitle("Simple K8055 datascope")
- #self.setAutoLegend(True)
+ self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend);
self.curve1 = QwtPlotCurve("Input 1")
self.curve2 = QwtPlotCurve("Input 2")
+ self.curve1.attach(self)
+ self.curve2.attach(self)
+
self.curve1.setPen(QPen(Qt.red))
- self.curve2.setPen(QPen(Qt.blue))
+ self.curve2.setPen(QPen(Qt.green))
# No automatic scaling, set y-scale 0-255
self.setAxisScale(QwtPlot.yLeft,0,255,50)
- # set marker line in the middle - value 128
- #mY = self.insertLineMarker("", QwtPlot.yLeft)
- mY = QwtPlotMarker()
- #self.setMarkerYPos(mY, 128.0)
+ mY = Qwt.QwtPlotMarker()
+ mY.setLineStyle(Qwt.QwtPlotMarker.HLine)
+ mY.setYValue(128.0)
+ mY.attach(self)
self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
self.setAxisTitle(QwtPlot.yLeft, "Values")
@@ -59,7 +62,7 @@ class DataPlot(QwtPlot):
self.a2[0] = self.k.ReadAnalogChannel(2)
self.curve1.setData(self.x, self.a1)
- self.curve1.setData(self.x, self.a2)
+ self.curve2.setData(self.x, self.a2)
self.replot()
# timerEvent()
diff --git a/pyk8055/pyplotD.py b/pyk8055/pyplotD.py
index 16872fa..d39edbe 100755
--- a/pyk8055/pyplotD.py
+++ b/pyk8055/pyplotD.py
@@ -9,17 +9,18 @@ class DataPlot(QwtPlot):
def __init__(self, *args):
QwtPlot.__init__(self, *args)
+ self.setCanvasBackground(Qt.white)
# Initialize data
self.x = arrayrange(0.0, 100.1, 0.5)
self.d1 = 0.0 + zeros(len(self.x), Float)
- self.d2 = 1.0 + zeros(len(self.x), Float) # shift data up 1
- self.d3 = 2.0 + zeros(len(self.x), Float) # Shift data up 2...
+ self.d2 = 1.0 + zeros(len(self.x), Float)
+ self.d3 = 2.0 + zeros(len(self.x), Float)
self.d4 = 3.0 + zeros(len(self.x), Float)
self.d5 = 4.0 + zeros(len(self.x), Float)
self.setTitle("Simple K8055 datascope")
- #self.setAutoLegend(True)
+ self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend);
self.curve1 = QwtPlotCurve("Input 1")
self.curve2 = QwtPlotCurve("Input 2")
@@ -27,6 +28,12 @@ class DataPlot(QwtPlot):
self.curve4 = QwtPlotCurve("Input 4")
self.curve5 = QwtPlotCurve("Input 5")
+ self.curve1.attach(self)
+ self.curve2.attach(self)
+ self.curve3.attach(self)
+ self.curve4.attach(self)
+ self.curve5.attach(self)
+
self.curve1.setPen(QPen(Qt.red))
self.curve2.setPen(QPen(Qt.blue))
self.curve3.setPen(QPen(Qt.green))
@@ -46,10 +53,8 @@ class DataPlot(QwtPlot):
self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)")
self.setAxisTitle(QwtPlot.yLeft, "Values")
- self.startTimer(50)
-
- # init the K8055 board
self.k = k8055(0)
+ self.startTimer(50)
# __init__()
def timerEvent(self, e):
@@ -61,10 +66,10 @@ class DataPlot(QwtPlot):
self.d1[0] = self.k.ReadDigitalChannel(1) * 0.95
self.d2 = concatenate((self.d2[:1], self.d2[:-1]), 1)
- self.d2[0] = self.k.ReadDigitalChannel(2) * 0.95 + 1 # Shift data up 1
+ self.d2[0] = self.k.ReadDigitalChannel(2) * 0.95 + 1
self.d3 = concatenate((self.d3[:1], self.d3[:-1]), 1)
- self.d3[0] = self.k.ReadDigitalChannel(3) * 0.95 + 2 # Shift data up 2...
+ self.d3[0] = self.k.ReadDigitalChannel(3) * 0.95 + 2
self.d4 = concatenate((self.d4[:1], self.d4[:-1]), 1)
self.d4[0] = self.k.ReadDigitalChannel(4) * 0.95 + 3