diff --git a/q65w/CMakeLists.txt b/q65w/CMakeLists.txt index 3a024d0e9..a82c2da09 100644 --- a/q65w/CMakeLists.txt +++ b/q65w/CMakeLists.txt @@ -9,7 +9,6 @@ set (q65w_CXXSRCS mainwindow.cpp meterwidget.cpp plotter.cpp - set570.cpp signalmeter.cpp soundin.cpp widegraph.cpp diff --git a/q65w/set570.cpp b/q65w/set570.cpp deleted file mode 100644 index a56832292..000000000 --- a/q65w/set570.cpp +++ /dev/null @@ -1,272 +0,0 @@ - -/* Linux / Windows program to control the frequency of a si570 synthesizer - ON5GN 6 jan 2012 - Under Linux: - -use the linux version of function void si570_sleep(int us) - -compile with - gcc -Wall -o set_si570_freq set_si570_freq.c -lusb -lm - -run with sudo ./set_si570_freq - Under Windows: - -use the windows version of function void si570_sleep(int us) - -compile with mingw - C:\mingw\bin\mingw32-gcc -Wall -o set_si570_freq set_si570_freq.c -lusb -lm - -run with set_si570_freq.exe -*/ - -#include /* Standard input/output definitions */ -#include /* String function definitions */ -#include /* UNIX standard function definitions */ -#include - -#ifdef WIN32 -#include -#endif - -#include -#include - -#define USB_SUCCESS 0 -#define USB_ERROR_NOTFOUND 1 -#define USB_ERROR_ACCESS 2 -#define USB_ERROR_IO 3 -#define VENDOR_NAME "www.obdev.at" -#define PRODUCT_NAME "DG8SAQ-I2C" -#define USBDEV_SHARED_VENDOR 0x16C0 // VOTI VID -#define USBDEV_SHARED_PRODUCT 0x05DC // OBDEV PID - // Use obdev's generic shared VID/PID pair - // following the rules outlined in - // firmware/usbdrv/USBID-License.txt. -#define REQUEST_SET_FREQ_BY_VALUE 0x32 -#define MAX_USB_ERR_CNT 6 - -double freq_parm; -double delay_average; -int from_freq; -int to_freq; -int increment_freq; -int display_freq = -1; -int delay; -static libusb_device_handle * global_si570usb_handle; - -void si570_sleep(int us) -{ -#if defined (Q_OS_WIN) - ::Sleep (us / 1000); -#else - ::usleep (us); -#endif -} - -double round(double x) -{ - int i=x+0.5; - return (double)i; -} - -double current_time(void) //for delay measurements -{ - struct timeval t; - gettimeofday(&t,NULL); - return 0.000001*t.tv_usec+t.tv_sec; -} - -unsigned char Si570usbOpenDevice(libusb_device_handle **device, char *usbSerialID); -void setLongWord( int value, char * bytes); -int setFreqByValue(libusb_device_handle * handle, double frequency); -void sweepa_freq(void); -void sweepm_freq(void); - -int set570(double freq_MHz) -{ -//### -// qDebug() << "A" << freq_MHz; -// if(freq_MHz != 999.0) return 0; -//### - - char * my_usbSerialID = nullptr; - -// MAIN MENU DIALOG - if (Si570usbOpenDevice(&global_si570usb_handle, my_usbSerialID) != USB_SUCCESS) - { - return -1; - } - -//SET FREQUENCY - if((freq_MHz < 3.45)|(freq_MHz > 866.0)) return -2; - setFreqByValue(global_si570usb_handle,freq_MHz); - return 0; -} - -unsigned char Si570usbOpenDevice (libusb_device_handle * * udh, char * usbSerialID) -{ - if (*udh) return USB_SUCCESS; // only scan USB devices 1st time - - int vendor = USBDEV_SHARED_VENDOR; - char *vendorName = (char *)VENDOR_NAME; - int product = USBDEV_SHARED_PRODUCT; - char *productName = (char *)PRODUCT_NAME; - - libusb_device_handle * handle = nullptr; - unsigned char errorCode = USB_ERROR_NOTFOUND; - char buffer[256]; - int rc; - if ((rc = libusb_init (nullptr)) < 0) // init default context (safe to repeat) - { - printf ("usb initialization error message %s\n", libusb_error_name (rc)); - return errorCode = USB_ERROR_ACCESS; - } - - libusb_device * * device_list; - int device_count = libusb_get_device_list (nullptr, &device_list); - if (device_count < 0) - { - puts ("no usb devices"); - errorCode = USB_ERROR_NOTFOUND; - } - else - { - for (int i = 0; i < device_count; ++i) - { - libusb_device * device = device_list[i]; - libusb_device_descriptor descriptor; - if ((rc = libusb_get_device_descriptor (device, &descriptor)) < 0) - { - printf ("usb get device descriptor error message %s\n", libusb_error_name (rc)); - errorCode = USB_ERROR_ACCESS; - continue; - } - if (vendor == descriptor.idVendor && product == descriptor.idProduct) - { - // now we must open the device to query strings - if ((rc = libusb_open (device, &handle)) < 0) - { - printf ("usb open device error message %s\n", libusb_error_name (rc)); - errorCode = USB_ERROR_ACCESS; - continue; - } - if (!vendorName && !productName) - { - break; // good to go - } - if (libusb_get_string_descriptor_ascii (handle, descriptor.iManufacturer - , reinterpret_cast (buffer), sizeof buffer) < 0) - { - printf ("usb get vendor name error message %s\n", libusb_error_name (rc)); - errorCode = USB_ERROR_IO; - } - else - { - if (!vendorName || !strcmp (buffer, vendorName)) - { - if (libusb_get_string_descriptor_ascii (handle, descriptor.iProduct - , reinterpret_cast (buffer), sizeof buffer) < 0) - { - printf ("usb get product name error message %s\n", libusb_error_name (rc)); - errorCode = USB_ERROR_IO; - } - else - { - if (!productName || !strcmp (buffer, productName)) - { - if (libusb_get_string_descriptor_ascii (handle, descriptor.iSerialNumber - , reinterpret_cast (buffer), sizeof buffer) < 0) - { - printf ("usb get serial number error message %s\n", libusb_error_name (rc)); - errorCode = USB_ERROR_IO; - } - else - { - if (!usbSerialID || !strcmp (buffer, usbSerialID)) - { - break; // good to go - } - } - } - } - } - } - libusb_close (handle); - handle = nullptr; - } - } - libusb_free_device_list (device_list, 1); - } - if (handle) - { - errorCode = USB_SUCCESS; - *udh = handle; - } - return errorCode; -} - -void setLongWord( int value, char * bytes) -{ - bytes[0] = value & 0xff; - bytes[1] = ((value & 0xff00) >> 8) & 0xff; - bytes[2] = ((value & 0xff0000) >> 16) & 0xff; - bytes[3] = ((value & 0xff000000) >> 24) & 0xff; -} - -int setFreqByValue(libusb_device_handle * handle, double frequency) -{ -// Windows Doc from PE0FKO: -// -// Command 0x32: -// ------------- -// Set the oscillator frequency by value. The frequency is formatted in MHz -// as 11.21 bits value. -// The "automatic band pass filter selection", "smooth tune", -// "one side calibration" and the "frequency subtract multiply" are all -// done in this function. (if enabled in the firmware) -// -// Default: None -// -// Parameters: -// requesttype: LIBUSB_ENDPOINT_OUT -// request: 0x32 -// value: 0 -// index: 0 -// bytes: pointer 32 bits integer -// size: 4 -// -// Code sample: -// uint32_t iFreq; -// double dFreq; -// -// dFreq = 30.123456; // MHz -// iFreq = (uint32_t)( dFreq * (1UL << 21) ) -// r = usbCtrlMsgOUT(0x32, 0, 0, (char *)&iFreq, sizeof(iFreq)); -// if (r < 0) Error -// - - char buffer[4]; - int i2cAddress = 0x55; - int request = REQUEST_SET_FREQ_BY_VALUE; - int value = 0x700 + i2cAddress; - int my_index = 0; - int retval; - int err_cnt; - - err_cnt =0; - set_again:; - setLongWord(round(frequency * 2097152.0), buffer); // 2097152=2^21 - retval = libusb_control_transfer ( - handle, LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT, - request, - value, - my_index, - reinterpret_cast (buffer), - sizeof(buffer), - 5000); - if (retval != 4) { - err_cnt ++; - if(err_cnt < MAX_USB_ERR_CNT) { - si570_sleep(1000); // delay 1000 microsec - goto set_again; - } else { - printf("Error when setting frequency, returncode=%i\n",retval); - printf("usb error message: %s\n", libusb_error_name (retval)); - } - } - return retval; -} diff --git a/q65w/widegraph.cpp b/q65w/widegraph.cpp index 265b00fa3..4e3eeba7a 100644 --- a/q65w/widegraph.cpp +++ b/q65w/widegraph.cpp @@ -299,6 +299,7 @@ void WideGraph::on_fCenterLineEdit_editingFinished() m_dForceCenterFreq=ui->fCenterLineEdit->text().toDouble(); } +/* void WideGraph::on_pbSetRxHardware_clicked() { int iret=set570(m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq); @@ -322,7 +323,7 @@ void WideGraph::initIQplus() on_pbSetRxHardware_clicked(); } } - +*/ void WideGraph::on_cbSpec2d_toggled(bool b) { ui->widePlot->set2Dspec(b); @@ -343,7 +344,7 @@ void WideGraph::on_cbLockTxRx_stateChanged(int n) m_bLockTxRx = (n!=0); ui->widePlot->setLockTxRx(m_bLockTxRx); } - +/* void WideGraph::rx570() { double f=m_mult570*(1.0+0.000001*m_cal570)*m_dForceCenterFreq; @@ -372,7 +373,7 @@ void WideGraph::tx570() mb.exec(); } } - +*/ void WideGraph::updateFreqLabel() { auto rxFreq = QString {"%1"}.arg (ui->widePlot->rxFreq (), 10, 'f', 6); diff --git a/q65w/widegraph.h b/q65w/widegraph.h index 1e330cfde..29739beaa 100644 --- a/q65w/widegraph.h +++ b/q65w/widegraph.h @@ -33,8 +33,6 @@ public: void setPeriod(int n); void setDecodeFinished(); double fGreen(); - void rx570(); - void tx570(); void updateFreqLabel(); void enableSetRxHardware(bool b); @@ -46,7 +44,6 @@ signals: public slots: void wideFreezeDecode(int n); - void initIQplus(); protected: virtual void keyPressEvent( QKeyEvent *e ); @@ -61,7 +58,6 @@ private slots: void on_autoZeroPushButton_clicked(); void on_cbFcenter_stateChanged(int arg1); void on_fCenterLineEdit_editingFinished(); - void on_pbSetRxHardware_clicked(); void on_cbSpec2d_toggled(bool checked); void on_cbLockTxRx_stateChanged(int arg1); @@ -73,10 +69,7 @@ public: private: bool m_bLockTxRx; public: - qint32 m_mult570; - qint32 m_mult570Tx; double m_dForceCenterFreq; - double m_cal570; double m_TxOffset; private: bool m_bIQxt; @@ -87,6 +80,4 @@ private: qint32 m_TRperiod=60; }; -extern int set570(double freq_MHz); - #endif // WIDEGRAPH_H