def __init__(self, *args): super().__init__(BrickletCO2V2, *args) self.co2 = self.device self.cbe_all_values = CallbackEmulator(self, self.co2.get_all_values, None, self.cb_all_values, self.increase_error_count) self.current_co2 = CurveValueWrapper() # int, ppm self.current_temperature = CurveValueWrapper() # float, °C self.current_humidity = CurveValueWrapper() # float, %RH plots_co2 = [('CO2', Qt.red, self.current_co2, '{} PPM'.format)] self.plot_widget_co2 = PlotWidget('CO2 [PPM]', plots_co2, y_resolution=1.0) plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget('Temperature [°C]', plots_temperature, y_resolution=0.01) plots_humidity = [('Relative Humidity', Qt.red, self.current_humidity, '{} %RH'.format)] self.plot_widget_humidity = PlotWidget('Relative Humidity [%RH]', plots_humidity, y_resolution=0.01) layout_plot1 = QHBoxLayout() layout_plot1.addWidget(self.plot_widget_co2) layout_plot2 = QHBoxLayout() layout_plot2.addWidget(self.plot_widget_temperature) layout_plot2.addWidget(self.plot_widget_humidity) layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot1) layout_main.addLayout(layout_plot2)
def __init__(self, *args): super().__init__(BrickletAirQuality, *args) self.air_quality = self.device self.cbe_all_values = CallbackEmulator(self, self.air_quality.get_all_values, None, self.cb_all_values, self.increase_error_count) self.current_iaq_index = CurveValueWrapper() # float self.current_temperature = CurveValueWrapper() # float, °C self.current_humidity = CurveValueWrapper() # float, %RH self.current_air_pressure = CurveValueWrapper() # float, hPa self.iaq_accuracy_label = QLabel("(Accuracy: TBD)") plots_iaq_index = [('IAQ Index', Qt.red, self.current_iaq_index, '{}'.format)] self.plot_widget_iaq_index = PlotWidget( 'IAQ Index', plots_iaq_index, extra_key_widgets=(self.iaq_accuracy_label, ), y_resolution=1.0) plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget('Temperature [°C]', plots_temperature, y_resolution=0.01) plots_humidity = [('Relative Humidity', Qt.red, self.current_humidity, '{} %RH'.format)] self.plot_widget_humidity = PlotWidget('Relative Humidity [%RH]', plots_humidity, y_resolution=0.01) plots_air_pressure = [ ('Air Pressure', Qt.red, self.current_air_pressure, '{} hPa (QFE)'.format) ] self.plot_widget_air_pressure = PlotWidget('Air Pressure [hPa]', plots_air_pressure, y_resolution=0.01) layout_plot1 = QHBoxLayout() layout_plot1.addWidget(self.plot_widget_iaq_index) layout_plot1.addWidget(self.plot_widget_temperature) layout_plot2 = QHBoxLayout() layout_plot2.addWidget(self.plot_widget_humidity) layout_plot2.addWidget(self.plot_widget_air_pressure) layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot1) layout_main.addLayout(layout_plot2)
def __init__(self, *args): COMCUPluginBase.__init__(self, BrickletVoltageCurrentV2, *args) self.setupUi(self) self.vc = self.device self.cbe_voltage = CallbackEmulator(self.vc.get_voltage, None, self.cb_voltage, self.increase_error_count) self.cbe_current = CallbackEmulator(self.vc.get_current, None, self.cb_current, self.increase_error_count) self.cbe_power = CallbackEmulator(self.vc.get_power, None, self.cb_power, self.increase_error_count) self.current_voltage = CurveValueWrapper() # float, V self.current_current = CurveValueWrapper() # float, A self.current_power = CurveValueWrapper() # float, W plots_voltage = [('Voltage', Qt.red, self.current_voltage, format_voltage)] plots_current = [('Current', Qt.blue, self.current_current, format_current)] plots_power = [('Power', Qt.darkGreen, self.current_power, format_power)] self.plot_widget_voltage = PlotWidget( 'Voltage [V]', plots_voltage, clear_button=self.button_clear_graphs, y_resolution=0.001) self.plot_widget_current = PlotWidget( 'Current [A]', plots_current, clear_button=self.button_clear_graphs, y_resolution=0.001) self.plot_widget_power = PlotWidget( 'Power [W]', plots_power, clear_button=self.button_clear_graphs, y_resolution=0.001) self.save_conf_button.clicked.connect(self.save_conf_clicked) self.calibration = None self.button_calibration.clicked.connect(self.calibration_clicked) hlayout = QHBoxLayout() hlayout.addWidget(self.plot_widget_voltage) hlayout.addWidget(self.plot_widget_current) hlayout.addWidget(self.plot_widget_power) self.main_layout.insertLayout(0, hlayout)
def __init__(self, *args): super().__init__(BrickletHumidityV2, *args) self.hum = self.device self.cbe_humidity = CallbackEmulator(self.hum.get_humidity, None, self.cb_humidity, self.increase_error_count) self.cbe_temperature = CallbackEmulator(self.hum.get_temperature, None, self.cb_temperature, self.increase_error_count) self.current_humidity = CurveValueWrapper() # float, %RH self.current_temperature = CurveValueWrapper() # float, °C moving_average_humidity = MovingAverageConfig( 1, 1000, self.new_moving_average_humidity) plots_humidity = [('Relative Humidity', Qt.red, self.current_humidity, '{} %RH'.format)] self.plot_widget_humidity = PlotWidget( 'Relative Humidity [%RH]', plots_humidity, moving_average_config=moving_average_humidity, y_resolution=0.01) moving_average_temperature = MovingAverageConfig( 1, 1000, self.new_moving_average_temperature) plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget( 'Temperature [°C]', plots_temperature, moving_average_config=moving_average_temperature, y_resolution=0.01) self.enable_heater = QCheckBox("Enable Heater") self.enable_heater.stateChanged.connect(self.enable_heater_changed) layout_plot = QHBoxLayout() layout_plot.addWidget(self.plot_widget_humidity) layout_plot.addWidget(self.plot_widget_temperature) layout_config = QHBoxLayout() layout_config.addStretch() layout_config.addWidget(self.enable_heater) layout_config.addStretch() layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot) layout_main.addLayout(layout_config)
def __init__(self, *args): super().__init__(BrickletJoystick, *args) self.js = self.device self.cbe_position = CallbackEmulator( self, self.js.get_position, None, self.cb_position, self.increase_error_count, expand_result_tuple_for_callback=True) self.qtcb_pressed.connect(self.cb_pressed) self.js.register_callback(self.js.CALLBACK_PRESSED, self.qtcb_pressed.emit) self.qtcb_released.connect(self.cb_released) self.js.register_callback(self.js.CALLBACK_RELEASED, self.qtcb_released.emit) self.joystick_frame = JoystickFrame(self) self.joystick_frame.setMinimumSize(220, 220) self.joystick_frame.setMaximumSize(220, 220) self.joystick_frame.set_position(0, 0) self.calibrate_button = QPushButton('Calibrate Zero') self.calibrate_button.clicked.connect(self.calibrate_clicked) self.current_x = CurveValueWrapper() self.current_y = CurveValueWrapper() plots = [('X', Qt.darkGreen, self.current_x, str), ('Y', Qt.blue, self.current_y, str)] self.plot_widget = PlotWidget('Position', plots, update_interval=0.025, y_resolution=1.0) vlayout = QVBoxLayout() vlayout.addStretch() vlayout.addWidget(self.joystick_frame) vlayout.addWidget(self.calibrate_button) vlayout.addStretch() layout = QHBoxLayout(self) layout.addWidget(self.plot_widget) layout.addLayout(vlayout)
def __init__(self, *args): super().__init__(BrickletMotorizedLinearPoti, *args) self.mp = self.device self.cbe_position = CallbackEmulator(self.mp.get_position, None, self.cb_position, self.increase_error_count) self.current_position = CurveValueWrapper() self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, 100) self.slider.setMinimumWidth(200) self.slider.setEnabled(False) plots = [('Potentiometer Position', Qt.red, self.current_position, str) ] self.plot_widget = PlotWidget('Position', plots, extra_key_widgets=[self.slider], update_interval=0.025, y_resolution=1.0) self.motor_slider = QSlider(Qt.Horizontal) self.motor_slider.setRange(0, 100) self.motor_slider.valueChanged.connect(self.motor_slider_value_changed) self.motor_hold_position = QCheckBox("Hold Position") self.motor_drive_mode = QComboBox() self.motor_drive_mode.addItem('Fast') self.motor_drive_mode.addItem('Smooth') def get_motor_slider_value(): return self.motor_slider.value() self.motor_hold_position.stateChanged.connect( lambda x: self.motor_slider_value_changed(get_motor_slider_value() )) self.motor_drive_mode.currentIndexChanged.connect( lambda x: self.motor_slider_value_changed(get_motor_slider_value() )) self.motor_position_label = MotorPositionLabel( 'Motor Target Position:') hlayout = QHBoxLayout() hlayout.addWidget(self.motor_position_label) hlayout.addWidget(self.motor_slider) hlayout.addWidget(self.motor_drive_mode) hlayout.addWidget(self.motor_hold_position) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletRotaryPoti, *args) self.rp = self.device self.cbe_position = CallbackEmulator(self.rp.get_position, None, self.cb_position, self.increase_error_count) self.position_knob = KnobWidget(self) self.position_knob.setFocusPolicy(Qt.NoFocus) self.position_knob.set_total_angle(300) self.position_knob.set_range(-150, 150) self.position_knob.set_scale(30, 3) self.position_knob.set_knob_radius(25) self.current_position = CurveValueWrapper() plots = [('Position', Qt.red, self.current_position, str)] self.plot_widget = PlotWidget('Position', plots, update_interval=0.025, y_resolution=1.0) layout = QHBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(self.position_knob)
def __init__(self, *args): super().__init__(BrickletTemperatureV2, *args) self.tem = self.device self.cbe_temperature = CallbackEmulator(self.tem.get_temperature, None, self.cb_temperature, self.increase_error_count) self.current_temperature = CurveValueWrapper() # float, °C plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget('Temperature [°C]', plots_temperature, y_resolution=0.01) self.enable_heater = QCheckBox("Enable Heater") self.enable_heater.stateChanged.connect(self.enable_heater_changed) layout_plot = QHBoxLayout() layout_plot.addWidget(self.plot_widget_temperature) layout_config = QHBoxLayout() layout_config.addStretch() layout_config.addWidget(self.enable_heater) layout_config.addStretch() layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot) layout_main.addLayout(layout_config)
def __init__(self, *args): super().__init__(BrickletCurrent12, *args) self.cur = self.device self.cbe_current = CallbackEmulator(self.cur.get_current, None, self.cb_current, self.increase_error_count) self.qtcb_over.connect(self.cb_over) self.cur.register_callback(self.cur.CALLBACK_OVER_CURRENT, self.qtcb_over.emit) self.over_label = QLabel('Over Current: No') self.calibrate_button = QPushButton('Calibrate Zero') self.calibrate_button.clicked.connect(self.calibrate_clicked) self.current_current = CurveValueWrapper() # float, A plots = [('Current', Qt.red, self.current_current, format_current)] self.plot_widget = PlotWidget('Current [A]', plots, extra_key_widgets=[self.over_label], y_resolution=0.001) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addWidget(self.calibrate_button)
def __init__(self, *args): super().__init__(BrickletDistanceUSV2, *args) self.dist = self.device self.cbe_distance = CallbackEmulator(self, self.dist.get_distance, None, self.cb_distance, self.increase_error_count) self.current_distance = CurveValueWrapper() plots = [('Distance', Qt.red, self.current_distance, '{:.1f} cm'.format)] self.plot_widget = PlotWidget('Distance [cm]', plots, y_resolution=1.0) self.update_rate_label = QLabel('Update Rate:') self.update_rate_combo = QComboBox() self.update_rate_combo.addItem(" 2 Hz") self.update_rate_combo.addItem("10 Hz") self.update_rate_combo.currentIndexChanged.connect( self.new_update_rate) hlayout = QHBoxLayout() hlayout.addWidget(self.update_rate_label) hlayout.addWidget(self.update_rate_combo) hlayout.addStretch() layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addLayout(hlayout)
def __init__(self, *args): COMCUPluginBase.__init__(self, BrickletHallEffectV2, *args) self.setupUi(self) self.hf = self.device self.cbe_magnetic_flux_density = CallbackEmulator( self.hf.get_magnetic_flux_density, None, self.cb_magnetic_flux_density, self.increase_error_count) self.cbe_counter = CallbackEmulator(self.get_counter, False, self.cb_counter, self.increase_error_count) self.current_magnetic_flux_density = CurveValueWrapper() plots = [('Magnetic Flux Density', Qt.red, self.current_magnetic_flux_density, '{} µT'.format)] self.plot_widget = PlotWidget('Magnetic Flux Density [µT]', plots, y_resolution=1.0) self.button_reset.clicked.connect(self.button_reset_clicked) self.spinbox_low.editingFinished.connect(self.new_config) self.spinbox_high.editingFinished.connect(self.new_config) self.spinbox_debounce.editingFinished.connect(self.new_config) self.main_vert_layout.insertWidget(0, self.plot_widget)
def __init__(self, *args): super().__init__(BrickletAnalogInV2, *args) self.ai = self.device self.cbe_voltage = CallbackEmulator(self, self.ai.get_voltage, None, self.cb_voltage, self.increase_error_count) self.current_voltage = CurveValueWrapper() # float, V plots = [('Voltage', Qt.red, self.current_voltage, format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001) self.spin_average = QSpinBox() self.spin_average.setMinimum(1) self.spin_average.setMaximum(50) self.spin_average.setSingleStep(1) self.spin_average.setValue(50) self.spin_average.editingFinished.connect(self.spin_average_finished) layout_h1 = QHBoxLayout() layout_h1.addWidget(QLabel('Moving Average Length:')) layout_h1.addWidget(self.spin_average) layout_h1.addStretch() line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(layout_h1)
def __init__(self, *args): super().__init__(BrickletLoadCell, *args) self.lc = self.device self.cbe_weight = CallbackEmulator(self.lc.get_weight, None, self.cb_weight, self.increase_error_count) self.gain = 0 # 128x self.current_weight = CurveValueWrapper() # int, g self.calibration = None plots = [('Weight', Qt.red, self.current_weight, format_weight)] self.plot_widget = PlotWidget('Weight [g]', plots, y_resolution=1.0) self.button_calibration = QPushButton("Calibration...") self.button_calibration.clicked.connect( self.button_calibration_clicked) self.button_tare = QPushButton("Tare") self.button_tare.clicked.connect(self.button_tare_clicked) self.enable_led = QCheckBox("Enable LED") self.enable_led.stateChanged.connect(self.enable_led_changed) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(40) self.spin_average.setSingleStep(1) self.spin_average.setValue(5) self.spin_average.editingFinished.connect(self.spin_average_finished) self.label_average = QLabel('Moving Average Length:') self.rate_label = QLabel('Rate:') self.rate_combo = QComboBox() self.rate_combo.addItem("10 Hz") self.rate_combo.addItem("80 Hz") self.rate_combo.currentIndexChanged.connect(self.new_config) hlayout = QHBoxLayout() hlayout.addWidget(self.label_average) hlayout.addWidget(self.spin_average) hlayout.addWidget(self.rate_label) hlayout.addWidget(self.rate_combo) hlayout.addStretch() hlayout.addWidget(self.button_calibration) hlayout.addWidget(self.button_tare) hlayout.addWidget(self.enable_led) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletPTC, *args) self.ptc = self.device self.str_connected = 'Sensor is <font color="green">connected</font>' self.str_not_connected = 'Sensor is <font color="red">not connected</font>' self.cbe_temperature = CallbackEmulator(self, self.ptc.get_temperature, None, self.cb_temperature, self.increase_error_count) self.wire_label = QLabel('Wire Type:') self.wire_combo = QComboBox() self.wire_combo.addItem('2-Wire') self.wire_combo.addItem('3-Wire') self.wire_combo.addItem('4-Wire') self.noise_label = QLabel('Noise Rejection Filter:') self.noise_combo = QComboBox() self.noise_combo.addItem('50 Hz') self.noise_combo.addItem('60 Hz') self.connected_label = QLabel(self.str_connected) self.current_temperature = CurveValueWrapper() # float, °C self.wire_combo.currentIndexChanged.connect( self.wire_combo_index_changed) self.noise_combo.currentIndexChanged.connect( self.noise_combo_index_changed) plots = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget = PlotWidget('Temperature [°C]', plots, extra_key_widgets=[self.connected_label], y_resolution=0.01) hlayout = QHBoxLayout() hlayout.addWidget(self.wire_label) hlayout.addWidget(self.wire_combo) hlayout.addStretch() hlayout.addWidget(self.noise_label) hlayout.addWidget(self.noise_combo) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout) self.connected_timer = QTimer(self) self.connected_timer.timeout.connect(self.update_connected) self.connected_timer.setInterval(1000)
def __init__(self, *args): super().__init__(BrickletHallEffect, *args) self.hf = self.device self.cbe_edge_count = CallbackEmulator( self, self.get_edge_count, False, self.cb_edge_count, self.increase_error_count, expand_result_tuple_for_callback=True) self.current_value = CurveValueWrapper() self.label_count = CountLabel('Count') plots = [('Value', Qt.red, self.current_value, str)] self.plot_widget = PlotWidget('Value', plots, extra_key_widgets=[self.label_count], update_interval=0.05) self.plot_widget.set_fixed_y_scale(0, 1, 1, 1) self.combo_edge_type = QComboBox() self.combo_edge_type.addItem('Rising') self.combo_edge_type.addItem('Falling') self.combo_edge_type.addItem('Both') self.combo_edge_type.currentIndexChanged.connect(self.edge_changed) self.spin_debounce = QSpinBox() self.spin_debounce.setMinimum(0) self.spin_debounce.setMaximum(255) self.spin_debounce.setValue(100) self.spin_debounce.editingFinished.connect(self.debounce_changed) self.button_reset = QPushButton('Reset Count') self.button_reset.clicked.connect(self.reset_count) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Edge Type:')) hlayout.addWidget(self.combo_edge_type) hlayout.addStretch() hlayout.addWidget(QLabel('Debounce Period [ms]:')) hlayout.addWidget(self.spin_debounce) hlayout.addStretch() hlayout.addWidget(self.button_reset) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletTemperatureIRV2, *args) self.tir = self.device self.cbe_ambient_temperature = CallbackEmulator( self, self.tir.get_ambient_temperature, None, self.cb_ambient_temperature, self.increase_error_count) self.cbe_object_temperature = CallbackEmulator( self, self.tir.get_object_temperature, None, self.cb_object_temperature, self.increase_error_count) self.current_ambient = CurveValueWrapper() # float, °C self.current_object = CurveValueWrapper() # float, °C plots = [('Ambient', Qt.blue, self.current_ambient, '{} °C'.format), ('Object', Qt.red, self.current_object, '{} °C'.format)] self.plot_widget = PlotWidget('Temperature [°C]', plots, y_resolution=0.1) self.spin_emissivity = QSpinBox() self.spin_emissivity.setMinimum(6553) self.spin_emissivity.setMaximum(65535) self.spin_emissivity.setValue(65535) self.spin_emissivity.editingFinished.connect( self.spin_emissivity_finished) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Emissivity:')) hlayout.addWidget(self.spin_emissivity) hlayout.addStretch() line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletDistanceIRV2, *args) self.dist = self.device self.cbe_distance = CallbackEmulator(self, self.dist.get_distance, None, self.cb_distance, self.increase_error_count) self.cbe_analog_value = CallbackEmulator(self, self.dist.get_analog_value, None, self.cb_analog_value, self.increase_error_count) self.analog_label = AnalogLabel('Analog Value:') hlayout = QHBoxLayout() self.average_label = QLabel('Moving Average Length:') self.average_spin = QSpinBox() self.average_spin.setMinimum(1) self.average_spin.setMaximum(1000) self.average_spin.setSingleStep(1) self.average_spin.setValue(25) self.average_spin.editingFinished.connect(self.average_spin_finished) self.sensor_label = QLabel('Sensor Type:') self.sensor_combo = QComboBox() self.sensor_combo.addItem('2Y0A41 (4-30cm)') self.sensor_combo.addItem('2Y0A21 (10-80cm)') self.sensor_combo.addItem('2Y0A02 (20-150cm)') self.sensor_combo.currentIndexChanged.connect( self.sensor_combo_changed) hlayout.addWidget(self.average_label) hlayout.addWidget(self.average_spin) hlayout.addStretch() hlayout.addWidget(self.sensor_label) hlayout.addWidget(self.sensor_combo) self.current_distance = CurveValueWrapper() # float, cm plots = [('Distance', Qt.red, self.current_distance, '{} cm'.format)] self.plot_widget = PlotWidget('Distance [cm]', plots, extra_key_widgets=[self.analog_label], y_resolution=0.1) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletRotaryEncoder, *args) self.re = self.device # the firmware version of a EEPROM Bricklet can (under common circumstances) # not change during the lifetime of an EEPROM Bricklet plugin. therefore, # it's okay to make final decisions based on it here self.has_fixed_is_pressed = self.firmware_version >= ( 2, 0, 2) # is_pressed return value was inverted before self.cbe_count = CallbackEmulator(self, self.get_count, False, self.cb_count, self.increase_error_count) self.qtcb_pressed.connect(self.cb_pressed) self.re.register_callback(self.re.CALLBACK_PRESSED, self.qtcb_pressed.emit) self.qtcb_released.connect(self.cb_released) self.re.register_callback(self.re.CALLBACK_RELEASED, self.qtcb_released.emit) self.reset_button = QPushButton('Reset Count') self.reset_button.clicked.connect(self.reset_clicked) self.encoder_knob = KnobWidget(self) self.encoder_knob.setFocusPolicy(Qt.NoFocus) self.encoder_knob.set_total_angle(360) self.encoder_knob.set_range(0, 24) self.encoder_knob.set_scale(2, 2) self.encoder_knob.set_scale_text_visible(False) self.encoder_knob.set_scale_arc_visible(False) self.encoder_knob.set_knob_radius(25) self.encoder_knob.set_value(0) self.current_count = CurveValueWrapper() plots = [('Count', Qt.red, self.current_count, str)] self.plot_widget = PlotWidget('Count', plots, update_interval=0.025, y_resolution=1.0) vlayout = QVBoxLayout() vlayout.addStretch() vlayout.addWidget(self.encoder_knob) vlayout.addWidget(self.reset_button) vlayout.addStretch() layout = QHBoxLayout(self) layout.addWidget(self.plot_widget) layout.addLayout(vlayout)
def __init__(self, *args): super().__init__(BrickletAnalogInV3, *args) self.ai = self.device self.cbe_voltage = CallbackEmulator(self.ai.get_voltage, None, self.cb_voltage, self.increase_error_count) self.current_voltage = CurveValueWrapper() # float, V plots = [('Voltage', Qt.red, self.current_voltage, format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001) self.oversampling_combo = QComboBox() self.oversampling_combo.addItem('32x (0.56ms)') self.oversampling_combo.addItem('64x (1.12ms)') self.oversampling_combo.addItem('128x (2.24ms)') self.oversampling_combo.addItem('256x (4.48ms)') self.oversampling_combo.addItem('512x (8.96ms)') self.oversampling_combo.addItem('1024x (17.92ms)') self.oversampling_combo.addItem('2048x (35.84ms)') self.oversampling_combo.addItem('4096x (71.68ms)') self.oversampling_combo.addItem('8192x (143.36ms)') self.oversampling_combo.addItem('16384x (286.72ms)') self.oversampling_combo.currentIndexChanged.connect( self.oversampling_combo_index_changed) self.calibration = None self.calibration_button = QPushButton('Calibration...') self.calibration_button.clicked.connect( self.calibration_button_clicked) layout_h1 = QHBoxLayout() layout_h1.addWidget(QLabel('Oversampling:')) layout_h1.addWidget(self.oversampling_combo) layout_h1.addStretch() layout_h1.addWidget(self.calibration_button) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(layout_h1)
def __init__(self, *args): super().__init__(BrickletVoltage, *args) self.vol = self.device self.cbe_voltage = CallbackEmulator(self.vol.get_voltage, None, self.cb_voltage, self.increase_error_count) self.current_voltage = CurveValueWrapper() # float, V plots = [('Voltage', Qt.red, self.current_voltage, format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): super().__init__(BrickletRotaryEncoderV2, *args) self.re = self.device self.cbe_count = CallbackEmulator(self, self.get_count, False, self.cb_count, self.increase_error_count) self.qtcb_pressed.connect(self.cb_pressed) self.re.register_callback(self.re.CALLBACK_PRESSED, self.qtcb_pressed.emit) self.qtcb_released.connect(self.cb_released) self.re.register_callback(self.re.CALLBACK_RELEASED, self.qtcb_released.emit) self.reset_button = QPushButton('Reset Count') self.reset_button.clicked.connect(self.reset_clicked) self.encoder_knob = KnobWidget(self) self.encoder_knob.setFocusPolicy(Qt.NoFocus) self.encoder_knob.set_total_angle(360) self.encoder_knob.set_range(0, 24) self.encoder_knob.set_scale(2, 2) self.encoder_knob.set_scale_text_visible(False) self.encoder_knob.set_scale_arc_visible(False) self.encoder_knob.set_knob_radius(25) self.encoder_knob.set_value(0) self.current_count = CurveValueWrapper() plots = [('Count', Qt.red, self.current_count, str)] self.plot_widget = PlotWidget('Count', plots, update_interval=0.025, y_resolution=1.0) vlayout = QVBoxLayout() vlayout.addStretch() vlayout.addWidget(self.encoder_knob) vlayout.addWidget(self.reset_button) vlayout.addStretch() layout = QHBoxLayout(self) layout.addWidget(self.plot_widget) layout.addLayout(vlayout)
def __init__(self, *args): super().__init__(BrickletCO2, *args) self.co2 = self.device self.cbe_co2_concentration = CallbackEmulator(self.co2.get_co2_concentration, None, self.cb_co2_concentration, self.increase_error_count) self.current_co2_concentration = CurveValueWrapper() # int, ppm plots = [('CO2 Concentration', Qt.red, self.current_co2_concentration, '{} ppm'.format)] self.plot_widget = PlotWidget('CO2 Concentration [ppm]', plots, y_resolution=1.0) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): super().__init__(BrickletDistanceIR, *args) self.dist = self.device self.cbe_distance = CallbackEmulator(self, self.dist.get_distance, None, self.cb_distance, self.increase_error_count) self.cbe_analog_value = CallbackEmulator(self, self.dist.get_analog_value, None, self.cb_analog_value, self.increase_error_count) self.analog_label = AnalogLabel('Analog Value:') hlayout = QHBoxLayout() self.sample_label = QLabel('Sample Points:') self.sample_edit = QLineEdit() self.sample_file = QPushButton("Browse") self.sample_save = QPushButton("Save") self.sample_file.clicked.connect(self.sample_file_clicked) self.sample_save.clicked.connect(self.sample_save_clicked) hlayout.addWidget(self.sample_label) hlayout.addWidget(self.sample_edit) hlayout.addWidget(self.sample_file) hlayout.addWidget(self.sample_save) self.current_distance = CurveValueWrapper() # float, cm plots = [('Distance', Qt.red, self.current_distance, '{} cm'.format)] self.plot_widget = PlotWidget('Distance [cm]', plots, extra_key_widgets=[self.analog_label], y_resolution=0.1) line = QFrame() line.setObjectName("line") line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): super().__init__(BrickletMoisture, *args) self.moisture = self.device self.cbe_moisture_value = CallbackEmulator( self, self.moisture.get_moisture_value, None, self.cb_moisture_value, self.increase_error_count) self.current_moisture_value = CurveValueWrapper() plots = [('Moisture Value', Qt.red, self.current_moisture_value, str)] self.plot_widget = PlotWidget('Moisture Value', plots, y_resolution=1.0) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): super().__init__(BrickletDustDetector, *args) self.dust_detector = self.device self.cbe_dust_density = CallbackEmulator(self, self.dust_detector.get_dust_density, None, self.cb_dust_density, self.increase_error_count) self.current_dust_density = CurveValueWrapper() plots = [('Dust Density', Qt.red, self.current_dust_density, '{} µg/m³'.format)] self.plot_widget = PlotWidget('Dust Density [µg/m³]', plots, y_resolution=1.0) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): super().__init__(BrickletHumidity, *args) self.hum = self.device self.cbe_humidity = CallbackEmulator(self, self.hum.get_humidity, None, self.cb_humidity, self.increase_error_count) self.current_humidity = CurveValueWrapper() # float, %RH plots = [('Relative Humidity', Qt.red, self.current_humidity, '{} %RH'.format)] self.plot_widget = PlotWidget('Relative Humidity [%RH]', plots, y_resolution=0.1) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): super().__init__(BrickletLine, *args) self.line = self.device self.cbe_reflectivity = CallbackEmulator(self.line.get_reflectivity, None, self.cb_reflectivity, self.increase_error_count) self.rf = ReflectivityFrame() self.current_reflectivity = CurveValueWrapper() plots = [('Reflectivity', Qt.red, self.current_reflectivity, str)] self.plot_widget = PlotWidget('Reflectivity', plots, y_resolution=1.0) layout = QHBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(self.rf)
def __init__(self, *args): super().__init__(BrickletTemperature, *args) self.tem = self.device self.cbe_temperature = CallbackEmulator(self, self.tem.get_temperature, None, self.cb_temperature, self.increase_error_count) self.current_temperature = CurveValueWrapper() # float, °C plots = [('Temperature', Qt.red, self.current_temperature, '{:.2f} °C'.format)] self.plot_widget = PlotWidget('Temperature [°C]', plots, y_resolution=0.01) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): super().__init__(BrickletUVLight, *args) self.uv_light = self.device self.cbe_uv_light = CallbackEmulator(self, self.uv_light.get_uv_light, None, self.cb_uv_light, self.increase_error_count) self.index_label = IndexLabel(' UV Index: ? ') self.current_uv_light = CurveValueWrapper() plots = [('UV Light', Qt.red, self.current_uv_light, '{} mW/m²'.format)] self.plot_widget = PlotWidget('UV Light [mW/m²]', plots, extra_key_widgets=[self.index_label], y_resolution=0.1) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): super().__init__(BrickletSoundIntensity, *args) self.si = self.device self.cbe_intensity = CallbackEmulator(self.si.get_intensity, None, self.cb_intensity, self.increase_error_count) self.current_intensity = CurveValueWrapper() self.thermo = TuningThermo() plots = [('Intensity Value', Qt.red, self.current_intensity, str)] self.plot_widget = PlotWidget('Intensity Value', plots, update_interval=0.025, extra_key_widgets=[self.thermo], y_resolution=1.0) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)