diff --git a/CMakeLists.txt b/CMakeLists.txt index a210d5b..4effcf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ if(WIN32) endif() endif() +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + # Project project(nanovna_qt C CXX) @@ -19,10 +21,10 @@ set(xaVNA_VERSION_MINOR 1) set(xaVNA_VERSION_STRING ${xaVNA_VERSION_MAJOR}.${xaVNA_VERSION_MINOR}) # Set C++11 as standard for the whole project -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) if(UNIX) - set(CMAKE_CXX_FLAGS "-O2 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-O2 -Wall ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "-O2 -g ${CMAKE_CXX_FLAGS}") endif() @@ -63,21 +65,21 @@ endif() # ============================================================================== # FFTW3 # ============================================================================== -find_package(FFTW3 REQUIRED) -if(FFTW3_FOUND) - message(STATUS "Found FFTW3 (${FFTW3_VERSION})") - message(STATUS " fftw3 includes: ${FFTW3_INCLUDE_DIRS}") - message(STATUS " fftw3 libraries: ${FFTW3_LIBRARIES}") - include_directories(${FFTW3_INCLUDE_DIR}) +find_package(FFTW REQUIRED) +if(FFTW_FOUND) + message(STATUS "Found FFTW (${FFTW_VERSION})") + message(STATUS " fftw includes: ${FFTW_INCLUDE_DIRS}") + message(STATUS " fftw libraries: ${FFTW_LIBRARIES}") + include_directories(${FFTW_INCLUDE_DIR}) endif() # ============================================================================== # QT5 Charts (and QT5 subdependences) # ============================================================================== -find_package(Qt5 COMPONENTS Core Gui Widgets Charts REQUIRED) +find_package(Qt6 COMPONENTS Core Gui Widgets Charts REQUIRED) if(Qt5Charts_FOUND) - message(STATUS "Found QT5 version: ${Qt5_VERSION}") - message(STATUS " qt5 charts dir: ${Qt5Charts_DIR}") + message(STATUS "Found QT6 version: ${Qt6_VERSION}") + message(STATUS " qt6 charts dir: ${Qt6Charts_DIR}") endif() # ============================================================================== @@ -86,3 +88,4 @@ endif() add_subdirectory(libxavna) add_subdirectory(libxavna/xavna_mock_ui) add_subdirectory(vna_qt) +add_subdirectory(vna_diagtool) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index ddc8e80..0000000 --- a/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 --install - -SUBDIRS = libxavna diff --git a/README.md b/README.md index b333b0a..1dbc229 100644 --- a/README.md +++ b/README.md @@ -1,100 +1,10 @@ # NanoVNA-QT -PC GUI software for NanoVNA V2 series (V2 Plus4/V2 Plus4 Pro). -- Supports hardware versions listed here: https://nanorfe.com/nanovna-v2.html -- https://www.tindie.com/products/hcxqsgroup/nanovna-v2/ +This is the original NanoVNA software updated to Qt6 by IV3IWE. +To compile: -NanoVNA V2配套的PC软件,可用于实时网络分析和测量。 - - -# Downloads / 下载 -https://nanorfe.com/nanovna-v2-software.html - - -# Screenshots / 截图 - -##### Open circuited coax stub / 开路同轴电缆 - - - -##### Antenna / 天线 - - - -##### Time to fault / 障碍距离 - - - - -# 编译 / Building the software - -__Linux系统下编译 / Building on Linux__ - -编译 libxavna: -```bash -sudo apt-get install automake libtool make g++ libeigen3-dev libfftw3-dev -cd /PATH/TO/NanoVNA-QT -autoreconf --install -./configure -make -cd libxavna/xavna_mock_ui/ -/PATH/TO/qmake -make ``` - -编译 QT 界面: -```bash -sudo apt-get install libqt5charts5-dev -cd /PATH/TO/NanoVNA-QT -cd vna_qt -/PATH/TO/qmake +cmake . make -export QT=/PATH/TO/QT # optional, e.g. ~/qt/5.10.1/gcc_64 -../run ./vna_qt -``` - -__Mac系统下编译 / Building on mac os__ - - MacPorts: -```bash -sudo port install NanoVNA-QT -# result in /Applications/MacPorts/NanoVNA-QT.app -``` - - Homebrew: -```bash -brew install automake libtool make eigen fftw -cd /PATH/TO/NanoVNA-QT -./deploy_macos.sh -# result is in ./vna_qt/vna_qt.app ``` - -__Linux系统下编译Windows目标 / Cross-compile for windows (from Linux)__ - -Prerequisites: -```bash -sudo apt-get install python make autoconf automake autopoint bison flex gperf intltool libtool libtool-bin lzip ruby unzip p7zip-full libgdk-pixbuf2.0-dev libssl-dev libeigen3-dev fftw3-dev mingw-w64 -``` - -下载与编译 MXE: -```bash -cd ~/ -git clone https://github.com/mxe/mxe.git -cd mxe -echo "MXE_TARGETS := i686-w64-mingw32.shared" >> settings.mk -export QT_MXE_ARCH=386 -make qt5 qtcharts cc eigen fftw pthreads -``` - -编译 Application: -```bash -cd ~/ -git clone https://github.com/nanovna/NanoVNA-QT.git -cd NanoVNA-QT -export PATH="~/mxe/usr/bin:$PATH" -./deploy_windows.sh -# Result is in ./vna_qt_windows.zip -``` - -Tested on a fresh install of Ubuntu 18.04 LTS. diff --git a/appimage/.gitignore b/appimage/.gitignore deleted file mode 100644 index 6ecb169..0000000 --- a/appimage/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -doc/ -lib/ -plugins/ -translations/ -qt.conf -vna_qt -AppRun -.DirIcon diff --git a/appimage/default.desktop b/appimage/default.desktop deleted file mode 100644 index 8c6824c..0000000 --- a/appimage/default.desktop +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Type=Application -Name=NanoVNA QT GUI -Exec=AppRun %F -Icon=default -Comment=GUI for NanoVNA V2 -Terminal=false -Categories=Science; diff --git a/appimage/default.png b/appimage/default.png deleted file mode 100644 index e69de29..0000000 diff --git a/cmake/FindFFTW.cmake b/cmake/FindFFTW.cmake new file mode 100644 index 0000000..3c65f2d --- /dev/null +++ b/cmake/FindFFTW.cmake @@ -0,0 +1,420 @@ +# - Find the FFTW library +# +# Original version of this file: +# Copyright (c) 2015, Wenzel Jakob +# https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake, commit 4d58bfdc28891b4f9373dfe46239dda5a0b561c6 +# Modifications: +# Copyright (c) 2017, Patrick Bos +# +# Usage: +# find_package(FFTW [REQUIRED] [QUIET] [COMPONENTS component1 ... componentX] ) +# +# It sets the following variables: +# FFTW_FOUND ... true if fftw is found on the system +# FFTW_[component]_LIB_FOUND ... true if the component is found on the system (see components below) +# FFTW_LIBRARIES ... full paths to all found fftw libraries +# FFTW_[component]_LIB ... full path to one of the components (see below) +# FFTW_INCLUDE_DIRS ... fftw include directory paths +# +# The following variables will be checked by the function +# FFTW_USE_STATIC_LIBS ... if true, only static libraries are found, otherwise both static and shared. +# FFTW_ROOT ... if set, the libraries are exclusively searched +# under this path +# +# This package supports the following components: +# FLOAT_LIB +# DOUBLE_LIB +# LONGDOUBLE_LIB +# FLOAT_THREADS_LIB +# DOUBLE_THREADS_LIB +# LONGDOUBLE_THREADS_LIB +# FLOAT_OPENMP_LIB +# DOUBLE_OPENMP_LIB +# LONGDOUBLE_OPENMP_LIB +# + +# TODO (maybe): extend with ExternalProject download + build option +# TODO: put on conda-forge + + +if( NOT FFTW_ROOT AND DEFINED ENV{FFTWDIR} ) + set( FFTW_ROOT $ENV{FFTWDIR} ) +endif() + +# Check if we can use PkgConfig +find_package(PkgConfig) + +#Determine from PKG +if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT ) + pkg_check_modules( PKG_FFTW QUIET "fftw3" ) +endif() + +#Check whether to search static or dynamic libs +set( CMAKE_FIND_LIBRARY_SUFFIXES_SAV ${CMAKE_FIND_LIBRARY_SUFFIXES} ) + +if( ${FFTW_USE_STATIC_LIBS} ) + set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX} ) +else() + set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} ) +endif() + +if( FFTW_ROOT ) + # find libs + + find_library( + FFTW_DOUBLE_LIB + NAMES "fftw3" libfftw3-3 + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_DOUBLE_THREADS_LIB + NAMES "fftw3_threads" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_DOUBLE_OPENMP_LIB + NAMES "fftw3_omp" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_DOUBLE_MPI_LIB + NAMES "fftw3_mpi" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_FLOAT_LIB + NAMES "fftw3f" libfftw3f-3 + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_FLOAT_THREADS_LIB + NAMES "fftw3f_threads" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_FLOAT_OPENMP_LIB + NAMES "fftw3f_omp" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_FLOAT_MPI_LIB + NAMES "fftw3f_mpi" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_LONGDOUBLE_LIB + NAMES "fftw3l" libfftw3l-3 + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_LONGDOUBLE_THREADS_LIB + NAMES "fftw3l_threads" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_LONGDOUBLE_OPENMP_LIB + NAMES "fftw3l_omp" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + find_library( + FFTW_LONGDOUBLE_MPI_LIB + NAMES "fftw3l_mpi" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "lib" "lib64" + NO_DEFAULT_PATH + ) + + #find includes + find_path(FFTW_INCLUDE_DIRS + NAMES "fftw3.h" + PATHS ${FFTW_ROOT} + PATH_SUFFIXES "include" + NO_DEFAULT_PATH + ) + +else() + + find_library( + FFTW_DOUBLE_LIB + NAMES "fftw3" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_DOUBLE_THREADS_LIB + NAMES "fftw3_threads" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_DOUBLE_OPENMP_LIB + NAMES "fftw3_omp" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_DOUBLE_MPI_LIB + NAMES "fftw3_mpi" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_FLOAT_LIB + NAMES "fftw3f" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_FLOAT_THREADS_LIB + NAMES "fftw3f_threads" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_FLOAT_OPENMP_LIB + NAMES "fftw3f_omp" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_FLOAT_MPI_LIB + NAMES "fftw3f_mpi" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_LONGDOUBLE_LIB + NAMES "fftw3l" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library( + FFTW_LONGDOUBLE_THREADS_LIB + NAMES "fftw3l_threads" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library(FFTW_LONGDOUBLE_OPENMP_LIB + NAMES "fftw3l_omp" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_library(FFTW_LONGDOUBLE_MPI_LIB + NAMES "fftw3l_mpi" + PATHS ${PKG_FFTW_LIBRARY_DIRS} ${LIB_INSTALL_DIR} + ) + + find_path(FFTW_INCLUDE_DIRS + NAMES "fftw3.h" + PATHS ${PKG_FFTW_INCLUDE_DIRS} ${INCLUDE_INSTALL_DIR} + ) + +endif( FFTW_ROOT ) + +#--------------------------------------- components + +if (FFTW_DOUBLE_LIB) + set(FFTW_DOUBLE_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_LIB}) + add_library(FFTW::Double INTERFACE IMPORTED) + set_target_properties(FFTW::Double + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_LIB}" + ) +else() + set(FFTW_DOUBLE_LIB_FOUND FALSE) +endif() + +if (FFTW_FLOAT_LIB) + set(FFTW_FLOAT_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_LIB}) + add_library(FFTW::Float INTERFACE IMPORTED) + set_target_properties(FFTW::Float + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_LIB}" + ) +else() + set(FFTW_FLOAT_LIB_FOUND FALSE) +endif() + +if (FFTW_LONGDOUBLE_LIB) + set(FFTW_LONGDOUBLE_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_LIB}) + add_library(FFTW::LongDouble INTERFACE IMPORTED) + set_target_properties(FFTW::LongDouble + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_LIB}" + ) +else() + set(FFTW_LONGDOUBLE_LIB_FOUND FALSE) +endif() + +if (FFTW_DOUBLE_THREADS_LIB) + set(FFTW_DOUBLE_THREADS_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_THREADS_LIB}) + add_library(FFTW::DoubleThreads INTERFACE IMPORTED) + set_target_properties(FFTW::DoubleThreads + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_THREADS_LIB}" + ) +else() + set(FFTW_DOUBLE_THREADS_LIB_FOUND FALSE) +endif() + +if (FFTW_FLOAT_THREADS_LIB) + set(FFTW_FLOAT_THREADS_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_THREADS_LIB}) + add_library(FFTW::FloatThreads INTERFACE IMPORTED) + set_target_properties(FFTW::FloatThreads + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_THREADS_LIB}" + ) +else() + set(FFTW_FLOAT_THREADS_LIB_FOUND FALSE) +endif() + +if (FFTW_LONGDOUBLE_THREADS_LIB) + set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_THREADS_LIB}) + add_library(FFTW::LongDoubleThreads INTERFACE IMPORTED) + set_target_properties(FFTW::LongDoubleThreads + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_THREADS_LIB}" + ) +else() + set(FFTW_LONGDOUBLE_THREADS_LIB_FOUND FALSE) +endif() + +if (FFTW_DOUBLE_OPENMP_LIB) + set(FFTW_DOUBLE_OPENMP_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_OPENMP_LIB}) + add_library(FFTW::DoubleOpenMP INTERFACE IMPORTED) + set_target_properties(FFTW::DoubleOpenMP + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_OPENMP_LIB}" + ) +else() + set(FFTW_DOUBLE_OPENMP_LIB_FOUND FALSE) +endif() + +if (FFTW_FLOAT_OPENMP_LIB) + set(FFTW_FLOAT_OPENMP_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_OPENMP_LIB}) + add_library(FFTW::FloatOpenMP INTERFACE IMPORTED) + set_target_properties(FFTW::FloatOpenMP + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_OPENMP_LIB}" + ) +else() + set(FFTW_FLOAT_OPENMP_LIB_FOUND FALSE) +endif() + +if (FFTW_LONGDOUBLE_OPENMP_LIB) + set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_OPENMP_LIB}) + add_library(FFTW::LongDoubleOpenMP INTERFACE IMPORTED) + set_target_properties(FFTW::LongDoubleOpenMP + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_OPENMP_LIB}" + ) +else() + set(FFTW_LONGDOUBLE_OPENMP_LIB_FOUND FALSE) +endif() + +if (FFTW_DOUBLE_MPI_LIB) + set(FFTW_DOUBLE_MPI_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_DOUBLE_MPI_LIB}) + add_library(FFTW::DoubleMPI INTERFACE IMPORTED) + set_target_properties(FFTW::DoubleMPI + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_DOUBLE_MPI_LIB}" + ) +else() + set(FFTW_DOUBLE_MPI_LIB_FOUND FALSE) +endif() + +if (FFTW_FLOAT_MPI_LIB) + set(FFTW_FLOAT_MPI_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_FLOAT_MPI_LIB}) + add_library(FFTW::FloatMPI INTERFACE IMPORTED) + set_target_properties(FFTW::FloatMPI + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_FLOAT_MPI_LIB}" + ) +else() + set(FFTW_FLOAT_MPI_LIB_FOUND FALSE) +endif() + +if (FFTW_LONGDOUBLE_MPI_LIB) + set(FFTW_LONGDOUBLE_MPI_LIB_FOUND TRUE) + set(FFTW_LIBRARIES ${FFTW_LIBRARIES} ${FFTW_LONGDOUBLE_MPI_LIB}) + add_library(FFTW::LongDoubleMPI INTERFACE IMPORTED) + set_target_properties(FFTW::LongDoubleMPI + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${FFTW_LONGDOUBLE_MPI_LIB}" + ) +else() + set(FFTW_LONGDOUBLE_MPI_LIB_FOUND FALSE) +endif() + +#--------------------------------------- end components + +set( CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAV} ) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(FFTW + REQUIRED_VARS FFTW_INCLUDE_DIRS + HANDLE_COMPONENTS + ) + +mark_as_advanced( + FFTW_INCLUDE_DIRS + FFTW_LIBRARIES + FFTW_FLOAT_LIB + FFTW_DOUBLE_LIB + FFTW_LONGDOUBLE_LIB + FFTW_FLOAT_THREADS_LIB + FFTW_DOUBLE_THREADS_LIB + FFTW_LONGDOUBLE_THREADS_LIB + FFTW_FLOAT_OPENMP_LIB + FFTW_DOUBLE_OPENMP_LIB + FFTW_LONGDOUBLE_OPENMP_LIB + FFTW_FLOAT_MPI_LIB + FFTW_DOUBLE_MPI_LIB + FFTW_LONGDOUBLE_MPI_LIB + ) + diff --git a/configure.ac b/configure.ac deleted file mode 100644 index e9c6df7..0000000 --- a/configure.ac +++ /dev/null @@ -1,70 +0,0 @@ -AC_INIT(vna, version-0.1, 54525305+nanovna@users.noreply.github.com) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -AC_PROG_CXX -AC_LANG(C++) -AC_CONFIG_MACRO_DIR([m4]) -#AC_CONFIG_HEADERS([libxavna/include/xavna.h]) -AC_CONFIG_FILES([ - Makefile - libxavna/Makefile -]) -LT_INIT([win32-dll]) -AC_CANONICAL_HOST - -is_windows=no -case "${host_os}" in - cygwin*|mingw*) - is_windows=yes - ;; - linux-androideabi) - is_android=yes - ;; -esac - -AM_CONDITIONAL([WINDOWS], [test "$is_windows" = "yes"]) -AM_CONDITIONAL([ANDROID], [test "$is_android" = "yes"]) - -AC_CHECK_HEADER(eigen3/Eigen/Dense) -if test "$ac_cv_header_eigen3_Eigen_Dense" == no -then - AC_MSG_ERROR([eigen3 not installed (eigen3/Eigen/Dense include not found)]) -fi - - -AC_CHECK_HEADER(fftw3.h) -if test "$ac_cv_header_fftw3_h" == no -then - AC_MSG_ERROR([fftw3 not installed (fftw3.h include not found)]) -fi - - - -#if test -z $CXXFLAGS; then -# CXXFLAGS='-O2 -std=c++0x -fPIC -fwrapv -fno-delete-null-pointer-checks -funsigned-char -fno-strict-aliasing -Wno-pmf-conversions' -#fi - -#AC_SUBST(OBJECTS) -#OBJECTS="lib/libxavna.so" - - - -#AC_SUBST(EXTRA_LIBRARIES) -#AC_SUBST(EXTRA_SOURCES) - -#AC_ARG_VAR([QMAKE], [Path to qmake]) - -#AC_ARG_WITH([qt_gui], - #[AS_HELP_STRING([--with-qt-gui], - #[Build QT GUI @<:@default=yes@:>@])], - #[], - #[with_qt_gui=yes]) - - -#if test "$with_qt_gui" == "yes" -#then - #AC_CHECK_PROG([QMAKE], [qmake], [qmake]) - #OBJECTS+=" vna_qt/vna_qt" -#fi - -AC_OUTPUT diff --git a/deploy_linux.sh b/deploy_linux.sh deleted file mode 100755 index 5efa3b6..0000000 --- a/deploy_linux.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# please edit env.cfg and set the correct paths before running - -cd "$(dirname $0)" -. env.cfg -if [ ! -e "$QT" ]; then - echo "please edit env.cfg and set \$QT" - exit 1 -fi -if [ ! -e "$LINUXDEPLOYQT" ]; then - echo "please edit env.cfg and set \$LINUXDEPLOYQT" - exit 1 -fi -QMAKE="$QT/bin/qmake" - -autoreconf --install -./configure -make -j$(nproc) - -pushd libxavna/xavna_mock_ui -$QMAKE -make -j$(nproc) -popd - -pushd vna_qt -$QMAKE -make -j$(nproc) -popd - -export LD_LIBRARY_PATH="$(pwd)/libxavna/.libs:$(pwd)/libxavna/xavna_mock_ui:$QT/lib" -cp -a vna_qt/vna_qt appimage/ -rm -rf appimage/lib appimage/plugins -"$LINUXDEPLOYQT" appimage/vna_qt -qmake="$QMAKE" -appimage - diff --git a/deploy_macos.sh b/deploy_macos.sh deleted file mode 100755 index a424d5d..0000000 --- a/deploy_macos.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -cd "$(dirname $0)" -. env.cfg -if [ ! -e "$QT" ]; then - echo "please edit env.cfg and set \$QT" - exit 1 -fi -QMAKE="$QT/bin/qmake" - -autoreconf --install -./configure -make -j8 - -pushd libxavna/xavna_mock_ui -$QMAKE -make -j8 -popd - -pushd vna_qt -rm -rf *.app -$QMAKE -make -j8 -"$QT"/bin/macdeployqt vna_qt.app -libpath=../libxavna/xavna_mock_ui -cp -a ../libxavna/.libs/libxavna.0.dylib vna_qt.app/Contents/Frameworks - -pushd vna_qt.app/Contents -install_name_tool -add_rpath "@executable_path/../Frameworks" MacOS/vna_qt -install_name_tool -change libxavna_mock_ui.1.dylib @executable_path/../Frameworks/libxavna_mock_ui.1.dylib MacOS/vna_qt -install_name_tool -change /usr/local/lib/libxavna.0.dylib @executable_path/../Frameworks/libxavna.0.dylib MacOS/vna_qt -install_name_tool -change /usr/local/lib/libxavna.0.dylib @executable_path/../Frameworks/libxavna.0.dylib Frameworks/libxavna_mock_ui.1.dylib -popd - -rm -rf dmg_contents ../NanoVNA_QT_MacOS.dmg tmp.dmg -mkdir dmg_contents -cp -a vna_qt.app dmg_contents/ - -hdiutil create tmp.dmg -ov -volname "NanoVNA QT GUI" -fs HFS+ -srcfolder dmg_contents -hdiutil convert tmp.dmg -format UDZO -o ../NanoVNA_QT_MacOS.dmg - diff --git a/deploy_windows.sh b/deploy_windows.sh deleted file mode 100755 index fc9a9bf..0000000 --- a/deploy_windows.sh +++ /dev/null @@ -1,41 +0,0 @@ -MXE=~/mxe -export PATH="$MXE/usr/bin:$PATH" -HOST="i686-w64-mingw32.shared" -QMAKE="$HOST-qmake-qt5" - -autoreconf --install -./configure --host "$HOST" CXXFLAGS=-O2 -make -j8 - -pushd libxavna/xavna_mock_ui -"$QMAKE" -make -j8 -popd - -pushd vna_qt -"$QMAKE" -make -j8 -for x in Qt5Charts Qt5Core Qt5Gui Qt5Widgets Qt5Svg; do - cp "$MXE/usr/$HOST/qt5/bin/$x.dll" release/ -done -mkdir -p release/platforms -mkdir -p release/styles -mkdir -p release/imageformats -mkdir -p release/iconengines - -for x in platforms/qwindows styles/qwindowsvistastyle \ - imageformats/qsvg iconengines/qsvgicon; do - cp "$MXE/usr/$HOST/qt5/plugins/$x.dll" release/"$x".dll -done; - -for x in libgcc_s_sjlj-1 libstdc++-6 libpcre2-16-0 zlib1 libharfbuzz-0 \ - libpng16-16 libfreetype-6 libglib-2.0-0 libbz2 libintl-8 libpcre-1\ - libiconv-2 libwinpthread-1 libjasper libjpeg-9 libmng-2 libtiff-5\ - libwebp-7 libwebpdemux-2 liblcms2-2 liblzma-5 libfftw3-3 libzstd; do - cp "$MXE/usr/$HOST/bin/$x.dll" release/ -done -cp ../libxavna/.libs/libxavna-0.dll release/ -cp ../libxavna/xavna_mock_ui/release/xavna_mock_ui.dll release/ -rm release/*.cpp release/*.o release/*.h -rm ../*.zip -zip -r ../vna_qt_windows.zip release diff --git a/env.cfg b/env.cfg deleted file mode 100644 index 4fd64c5..0000000 --- a/env.cfg +++ /dev/null @@ -1,7 +0,0 @@ - -# path to a qt build, e.g. ~/qt/5.10.1/gcc_64 -QT=/usr - -# path to a linuxdeployqt binary, e.g. ~/linuxdeployqt-continuous-x86_64.AppImage -LINUXDEPLOYQT=/persist/linuxdeployqt-continuous-x86_64.AppImage - diff --git a/libxavna/platform_abstraction.C b/libxavna/platform_abstraction.C index cbcf2ec..9663055 100644 --- a/libxavna/platform_abstraction.C +++ b/libxavna/platform_abstraction.C @@ -44,6 +44,8 @@ vector xavna_find_devices() { ret.push_back("/dev/"+name); if(name.find("cu.usbmodem")==0) ret.push_back("/dev/"+name); + if(name.find("nanovna")==0) + ret.push_back("/dev/"+name); } closedir (dir); return ret; diff --git a/libxavna/xavna.C b/libxavna/xavna.C index 01d6e10..89ea329 100644 --- a/libxavna/xavna.C +++ b/libxavna/xavna.C @@ -274,7 +274,7 @@ public: } else { tr = true; fprintf(stderr, "detected T/R vna\n"); - fprintf(stderr, "%lld %lld\n", result[0], result[1]); + fprintf(stderr, "%ld %ld\n", result[0], result[1]); } if(!tr) diff --git a/libxavna/xavna_cpp.C b/libxavna/xavna_cpp.C index 35c4a95..3c36fba 100644 --- a/libxavna/xavna_cpp.C +++ b/libxavna/xavna_cpp.C @@ -99,11 +99,13 @@ namespace xaxaxa { __sync_add_and_fetch(&_measurementCnt, 1); } + /* static inline void swap(VNARawValue& a, VNARawValue& b) { VNARawValue tmp = a; a = b; b = tmp; } + */ void* VNADevice::_mainThread() { if(xavna_is_autosweep(_dev)) { return _runAutoSweep(); @@ -211,7 +213,7 @@ namespace xaxaxa { void* VNADevice::_runAutoSweep() { uint32_t last_measurementCnt = _measurementCnt; int lastFreqIndex = -1; - int measurementEndPoint = -1; + //int measurementEndPoint = -1; double currChunkPoints = 16.; int chunkPoints = (int)currChunkPoints; int nValues = this->nValues; @@ -313,7 +315,7 @@ namespace xaxaxa { if(newChunkPoints < 8) newChunkPoints = 8; currChunkPoints = currChunkPoints * 0.7 + newChunkPoints * 0.3; chunkPoints = (int)currChunkPoints; - fprintf(stderr, "chunkPoints %d\n", chunkPoints); + //fprintf(stderr, "chunkPoints %d\n", chunkPoints); } return NULL; } diff --git a/libxavna/xavna_mock_ui/CMakeLists.txt b/libxavna/xavna_mock_ui/CMakeLists.txt index b169a7a..a93cb90 100644 --- a/libxavna/xavna_mock_ui/CMakeLists.txt +++ b/libxavna/xavna_mock_ui/CMakeLists.txt @@ -1,7 +1,7 @@ add_definitions(-DXAVNA_MOCK_UI_LIBRARY) -include_directories(${Qt5Charts_INCLUDE_DIRS}) +include_directories(${Qt6Charts_INCLUDE_DIRS}) # Instruct CMake to run moc automatically when needed set(CMAKE_AUTOMOC ON) @@ -28,7 +28,7 @@ set_target_properties(xavna_mock_ui PROPERTIES VERSION ${xaVNA_VERSION_STRING} SOVERSION ${xaVNA_VERSION_MAJOR}) -target_link_libraries(xavna_mock_ui Qt5::Core Qt5::Widgets Qt5::Gui xavna) +target_link_libraries(xavna_mock_ui Qt6::Core Qt6::Widgets Qt6::Gui xavna) # Declare destinations install(TARGETS xavna_mock_ui diff --git a/libxavna/xavna_mock_ui/xavna_mock_ui.pro b/libxavna/xavna_mock_ui/xavna_mock_ui.pro index 34bbd18..d04e635 100644 --- a/libxavna/xavna_mock_ui/xavna_mock_ui.pro +++ b/libxavna/xavna_mock_ui/xavna_mock_ui.pro @@ -7,7 +7,7 @@ QT += widgets CONFIG += shared -QMAKE_CXXFLAGS += -Wextra -std=c++11 -I/usr/local/include -I../../include +QMAKE_CXXFLAGS += -Wextra -std=c++17 -I/usr/local/include -I../../include QMAKE_CXXFLAGS += -DEIGEN_DONT_VECTORIZE -DEIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT android: QMAKE_CXXFLAGS += -DANDROID_WORKAROUNDS diff --git a/run b/run deleted file mode 100755 index 8d31fd4..0000000 --- a/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -LIBDIR="$(dirname $0)" -LD_LIBRARY_PATH="$LIBDIR/libxavna/.libs:$LIBDIR/libxavna/xavna_mock_ui" "$@" diff --git a/udev/99-nanovna.rules b/udev/99-nanovna.rules new file mode 100644 index 0000000..f0ea42b --- /dev/null +++ b/udev/99-nanovna.rules @@ -0,0 +1,2 @@ +SUBSYSTEM=="tty", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="0008", ATTRS{serial}=="DEMO", SYMLINK+="nanovna" + diff --git a/ug1101.pdf b/ug1101.pdf deleted file mode 120000 index 3285724..0000000 --- a/ug1101.pdf +++ /dev/null @@ -1 +0,0 @@ -Latest user guide is at https://nanorfe.com/nanovna-v2-user-manual.html \ No newline at end of file diff --git a/vna_diagtool/CMakeLists.txt b/vna_diagtool/CMakeLists.txt new file mode 100644 index 0000000..6e63552 --- /dev/null +++ b/vna_diagtool/CMakeLists.txt @@ -0,0 +1,23 @@ +include_directories(${Qt6Charts_INCLUDE_DIRS}) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) + +set(vna_diagtool_SRCS + main.cpp + mainwindow.C +) + +set(vna_diagtool_FRMS + mainwindow.ui +) + +set(vna_diagtool_HDRS + mainwindow.H +) + +add_executable(vna_diagtool ${vna_diagtool_SRCS} + ${vna_diagtool_FRMS} ${vna_diagtool_HDRS}) + +target_link_libraries(vna_diagtool Qt6::Charts xavna xavna_mock_ui) + diff --git a/vna_diagtool/mainwindow.C b/vna_diagtool/mainwindow.C index ddd42c7..2e1b2bd 100644 --- a/vna_diagtool/mainwindow.C +++ b/vna_diagtool/mainwindow.C @@ -115,9 +115,9 @@ void MainWindow::openDevice(string dev) { } void MainWindow::setCallbacks() { - vna->frequencyCompletedCallback = [this](int freqIndex, VNARawValue val) { + vna->frequencyCompletedCallback = [](int freqIndex, VNARawValue val) { }; - vna->sweepCompletedCallback = [this](const vector&) { + vna->sweepCompletedCallback = [](const vector&) { }; vna->frequencyCompletedCallback2_ = [this](int freqIndex, const vector, 4> >& values) { this->rawValues[freqIndex] = values; diff --git a/vna_diagtool/mainwindow.H b/vna_diagtool/mainwindow.H index f644ae7..71cb39a 100644 --- a/vna_diagtool/mainwindow.H +++ b/vna_diagtool/mainwindow.H @@ -4,16 +4,17 @@ #include #include #include + +#include +#include +#include +#include + namespace Ui { class MainWindow; } -namespace QtCharts { -class QChartView; -class QChart; -class QValueAxis; -class QLineSeries; -} + namespace xaxaxa { class VNADevice; class VNACalibration; @@ -22,7 +23,6 @@ class QTimer; class MarkerSlider; class QTextStream; -using namespace QtCharts; using namespace xaxaxa; using namespace std; diff --git a/vna_gtk/common_types.h b/vna_gtk/common_types.h deleted file mode 100644 index f9b87ce..0000000 --- a/vna_gtk/common_types.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -typedef unsigned long ul; -typedef unsigned int ui; -typedef long long ll; -typedef unsigned long long ull; -typedef uint64_t u64; -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint8_t u8; -typedef int8_t s8; - diff --git a/vna_gtk/configure.ac b/vna_gtk/configure.ac deleted file mode 100644 index 2f11ced..0000000 --- a/vna_gtk/configure.ac +++ /dev/null @@ -1,16 +0,0 @@ -AC_INIT(vna, version-0.1, private0x01@gmail.com) - -if test -z $CXXFLAGS; then - CXXFLAGS='-O2 -std=c++0x -fPIC -fwrapv -fno-delete-null-pointer-checks -funsigned-char -fno-strict-aliasing -Wno-pmf-conversions' -fi - -AC_PROG_CXX -AC_LANG(C++) - -AC_SUBST(EXTRA_LIBRARIES) -AC_SUBST(EXTRA_SOURCES) - -PKG_CHECK_MODULES([GTK], [gtkmm-3.0]) -PKG_CHECK_MODULES([FFTW], [fftw3]) - -AC_OUTPUT(Makefile) diff --git a/vna_gtk/graph_view.H b/vna_gtk/graph_view.H deleted file mode 100644 index cf9df69..0000000 --- a/vna_gtk/graph_view.H +++ /dev/null @@ -1,145 +0,0 @@ -/* - * polarView.C - * - * Copyright 2012 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * - */ -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace Gdk; -using namespace Gtk; -//using namespace ::Cairo; -namespace xaxaxa -{ - class GraphView: public Gtk::DrawingArea - { - public: - vector > lines; - vector colors; // colors must have the same length as lines - double minValue=0.; - double maxValue=1.; - double hgridMin=0.; - double hgridSpacing=10.; - - double w,h; - vector selectedPoints; - - double ptX(int index, int totalPoints) { - return index*(w-1)/(totalPoints-1); - } - double ptY(double val) { - return (maxValue-val)*(h-1)/(maxValue-minValue); - } - void do_draw(const ::Cairo::RefPtr< ::Cairo::Context>& gc) - { - w=get_allocation().get_width(); - h=get_allocation().get_height(); - - gc->set_source_rgb(0.5, 0.5, 0.5); - for(double y=hgridMin; ymove_to(0, ptY(y)); - gc->line_to(w, ptY(y)); - gc->stroke(); - } - - for(int i=0;i<(int)lines.size();i++) { - const vector& points = lines[i]; - if(points.size() == 0) continue; - int pts=(int)points.size(); - - uint32_t color = colors[i]; - gc->set_source_rgb(double((color>>16)&0xFF)/255, - double((color>>8)&0xFF)/255,double((color)&0xFF)/255); - - gc->move_to(ptX(0, pts), ptY(points[0])); - for(int j=1;jmove_to(ptX(j, pts), ptY(points[j])); - continue; - } - gc->line_to(ptX(j, pts), ptY(points[j])); - } - gc->stroke(); - } - - gc->set_source_rgb(0.5, 0.5, 0.5); - for(int i=0;i<(int)selectedPoints.size();i++) - draw_point(gc,ptX(selectedPoints[i], (int)lines[i].size()),ptY(lines[i][selectedPoints[i]]),3); - } - void draw_point(const ::Cairo::RefPtr< ::Cairo::Context>& gc, double x, double y, double size) { - gc->arc(x, y, size, 0.0, 2 * M_PI); - gc->stroke(); - } - virtual bool on_motion_notify_event(GdkEventMotion* event) - { - Gtk::DrawingArea::on_motion_notify_event(event); - - return false; - } - virtual bool on_button_press_event(GdkEventButton* event) - { - Gtk::DrawingArea::on_button_press_event(event); - return false; - } - virtual bool on_button_release_event(GdkEventButton* event) - { - Gtk::DrawingArea::on_button_release_event(event); - return false; - } - void do_draw(GdkEventExpose* evt=NULL) - { - Glib::RefPtr window = get_window(); - if(window) - { - ::Cairo::RefPtr< ::Cairo::Context> ctx = window->create_cairo_context(); - if(evt) - { - ctx->rectangle(evt->area.x, evt->area.y, evt->area.width, evt->area.height); - ctx->clip(); - } - do_draw(ctx); - } - } - virtual bool on_expose_event(GdkEventExpose* evt) - { - printf("on_expose_event\n"); - do_draw(evt); - return false; - } - virtual bool on_draw(const ::Cairo::RefPtr<::Cairo::Context>& cr) { - do_draw(cr); - return false; - } - GraphView(): Gtk::DrawingArea() - { - set_app_paintable(true); - set_double_buffered(true); - set_redraw_on_allocate(true); - set_events(get_events()|EXPOSURE_MASK|POINTER_MOTION_MASK|BUTTON_MOTION_MASK|BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK); - } - }; -} - diff --git a/vna_gtk/polar_view.H b/vna_gtk/polar_view.H deleted file mode 100644 index c700195..0000000 --- a/vna_gtk/polar_view.H +++ /dev/null @@ -1,202 +0,0 @@ -/* - * polarView.C - * - * Copyright 2012 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * - */ -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace Gdk; -using namespace Gtk; -//using namespace ::Cairo; -namespace xaxaxa -{ - class PolarView: public Gtk::DrawingArea - { - public: - vector > points; - double scale=1.; - double margin=10; // pixels - - double w,h; - double r,centerX,centerY; - int selectedPoint=0; - bool persistence = false; - //ARGB - uint32_t cursorColor = 0xffffff00; - - ::Cairo::RefPtr< ::Cairo::ImageSurface > img; - - - double ptX(double x) { - return centerX+x/scale*r; - } - double ptY(double y) { - return centerY-y/scale*r; - } - void draw_grid(const ::Cairo::RefPtr< ::Cairo::Context>& gc) { - w=get_allocation().get_width(); - h=get_allocation().get_height(); - - // calculate position and radius of smith chart - centerX=w/2; - centerY=h/2; - r=w/2; - if(h/2set_line_width(2.0); - gc->arc(centerX, centerY, r, 0.0, 2 * M_PI); - gc->stroke(); - - gc->set_line_width(1.0); - gc->set_source_rgb(.2,.2,.2); - - // draw constant resistance circles - for(int i=1;i<4;i++) { - gc->arc(centerX+r-r/4*i, centerY, r/4*i, 0.0, 2 * M_PI); - gc->stroke(); - } - - // draw constant reactance circles - gc->save(); - gc->arc(centerX, centerY, r, 0.0, 2 * M_PI); - gc->clip(); - int n=1; - for(int i=1;i<4;i++) { - gc->arc(centerX+r, centerY+r/2*n, r/2*n, 0.0, 2 * M_PI); - gc->stroke(); - gc->arc(centerX+r, centerY-r/2*n, r/2*n, 0.0, 2 * M_PI); - gc->stroke(); - n*=2; - } - gc->restore(); - - // draw center line - gc->move_to(centerX-r,centerY); - gc->line_to(centerX+r,centerY); - gc->stroke(); - } - void draw_chart(const ::Cairo::RefPtr< ::Cairo::Context>& gc) - { - if(points.size()==0) return; - for(int i=1;i<(int)points.size();i++) { - if(isnan(points[i-1].real()) || isnan(points[i].real())) continue; - gc->move_to(ptX(points[i-1].real()), ptY(points[i-1].imag())); - gc->line_to(ptX(points[i].real()), ptY(points[i].imag())); - gc->stroke(); - } - } - void do_draw(const ::Cairo::RefPtr< ::Cairo::Context>& gc) { - draw_grid(gc); - if(persistence) { - if(img) { - gc->set_source(img, 0, 0); - gc->paint(); - } - } else { - gc->set_line_width(2.0); - gc->set_source_rgb(0,0,1); - draw_chart(gc); - } - gc->set_line_width(2.0); - uint32_t c = cursorColor; - gc->set_source_rgba(double((c>>16)&0xFF)/255, double((c>>8)&0xFF)/255, - double((c)&0xFF)/255, double((c>>24)&0xFF)/255); - draw_point(gc,points[selectedPoint].real(),points[selectedPoint].imag(),3); - } - void draw_point(const ::Cairo::RefPtr< ::Cairo::Context>& gc, double re, double im, double size) { - double pointX=centerX+re/scale*r; - double pointY=centerY-im/scale*r; - gc->arc(pointX, pointY, size, 0.0, 2 * M_PI); - gc->stroke(); - } - virtual bool on_motion_notify_event(GdkEventMotion* event) - { - Gtk::DrawingArea::on_motion_notify_event(event); - - return false; - } - virtual bool on_button_press_event(GdkEventButton* event) - { - Gtk::DrawingArea::on_button_press_event(event); - return false; - } - virtual bool on_button_release_event(GdkEventButton* event) - { - Gtk::DrawingArea::on_button_release_event(event); - return false; - } - void do_draw(GdkEventExpose* evt=NULL) - { - Glib::RefPtr window = get_window(); - if(window) - { - ::Cairo::RefPtr< ::Cairo::Context> ctx = window->create_cairo_context(); - if(evt) - { - ctx->rectangle(evt->area.x, evt->area.y, evt->area.width, evt->area.height); - ctx->clip(); - } - do_draw(ctx); - } - } - void clearPersistence() { - int w=(int)get_allocation().get_width(); - int h=(int)get_allocation().get_height(); - img=::Cairo::ImageSurface::create(::Cairo::FORMAT_ARGB32,w,h); - } - void commitTrace() { - if(!persistence) return; - int w=(int)get_allocation().get_width(); - int h=(int)get_allocation().get_height(); - if(!img || img->get_width()!=w || img->get_height()!=h) - clearPersistence(); - ::Cairo::RefPtr< ::Cairo::Context > imgCtx = ::Cairo::Context::create(img); - imgCtx->set_line_width(2.0); - imgCtx->set_source_rgba(0,0,1, 1); - draw_chart(imgCtx); - } - virtual bool on_expose_event(GdkEventExpose* evt) - { - printf("on_expose_event\n"); - do_draw(evt); - return false; - } - virtual bool on_draw(const ::Cairo::RefPtr<::Cairo::Context>& cr) { - do_draw(cr); - return false; - } - PolarView(): Gtk::DrawingArea() - { - set_app_paintable(true); - set_double_buffered(true); - set_redraw_on_allocate(true); - set_events(get_events()|EXPOSURE_MASK|POINTER_MOTION_MASK|BUTTON_MOTION_MASK|BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK); - } - }; -} - diff --git a/vna_gtk/vna.glade b/vna_gtk/vna.glade deleted file mode 100644 index 63dbacc..0000000 --- a/vna_gtk/vna.glade +++ /dev/null @@ -1,1053 +0,0 @@ - - - - - - False - True - dialog - - - False - vertical - 2 - - - False - end - - - gtk-ok - True - True - True - True - True - True - - - True - True - 0 - - - - - gtk-cancel - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - 10 - 10 - 10 - True - 5 - 15 - True - - - True - False - Start frequency - - - 0 - 0 - - - - - True - False - Frequency step - - - 0 - 1 - - - - - True - False - Span - - - 0 - 2 - - - - - True - False - End frequency - - - 0 - 3 - - - - - True - False - 1234 - - - 1 - 3 - - - - - True - True - True - True - True - 0.01 - number - - - 1 - 0 - - - - - True - True - True - True - 0.01 - number - - - 1 - 1 - - - - - True - True - True - True - 1 - digits - - - 1 - 2 - - - - - True - False - MHz - - - 2 - 0 - - - - - True - False - MHz - - - 2 - 1 - - - - - True - False - points - - - 2 - 2 - - - - - True - False - MHz - - - 2 - 3 - - - - - True - False - 0 - - - - - True - False - True - - - False - True - 2 - - - - - - button1 - button2 - - - - False - 450 - 300 - - - True - False - - - True - False - start - 2 - 8 - False - - - True - False - False - 4 - 4 - True - - - True - False - 10 - 6 - 6 - Calibration - - - 0 - 0 - - - - - Set open circuit - True - True - True - - - 2 - 0 - - - - - Set short circuit - True - True - True - - - 1 - 0 - - - - - Set load - True - True - True - - - 1 - 1 - - - - - Apply - True - True - True - - - 3 - 0 - - - - - Clear - True - True - True - - - 3 - 1 - - - - - Set through - True - True - True - - - 2 - 1 - - - - - Load... - True - True - True - - - 4 - 0 - - - - - Save... - True - True - True - - - 4 - 1 - - - - - - - - False - True - 10 - 0 - - - - - True - False - 4 - 4 - True - - - Capture S*1 - True - True - True - - - 1 - 0 - - - - - Export s1p - True - True - True - - - 0 - 1 - - - - - Capture S*2 - True - True - True - - - 1 - 1 - - - - - True - False - 6 - 6 - S-param - - - 0 - 0 - - - - - Export s2p - True - True - True - - - 2 - 1 - - - - - - - - False - True - 10 - 1 - - - - - True - False - True - - - True - False - 8 - 8 - 6 - 6 - Options - - - 0 - 0 - - - - - Persistence - True - True - True - - - 1 - 0 - - - - - Time to fault - True - True - True - - - 1 - 1 - - - - - - - - False - True - 2 - - - - - True - False - True - - - True - False - 8 - 8 - 6 - 6 - Freq - - - 0 - 0 - - - - - 500 MHz - -1500 MHz - True - True - True - True - - - 1 - 0 - 2 - - - - - - - - False - True - 3 - - - - - 0 - 0 - 3 - - - - - True - False - - - 1000.00 MHz - 110 - True - True - True - True - - - False - True - 0 - - - - - 70 - True - False - Reflection coefficient - 6 - 6 - -10 dB - - - - - - - False - True - 1 - - - - - 70 - True - False - Reflection coefficient phase - 6 - 6 - 128 ° - - - - - - - False - True - 2 - - - - - True - True - on - on - 1 - False - left - - - True - True - 3 - - - - - 70 - True - False - Forward transmission coefficient - 6 - 6 - 15 dB - - - - - - - False - True - 4 - - - - - 70 - True - False - Forward transmission coefficient phase - 6 - 6 - 120° - - - - - - - False - True - 5 - - - - - 0 - 2 - 3 - - - - - True - False - True - True - - - - - - 2 - 1 - - - - - True - False - True - True - - - - - - 1 - 1 - - - - - 106 - True - False - vertical - - - True - False - 5 - 5 - 6 - 6 - Impedance - - - False - True - 0 - - - - - True - False - 6 - 6 - - - False - True - 1 - - - - - True - False - 5 - 5 - 6 - 6 - Admittance - - - False - True - 2 - - - - - True - False - 6 - 6 - - - False - True - 3 - - - - - True - False - 6 - 6 - Series -Admittance - - - False - True - 4 - - - - - True - False - 6 - 6 - - - False - True - 5 - - - - - True - False - 5 - 5 - 6 - 6 - Parallel -Impedance - - - False - True - 6 - - - - - True - False - 6 - 6 - - - False - True - 7 - - - - - True - False - 6 - 6 - Series -Equivalent - - - False - True - 8 - - - - - True - False - 6 - 6 - - - False - True - 9 - - - - - True - False - 6 - 6 - Parallel -Equivalent - - - False - True - 10 - - - - - True - False - 6 - 6 - - - False - True - 11 - - - - - 0 - 1 - - - - - - - False - 0.5 - - - True - False - vertical - - - Normalize - True - True - True - - - False - True - 0 - - - - - Reset - True - True - True - - - False - True - 1 - - - - - - - - - - False - 550 - 350 - - - True - False - vertical - - - True - False - True - True - - - - - - False - True - 0 - - - - - True - False - - - 1 ns - 100 - True - True - True - True - - - False - True - 0 - - - - - 70 - True - False - Reflection coefficient - 6 - 6 - -10 dB - - - - - - - False - True - 1 - - - - - True - True - on - on - 1 - False - left - - - True - True - 2 - - - - - 70 - True - False - Forward transmission coefficient - 6 - 6 - 15 dB - - - - - - - False - True - 3 - - - - - False - True - 1 - - - - - - diff --git a/vna_gtk/vna_main.C b/vna_gtk/vna_main.C deleted file mode 100644 index 09415f0..0000000 --- a/vna_gtk/vna_main.C +++ /dev/null @@ -1,421 +0,0 @@ - -#include "polar_view.H" -#include "graph_view.H" -#include -#include -#include -#include "vna_ui_core.H" - -//#include "adf4350_board.H" - -using namespace std; -//using namespace adf4350Board; - -#define GETWIDGET(x) builder->get_widget(TOKEN_TO_STRING(x), x) - - - - -// globals - -// to be declared in the generated vna.glade.c file -extern unsigned char vna_glade[]; -extern unsigned int vna_glade_len; - - -Glib::RefPtr builder; -xaxaxa::PolarView* polarView=NULL; -xaxaxa::GraphView* graphView=NULL; -xaxaxa::GraphView* timeGraphView=NULL; -pthread_t refreshThread_; - - -bool timeDomain = false; -bool showCursor = true; - -void alert(string msg) { - Gtk::Window* window1; - GETWIDGET(window1); - Gtk::MessageDialog dialog(*window1, msg, - false /* use_markup */, Gtk::MESSAGE_WARNING, - Gtk::BUTTONS_OK); - dialog.run(); -} - -void updateGraph(int i, complex2 values) { - complex refl = values[reflIndex], thru = values[thruIndex]; - polarView->points[i]=refl; - graphView->lines[0][i] = arg(refl); - graphView->lines[1][i] = arg(thru); - graphView->lines[2][i] = dB(norm(refl)); - graphView->lines[3][i] = dB(norm(thru)); -} -void updateTimeGraph(int i, complex2 values) { - timeGraphView->lines[0][i] = dB(norm(values[reflIndex])); - timeGraphView->lines[1][i] = dB(norm(values[thruIndex])); -} -void sweepCompleted() { - Glib::signal_idle().connect([]() { - polarView->commitTrace(); - return false; - }); -} - -void resizeVectors2() { - Gtk::Scale *s_freq,*s_time; - GETWIDGET(s_freq); GETWIDGET(s_time); - s_freq->set_range(0, nPoints-1); - s_time->set_range(0, timePoints()-1); - polarView->points.resize(nPoints); - for(int i=0;i<4;i++) - graphView->lines[i].resize(nPoints); - for(int i=0;i<2;i++) - timeGraphView->lines[i].resize(timePoints()); -} - -void updateFreqButton() { - Gtk::Button *b_freq; - GETWIDGET(b_freq); - b_freq->set_label(ssprintf(31, "%.2f MHz -\n%.2f MHz", freqAt(0), freqAt(nPoints-1))); -} - - -void measureCalReference(int index) { - Gtk::Window *window1; - GETWIDGET(window1); - - for(int i=0;ipoints[i] = NAN; - for(int i=0;ilines[3][i] = NAN; - window1->set_sensitive(false); - takeMeasurement([window1,index](vector values) { - calibrationReferences[index] = values; - - Glib::signal_idle().connect([window1]() { - window1->set_sensitive(true); - return false; - }); - }); -} - - -void addButtonHandlers() { - // controls - Gtk::Window *window1, *window3; - Gtk::Button *b_oc, *b_sc, *b_t, *b_thru, *b_apply, *b_clear, *b_load, *b_save, *b_freq; - Gtk::ToggleButton *c_persistence, *c_freq, *c_ttf; - - // get controls - GETWIDGET(window1); GETWIDGET(window3); - GETWIDGET(b_oc); GETWIDGET(b_sc); GETWIDGET(b_t); GETWIDGET(b_thru); - GETWIDGET(b_apply); GETWIDGET(b_clear); - GETWIDGET(b_load); GETWIDGET(b_save); - GETWIDGET(b_freq); GETWIDGET(c_persistence); - GETWIDGET(c_freq); GETWIDGET(c_ttf); - b_oc->signal_clicked().connect([]() { - measureCalReference(CAL_OPEN); - }); - b_sc->signal_clicked().connect([window1]() { - measureCalReference(CAL_SHORT); - }); - b_t->signal_clicked().connect([window1]() { - measureCalReference(CAL_LOAD); - }); - b_thru->signal_clicked().connect([window1]() { - measureCalReference(CAL_THRU); - }); - b_apply->signal_clicked().connect([]() { - applySOLT(); - }); - b_clear->signal_clicked().connect([]() { - clearCalibration(); - }); - - b_save->signal_clicked().connect([window1]() { - Gtk::FileChooserDialog d(*window1, "Save calibration file...", FILE_CHOOSER_ACTION_SAVE); - Gtk::Button* b = d.add_button(Stock::SAVE, RESPONSE_OK); - if(d.run() == RESPONSE_OK) - { - string data=saveCalibration(); - string etag; - d.get_file()->replace_contents(data, "", etag); - } - }); - b_load->signal_clicked().connect([window1]() { - Gtk::FileChooserDialog d(*window1, "Open calibration file...", FILE_CHOOSER_ACTION_OPEN); - Gtk::Button* b = d.add_button(Stock::OPEN, RESPONSE_OK); - if(d.run() == RESPONSE_OK) - { - char* fileData = NULL; - gsize sz = 0; - d.get_file()->load_contents(fileData, sz); - loadCalibration(fileData, sz); - free(fileData); - } - }); - b_freq->signal_clicked().connect([window1]() { - Gtk::Dialog* dialog_freq; - Gtk::Entry *d_t_start, *d_t_step, *d_t_span; - GETWIDGET(dialog_freq); - GETWIDGET(d_t_start); GETWIDGET(d_t_step); GETWIDGET(d_t_span); - - d_t_start->set_text(ssprintf(20, "%.2f", double(startFreq)*freqMultiplier)); - d_t_step->set_text(ssprintf(20, "%.2f", double(freqStep)*freqMultiplier)); - d_t_span->set_text(ssprintf(20, "%d", nPoints)); - - dialog_freq->set_transient_for(*window1); - if(dialog_freq->run() == RESPONSE_OK) { - refreshThreadShouldExit = true; - pthread_join(refreshThread_, NULL); - refreshThreadShouldExit = false; - - Gtk::Entry *d_t_start, *d_t_step, *d_t_span; - GETWIDGET(d_t_start); GETWIDGET(d_t_step); GETWIDGET(d_t_span); - auto start = d_t_start->get_text(); - auto step = d_t_step->get_text(); - auto span = d_t_span->get_text(); - startFreq = atof(start.c_str())/freqMultiplier; - freqStep = atof(step.c_str())/freqMultiplier; - - resizeVectors(atoi(span.c_str())); - resizeVectors2(); - updateFreqButton(); - clearCalibration(); - - if(pthread_create(&refreshThread_, NULL, &refreshThread,NULL)<0) { - perror("pthread_create"); - exit(1); - } - } - dialog_freq->hide(); - }); - c_persistence->signal_toggled().connect([c_persistence]() { - polarView->persistence = c_persistence->get_active(); - if(polarView->persistence) - polarView->clearPersistence(); - }); - c_freq->signal_toggled().connect([c_freq]() { - showCursor = c_freq->get_active(); - if(showCursor) { - polarView->cursorColor = 0xffffff00; - } else { - polarView->cursorColor = 0x00000000; - } - polarView->queue_draw(); - }); - c_ttf->signal_toggled().connect([c_ttf, window3]() { - if(c_ttf->get_active()) - window3->show(); - else window3->hide(); - }); -} - -string GetDirFromPath(const string path) -{ - int i = path.rfind("/"); - if (i < 0) return string(); - return path.substr(0, i + 1); -} -string GetProgramPath() -{ - char buf[256]; - int i = readlink("/proc/self/exe", buf, sizeof(buf)); - if (i < 0) { - perror("readlink"); - return ""; - } - return string(buf, i); -} - - -void updateLabels() { - Gtk::Scale *s_freq; - Gtk::Label *l_freq,*l_refl,*l_refl_phase,*l_through,*l_through_phase; - Gtk::Label *l_impedance, *l_admittance, *l_s_admittance, *l_p_impedance, *l_series, *l_parallel; - Gtk::ToggleButton *c_freq; - GETWIDGET(s_freq); GETWIDGET(c_freq); GETWIDGET(l_refl); GETWIDGET(l_refl_phase); - GETWIDGET(l_through); GETWIDGET(l_through_phase); - GETWIDGET(l_impedance); GETWIDGET(l_admittance); GETWIDGET(l_s_admittance); - GETWIDGET(l_p_impedance); GETWIDGET(l_series); GETWIDGET(l_parallel); - - // frequency label - int freqIndex=(int)s_freq->get_value(); - double freq=freqAt(freqIndex); - c_freq->set_label(ssprintf(20, "%.2f MHz", freq)); - - - complex reflCoeff = polarView->points[freqIndex]; - l_refl->set_text(ssprintf(20, "%.1f dB", dB(norm(reflCoeff)))); - l_refl_phase->set_text(ssprintf(20, "%.1f °", arg(reflCoeff)*180/M_PI)); - - l_through->set_text(ssprintf(20, "%.1f dB", graphView->lines[3][freqIndex])); - l_through_phase->set_text(ssprintf(20, "%.1f °", graphView->lines[1][freqIndex]*180/M_PI)); - - if(!use_cal) { - l_impedance->set_text(""); - l_admittance->set_text(""); - l_s_admittance->set_text(""); - l_p_impedance->set_text(""); - l_series->set_text(""); - l_parallel->set_text(""); - return; - } - - // impedance display panel (left side) - - complex Z = -Z0*(reflCoeff+1.)/(reflCoeff-1.); - complex Y = -(reflCoeff-1.)/(Z0*(reflCoeff+1.)); - - l_impedance->set_text(ssprintf(127, " %.2f\n%s j%.2f", Z.real(), Z.imag()>=0 ? "+" : "-", fabs(Z.imag()))); - l_admittance->set_text(ssprintf(127, " %.4f\n%s j%.4f", Y.real(), Y.imag()>=0 ? "+" : "-", fabs(Y.imag()))); - l_s_admittance->set_text(ssprintf(127, " %.4f\n%s j%.4f", 1./Z.real(), Z.imag()>=0 ? "+" : "-", fabs(1./Z.imag()))); - l_p_impedance->set_text(ssprintf(127, " %.2f\n|| j%.2f", 1./Y.real(), 1./Y.imag())); - - double value = capacitance_inductance(freq*1e6, Z.imag()); - l_series->set_text(ssprintf(127, "%.2f Ω\n%.2f %s%s", Z.real(), fabs(si_scale(value)), si_unit(value), value>0?"H":"F")); - - value = capacitance_inductance_Y(freq*1e6, Y.imag()); - l_parallel->set_text(ssprintf(127, "%.2f Ω\n%.2f %s%s", 1./Y.real(), fabs(si_scale(value)), si_unit(value), value>0?"H":"F")); -} -void updateLabels_ttf() { - Gtk::Scale *s_time; - Gtk::ToggleButton *c_time; - Gtk::Label *l_refl1,*l_through1; - GETWIDGET(s_time); GETWIDGET(c_time); - GETWIDGET(l_refl1); GETWIDGET(l_through1); - - // time label - int timeIndex=(int)s_time->get_value(); - double t=timeAt(timeIndex); - c_time->set_label(ssprintf(20, "%.2f ns", t)); - - // reflection and through labels - double refl = timeGraphView->lines[0][timeIndex]; - double through = timeGraphView->lines[1][timeIndex]; - l_refl1->set_text(ssprintf(20, "%.1f dB", refl)); - l_through1->set_text(ssprintf(20, "%.1f dB", through)); - -} - - - -int main(int argc, char** argv) { - if(argc<2) { - fprintf(stderr,"usage: %s /PATH/TO/TTY\n",argv[0]); - return 1; - } - xavna_dev = xavna_open(argv[1]); - if(xavna_dev == NULL) { - perror("xavna_open"); - return 1; - } - - - // set up UI - int argc1=1; - auto app = Gtk::Application::create(argc1, argv, "org.gtkmm.example"); - string binDir=GetDirFromPath(GetProgramPath()); - if(chdir(binDir.c_str())<0) - perror("chdir"); - - builder = Gtk::Builder::create_from_string(string((char*)vna_glade, vna_glade_len)); - - // controls - Gtk::Window* window1; - Gtk::Viewport *vp_main, *vp_graph, *vp_ttf; - Gtk::Scale *s_freq, *s_time; - - // get controls - GETWIDGET(window1); GETWIDGET(vp_main); GETWIDGET(vp_graph); GETWIDGET(vp_ttf); GETWIDGET(s_freq); GETWIDGET(s_time); - addButtonHandlers(); - - - // polar view - polarView = new xaxaxa::PolarView(); - vp_main->add(*polarView); - polarView->show(); - - // graph view - graphView = new xaxaxa::GraphView(); - graphView->minValue = -80; - graphView->maxValue = 50; - graphView->hgridMin = -80; - graphView->hgridSpacing = 10; - graphView->selectedPoints = {0, 0, 0, 0}; - graphView->colors = {0x00aadd, 0xff8833, 0x0000ff, 0xff0000}; - graphView->lines.resize(4); - vp_graph->add(*graphView); - graphView->show(); - - // time graph view - timeGraphView = new xaxaxa::GraphView(); - timeGraphView->minValue = -60; - timeGraphView->maxValue = 0; - timeGraphView->hgridMin = -60; - timeGraphView->hgridSpacing = 10; - timeGraphView->selectedPoints = {0, 0}; - timeGraphView->colors = {0x0000ff, 0xff0000}; - timeGraphView->lines.resize(2); - vp_ttf->add(*timeGraphView); - timeGraphView->show(); - - resizeVectors(nPoints); - resizeVectors2(); - - // controls - s_freq->set_value(0); - s_time->set_value(0); - s_freq->set_increments(1, 10); - s_time->set_increments(1, 10); - updateLabels(); - updateLabels_ttf(); - s_freq->signal_value_changed().connect([s_freq](){ - polarView->selectedPoint = (int)s_freq->get_value(); - graphView->selectedPoints[0] = graphView->selectedPoints[1] - = graphView->selectedPoints[2] = graphView->selectedPoints[3] = (int)s_freq->get_value(); - updateLabels(); - polarView->queue_draw(); - graphView->queue_draw(); - }); - s_time->signal_value_changed().connect([s_time](){ - timeGraphView->selectedPoints[0] = timeGraphView->selectedPoints[1] = (int)s_time->get_value(); - updateLabels_ttf(); - timeGraphView->queue_draw(); - }); - - // frequency dialog - Gtk::Dialog* dialog_freq; - Gtk::Entry *d_t_start, *d_t_step, *d_t_span; - Gtk::Label *d_l_end; - GETWIDGET(dialog_freq); GETWIDGET(d_l_end); - GETWIDGET(d_t_start); GETWIDGET(d_t_step); GETWIDGET(d_t_span); - - auto func = [d_t_start, d_t_step, d_t_span, d_l_end](){ - auto start = d_t_start->get_text(); - auto step = d_t_step->get_text(); - auto span = d_t_span->get_text(); - double endFreq = atof(start.c_str()) + atof(step.c_str()) * (atoi(span.c_str()) - 1); - d_l_end->set_text(ssprintf(20, "%.2f", endFreq)); - }; - d_t_start->signal_changed().connect(func); - d_t_step->signal_changed().connect(func); - d_t_span->signal_changed().connect(func); - updateFreqButton(); - - // periodic refresh - sigc::connection conn = Glib::signal_timeout().connect([](){ - updateLabels(); - updateLabels_ttf(); - polarView->queue_draw(); - graphView->queue_draw(); - timeGraphView->queue_draw(); - return true; - }, 200); - - - if(pthread_create(&refreshThread_, NULL, &refreshThread,NULL)<0) { - perror("pthread_create"); - return 1; - } - - return app->run(*window1); -} diff --git a/vna_gtk/vna_ui_core.C b/vna_gtk/vna_ui_core.C deleted file mode 100644 index 652ea03..0000000 --- a/vna_gtk/vna_ui_core.C +++ /dev/null @@ -1,281 +0,0 @@ -#include -#include -#include -#include -#include "common_types.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "vna_ui_core.H" - -using namespace std; -//using namespace adf4350Board; - - - -#define FFTWFUNC(x) fftw_ ## x - - -// settings -int nPoints=100; -int startFreq=137500; -int freqStep=25000; -int attenuation=20; - -// currently loaded calibration references -array, 4> calibrationReferences; - -bool newBoard = true; - -int nValues=100; //number of data points to integrate over -int nValuesExtended=nValues; - - - -void* xavna_dev=NULL; - -double Z0=50.; -bool use_cal=false; -bool refreshThreadShouldExit=false; - -// currently active calibration coefficients, calculated from measured calibration references -vector,3> > cal_coeffs; // the 3 calibration terms -vector > cal_thru; // the raw value for the thru reference -vector > cal_thru_leak; // leakage from port 1 forward to 2 -vector > cal_thru_leak_r; // leakage from port 1 reflected to 2 - - - -extern "C" int xavna_read_values_raw(void* dev, double* out_values, int n_samples); - - - - - -double avgRe=0,avgIm=0; - - -// increment this variable to request the thread take an extended measurement (for when more accuracy is required) -volatile int requestedMeasurements=0; -// function to be called from the main thread when a requested measurement is complete -function)>* volatile measurementCallback; - -void* refreshThread(void* v) { - int requestedMeasurementsPrev=requestedMeasurements; - - complex* reflArray = (complex*)FFTWFUNC(malloc)(timePoints()*sizeof(complex)); - complex* thruArray = (complex*)FFTWFUNC(malloc)(timePoints()*sizeof(complex)); - //double* reflTD = (double*)FFTWFUNC(malloc)(timePoints()*2*sizeof(double)); - //double* thruTD = (double*)FFTWFUNC(malloc)(timePoints()*2*sizeof(double)); - complex* reflTD = (complex*)FFTWFUNC(malloc)(timePoints()*sizeof(complex)); - complex* thruTD = (complex*)FFTWFUNC(malloc)(timePoints()*sizeof(complex)); - - FFTWFUNC(plan) p1, p2; - p1 = fftw_plan_dft_1d(timePoints(), (fftw_complex*)reflArray, (fftw_complex*)reflTD, FFTW_BACKWARD, FFTW_ESTIMATE); - p2 = fftw_plan_dft_1d(timePoints(), (fftw_complex*)thruArray, (fftw_complex*)thruTD, FFTW_BACKWARD, FFTW_ESTIMATE); - //p1 = fftw_plan_dft_c2r_1d(timePoints()*2, (fftw_complex*)reflArray, reflTD, 0); - //p2 = fftw_plan_dft_c2r_1d(timePoints()*2, (fftw_complex*)thruArray, thruTD, 0); - - complex2 values; - while(true) { - memset(reflArray, 0, timePoints()*sizeof(complex)); - memset(thruArray, 0, timePoints()*sizeof(complex)); - - for(int i=0;i reflValue=values[reflIndex]; - complex thruValue=values[thruIndex]; - printf("%7.2f %20lf %10lf %20lf %10lf\n",freq_kHz/1000., - abs(reflValue),arg(reflValue),abs(thruValue),arg(thruValue)); - auto refl = reflValue; - auto thru = thruValue; - if(use_cal) { - //auto refl=(cal_X[i]*cal_Y[i]-value*cal_Z[i])/(value-cal_X[i]); - //refl=(cal_X[i]*cal_Y[i]-reflValue)/(reflValue*cal_Z[i]-cal_X[i]); - refl = SOL_compute_reflection(cal_coeffs[i], reflValue); - - thru = thruValue - (cal_thru_leak[i] + reflValue*cal_thru_leak_r[i]); - - auto refThru = cal_thru[i] - (cal_thru_leak[i] + reflValue*cal_thru_leak_r[i]); - - thru /= refThru; - - //thru=(thruValue-cal_thru_leak[i])/(cal_thru[i]-cal_thru_leak[i]); - } - - reflArray[i] = refl * gauss(double(i)/nPoints, 0, 0.7); - thruArray[i] = thru * gauss(double(i)/nPoints, 0, 0.7); - - updateGraph(i, {refl, thru}); - - //if(requestedMeasurements>requestedMeasurementsPrev) - // if(i<(nPoints-50)) i = nPoints-50; - if(refreshThreadShouldExit) return NULL; - } - - // compute time domain values - FFTWFUNC(execute)(p1); - FFTWFUNC(execute)(p2); - int tPoints = timePoints(); - double scale=1./nPoints; - for(int i=0;irequestedMeasurementsPrev) { - requestedMeasurementsPrev = requestedMeasurements; - __sync_synchronize(); - - printf("taking extended measurement...\n"); - vector results; - - - for(int i=0;i)> cb) { - function)>* cbNew = new function)>(); - *cbNew = cb; - __sync_synchronize(); - measurementCallback = cbNew; - __sync_synchronize(); - __sync_add_and_fetch(&requestedMeasurements, 1); -} -vector > extract(vector in, int i) { - vector > tmp; - for(int j=0;j=(sizeof(uint32_t)+calSize)) { - uint32_t calType = *(uint32_t*)data; - if(calType >= nCal) { - alert(ssprintf(128, "calibration file has an entry of calType %u which is not recognized", calType)); - return false; - } - calibrationReferences[calType].resize(nPoints); - memcpy(calibrationReferences[calType].data(), data+4, calSize); - data += (4 + calSize); - size -= (4 + calSize); - } - - applySOLT(); - return true; -} - - -void resizeVectors(int n) { - nPoints = n; - - for(int i=0;i >(nPoints, 1); - cal_thru_leak = vector >(nPoints, 0); - cal_thru_leak_r = vector >(nPoints, 0); - cal_coeffs.resize(nPoints); -} - diff --git a/vna_gtk/vna_ui_core.H b/vna_gtk/vna_ui_core.H deleted file mode 100644 index 91a3c85..0000000 --- a/vna_gtk/vna_ui_core.H +++ /dev/null @@ -1,136 +0,0 @@ -#define TOKEN_TO_STRING(TOK) # TOK -using namespace std; - -typedef array,2> complex2; -static const int reflIndex=0, thruIndex=1; - - -// to be implemented by ui code -// pop up an info dialog with msg -void alert(string msg); -// update the ith point on the graph -void updateGraph(int i, complex2 values); -// update the ith point on the time domain graph -void updateTimeGraph(int i, complex2 values); -// called whenever a full frequency sweep is done -void sweepCompleted(); - - -// exported functions -extern double Z0; - -extern void* xavna_dev; -extern int nPoints; // how many frequency points; do not modify; call resizeVectors() -extern int startFreq; // start frequency in kHz -extern int freqStep; // frequency step in kHz -extern bool use_cal; // whether calibration is in effect; do not modify -extern bool refreshThreadShouldExit; // set to true to cause refreshThread to exit - - -static const int timeScale=3; -static const int nCal = 4; -static const double freqMultiplier=0.001; - -// indexed by CAL_* constants -extern array, 4> calibrationReferences; - -// you must call this function from a secondary thread (non UI thread) -// to perform continuous refresh -// make sure xavna_dev is initialized before calling -void* refreshThread(void* v); -// take a measurement over the complete frequency range -void takeMeasurement(function)> cb); -// using 4 measurements (short, open, load, thru) apply calibration to the graph -void applySOLT(); -// disable calibration -void clearCalibration(); -string saveCalibration(); -bool loadCalibration(char* data, int size); -// change nPoints to n; do not call when refreshThread is running -void resizeVectors(int n); - -vector > extract(vector in, int i); - - -enum { - CAL_SHORT=0, - CAL_OPEN, - CAL_LOAD, - CAL_THRU -}; - - - -// convenience functions - -// freq is in Hz, Z is in ohms -inline double capacitance_inductance(double freq, double Z) { - if(Z>0) return Z/(2*M_PI*freq); - return 1./(2*Z*M_PI*freq); -} -// freq is in Hz, Y is in mhos -inline double capacitance_inductance_Y(double freq, double Y) { - if(Y<0) return -1./(2*Y*M_PI*freq); - return -Y/(2*M_PI*freq); -} -inline double si_scale(double val) { - double val2 = fabs(val); - if(val2>1e12) return val*1e-12; - if(val2>1e9) return val*1e-9; - if(val2>1e6) return val*1e-6; - if(val2>1e3) return val*1e-3; - if(val2>1e0) return val; - if(val2>1e-3) return val*1e3; - if(val2>1e-6) return val*1e6; - if(val2>1e-9) return val*1e9; - if(val2>1e-12) return val*1e12; - return val*1e15; -} -inline const char* si_unit(double val) { - val = fabs(val); - if(val>1e12) return "T"; - if(val>1e9) return "G"; - if(val>1e6) return "M"; - if(val>1e3) return "k"; - if(val>1e0) return ""; - if(val>1e-3) return "m"; - if(val>1e-6) return "u"; - if(val>1e-9) return "n"; - if(val>1e-12) return "p"; - return "f"; -} -inline string ssprintf(int maxLen, const char* fmt, ...) { - string tmp(maxLen, '\0'); - va_list args; - va_start(args, fmt); - vsnprintf((char*)tmp.data(), maxLen, fmt, args); - va_end(args); - return tmp; -} - - -inline double dB(double power) { - return log10(power)*10; -} -inline double gauss(double x, double m, double s) { - static const double inv_sqrt_2pi = 0.3989422804014327; - double a = (x - m) / s; - return inv_sqrt_2pi / s * std::exp(-0.5d * a * a); -} - -inline int timePoints() { - //return (nPoints*3-1); - return nPoints*timeScale; -} - -// returns MHz -inline double freqAt(int i) { - return (startFreq+i*freqStep)*freqMultiplier; -} -// returns ns -inline double timeAt(int i) { - double fs=double(freqStep)*freqMultiplier; // MHz - double totalTime = 1000./fs/2; // ns - return double(i)*totalTime/double(timePoints())/2; -} - diff --git a/vna_gtk/xavna_mock.glade b/vna_gtk/xavna_mock.glade deleted file mode 100644 index f190e95..0000000 --- a/vna_gtk/xavna_mock.glade +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - 200 - 1 - 10 - - - 200 - 1 - 10 - - - False - toolbar - - - True - False - - - True - False - True - - - short - True - True - False - True - True - - - 0 - 0 - - - - - open - True - True - False - True - radiobutton1 - - - 0 - 1 - - - - - load - True - True - False - True - radiobutton1 - - - 0 - 2 - - - - - thru-1cm - True - True - False - True - radiobutton1 - - - 0 - 3 - - - - - thru-5cm - True - True - False - True - radiobutton1 - - - 0 - 4 - - - - - stub-5cm - True - True - False - True - radiobutton1 - - - 0 - 5 - - - - - 0 - 0 - - - - - True - True - Cable 1 length (mm) - False - vertical - adj1 - True - 1 - - - 1 - 0 - - - - - True - True - Cable 2 length (mm) - False - vertical - adj2 - True - 1 - - - 2 - 0 - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vna_qt/CMakeLists.txt b/vna_qt/CMakeLists.txt index 8f97487..569151b 100644 --- a/vna_qt/CMakeLists.txt +++ b/vna_qt/CMakeLists.txt @@ -1,5 +1,5 @@ -include_directories(${Qt5Charts_INCLUDE_DIRS}) +include_directories(${Qt6Charts_INCLUDE_DIRS}) # Instruct CMake to run moc automatically when needed set(CMAKE_AUTOMOC ON) @@ -18,8 +18,11 @@ set(vna_qt_SRCS touchstone.C calkitsettingsdialog.C calkitsettings.C + calibrationfinetunedialog.C networkview.C - dtfwindow.C) + dtfwindow.C + firmwareupdatedialog.C + firmwareupdater.C) set(vna_qt_FRMS mainwindow.ui @@ -31,7 +34,9 @@ set(vna_qt_FRMS calkitsettingsdialog.ui calkitsettingswidget.ui dtfwindow.ui - graphlimitsdialog.ui) + graphlimitsdialog.ui + firmwareupdatedialog.ui + calibrationfinetunedialog.ui) set(vna_qt_HDRS polarview.H @@ -46,12 +51,14 @@ set(vna_qt_HDRS calkitsettingsdialog.H calkitsettings.H networkview.H - dtfwindow.H) + dtfwindow.H + calibrationfinetunedialog.H + firmwareupdatedialog.H) add_executable(vna_qt ${vna_qt_SRCS} ${vna_qt_FRMS} ${vna_qt_HDRS}) -target_link_libraries(vna_qt Qt5::Charts ${FFTW3_LIBRARIES} xavna xavna_mock_ui) +target_link_libraries(vna_qt Qt6::Charts ${FFTW_LIBRARIES} xavna xavna_mock_ui) # Install destinations install(TARGETS vna_qt RUNTIME DESTINATION ${BIN_INSTALL_DIR}) diff --git a/vna_qt/calibrationfinetunedialog.H b/vna_qt/calibrationfinetunedialog.H index e7ff3be..7f985b4 100644 --- a/vna_qt/calibrationfinetunedialog.H +++ b/vna_qt/calibrationfinetunedialog.H @@ -30,7 +30,7 @@ public: function modelsChanged; explicit CalibrationFineTuneDialog(QWidget *parent = nullptr); - ~CalibrationFineTuneDialog(); + virtual ~CalibrationFineTuneDialog(); // calStdModels: indexed by [freqIndex][modelIndex], diff --git a/vna_qt/firmwareupdatedialog.H b/vna_qt/firmwareupdatedialog.H index d214828..439c982 100644 --- a/vna_qt/firmwareupdatedialog.H +++ b/vna_qt/firmwareupdatedialog.H @@ -16,7 +16,7 @@ class FirmwareUpdateDialog : public QDialog public: explicit FirmwareUpdateDialog(QWidget *parent = nullptr); - ~FirmwareUpdateDialog(); + virtual ~FirmwareUpdateDialog(); void beginUploadFirmware(string dev, string file); diff --git a/vna_qt/firmwareupdater.H b/vna_qt/firmwareupdater.H index 7654211..4f64ab0 100644 --- a/vna_qt/firmwareupdater.H +++ b/vna_qt/firmwareupdater.H @@ -3,6 +3,8 @@ #include #include #include +#include + using namespace std; class FirmwareUpdater diff --git a/vna_qt/graphpanel.C b/vna_qt/graphpanel.C index e174970..485e7c8 100644 --- a/vna_qt/graphpanel.C +++ b/vna_qt/graphpanel.C @@ -8,7 +8,7 @@ #include #include -using namespace QtCharts; + GraphPanel::GraphPanel(QWidget *parent) : QWidget(parent), ui(new Ui::GraphPanel) diff --git a/vna_qt/graphpanel.H b/vna_qt/graphpanel.H index f5d9441..b48bd1a 100644 --- a/vna_qt/graphpanel.H +++ b/vna_qt/graphpanel.H @@ -2,21 +2,18 @@ #define GRAPHPANEL_H #include +#include +#include +#include +#include +#include +#include #include namespace Ui { class GraphPanel; } -namespace QtCharts { -class QChartView; -class QChart; -class QValueAxis; -class QLineSeries; -} -class QComboBox; -class QPushButton; -using namespace QtCharts; using namespace std; class GraphPanel : public QWidget { diff --git a/vna_qt/main.C b/vna_qt/main.C index 6ace8e8..88cb55b 100644 --- a/vna_qt/main.C +++ b/vna_qt/main.C @@ -4,12 +4,13 @@ #include #include #include +#include int main(int argc, char *argv[]) { qRegisterMetaType("string"); qRegisterMetaType("CalKitSettings"); - qRegisterMetaTypeStreamOperators("CalKitSettings"); + //qRegisterMetaTypeStreamOperators("CalKitSettings"); QCoreApplication::setApplicationName("NanoVNA QT GUI"); @@ -18,15 +19,16 @@ int main(int argc, char *argv[]) QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - app.installTranslator(&qtTranslator); + if ( qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::path(QLibraryInfo::TranslationsPath)) ) { + app.installTranslator(&qtTranslator); + } QTranslator myappTranslator; - myappTranslator.load("languages/vna_qt_" + QLocale::system().name()); - fprintf(stderr, "%s\n", QLocale::system().name().toStdString().c_str()); - app.installTranslator(&myappTranslator); - + if ( myappTranslator.load("languages/vna_qt_" + QLocale::system().name()) ) { + fprintf(stderr, "%s\n", QLocale::system().name().toStdString().c_str()); + app.installTranslator(&myappTranslator); + } MainWindow* w = new MainWindow(); w->show(); diff --git a/vna_qt/mainwindow.C b/vna_qt/mainwindow.C index aac4abb..9c925ab 100644 --- a/vna_qt/mainwindow.C +++ b/vna_qt/mainwindow.C @@ -104,9 +104,6 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { - printf("aaaaa\n"); - fflush(stdout); - vna->stopScan(); vna->close(); @@ -115,8 +112,6 @@ MainWindow::~MainWindow() //delete polarView; delete vna; delete ui; - printf("ccccc\n"); - fflush(stdout); } void MainWindow::loadSettings() { @@ -224,7 +219,7 @@ void MainWindow::setCallbacks() { this->rawValues[freqIndex] = val; QMetaObject::invokeMethod(this, "updateViews", Qt::QueuedConnection, Q_ARG(int, freqIndex)); }; - vna->sweepCompletedCallback = [this](const vector&) { + vna->sweepCompletedCallback = [](const vector&) { }; vna->backgroundErrorCallback = [this](const exception& exc) { @@ -393,14 +388,16 @@ QWidget *MainWindow::createTopFloat(QWidget *w) { QWidget* widget2 = new QWidget(); layout2->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding)); - layout2->setMargin(0); + //layout2->setMargin(0); + layout2->setContentsMargins(0,0,0,0); widget2->setLayout(layout2); widget2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); layout->addWidget(widget2); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding)); w->setLayout(layout); - layout->setMargin(4); + //layout->setMargin(4); + layout->setContentsMargins(4,4,4,4); return widget2; } diff --git a/vna_qt/mainwindow.H b/vna_qt/mainwindow.H index e0e449b..693be9d 100644 --- a/vna_qt/mainwindow.H +++ b/vna_qt/mainwindow.H @@ -8,32 +8,31 @@ #include #include #include + +#include +#include +#include +#include + #include "calkitsettings.H" #include "networkview.H" #include "dtfwindow.H" namespace Ui { class MainWindow; } -class QWidget; -class QPushButton; + class PolarView; class ImpedanceDisplay; class GraphPanel; -namespace QtCharts { -class QChartView; -class QChart; -class QValueAxis; -} + namespace xaxaxa { class VNADevice; class VNACalibration; } -class QTimer; + class MarkerSlider; -class QTextStream; -using namespace QtCharts; using namespace xaxaxa; using namespace std; diff --git a/vna_qt/mainwindow.ui b/vna_qt/mainwindow.ui index 6604bf4..d598f29 100644 --- a/vna_qt/mainwindow.ui +++ b/vna_qt/mainwindow.ui @@ -217,7 +217,7 @@ - QComboBox::AdjustToMinimumContentsLength + QComboBox::AdjustToMinimumContentsLengthWithIcon diff --git a/vna_qt/networkview.C b/vna_qt/networkview.C index 87f27d0..a39d771 100644 --- a/vna_qt/networkview.C +++ b/vna_qt/networkview.C @@ -12,6 +12,7 @@ #include #include #include +#include using namespace std; using namespace xaxaxa; @@ -104,7 +105,7 @@ GraphPanel* NetworkView::createGraphView(bool freqDomain, bool tr) { vector curViews; for(int i=0;i<2;i++) { // set up markers - auto fn = [gp, i, this](SParamView& view){ + auto fn = [gp, i](SParamView& view){ QScatterSeries* markerSeries = new QScatterSeries(); gp->chart->addSeries(markerSeries); markerSeries->setPointsVisible(true); @@ -235,9 +236,8 @@ void NetworkView::updateMarkerViews(int marker) { ss->replace(0, -100, 0); continue; } - ss->replace(0,series->at(freqIndex)); - //printf("sss %f %f\n",series->at(freqIndex).x(), series->at(freqIndex).y()); - fflush(stdout); + if (freqIndex < series->count()) + ss->replace(0,series->at(freqIndex)); } } if(auto* pv = dynamic_cast(view.view)) { @@ -252,43 +252,58 @@ void NetworkView::updateMarkerViews(int marker) { } } -void NetworkView::updateBottomLabels(int marker) { +void NetworkView::updateBottomLabels(int marker) +{ SParamView* lineViews[4]; int lineViewCount=0; - for(auto& view:views) { + + for(auto& view : views) + { if(dynamic_cast(view.view)) { lineViews[lineViewCount] = &view; lineViewCount++; - if(lineViewCount>=4) break; + if(lineViewCount >= 4) + break; } } - for(int i=0;i<(int)markers.size();i++) { - if(marker>=0 && marker!=i) continue; + + for(int i = 0; i < (int)markers.size(); i++) + { + if(marker >= 0 && marker !=i ) + continue; auto& marker = markers[i]; - if(marker.ms == NULL) continue; - for(int j=0;j<4;j++) { - if(j>=lineViewCount) marker.ms->setLabelText(j, ""); + + if(marker.ms == NULL) + continue; + + for(int j = 0; j < 4; j++) + { + if(j >= lineViewCount) { + marker.ms->setLabelText(j, ""); + } else { auto* series = dynamic_cast(lineViews[j]->view); const char* fmt = ""; switch(lineViews[j]->src.type) { - case SParamViewSource::TYPE_MAG: fmt = "%.1lf dB"; break; - case SParamViewSource::TYPE_SWR: fmt = "%.2lf:1"; break; - case SParamViewSource::TYPE_PHASE: fmt = "%.1lf °"; break; - case SParamViewSource::TYPE_GRPDELAY: fmt = "%.2lf ns"; break; - case SParamViewSource::TYPE_Z_RE: fmt = "%.1lf Ω"; break; - case SParamViewSource::TYPE_Z_IM: fmt = "%.1lf Ω"; break; - case SParamViewSource::TYPE_Z_MAG: fmt = "%.1lf Ω"; break; - case SParamViewSource::TYPE_Z_CAP: fmt = "%.1lf pF"; break; - case SParamViewSource::TYPE_Z_IND: fmt = "%.2lf nH"; break; - case SParamViewSource::TYPE_Y_RE: fmt = "%.1lf mS"; break; - case SParamViewSource::TYPE_Y_IM: fmt = "%.1lf mS"; break; - case SParamViewSource::TYPE_Y_MAG: fmt = "%.1lf mS"; break; - case SParamViewSource::TYPE_Y_CAP: fmt = "%.1lf pF"; break; - case SParamViewSource::TYPE_Y_IND: fmt = "%.2lf nH"; break; - default: fmt = "%.2lf"; + case SParamViewSource::TYPE_MAG: fmt = "%.1lf dB"; break; + case SParamViewSource::TYPE_SWR: fmt = "%.2lf:1"; break; + case SParamViewSource::TYPE_PHASE: fmt = "%.1lf °"; break; + case SParamViewSource::TYPE_GRPDELAY: fmt = "%.2lf ns"; break; + case SParamViewSource::TYPE_Z_RE: fmt = "%.1lf Ω"; break; + case SParamViewSource::TYPE_Z_IM: fmt = "%.1lf Ω"; break; + case SParamViewSource::TYPE_Z_MAG: fmt = "%.1lf Ω"; break; + case SParamViewSource::TYPE_Z_CAP: fmt = "%.1lf pF"; break; + case SParamViewSource::TYPE_Z_IND: fmt = "%.2lf nH"; break; + case SParamViewSource::TYPE_Y_RE: fmt = "%.1lf mS"; break; + case SParamViewSource::TYPE_Y_IM: fmt = "%.1lf mS"; break; + case SParamViewSource::TYPE_Y_MAG: fmt = "%.1lf mS"; break; + case SParamViewSource::TYPE_Y_CAP: fmt = "%.1lf pF"; break; + case SParamViewSource::TYPE_Y_IND: fmt = "%.2lf nH"; break; + default: fmt = "%.2lf"; } - marker.ms->setLabelText(j, ssprintf(32, fmt, series->at(marker.freqIndex).y())); + + if ( marker.freqIndex < series->count() ) + marker.ms->setLabelText(j, ssprintf(32, fmt, series->at(marker.freqIndex).y())); } } } diff --git a/vna_qt/networkview.H b/vna_qt/networkview.H index 3524fc6..a3d806b 100644 --- a/vna_qt/networkview.H +++ b/vna_qt/networkview.H @@ -4,11 +4,12 @@ #include #include #include +#include namespace QtCharts { -class QChartView; -class QChart; -class QValueAxis; +//class QChartView; +//class QChart; +//class QValueAxis; } class QTimer; diff --git a/vna_qt/vna_qt.pro b/vna_qt/vna_qt.pro index 9665c8b..32dd63b 100644 --- a/vna_qt/vna_qt.pro +++ b/vna_qt/vna_qt.pro @@ -18,7 +18,7 @@ QTPLUGIN.imageformats += svg #QMAKE_LFLAGS += --static -lexpat -lz -lXext -lXau -lbsd -lXdmcp #QMAKE_LFLAGS += -L../lib -lxavna -QMAKE_CXXFLAGS += -Wextra -std=c++11 +QMAKE_CXXFLAGS += -Wextra -std=c++17 QMAKE_CXXFLAGS += -DEIGEN_DONT_VECTORIZE -DEIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT android: QMAKE_CXXFLAGS += -I../android_include -DANDROID_WORKAROUNDS