def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Sound Intensity Bricklet', version) self.si = BrickletSoundIntensity(uid, ipcon) self.qtcb_intensity.connect(self.cb_intensity) self.si.register_callback(self.si.CALLBACK_INTENSITY, self.qtcb_intensity.emit) self.intensity_label = IntensityLabel() self.current_value = None self.thermo = TuningThermo() # plot_list = [['', Qt.red, self.get_current_value]] # self.plot_widget = PlotWidget('Intensity', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.intensity_label) layout_h.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.thermo) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addLayout(layout_h2) layout.addStretch()
class SoundIntensity(PluginBase): qtcb_intensity = pyqtSignal(int) def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Sound Intensity Bricklet', version) self.si = BrickletSoundIntensity(uid, ipcon) self.qtcb_intensity.connect(self.cb_intensity) self.si.register_callback(self.si.CALLBACK_INTENSITY, self.qtcb_intensity.emit) self.intensity_label = IntensityLabel() self.current_value = None self.thermo = TuningThermo() # plot_list = [['', Qt.red, self.get_current_value]] # self.plot_widget = PlotWidget('Intensity', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.intensity_label) layout_h.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.thermo) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addLayout(layout_h2) layout.addStretch() # layout.addWidget(self.plot_widget) # def get_current_value(self): # return self.current_value def cb_intensity(self, intensity): self.thermo.setValue(intensity) # self.current_value = intensity self.intensity_label.setText(str(intensity)) def start(self): async_call(self.si.get_intensity, None, self.cb_intensity, self.increase_error_count) async_call(self.si.set_intensity_callback_period, 10, None, self.increase_error_count) # self.plot_widget.stop = False def stop(self): async_call(self.si.set_intensity_callback_period, 0, None, self.increase_error_count) # self.plot_widget.stop = True def get_url_part(self): return 'sound_intensity' @staticmethod def has_device_identifier(device_identifier): return device_identifier == BrickletSoundIntensity.DEVICE_IDENTIFIER