Skip to content

Instantly share code, notes, and snippets.

@michelp
Created September 16, 2014 04:44
Show Gist options
  • Save michelp/6e53847bb962cc593c16 to your computer and use it in GitHub Desktop.
Save michelp/6e53847bb962cc593c16 to your computer and use it in GitHub Desktop.
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph as pg
import scipy.ndimage as ndi
import numpy as np
from scipy import signal
import bladeRF
device = bladeRF.Device()
device.rx.config(bladeRF.FORMAT_SC16_Q12, 64, 16384, 16, 3500)
device.rx.enabled = True
#device.rx.frequency = 462562500
device.rx.frequency = 870000000
#device.rx.frequency = 2437000000
device.rx.bandwidth = 28000000
device.rx.sample_rate = 40000000
device.lna_gain = bladeRF.LNA_GAIN_MAX
device.rx.vga1 = 20
device.rx.vga2 = 18
Nf = 512 # No. of frames
Ns = 1024 # Signal length
app = QtGui.QApplication([])
Arx = np.zeros([Nf, Ns])
win = pg.image(Arx)
win.view.setAspectLocked()
num_samples = 2**19
def update():
global Arx
Arx = np.roll(Arx, 1, axis=0)
samples = bladeRF.samples_to_narray(device.rx(num_samples), num_samples)
f, fft = signal.periodogram(samples, window='flattop', scaling='spectrum', nfft=1024)
fft = 10*np.log10(fft)
Arx[0] = fft
win.setImage(Arx.T, autoRange=False)
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(30)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment