diff --git a/firmware/src/edubrm.c b/firmware/src/edubrm.c
index 6abf965..b9b5836 100644
--- a/firmware/src/edubrm.c
+++ b/firmware/src/edubrm.c
@@ -9,13 +9,13 @@ void GetInReport (uint8_t src[], uint32_t length)
uint32_t volatile reg = LPC_USB->CmdCode;
if (reg & (5<<8)) return;
- for (i=0; i<4; ++i) {
+ for (i=0; i<6; ++i) {
uint32_t v = ADCRead(i);
src[i*2 ] = v & 0xff;
src[i*2+1] = (v>>8) & 0xff;
}
- // TODO: fix the following - replace IP[i] with real value if input pin (I)
- // src[8] = IP[0] + (IP[1]<<1) + (IP[2]<<2) + (IP[3]<<3) + (IP[4]<<4) + (IP[5]<<5) + (IP[6]<<6) + (IP[7]<<7);
+ // TODO: fix the following - replace IP[i] with real value of input pin (I)
+ // src[12] = IP[0] + (IP[1]<<1) + (IP[2]<<2);
}
void SetOutReport (uint8_t dst[], uint32_t length)
@@ -32,33 +32,30 @@ void SetOutReport (uint8_t dst[], uint32_t length)
break;
case 'd':
wavetype = dst[1];
- freq = dst[2] + (dst[3]<<8) + (dst[4]<<16) + (dst[5]<<24);
- // TODO: set DDS to (wavetype) of (freq) Hz
+ // TODO: set DDS to (wavetype)
+ break;
+ case 'D':
+ freq = dst[1] + (dst[2]<<8) + (dst[3]<<16) + (dst[4]<<24);
+ // TODO: set DDS to (freq) Hz
break;
case 'm':
which = dst[1];
- mult = dst[2] + (dst[3]<<8);
- // TODO: set opamp (which) on channel (chan) with multiplicator (mult)
+ chan = dst[2];
+ gain = dst[3];
+ // TODO: set opamp (which) on channel (chan) with gain (gain)
break;
case 's':
- which = dst[1];
- if (dst[2]) {
- // TODO: set switch (which) to on
- } else {
- // TODO: set switch (which) to off
- }
- break;
- case 'S':
states = dst[1];
// TODO: set switches to states
break;
- case 'o':
- which = dst[1];
- // TODO: set output pins to 0 where indicated by (which)
+ case 'P':
+ states = dst[1];
+ // TODO: set pins to states
break;
- case 'O':
- which = dst[1];
- // TODO: set output pins to 1 where indicated by (which)
+ case 'o':
+ which = dst[1] >> 1;
+ state = dst[1] & 0x01;
+ // TODO: set output pins (which) to state (state)
break;
}
}
diff --git a/software/device.py b/software/device.py
index c86c572..3b3f7d0 100644
--- a/software/device.py
+++ b/software/device.py
@@ -27,33 +27,33 @@ class Device:
def pwm(self, which, duty):
self.epo.write('p' + chr(which) + chr(duty & 0xff) + chr(duty >> 8))
- # sets dds (wave=square,sine,saw1,saw2), (freq=32bit)
- def dds(self, wavetype, freq):
- self.epo.write('d' + chr(wavetype) + chr(freq & 0xff) + chr((freq >> 8) & 0xff) + chr((freq >> 16) & 0xff) + chr(freq >> 24))
+ # sets ddswave (wave=square,sine,saw1,saw2)
+ def ddswave(self, wavetype):
+ self.epo.write('d' + chr(wavetype))
- # set opamp (which=1,2), (mult=16bit)
- def opamp(self, which, mult):
- self.epo.write('m' + chr(which) + chr(mult & 0xff) + chr(mult >> 8))
+ # sets ddsfreq (freq=32bit)
+ def ddsfreq(self, freq):
+ self.epo.write('D' + chr(freq & 0xff) + chr((freq >> 8) & 0xff) + chr((freq >> 16) & 0xff) + chr(freq >> 24))
- # set switch (which=1..8), state=(0,1)
- def switch(self, which, state):
- self.epo.write('s' + chr(which) + (state and '\x01' or '\x00'))
+ # set opamp (which=1,2), (chan=1..6), (gain=1, 2, 4, 5, 8, 10, 16, 32)
+ def opamp(self, which, chan, gain):
+ self.epo.write('m' + chr(which) + chr(chan) + chr(gain))
- # set all switches (which=8bit)
+ # set all switches (states=6bit)
def switches(self, states):
- self.epo.write('S' + chr(states))
+ self.epo.write('s' + chr(states))
- # clear output (which=8bit)
- def clrout(self, which):
- self.epo.write('o' + chr(which))
+ # set pins state (states=3bit) (1 = input, 0 = output)
+ def setpins(self, states):
+ self.epo.write('P' + chr(states))
- # set output (which=8bit)
- def setout(self, which):
- self.epo.write('O' + chr(which))
+ # set output (which=1,2,3), (state=0,1)
+ def setout(self, which, state):
+ self.epo.write('o' + chr(which<<1 + state))
- def state(self):
- # 4x AD (16 bits) + 8x I
+ def read(self):
+ # 6x AD (16 bits) + 3 x I
i = self.epi.read(self.INSIZE)
- return (i[0] + i[1]<<8, i[2] + i[3]<<8, i[4] + i[5]<<8, i[6] + i[7]<<8,
- i[8] & 0x01, i[8] & 0x02, i[8] & 0x04, i[8] & 0x08,
- i[8] & 0x10, i[8] & 0x20, i[8] & 0x40, i[8] & 0x80)
+ return (i[0] + i[1]<<8, i[2] + i[3]<<8, i[4] + i[5]<<8,
+ i[6] + i[7]<<8, i[9] + i[9]<<8, i[10] + i[11]<<8,
+ i[12] & 0x01, (i[12] & 0x02) >> 1, (i[12] & 0x04) >> 2)
diff --git a/software/modules/ModuleDebug.py b/software/modules/ModuleDebug.py
index db53549..179ce6f 100644
--- a/software/modules/ModuleDebug.py
+++ b/software/modules/ModuleDebug.py
@@ -1,5 +1,7 @@
from PyQt4.QtGui import QWidget
from PyQt4.QtCore import pyqtSlot
+from PyQt4.QtCore import SIGNAL
+from PyQt4.QtCore import QObject
from ModuleDebugUi import Ui_ModuleDebug
#from device import Device
@@ -9,6 +11,20 @@ class ModuleDebugWidget(QWidget):
QWidget.__init__(self)
self.ui = Ui_ModuleDebug()
self.ui.setupUi(self)
+ QObject.connect(self.ui.comboAMP1c, SIGNAL("currentIndexChanged(int)"), self.on_comboAMP1_changed)
+ QObject.connect(self.ui.comboAMP1g, SIGNAL("currentIndexChanged(int)"), self.on_comboAMP1_changed)
+ QObject.connect(self.ui.comboAMP2c, SIGNAL("currentIndexChanged(int)"), self.on_comboAMP2_changed)
+ QObject.connect(self.ui.comboAMP2g, SIGNAL("currentIndexChanged(int)"), self.on_comboAMP2_changed)
+ QObject.connect(self.ui.pushSwitch1, SIGNAL("clicked(bool)"), self.on_switches_changed)
+ QObject.connect(self.ui.pushSwitch2, SIGNAL("clicked(bool)"), self.on_switches_changed)
+ QObject.connect(self.ui.pushSwitch3, SIGNAL("clicked(bool)"), self.on_switches_changed)
+ QObject.connect(self.ui.pushSwitch4, SIGNAL("clicked(bool)"), self.on_switches_changed)
+ QObject.connect(self.ui.pushSwitch5, SIGNAL("clicked(bool)"), self.on_switches_changed)
+ QObject.connect(self.ui.pushSwitch6, SIGNAL("clicked(bool)"), self.on_switches_changed)
+ QObject.connect(self.ui.pushPin1, SIGNAL("clicked(bool)"), self.on_pins_changed)
+ QObject.connect(self.ui.pushPin2, SIGNAL("clicked(bool)"), self.on_pins_changed)
+ QObject.connect(self.ui.pushPin3, SIGNAL("clicked(bool)"), self.on_pins_changed)
+
# self.dev = Device()
@pyqtSlot(int)
@@ -71,6 +87,84 @@ class ModuleDebugWidget(QWidget):
# state and self.dev.setout(1<<7) or self.dev.clrout(1<<7)
print 'out7:', state and '1' or '0'
+ @pyqtSlot(bool)
+ def on_radioSine_clicked(self, checked):
+# self.dev.ddswave(0)
+ print 'dds: sine'
+
+ @pyqtSlot(bool)
+ def on_radioSquare_clicked(self, checked):
+# self.dev.ddswave(1)
+ print 'dds: square'
+
+ @pyqtSlot(bool)
+ def on_radioSaw_clicked(self, checked):
+# self.dev.ddswave(2)
+ print 'dds: saw'
+
+ @pyqtSlot(bool)
+ def on_radioInvSaw_clicked(self, checked):
+# self.dev.ddswave(3)
+ print 'dds: invsaw'
+
+ @pyqtSlot(int)
+ def on_dialDDS_valueChanged(self, val):
+# self.dev.ddsfreq(val)
+ print 'dds:', val
+
+ @pyqtSlot()
+ def on_comboAMP1_changed(self):
+ c = self.ui.comboAMP1c.currentIndex() + 1
+ g = (1,2,4,5,8,10,16,32)[self.ui.comboAMP1g.currentIndex()]
+# self.dev.opamp(1, c, g)
+ print 'amp1:', c, g
+
+ @pyqtSlot()
+ def on_comboAMP2_changed(self):
+ c = self.ui.comboAMP2c.currentIndex() + 1
+ g = (1,2,4,5,8,10,16,32)[self.ui.comboAMP2g.currentIndex()]
+# self.dev.opamp(2, c, g)
+ print 'amp2:', c, g
+
+ @pyqtSlot()
+ def on_switches_changed(self):
+ s = (self.ui.pushSwitch1.isChecked() and 1 or 0,
+ self.ui.pushSwitch2.isChecked() and 1 or 0,
+ self.ui.pushSwitch3.isChecked() and 1 or 0,
+ self.ui.pushSwitch4.isChecked() and 1 or 0,
+ self.ui.pushSwitch5.isChecked() and 1 or 0,
+ self.ui.pushSwitch6.isChecked() and 1 or 0)
+# self.dev.switches(s[0] + s[1]<<1 + s[2]<<2 + s[3]<<3 + s[4]<<4 + s[5]<<5)
+ print 'switches:', s
+
+ @pyqtSlot()
+ def on_pins_changed(self):
+ s = (self.ui.pushPin1.isChecked() and 1 or 0,
+ self.ui.pushPin2.isChecked() and 1 or 0,
+ self.ui.pushPin3.isChecked() and 1 or 0)
+ self.ui.pushOut1.setEnabled(not s[0])
+ self.ui.pushOut2.setEnabled(not s[1])
+ self.ui.pushOut3.setEnabled(not s[2])
+# self.dev.setpins(s[0] + s[1]<<1 + s[2]<<2)
+ print 'pins:', s
+
+ @pyqtSlot(bool)
+ def on_pushOut1_clicked(self, checked):
+# self.dev.setout(1, checked and 1 or 0)
+ print 'out1:', checked and 1 or 0
+
+ @pyqtSlot(bool)
+ def on_pushOut2_clicked(self, checked):
+# self.dev.setout(2, checked and 1 or 0)
+ print 'out2:', checked and 1 or 0
+
+ @pyqtSlot(bool)
+ def on_pushOut3_clicked(self, checked):
+# self.dev.setout(3, checked and 1 or 0)
+ print 'out3:', checked and 1 or 0
+
+
+
class ModuleDebug():
def __init__(self):
diff --git a/software/modules/ModuleDebug.ui b/software/modules/ModuleDebug.ui
index d93d7c1..9764515 100644
--- a/software/modules/ModuleDebug.ui
+++ b/software/modules/ModuleDebug.ui
@@ -116,7 +116,7 @@
190
10
- 201
+ 211
131
@@ -126,7 +126,7 @@
- 90
+ 100
90
101
31
@@ -136,13 +136,16 @@
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
- 0
+ 1
+
+
+ 1
- 16777216
+ 50000000
- 0
+ 1
8
@@ -151,14 +154,17 @@
- 90
+ 100
10
101
81
+
+ 1
+
- 16777216
+ 50000000
100
@@ -169,7 +175,7 @@
10
30
- 71
+ 81
26
@@ -185,7 +191,7 @@
10
50
- 71
+ 81
26
@@ -198,7 +204,7 @@
10
70
- 71
+ 81
26
@@ -211,7 +217,7 @@
10
90
- 71
+ 81
26
@@ -225,8 +231,8 @@
10
150
- 171
- 131
+ 151
+ 111
@@ -235,218 +241,581 @@
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
+
10
- 90
- 71
+ 30
+ 61
31
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
- 0
-
-
- 65535
-
-
- 0
-
-
- 5
-
+ -
+
+ ch 1
+
+
+ -
+
+ ch 2
+
+
+ -
+
+ ch 3
+
+
+ -
+
+ ch 4
+
+
+ -
+
+ ch 5
+
+
+ -
+
+ ch 6
+
+
-
-
-
- 90
- 90
- 71
- 31
-
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
- 0
-
-
- 65535
-
-
- 0
-
-
- 5
-
-
-
-
-
- 90
- 20
- 71
- 71
-
-
-
- 65535
-
-
- 256
-
-
-
+
10
- 20
- 71
- 71
+ 70
+ 61
+ 31
-
- 65535
+ -
+
+ ch 1
+
+
+ -
+
+ ch 2
+
+
+ -
+
+ ch 3
+
+
+ -
+
+ ch 4
+
+
+ -
+
+ ch 5
+
+
+ -
+
+ ch 6
+
+
+
+
+
+
+ 80
+ 30
+ 61
+ 31
+
-
- 256
+ -
+
+ * 1
+
+
+ -
+
+ * 2
+
+
+ -
+
+ * 4
+
+
+ -
+
+ * 5
+
+
+ -
+
+ * 8
+
+
+ -
+
+ * 10
+
+
+ -
+
+ * 16
+
+
+ -
+
+ * 32
+
+
+
+
+
+
+ 80
+ 70
+ 61
+ 31
+
+ -
+
+ * 1
+
+
+ -
+
+ * 2
+
+
+ -
+
+ * 4
+
+
+ -
+
+ * 5
+
+
+ -
+
+ * 8
+
+
+ -
+
+ * 10
+
+
+ -
+
+ * 16
+
+
+ -
+
+ * 32
+
+
- 190
+ 170
150
- 201
- 61
+ 151
+ 111
- Outputs
+ IO Pins (up=O, dn=I)
-
+
10
30
- 21
- 26
+ 31
+ 31
-
+ 1
+
+
+ true
-
-
-
- 30
- 30
- 21
- 26
-
-
-
-
-
-
-
+
50
30
- 21
- 26
+ 31
+ 31
-
+ 2
+
+
+ true
-
-
-
- 70
- 30
- 21
- 26
-
-
-
-
-
-
-
+
90
30
- 21
- 26
+ 31
+ 31
-
+ 3
+
+
+ true
-
+
- 110
- 30
- 21
- 26
+ 10
+ 70
+ 31
+ 31
-
+ O
+
+
+ true
-
+
- 130
- 30
- 21
- 26
+ 50
+ 70
+ 31
+ 31
-
+ O
+
+
+ true
-
+
- 150
- 30
- 21
- 26
+ 90
+ 70
+ 31
+ 31
-
+ O
+
+
+ true
-
+
- 200
- 200
- 161
- 21
+ 330
+ 150
+ 141
+ 111
-
- 7 6 5 4 3 2 1 0
+
+ Switches
+
+
+
+ 10
+ 30
+ 31
+ 31
+
+
+
+ 1
+
+
+ true
+
+
+
+
+
+ 50
+ 30
+ 31
+ 31
+
+
+
+ 2
+
+
+ true
+
+
+
+
+
+ 90
+ 30
+ 31
+ 31
+
+
+
+ 3
+
+
+ true
+
+
+
+
+
+ 90
+ 70
+ 31
+ 31
+
+
+
+ 6
+
+
+ true
+
+
+
+
+
+ 50
+ 70
+ 31
+ 31
+
+
+
+ 5
+
+
+ true
+
+
+
+
+
+ 10
+ 70
+ 31
+ 31
+
+
+
+ 4
+
+
+ true
+
+
+
+
+
+
+ 10
+ 270
+ 461
+ 151
+
+
+
+ Input
+
+
+
+
+ 10
+ 30
+ 81
+ 81
+
+
+
+ 1
+
+
+ 999
+
+
+ 10
+
+
+
+
+
+ 10
+ 110
+ 81
+ 31
+
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ 1
+
+
+ 1
+
+
+ 999
+
+
+ 1
+
+
+ 3
+
+
+
+
+
+ 110
+ 20
+ 91
+ 21
+
+
+
+ AD1: 0
+
+
+
+
+
+ 110
+ 40
+ 91
+ 21
+
+
+
+ AD2: 0
+
+
+
+
+
+ 110
+ 60
+ 91
+ 21
+
+
+
+ AD3: 0
+
+
+
+
+
+ 110
+ 80
+ 91
+ 21
+
+
+
+ AD4: 0
+
+
+
+
+
+ 110
+ 100
+ 91
+ 21
+
+
+
+ AD5: 0
+
+
+
+
+
+ 110
+ 120
+ 91
+ 21
+
+
+
+ AD6: 0
+
+
+
+
+
+ 210
+ 40
+ 91
+ 21
+
+
+
+ IO2: 0
+
+
+
+
+
+ 210
+ 60
+ 91
+ 21
+
+
+
+ IO3: 0
+
+
+
+
+
+ 210
+ 20
+ 91
+ 21
+
+
+
+ IO1: 0
+
+
@@ -515,70 +884,6 @@
-
- dialAMP1
- valueChanged(int)
- lineAMP1
- setValue(int)
-
-
- 55
- 205
-
-
- 55
- 255
-
-
-
-
- dialAMP2
- valueChanged(int)
- lineAMP2
- setValue(int)
-
-
- 135
- 205
-
-
- 135
- 255
-
-
-
-
- lineAMP1
- valueChanged(int)
- dialAMP1
- setValue(int)
-
-
- 55
- 255
-
-
- 55
- 205
-
-
-
-
- lineAMP2
- valueChanged(int)
- dialAMP2
- setValue(int)
-
-
- 135
- 255
-
-
- 135
- 205
-
-
-
dialDDS
valueChanged(int)
@@ -611,5 +916,37 @@
+
+ dialInputFreq
+ valueChanged(int)
+ lineInputFreq
+ setValue(int)
+
+
+ 70
+ 340
+
+
+ 70
+ 395
+
+
+
+
+ lineInputFreq
+ valueChanged(int)
+ dialInputFreq
+ setValue(int)
+
+
+ 70
+ 395
+
+
+ 70
+ 340
+
+
+
diff --git a/software/test-device.py b/software/test-device.py
deleted file mode 100755
index bef24b0..0000000
--- a/software/test-device.py
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/python
-
-from device import Device
-
-d = Device()