kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
commit
991ae9bea8
|
@ -25,14 +25,8 @@ If applicable, add screenshots to help explain your problem.
|
|||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
- Python version: [if applicable]
|
||||
- NanoVNA-Saver version: [e.g. 0.1.4]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import collections
|
||||
import logging
|
||||
import math
|
||||
import sys
|
||||
|
@ -618,11 +617,11 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
if frequencies:
|
||||
logger.info("Read starting frequency %s and end frequency %s", frequencies[0], frequencies[100])
|
||||
if int(frequencies[0]) == int(frequencies[100]) and (self.sweepStartInput.text() == "" or self.sweepEndInput.text() == ""):
|
||||
self.sweepStartInput.setText(frequencies[0])
|
||||
self.sweepEndInput.setText(str(int(frequencies[100]) + 100000))
|
||||
self.sweepStartInput.setText(RFTools.formatFixedFrequency(int(frequencies[0])))
|
||||
self.sweepEndInput.setText(RFTools.formatFixedFrequency(int(frequencies[100]) + 100000))
|
||||
elif self.sweepStartInput.text() == "" or self.sweepEndInput.text() == "":
|
||||
self.sweepStartInput.setText(frequencies[0])
|
||||
self.sweepEndInput.setText(frequencies[100])
|
||||
self.sweepStartInput.setText(RFTools.formatFixedFrequency(int(frequencies[0])))
|
||||
self.sweepEndInput.setText(RFTools.formatFixedFrequency(int(frequencies[100])))
|
||||
self.sweepStartInput.textEdited.emit(self.sweepStartInput.text())
|
||||
self.sweepStartInput.textChanged.emit(self.sweepStartInput.text())
|
||||
else:
|
||||
|
@ -772,8 +771,8 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
fcenter = int(round((fstart+fstop)/2))
|
||||
if fspan < 0 or fstart < 0 or fstop < 0:
|
||||
return
|
||||
self.sweepSpanInput.setText(str(fspan))
|
||||
self.sweepCenterInput.setText(str(fcenter))
|
||||
self.sweepSpanInput.setText(RFTools.formatFixedFrequency(fspan))
|
||||
self.sweepCenterInput.setText(RFTools.formatFixedFrequency(fcenter))
|
||||
|
||||
def updateStartEnd(self):
|
||||
fcenter = RFTools.parseFrequency(self.sweepCenterInput.text())
|
||||
|
@ -784,8 +783,8 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
fstop = int(round(fcenter + fspan/2))
|
||||
if fstart < 0 or fstop < 0:
|
||||
return
|
||||
self.sweepStartInput.setText(str(fstart))
|
||||
self.sweepEndInput.setText(str(fstop))
|
||||
self.sweepStartInput.setText(RFTools.formatFixedFrequency(fstart))
|
||||
self.sweepEndInput.setText(RFTools.formatFixedFrequency(fstop))
|
||||
|
||||
def updateStepSize(self):
|
||||
fspan = RFTools.parseFrequency(self.sweepSpanInput.text())
|
||||
|
@ -1919,8 +1918,8 @@ class SweepSettingsWindow(QtWidgets.QWidget):
|
|||
start = max(1, start)
|
||||
stop += round(span / 10)
|
||||
|
||||
self.app.sweepStartInput.setText(str(start))
|
||||
self.app.sweepEndInput.setText(str(stop))
|
||||
self.app.sweepStartInput.setText(RFTools.formatFixedFrequency(start))
|
||||
self.app.sweepEndInput.setText(RFTools.formatFixedFrequency(stop))
|
||||
self.app.sweepEndInput.textEdited.emit(self.app.sweepEndInput.text())
|
||||
|
||||
def updateAveraging(self):
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
import collections
|
||||
import math
|
||||
|
||||
PREFIXES = ("", "k", "M", "G", "T")
|
||||
|
||||
Datapoint = collections.namedtuple('Datapoint', 'freq re im')
|
||||
|
||||
|
||||
|
@ -122,7 +124,37 @@ class RFTools:
|
|||
return "{:.1f}".format(freq/1000000) + " MHz"
|
||||
|
||||
@staticmethod
|
||||
def parseFrequency(freq: str):
|
||||
def formatFixedFrequency(freq: int,
|
||||
maxdigits: int = 6,
|
||||
appendHz: bool = True,
|
||||
assumeInfinity: bool = True) -> str:
|
||||
""" Format frequency with SI prefixes
|
||||
|
||||
maxdigits count include the dot, so that default leads
|
||||
to a maximum output of 9 characters
|
||||
"""
|
||||
freqstr = str(freq)
|
||||
freqlen = len(freqstr)
|
||||
|
||||
if freqlen > 15:
|
||||
if assumeInfinity:
|
||||
return "\N{INFINITY}"
|
||||
raise ValueError("Frequency to big. More than 15 digits!")
|
||||
if maxdigits < 3:
|
||||
raise ValueError(
|
||||
"At least 3 digits are needed, given ({})".format(maxdigits))
|
||||
|
||||
if freq < 1:
|
||||
return " - " + ("Hz" if appendHz else "")
|
||||
si_index = (freqlen -1) // 3
|
||||
dot_pos = freqlen % 3 or 3
|
||||
freqstr = freqstr[:dot_pos] + "." + freqstr[dot_pos:] + "00"
|
||||
|
||||
return freqstr[:maxdigits] + PREFIXES[si_index] + \
|
||||
("Hz" if appendHz else "")
|
||||
|
||||
@staticmethod
|
||||
def parseFrequency(freq: str) -> int:
|
||||
freq = freq.replace(" ", "") # People put all sorts of weird whitespace in.
|
||||
if freq.isnumeric():
|
||||
return int(freq)
|
||||
|
@ -130,11 +162,12 @@ class RFTools:
|
|||
multiplier = 1
|
||||
freq = freq.lower()
|
||||
|
||||
if freq.endswith("k"):
|
||||
multiplier = 1000
|
||||
freq = freq[:-1]
|
||||
elif freq.endswith("m"):
|
||||
multiplier = 1000000
|
||||
if freq.endswith("hz"):
|
||||
freq = freq[:-2]
|
||||
|
||||
my_prefixes = [pfx.lower() for pfx in PREFIXES]
|
||||
if len(freq) and freq[-1] in my_prefixes:
|
||||
multiplier = 10 ** (my_prefixes.index(freq[-1]) * 3)
|
||||
freq = freq[:-1]
|
||||
|
||||
if freq.isnumeric():
|
||||
|
|
2
setup.py
2
setup.py
|
@ -50,7 +50,7 @@ setup(
|
|||
},
|
||||
install_requires=[
|
||||
'pyserial',
|
||||
'PyQt5==5.11.2',
|
||||
'PyQt5>=5.11.2',
|
||||
'numpy',
|
||||
'scipy'
|
||||
],
|
||||
|
|
Ładowanie…
Reference in New Issue