def configure_device_combo(self): dev_name_list = sorted(self.device_dict.keys()) self.device_control = MyCombo.Combo(self,self.config,self.device_combo,self.select_device,'selected_device',dev_name_list) self.device_control.get_value()
def __init__(self,app): QMainWindow.__init__(self) Ui_MainWindow.__init__(self) PLSDR.VERSION = "2.0" # device names and invocation strings -- # some are tested, some are search results # of doubtful accuracy. # feel free to add new entries. # please tell the author of any new, successful # devices and invocation strings # or problems with (or changes to) these # also enter local IP:port values where required self.device_dict = { 'AirSpy':'airspy', 'BladeRF':'bladerf', 'FCD':'fcd', 'HackRF':'hackrf', 'LimeSDR':'soapy=0,driver=lime', 'Miri':'miri', 'OsmoSDR':'osmosdr', 'PlutoSDR':'ip:pluto.local', 'RedPitaya':'redpitaya=127.0.0.1:1234', # change this IP:port value 'RFSPACE':'sdr-iq', 'RTL-SDR':'rtl', 'RTL-SDR TCP':'rtl_tcp=127.0.0.1:1234', # change this IP:port value 'SDRplay':'soapy=0,driver=sdrplay', 'USRP':'uhd', } self.app = app self.setupUi(self) self.setWindowTitle("PLSDR Version %s" % PLSDR.VERSION) self.app_icon = QtGui.QIcon() self.app_icon.addFile('icon/app_icon_16x16.png', QtCore.QSize(16,16)) self.app_icon.addFile('icon/app_icon_24x24.png', QtCore.QSize(24,24)) self.app_icon.addFile('icon/app_icon_32x32.png', QtCore.QSize(32,32)) self.app_icon.addFile('icon/app_icon_48x48.png', QtCore.QSize(48,48)) self.app_icon.addFile('icon/app_icon_128x128.png', QtCore.QSize(128,128)) self.app_icon.addFile('icon/app_icon_256x256.png', QtCore.QSize(256,256)) app.setWindowIcon(self.app_icon) app.aboutToQuit.connect(self.app_quit) self.graphic_data = None self.config = self.get_default_config() self.full_rebuild_flag = True self.running = False self.enabled = False self.upconvert_state_control = None self.radio = Radio.Radio(self) self.meta_style_sheet = """ QLabel[accessibleName=FreqDigit] { color:#00c000; font-size:24pt; background:black; padding:0; } QLabel[accessibleName=FreqDigitDark] { color:#003000; font-size:24pt; background:black; padding:0; } QLabel[accessibleName=FreqDigit]:hover { color:#00ff00; background:#404040; } QLabel[accessibleName=FreqDigitDark]:hover { color:#00ff00; background:#404040; } QWidget[objectName=digit_widget] { background:black; } /* this solves the mouse tooltip color problem */ DisplayPlot { qproperty-zoomer_color: #c0e0ff; } QTextEdit { text-align:right; } """ self.setStyleSheet(self.meta_style_sheet) # maps keyboard keys to frequency changes in Hz self.key_hash = { QtCore.Qt.Key_Minus : -1e2, QtCore.Qt.Key_Plus : 1e2, QtCore.Qt.Key_Left : -1e3, QtCore.Qt.Key_Right : 1e3, QtCore.Qt.Key_Up : -1e4, QtCore.Qt.Key_Down : 1e4, QtCore.Qt.Key_PageUp : -1e5, QtCore.Qt.Key_PageDown : 1e5, QtCore.Qt.Key_Insert : -1e6, QtCore.Qt.Key_Delete : 1e6, } # locate user's home directory, create configuration path home_dir = os.path.expanduser('~') classname = self.__class__.__name__ self.config_path = os.path.join(home_dir,".%s" % classname) if not os.path.exists(self.config_path): os.makedirs(self.config_path) self.config_file = os.path.join(self.config_path,'config.ini') os.chdir(os.path.dirname(os.path.realpath(__file__))) self.run_stop_button.clicked.connect(self.run_stop_event) self.quit_button.clicked.connect(self.app_quit) self.offset_freq_control = None self.signal_progress_bar.setMinimum(-120) self.signal_progress_bar.setMaximum(10) self.mode_list = ['AM','FM','WFM','USB','LSB','CW_USB','CW_LSB'] self.MODE_AM = 0 self.MODE_FM = 1 self.MODE_WFM = 2 self.MODE_USB = 3 self.MODE_LSB = 4 self.MODE_CW_USB = 5 self.MODE_CW_LSB = 6 self.mode_control = MyCombo.Combo(self,self.config,self.mode_combo,self.change_modes,'mode',self.mode_list) self.agc_list = ['SW/F','SW/S','HW','OFF'] self.AGC_FAST = 0 self.AGC_SLOW = 1 self.AGC_HW = 2 self.AGC_OFF = 3 self.agc_control = MyCombo.Combo(self,self.config,self.agc_combo,self.set_agc_mode,'agc_mode',self.agc_list) self.bw_buttonlist = [self.if_bw_wide_button,self.if_bw_medium_button,self.if_bw_narrow_button] self.BW_WIDE = 0 self.BW_MEDIUM = 1 self.BW_NARROW = 2 self.if_bw_buttongroup_control = MyButtonGroup.ButtonGroup(self.config,self.if_bw_button_group,self.set_bw_mode,'bw_mode',self.bw_buttonlist) self.gain_control_a = MySlider.Slider(self.config,self.gain_slider_a,self.set_named_gain,'gain_a',0,50) self.gain_control_b = MySlider.Slider(self.config,self.gain_slider_b,self.set_named_gain,'gain_b',0,50) self.gain_control_c = MySlider.Slider(self.config,self.gain_slider_c,self.set_named_gain,'gain_c',0,50) self.gain_control_d = MySlider.Slider(self.config,self.gain_slider_d,self.set_named_gain,'gain_d',0,50) self.af_gain_control = MySlider.Slider(self.config,self.af_gain_slider,self.set_af_gain,'af_gain',0,1,400) self.average_control = MySlider.Slider(self.config,self.averaging_slider,self.set_average,'average',1,.01) self.squelch_control = MySlider.Slider(self.config,self.squelch_slider,self.set_squelch,'squelch_level',-130,50,400) self.populate_freq_list() model = self.freq_table.model() selectionModel = QtCore.QItemSelectionModel(model) self.freq_table.setSelectionModel(selectionModel) selectionModel.selectionChanged.connect(self.row_selected) self.setup_freq_digits() self.bandwidth_control = MyCombo.Combo(self,self.config,self.bandwidth_combo,self.set_bandwidth,'bandwidth') self.fft_sizes = ["%d" % 2**n for n in range(6,20)] self.fft_size_control = MyCombo.Combo(self,self.config,self.fft_size_combo,self.critical_change,'fft_size',self.fft_sizes) self.framerates = ["%d" % n for n in (60,50,30,25,20,15,10,5,2,1)] self.framerate_control = MyCombo.Combo(self,self.config,self.framerate_combo,self.critical_change,'framerate',self.framerates) self.antenna_control = MyCombo.Combo(self,self.config,self.antenna_combo,self.change_antennas,'antenna') self.sample_rate_control = MyCombo.Combo(self,self.config,self.sample_rate_combo,self.critical_change,'sample_rate') self.audio_rate_control = MyTextEntry.TextEntry(self,self.audio_rate_text,self.critical_change,'audio_rate',1e3,60e3) self.cw_base_control = MyTextEntry.TextEntry(self,self.cw_base_text,self.critical_change,'cw_base',1e2,3e3) self.audio_device_control = MyTextEntry.TextEntry(self,self.audio_device_text,self.critical_change,'audio_device',0,0,True) self.corr_ppm_control = MyTextEntry.TextEntry(self,self.corr_ppm_text,self.set_corr_ppm,'corr_ppm',-100,100) self.corr_ppm_upc_control = MyTextEntry.TextEntry(self,self.corr_ppm_upc_text,self.set_corr_ppm_upc,'corr_ppm_upc',-100,100) self.upconvert_state_control = MyCheckbox.Checkbox(self,self.upconversion_checkbox,self.use_upconversion,'upconvert_state') self.upconvert_trans_control = MyTextEntry.TextEntry(self,self.upconvert_trans_text,self.update_freq_event,'upconvert_trans',0,50e6) self.upconvert_freq_control = MyTextEntry.TextEntry(self,self.upconvert_freq_text,self.update_freq_event,'upconvert_freq',0,1000e6) self.offset_state_control = MyCheckbox.Checkbox(self,self.offset_checkbox,self.use_offset,'offset_state') self.offset_freq_control = MyTextEntry.TextEntry(self,self.offset_freq_text,self.update_offset_freq,'offset_freq',-10000,10000) self.dc_offset_control = MyCheckbox.Checkbox(self,self.dc_offset_checkbox,self.set_dc_offset,'dc_offset') self.iq_balance_control = MyCheckbox.Checkbox(self,self.iq_balance_checkbox,self.set_iq_balance,'iq_balance') # pause number 1 waits for interface to be rendered # before modifying it QtCore.QTimer.singleShot(100, self.first_read_config)