def I2CScan(self): if self.p.connected: x = self.p.I2CScan() print('Responses from: ', x) for a in self.sensorList: a[0].setParent(None) a[1].setParent(None) self.sensorList = [] for a in self.controllerList: a[0].setParent(None) a[1].setParent(None) self.controllerList = [] for a in x: s = self.p.sensors.get(a, None) if s is not None: btn = QtWidgets.QPushButton(s['name'] + ':' + hex(a)) dialog = dio.DIOSENSOR(self, s) btn.clicked.connect(dialog.launch) self.sensorLayout.addWidget(btn) self.sensorList.append([dialog, btn]) continue s = self.p.controllers.get(a, None) if s is not None: btn = QtWidgets.QPushButton(s['name'] + ':' + hex(a)) dialog = dio.DIOCONTROL(self, s) btn.clicked.connect(dialog.launch) self.sensorLayout.addWidget(btn) self.controllerList.append([dialog, btn]) continue s = self.p.special.get(a, None) if s is not None: btn = QtWidgets.QPushButton(s['name'] + ':' + hex(a)) dialog = dio.DIOROBOT(self, s) btn.clicked.connect(dialog.launch) self.sensorLayout.addWidget(btn) self.controllerList.append([dialog, btn]) continue
def __init__(self, parent=None, **kwargs): super(AppWindow, self).__init__(parent) self.setupUi(self) self.VERSION = REGISTERS.VERSIONNUM self.SPECIALS = REGISTERS.SPECIALS self.REGISTERS = REGISTERS.REGISTERS self.EXAMPLES_DIR = REGISTERS.EXAMPLES self.ADC_PINS = REGISTERS.ADC self.docks = [self.leftdock, self.rightdock] self.sensorList = [] self.controllerList = [] self.monitoring = True self.logRegisters = True self.userHexRunning = False self.uploadingHex = False self.autoUpdateUserRegisters = False self.CFile = None #'~/kuttyPy.c' self.ipy = None self.setTheme("material") examples = [ a for a in os.listdir( os.path.join(path["examples"], self.EXAMPLES_DIR)) if ('.py' in a) and a is not 'kuttyPy.py' ] #.py files except the library self.exampleList.addItems(examples) blinkindex = self.exampleList.findText('blink.py') if blinkindex != -1: #default example. blink.py present in examples directory self.exampleList.setCurrentIndex(blinkindex) ######## PYTHON CODE self.codeThread = QtCore.QThread() self.codeEval = self.codeObject(self.REGISTERS) self.codeEval.moveToThread(self.codeThread) self.codeEval.finished.connect(self.codeThread.quit) self.codeEval.logThis.connect( self.appendLog) #Connect to the log window self.logThis.connect(self.appendLog) #Connect to the log window self.logThisPlain.connect( self.appendLogPlain) #Connect to the log window self.serialGaugeSignal.connect(self.setSerialgauge) self.codeThread.started.connect(self.codeEval.execute) self.codeThread.finished.connect(self.codeFinished) ######### C CODE UPLOADER self.uploadThread = QtCore.QThread() self.UploadObject = self.uploadObject() self.UploadObject.moveToThread(self.uploadThread) self.UploadObject.finished.connect(self.uploadThread.quit) self.UploadObject.logThis.connect( self.appendLog) #Connect to the log window self.UploadObject.logThisPlain.connect( self.appendLogPlain) #Connect to the log window. add plain text self.logThis.connect(self.appendLog) #Connect to the log window self.uploadThread.started.connect(self.UploadObject.execute) self.uploadThread.finished.connect(self.codeFinished) self.commandQ = [] self.btns = {} self.registers = [] self.addPins() self.statusBar = self.statusBar() self.makeBottomMenu() global app self.initializeCommunications() self.pending = { 'status': myTimer(constants.STATUS_UPDATE_INTERVAL), 'update': myTimer(constants.AUTOUPDATE_INTERVAL), } serialgaugeoptions = { 'name': 'Serial Monitor', 'init': print, 'read': None, 'fields': ['Value'], 'min': [0], 'max': [255] } self.serialGauge = dio.DIOSENSOR(self, serialgaugeoptions) self.startTime = time.time() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.updateEverything) self.timer.start(20) #Auto-Detector self.shortlist = KuttyPyLibUno.getFreePorts()
def __init__(self, parent=None, **kwargs): super(AppWindow, self).__init__(parent) self.setupUi(self) self.VERSION = REGISTERS.VERSION_ATMEGA32 #This needs to be dynamically changed when hardware is connected self.SPECIALS = REGISTERS.VERSIONS[self.VERSION]['SPECIALS'] self.REGISTERS = REGISTERS.VERSIONS[self.VERSION]['REGISTERS'] self.EXAMPLES_DIR = REGISTERS.VERSIONS[ self.VERSION]['examples directory'] self.docks = [self.padock, self.pbdock, self.pcdock, self.pddock] self.sensorList = [] self.controllerList = [] self.monitoring = True self.logRegisters = True self.userHexRunning = False self.uploadingHex = False self.autoUpdateUserRegisters = False self.CFile = None #'~/kuttyPy.c' self.ipy = None self.setTheme("material") examples = [ a for a in os.listdir( os.path.join(path["examples"], self.EXAMPLES_DIR)) if ('.py' in a) and a is not 'kuttyPy.py' ] #.py files except the library self.exampleList.addItems(examples) blinkindex = self.exampleList.findText('blink.py') if blinkindex != -1: #default example. blink.py present in examples directory self.exampleList.setCurrentIndex(blinkindex) #Define some keyboard shortcuts for ease of use self.shortcutActions = {} self.shortcuts = { "f": partial(self.setLanguage, 'fr_FR'), "e": partial(self.setLanguage, 'en_IN'), "m": partial(self.setLanguage, 'ml_IN') } for a in self.shortcuts: shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(a), self) shortcut.activated.connect(self.shortcuts[a]) self.shortcutActions[a] = shortcut ######## PYTHON CODE self.codeThread = QtCore.QThread() self.codeEval = self.codeObject(self.REGISTERS) self.codeEval.moveToThread(self.codeThread) self.codeEval.finished.connect(self.codeThread.quit) self.codeEval.logThis.connect( self.appendLog) #Connect to the log window self.logThis.connect(self.appendLog) #Connect to the log window self.logThisPlain.connect( self.appendLogPlain) #Connect to the log window self.serialGaugeSignal.connect(self.setSerialgauge) self.codeThread.started.connect(self.codeEval.execute) self.codeThread.finished.connect(self.codeFinished) ######### C CODE UPLOADER self.uploadThread = QtCore.QThread() self.UploadObject = self.uploadObject() self.UploadObject.moveToThread(self.uploadThread) self.UploadObject.finished.connect(self.uploadThread.quit) self.UploadObject.logThis.connect( self.appendLog) #Connect to the log window self.UploadObject.logThisPlain.connect( self.appendLogPlain) #Connect to the log window. add plain text self.logThis.connect(self.appendLog) #Connect to the log window self.uploadThread.started.connect(self.UploadObject.execute) self.uploadThread.finished.connect(self.codeFinished) self.commandQ = [] self.btns = {} self.registers = [] self.addPins() self.statusBar = self.statusBar() self.makeBottomMenu() global app self.initializeCommunications() self.pending = { 'status': myTimer(constants.STATUS_UPDATE_INTERVAL), 'update': myTimer(constants.AUTOUPDATE_INTERVAL), } serialgaugeoptions = { 'name': 'Serial Monitor', 'init': print, 'read': None, 'fields': ['Value'], 'min': [0], 'max': [1000], 'config': [{ 'name': 'Data Type', 'options': ['byte', 'ASCII'], 'function': self.configSerialGauge }] } self.serialGauge = dio.DIOSENSOR(self, serialgaugeoptions) self.startTime = time.time() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.updateEverything) self.timer.start(20) #Auto-Detector self.shortlist = KuttyPyLib.getFreePorts()