def addPlot(self, addr, param): newNode = self.I.newRadioLink(address=addr) self.nodeList.append(newNode) print('made link', addr, param) #newNode.write_register(self.I.NRF.RF_SETUP,0x0E) #self.I.NRF.write_register(self.I.NRF.RF_SETUP,0x0E) #Change to 2MBPS cls = False cls_module = supported.get(param, None) if cls_module: cls = cls_module.connect(newNode) else: cls = None if cls: if hasattr(cls, 'name'): label = cls.name else: label = '' if not self.active_device_counter: if len(label): self.plot.setLabel('left', label) curves = [ self.addCurve(self.plot, '%s[%s]' % (label[:10], cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS) ] else: if label: colStr = lambda col: hex(col[0])[2:] + hex(col[1])[ 2:] + hex(col[2])[2:] newplt = self.addAxis( self.plot, label=label) #,color='#'+colStr(cols[0].getRgb())) else: newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curves = [ self.addCurve(newplt, '%s[%s]' % (label[:10], cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS) ] #for a in range(cls.NUMPLOTS): # self.plotLegend.addItem(curves[a],'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) self.createMenu(cls, param) for a in range(cls.NUMPLOTS): curves[a].checked = True Callback = functools.partial(self.setTraceVisibility, curves[a]) action = QtGui.QCheckBox( '%s' % (cls.PLOTNAMES[a]) ) #self.curveMenu.addAction('%s[%d]'%(label[:12],a)) action.toggled[bool].connect(Callback) action.setChecked(True) action.setStyleSheet( "background-color:rgb%s;" % (str(curves[a].opts['pen'].color().getRgb()))) self.paramMenus.insertWidget(1, action) self.actionWidgets.append(action) self.acquireList.append( self.plotItem(cls, np.zeros((cls.NUMPLOTS, self.POINTS)), curves)) self.active_device_counter += 1
def addPlot(self,param): cls=False cls_module = supported.get(param,None) if cls_module: cls = cls_module.connect(self.I.I2C) else: cls=None if cls: if hasattr(cls,'name'): label = cls.name else: label ='' cols=[self.random_color() for a in cls.PLOTNAMES] if cls.ADDRESS==0x68: #accelerometer, gyro. split plots curvesA=[self.addCurve(self.plot,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(4)] newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curvesB=[self.addCurve(newplt ,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(4,7)] curves = curvesA+curvesB else: if not self.active_device_counter: if len(label):self.plot.setLabel('left', label) curves=[self.addCurve(self.plot,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS)] else: if label: colStr = lambda col: hex(col[0])[2:]+hex(col[1])[2:]+hex(col[2])[2:] newplt = self.addAxis(self.plot,label=label,color='#'+colStr(cols[0].getRgb())) else: newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curves=[self.addCurve(newplt ,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS)] for a in range(cls.NUMPLOTS): self.plotLegend.addItem(curves[a],'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) self.createMenu(cls,param) for a in range(cls.NUMPLOTS): curves[a].checked=True Callback = functools.partial(self.setTraceVisibility,curves[a]) action=QtGui.QCheckBox('%s'%(cls.PLOTNAMES[a])) #self.curveMenu.addAction('%s[%d]'%(label[:12],a)) action.toggled[bool].connect(Callback) action.setChecked(True) action.setStyleSheet("background-color:rgb%s;"%(str(cols[a].getRgb()))) self.paramMenus.insertWidget(1,action) self.actions.append(action) self.acquireList.append(self.plotItem(cls,np.zeros((cls.NUMPLOTS,self.POINTS)), curves)) self.active_device_counter+=1
def addPlot(self,addr,param): newNode = self.I.newRadioLink(address=addr) self.nodeList.append(newNode) print ('made link',addr,param) #newNode.write_register(self.I.NRF.RF_SETUP,0x0E) #self.I.NRF.write_register(self.I.NRF.RF_SETUP,0x0E) #Change to 2MBPS cls=False cls_module = supported.get(param,None) if cls_module: cls = cls_module.connect(newNode) else: cls=None if cls: if hasattr(cls,'name'): label = cls.name else: label ='' if not self.active_device_counter: if len(label):self.plot.setLabel('left', label) curves=[self.addCurve(self.plot,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS)] else: if label: colStr = lambda col: hex(col[0])[2:]+hex(col[1])[2:]+hex(col[2])[2:] newplt = self.addAxis(self.plot,label=label)#,color='#'+colStr(cols[0].getRgb())) else: newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curves=[self.addCurve(newplt ,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS)] #for a in range(cls.NUMPLOTS): # self.plotLegend.addItem(curves[a],'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) self.createMenu(cls,param) for a in range(cls.NUMPLOTS): curves[a].checked=True Callback = functools.partial(self.setTraceVisibility,curves[a]) action=QtGui.QCheckBox('%s'%(cls.PLOTNAMES[a])) #self.curveMenu.addAction('%s[%d]'%(label[:12],a)) action.toggled[bool].connect(Callback) action.setChecked(True) action.setStyleSheet("background-color:rgb%s;"%(str(curves[a].opts['pen'].color().getRgb()))) self.paramMenus.insertWidget(1,action) self.actionWidgets.append(action) self.acquireList.append(self.plotItem(cls,np.zeros((cls.NUMPLOTS,self.POINTS)), curves)) self.active_device_counter+=1
def addPlot(self, param): cls = False cls_module = supported.get(param, None) if cls_module: cls = cls_module.connect(self.I.I2C) else: cls = None if cls: if hasattr(cls, 'name'): label = cls.name else: label = '' cols = [self.random_color() for a in cls.PLOTNAMES] if cls.ADDRESS == 0x68: #accelerometer, gyro. split plots curvesA = [ self.addCurve(self.plot, '%s[%s]' % (label[:10], cls.PLOTNAMES[a])) for a in range(4) ] newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curvesB = [ self.addCurve(newplt, '%s[%s]' % (label[:10], cls.PLOTNAMES[a])) for a in range(4, 7) ] curves = curvesA + curvesB else: if not self.active_device_counter: if len(label): self.plot.setLabel('left', label) curves = [ self.addCurve( self.plot, '%s[%s]' % (label[:10], cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS) ] else: if label: colStr = lambda col: hex(col[0])[2:] + hex(col[1])[ 2:] + hex(col[2])[2:] newplt = self.addAxis(self.plot, label=label, color='#' + colStr(cols[0].getRgb())) else: newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curves = [ self.addCurve( newplt, '%s[%s]' % (label[:10], cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS) ] for a in range(cls.NUMPLOTS): self.plotLegend.addItem( curves[a], '%s[%s]' % (label[:10], cls.PLOTNAMES[a])) self.createMenu(cls, param) for a in range(cls.NUMPLOTS): curves[a].checked = True Callback = functools.partial(self.setTraceVisibility, curves[a]) action = QtGui.QCheckBox( '%s' % (cls.PLOTNAMES[a]) ) #self.curveMenu.addAction('%s[%d]'%(label[:12],a)) action.toggled[bool].connect(Callback) action.setChecked(True) action.setStyleSheet("background-color:rgb%s;" % (str(cols[a].getRgb()))) self.paramMenus.insertWidget(1, action) self.actions.append(action) self.acquireList.append( self.plotItem(cls, np.zeros((cls.NUMPLOTS, self.POINTS)), curves)) self.active_device_counter += 1