class_docstr: Thread which runs hackrf_sweep process
class_docstr_tok: ["Thread","which","runs","hackrf_sweep","process"]
docstr: Setup hackrf_sweep params
docstr_tok: ["Setup","hackrf_sweep","params"]
code: def setup(
      self,
      start_freq=0,
      stop_freq=6000,
      bin_size=1000,
      interval=0.0,
      gain=40,
      ppm=0,
      crop=0,
      single_shot=False,
      device=0,
      sample_rate=20000000,
      bandwidth=0,
      lnb_lo=0,
  ):
      """Setup hackrf_sweep params"""
      # Small bin sizes (<40 kHz) are only suitable with an arbitrarily
      # reduced sweep interval. Bin sizes smaller than 3 kHz showed to be
      # infeasible also in these cases.
      if bin_size < 3:
          bin_size = 3
      if bin_size > 5000:
          bin_size = 5000
  
      # We only support whole numbers of steps with bandwidth equal to the
      # sample rate.
      step_bandwidth = sample_rate / 1000000
      total_bandwidth = stop_freq - start_freq
      step_count = 1 + (total_bandwidth - 1) // step_bandwidth
      total_bandwidth = step_count * step_bandwidth
      stop_freq = start_freq + total_bandwidth
  
      # distribute gain between two analog gain stages
      if gain > 102:
          gain = 102
      lna_gain = 8 * (gain // 18) if gain >= 0 else 0
      vga_gain = 2 * ((gain - lna_gain) // 2) if gain >= 0 else 0
  
      self.params = {
          "start_freq": start_freq,  # MHz
          "stop_freq": stop_freq,  # MHz
          "hops": 0,
          "device": 0,
          "sample_rate": 20e6,  # sps
          "bin_size": bin_size,  # kHz
          "interval": interval,  # seconds
          "gain": gain,
          "lna_gain": lna_gain,
          "vga_gain": vga_gain,
          "ppm": 0,
          "crop": 0,
          "single_shot": single_shot,
      }
      self.lnb_lo = lnb_lo
      self.databuffer = {"timestamp": [], "x": [], "y": []}
      self.lastsweep = 0
      self.interval = interval
  
file_path: qspectrumanalyzer/qspectrumanalyzer/backends/hackrf_sweep.py
imports: import struct, shlex, sys, time
  import numpy
  from Qt import QtCore
  from qspectrumanalyzer import subprocess
  from qspectrumanalyzer.backends import BaseInfo, BasePowerThread
label_desc: Use image node_id 1 for calling the PowerThread obj's underlying member method code with example usage: obj.setup(start_freq, stop_freq, bin_size, interval, gain, ppm, crop, single_shot, device, sample_rate, bandwidth, lnb_lo) without return types