Ejemplo n.º 1
0
bool CSI570Controller::setFrequency(const CFrequency& freq)
{
	double dFrequency = double(freq.get()) / 1000000.0;

	wxUint32 frequency = wxUint32(dFrequency * (1UL << 21)) * m_freqMult;

	int n = ::libusb_control_transfer(m_device, LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT, REQUEST_SET_FREQUENCY, 0U, 0U, (unsigned char*)&frequency, 4U, 500);
	if (n < 0) {
		wxLogError(wxT("Error from libusb_control_transfer: err=%d"), n);
		return false;
	}

	return true;
}
Ejemplo n.º 2
0
bool CSI570Controller::setFrequency(const CFrequency& freq)
{
	double dFrequency = double(freq.get()) / 1000000.0;

	wxUint32 frequency = wxUint32(dFrequency * (1UL << 21)) * m_freqMult;

	int n = ::usb_control_msg(m_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, REQUEST_SET_FREQUENCY, 0U, 0U, (char*)&frequency, 4U, 500);
	if (n < 0) {
		wxString err(::usb_strerror(), wxConvLocal);
		wxLogError(wxT("Error from usb_control_msg: %s"), err.c_str());
		return false;
	}

	return true;
}
Ejemplo n.º 3
0
void CFreqDisplay::setMaxFrequency(const CFrequency& frequency)
{
	wxInt64 hz = frequency.get();

	m_mhzDigits = 1;

	if (hz >= 10000000000LL)		// 10 GHz
		m_mhzDigits = 5;
	else if (hz >= 1000000000LL)		// 1000 MHz
		m_mhzDigits = 4;
	else if (hz >= 100000000LL)		// 100 MHz
		m_mhzDigits = 3;
	else if (hz >= 10000000LL)		// 10 MHz
		m_mhzDigits = 2;
}
bool CHackRFController::setFrequency(const CFrequency& freq)
{
	/* Convert Freq Hz 64bits to Freq MHz (32bits) & Freq Hz (32bits) */
	wxUint32 lFreqMHz = wxUint32(freq.get() / wxUint64(1000000U));
	wxUint32 lFreqHz  = wxUint32(freq.get() % wxUint64(1000000U));

	struct {
		wxUint32 freqMHz;	/* From 30 to 6000MHz */
		wxUint32 freqHz;	/* From 0 to 999999Hz */
							/* Final Freq = freq_mhz+freq_hz */
	} setFreqParams;

	setFreqParams.freqMHz = wxUINT32_SWAP_ON_BE(lFreqMHz);
	setFreqParams.freqHz  = wxUINT32_SWAP_ON_BE(lFreqHz);

	wxUint8 length = sizeof(setFreqParams);
	int result = ::libusb_control_transfer(m_device, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, REQUEST_SET_FREQUENCY, 0, 0, (unsigned char*)&setFreqParams, length, 0);
	if (result < 0) {
		wxLogError(wxT("Error from libusb_control_transfer: err=%d"), result);
		return false;
	}

	return true;
}
Ejemplo n.º 5
0
void CFreqDisplay::setFrequency(const CFrequency& frequency)
{
	wxInt64 hz = frequency.get();

	// Only display to 10 Hz
	if ((m_lastFrequency.get() / 10LL) == (hz / 10LL))
		return;

	clearGraph();

	wxMemoryDC memoryDC;
	memoryDC.SelectObject(*m_bitmap);

	int mhzDigits = m_mhzDigits;
	if (mhzDigits == 0) {
		mhzDigits = 1;
		if (hz >= 10000000000LL)		// 10 GHz
			mhzDigits = 5;
		else if (hz >= 1000000000LL)		// 1000 MHz
			mhzDigits = 4;
		else if (hz >= 100000000LL)		// 100 MHz
			mhzDigits = 3;
		else if (hz >= 10000000LL)		// 10 MHz
			mhzDigits = 2;
	}

	const int bigThickness    = 5;
	const int littleThickness = 4;

	int bigHeight    = m_height - 2 * BORDER_SIZE;
	int littleHeight = 3 * bigHeight / 4;

	int bigWidth    = (m_width - 2 * BORDER_SIZE) / (mhzDigits + 5);
	int littleWidth = 3 * bigWidth / 4;

	int bigY    = BORDER_SIZE;
	int littleY = (bigHeight + BORDER_SIZE) - littleHeight;

	int x = BORDER_SIZE + (mhzDigits + 4) * bigWidth;

	wxInt64 rem = hz / 10LL;

	drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false);
	x   -= littleWidth;
	rem /= 10LL;

	drawDigit(memoryDC, littleWidth, littleHeight, littleThickness, x, littleY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, false);
	x   -= bigWidth;
	rem /= 10LL;

	drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, rem % 10LL, true);
	x   -= bigWidth;

	rem = hz / 1000000LL;

	for (int i = 0; i < mhzDigits; i++) {
		wxInt64 n = rem % 10LL;
		rem /= 10LL;

		if (rem != 0LL || (rem == 0LL && n != 0LL))
			drawDigit(memoryDC, bigWidth, bigHeight, bigThickness, x, bigY, n, false);

		x -= bigWidth;
	}

	memoryDC.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);

	m_lastFrequency = frequency;
}