mirror of
https://github.com/brmlab/edubrm.git
synced 2025-06-08 12:53:59 +02:00
use env variable to create fake device
we have 10bits ADCs
This commit is contained in:
parent
985b3d8dd7
commit
21ecdcdca4
2 changed files with 9 additions and 11 deletions
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
|
||||
class Device:
|
||||
|
||||
VENDORID = 0x1fc9
|
||||
|
@ -5,9 +7,9 @@ class Device:
|
|||
INSIZE = 64
|
||||
OUTSIZE = 64
|
||||
|
||||
def __init__(self, fake = False):
|
||||
self.fake = fake
|
||||
if not fake:
|
||||
def __init__(self):
|
||||
self.fake = os.getenv('EDUBRM') == 'fake'
|
||||
if not self.fake:
|
||||
import usb
|
||||
usbdev = usb.core.find(idVendor = self.VENDORID, idProduct = self.PRODUCTID)
|
||||
if usbdev == None:
|
||||
|
@ -85,9 +87,9 @@ class Device:
|
|||
def read(self):
|
||||
if self.fake:
|
||||
from random import randint
|
||||
return (randint(0,65535), # AD0
|
||||
randint(0,65535), randint(0,65535), randint(0,65535), # AD1 .. AD3
|
||||
randint(0,65535), randint(0,65535), randint(0,65535), # AD4 .. AD6
|
||||
return (randint(0,1023), # AD0
|
||||
randint(0,1023), randint(0,1023), randint(0,1023), # AD1 .. AD3
|
||||
randint(0,1023), randint(0,1023), randint(0,1023), # AD4 .. AD6
|
||||
randint(0,1), randint(0,1), randint(0,1)) # IO1 .. IO3
|
||||
else:
|
||||
i = self.epi.read(self.INSIZE)
|
||||
|
|
|
@ -26,11 +26,6 @@ class ModuleDebugWidget(QWidget):
|
|||
QObject.connect(self.ui.pushPin2, SIGNAL("clicked(bool)"), self.on_pins_changed)
|
||||
QObject.connect(self.ui.pushPin3, SIGNAL("clicked(bool)"), self.on_pins_changed)
|
||||
|
||||
# real device:
|
||||
self.dev = Device()
|
||||
# fake device:
|
||||
# self.dev = Device(True)
|
||||
|
||||
self.timer = QTimer()
|
||||
QObject.connect(self.timer, SIGNAL("timeout()"), self.read_inputs)
|
||||
|
||||
|
@ -153,6 +148,7 @@ class ModuleDebug():
|
|||
|
||||
def start(self):
|
||||
print 'start Debug'
|
||||
self.widget.dev = Device()
|
||||
|
||||
def stop(self):
|
||||
print 'stop Debug'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue