Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add charts to debug module as well

  • Loading branch information...
commit 7bdfecfbe7d0eebeb535a5755477a34b1c040c1b 1 parent 7370607
@prusnak prusnak authored
Showing with 192 additions and 1 deletion.
  1. +45 −0 software/modules/ModuleDebug.py
  2. +147 −1 software/modules/ModuleDebug.ui
View
45 software/modules/ModuleDebug.py
@@ -1,4 +1,8 @@
from PyQt4.QtGui import QWidget
+from PyQt4.QtGui import QGraphicsScene
+from PyQt4.QtGui import QPainterPath
+from PyQt4.QtGui import QPen
+from PyQt4.QtGui import QColor
from PyQt4.QtCore import pyqtSlot
from PyQt4.QtCore import SIGNAL
from PyQt4.QtCore import QObject
@@ -31,6 +35,9 @@ def __init__(self):
self.timer = QTimer()
QObject.connect(self.timer, SIGNAL("timeout()"), self.read_inputs)
+ self.data1 = 100*[0.0]
+ self.data2 = 100*[0.0]
+
@pyqtSlot(int)
def on_dialPWM1_valueChanged(self, val):
self.dev.pwm(1, val)
@@ -151,6 +158,44 @@ def read_inputs(self):
self.ui.labelIO1.setText('IO1: ' + str(r[7]))
self.ui.labelIO2.setText('IO2: ' + str(r[8]))
self.ui.labelIO3.setText('IO3: ' + str(r[9]))
+ v1 = -1
+ if self.ui.comboChart1.currentIndex() > 0:
+ v1 = r[self.ui.comboChart1.currentIndex() - 1]
+ v2 = -1
+ if self.ui.comboChart2.currentIndex() > 0:
+ v2 = r[self.ui.comboChart2.currentIndex() - 1]
+ if v1 != -1 or v2 != -1:
+ self.chart(v1, v2)
+
+ def setup_scene(self, scene):
+ scene.addLine(-5, 0, 205, 0)
+ scene.addLine(-5, -512/6, 205, -512/6)
+ scene.addLine(-5, -1023/6, 205, -1023/6)
+ scene.addSimpleText('0').moveBy(-40, -10)
+ scene.addSimpleText('512').moveBy(-40, -512/6-10)
+ scene.addSimpleText('1023').moveBy(-40, -1023/6-10)
+
+ def chart(self, v1, v2):
+ self.data1.pop(0)
+ self.data2.pop(0)
+ self.data1.append(v1)
+ self.data2.append(v2)
+ self.scene1 = QGraphicsScene()
+ self.scene2 = QGraphicsScene()
+ self.setup_scene(self.scene1)
+ self.setup_scene(self.scene2)
+ path = QPainterPath()
+ path.moveTo(0,-self.data1[0]/6)
+ for i in xrange(1,100):
+ path.lineTo(2*(i+1), -self.data1[i]/6)
+ self.scene1.addPath(path, QPen(QColor(0,0,255), 3))
+ path = QPainterPath()
+ path.moveTo(0,-self.data2[0]/6)
+ for i in xrange(1,100):
+ path.lineTo(2*(i+1), -self.data2[i]/6)
+ self.scene2.addPath(path, QPen(QColor(0,0,255), 3))
+ self.ui.chart1.setScene(self.scene1)
+ self.ui.chart2.setScene(self.scene2)
class ModuleDebug():
View
148 software/modules/ModuleDebug.ui
@@ -644,7 +644,7 @@
<x>10</x>
<y>270</y>
<width>461</width>
- <height>161</height>
+ <height>241</height>
</rect>
</property>
<property name="title">
@@ -846,6 +846,152 @@
<bool>true</bool>
</property>
</widget>
+ <widget class="QComboBox" name="comboChart1">
+ <property name="geometry">
+ <rect>
+ <x>90</x>
+ <y>170</y>
+ <width>85</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <item>
+ <property name="text">
+ <string>none</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD0</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD3</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD4</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD5</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD6</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QComboBox" name="comboChart2">
+ <property name="geometry">
+ <rect>
+ <x>290</x>
+ <y>170</y>
+ <width>85</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <item>
+ <property name="text">
+ <string>none</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD0</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD3</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD4</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD5</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>AD6</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QLabel" name="labelChart1">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>170</y>
+ <width>66</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Chart1:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelChart2">
+ <property name="geometry">
+ <rect>
+ <x>210</x>
+ <y>170</y>
+ <width>66</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Chart2:</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGraphicsView" name="chart1">
+ <property name="geometry">
+ <rect>
+ <x>480</x>
+ <y>10</y>
+ <width>291</width>
+ <height>251</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QGraphicsView" name="chart2">
+ <property name="geometry">
+ <rect>
+ <x>480</x>
+ <y>270</y>
+ <width>291</width>
+ <height>251</height>
+ </rect>
+ </property>
</widget>
</widget>
<resources/>
Please sign in to comment.
Something went wrong with that request. Please try again.