def run(self): while True: self.updated.emit(vlfrx.wideband_spectrum( SETTINGS.value('spectrum/resolution', 10, int), SETTINGS.value('spectrum/frames', 100, int), SETTINGS.value('spectrum/channels', '1,2') )) # Wait for render render_wait.wait(mutex)
def get_selected_frequencies(): option_lock.lock() out = str(SETTINGS.value('spectrum/frequencies', '')).split(',') def is_float(val): try: float(val) return True except ValueError: return False out = list(map(float, filter(is_float, out))) option_lock.unlock() return out
def ch_buttons(self): option_lock.lock() # Uncheck all buttons self.button_c_h.setChecked(False) self.button_c_v.setChecked(False) self.button_c_vh.setChecked(False) chs = SETTINGS.value('spectrum/channels', '1,2', str).split(',') ch_h = '1' in chs ch_v = '2' in chs if ch_v and ch_h: self.button_c_vh.setChecked(True) elif ch_h: self.button_c_h.setChecked(True) elif ch_v: self.button_c_v.setChecked(True) option_lock.unlock()
def __init__(self, *args): super(MainWindow, self).__init__(*args) self.setCentralWidget(IntroView()) QtCore.QTimer.singleShot(SETTINGS.value('common/intro_length', 5000), self._start_main_view)
def get_val(): option_lock.lock() out = SETTINGS.value(option_key, default, float) option_lock.unlock() return out
def plot(self, data): render_lock.lock() option_lock.lock() if not self.canvas_initiated: self.init_canvas() # Plot ch = SETTINGS.value('spectrum/channels', '1,2') c = 0 for ch in ch.split(','): self.axes.plot( data[c * 2], data[c * 2 + 1], color='r' if ch == '1' else 'b', label='Horizontal' if ch == '1' else 'Vertical' ) c += 1 self.axes.hold(True) self.axes.hold(False) # Title self.figure.suptitle('%s R=%d F=%d AH=%.2f AV=%.2f V=%d' % ( datetime.now().strftime('%c'), SETTINGS.value('spectrum/resolution', 10, int), SETTINGS.value('spectrum/frames', 10, int), self.current_aa_h, self.current_aa_v, get_mic_vol() )) # Grid self.axes.grid(True, which='both') self.axes.set_xlim([SETTINGS.value('spectrum/x_min', 15000, int), SETTINGS.value('spectrum/x_max', 30000, int)]) y_max = SETTINGS.value('spectrum/y_max', 0.1, float) if y_max > 0: self.axes.set_ylim([0, y_max]) # Labels self.axes.set_xlabel(translate('SpectrumView', 'Frequency [kHz]')) self.axes.set_ylabel(translate('SpectrumView', 'Amplitude')) option_lock.unlock() # Transmitter indicators selected = SpectrumOptionsView.get_selected_frequencies() if len(selected): frequencies = [] for tx in TRANSMITTERS: freq = float(tx[0]) if freq in selected: frequencies.append([freq, tx[1]]) # Color Map scalar_color_map = cmx.ScalarMappable( norm=colors.Normalize(vmin=1, vmax=len(frequencies)), cmap=plt.get_cmap('Dark2') ) clr_idx = 0 for freq in frequencies: clr_idx += 1 self.axes.axvline( freq[0] * 1000, linewidth=2, color=scalar_color_map.to_rgba(clr_idx), alpha=0.9, linestyle='-', label="%.2f kHz [%s]" % (freq[0], freq[1]) ) self.axes.legend(prop={'family': 'monospace', 'size': 'small'}) self.axes.xaxis.set_major_formatter(HZ_2_KHZ_FORMATTER) # Refresh canvas self.canvas.draw() render_lock.unlock() # Start the calculation again render_wait.wakeAll()
def run(self): while True: self.updated.emit(read_t()) sleep(SETTINGS.value('inclinometer/t_freq', 1))
def run(self): while True: self.updated.emit(*read_xy()) sleep(SETTINGS.value('inclinometer/xy_freq', 0.1))