XnStatus XnSensorStreamHelper::AfterSettingFirmwareParam(XnActualIntProperty& Property)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	XnSensorStreamHelperCookie* pPropData = NULL;
	nRetVal = m_FirmwareProperties.Get(&Property, pPropData);
	XN_IS_STATUS_OK(nRetVal);
	
	if (pPropData->CurrentTransaction.bShouldOpen)
	{
		nRetVal = m_pStream->Open();
		XN_IS_STATUS_OK(nRetVal);
	}
	else if (pPropData->CurrentTransaction.bChooseProcessor)
	{
		XnDataProcessor* pProcessor = NULL;
		nRetVal = m_pSensorStream->CreateDataProcessor(&pProcessor);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = GetFirmware()->GetStreams()->ReplaceStreamProcessor(m_pStream->GetType(), m_pStream, pProcessor);
		XN_IS_STATUS_OK(nRetVal);

		// and unlock
		nRetVal = GetFirmware()->GetStreams()->UnlockStreamProcessor(m_pStream->GetType(), m_pStream);
		XN_IS_STATUS_OK(nRetVal);
	}
	
	return (XN_STATUS_OK);
}
XnStatus XnSensorStreamHelper::Close()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	if (GetFirmware()->GetStreams()->IsClaimed(m_pStream->GetType(), m_pStream))
	{
		nRetVal = m_pSensorStream->CloseStreamImpl();
		XN_IS_STATUS_OK(nRetVal);

		GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream);
	}
	
	return (XN_STATUS_OK);
}
XnStatus XnSensor::OnFrameSyncPropertyChanged()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	if (m_ReadData.GetValue() == TRUE)
	{
		// decide firmware frame sync - both streams are on, and user asked for it
		XnBool bFrameSync = (
			m_FrameSync.GetValue() == TRUE &&
			GetFirmware()->GetParams()->m_Stream0Mode.GetValue() == XN_VIDEO_STREAM_COLOR &&
			GetFirmware()->GetParams()->m_Stream1Mode.GetValue() == XN_VIDEO_STREAM_DEPTH
			);

		nRetVal = GetFirmware()->GetParams()->m_FrameSyncEnabled.SetValue(bFrameSync);
		XN_IS_STATUS_OK(nRetVal);
	}
	
	return (XN_STATUS_OK);
}
XnStatus XnSensorStreamHelper::BeforeSettingFirmwareParam(XnActualIntProperty& Property, XnUInt16 nValue)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	XnSensorStreamHelperCookie* pPropData = NULL;
	nRetVal = m_FirmwareProperties.Get(&Property, pPropData);
	XN_IS_STATUS_OK(nRetVal);

	pPropData->CurrentTransaction.bShouldOpen = FALSE;
	pPropData->CurrentTransaction.bChooseProcessor = FALSE;

	// if stream is closed, we can just update the prop.
	if (m_pStream->IsOpen())
	{
		// check if we need to close the stream first
		if (pPropData->bAllowWhileOpen)
		{
			// before actual changing it, check if this is a processor property
			if (pPropData->bProcessorProp)
			{
				// lock processor
				nRetVal = GetFirmware()->GetStreams()->LockStreamProcessor(m_pStream->GetType(), m_pStream);
				XN_IS_STATUS_OK(nRetVal);
				pPropData->CurrentTransaction.bChooseProcessor = TRUE;
			}

			// OK. change the value
			XnUInt64 nFirmwareValue = nValue;

			if (pPropData->pStreamToFirmwareFunc != NULL)
			{
				nRetVal = pPropData->pStreamToFirmwareFunc(nValue, &nFirmwareValue);
				XN_IS_STATUS_OK(nRetVal);
			}

			// set the param in firmware
			nRetVal = pPropData->pFirmwareProp->SetValue(nFirmwareValue);
			XN_IS_STATUS_OK(nRetVal);

			// no need to do anything after property will be set
			pPropData->CurrentTransaction.bShouldOpen = FALSE;
		}
		else
		{
			// we can't change the firmware param. We should first close the stream
			nRetVal = m_pStream->Close();
			XN_IS_STATUS_OK(nRetVal);

			// after property will be set, we need to reopen the stream
			pPropData->CurrentTransaction.bShouldOpen = TRUE;
		}
	}
	
	return (XN_STATUS_OK);
}
XnStatus XnSensorStreamHelper::Free()
{
	if (m_pStream != NULL)
	{
		GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream);
	}

	m_FirmwareProperties.Clear();

	return XN_STATUS_OK;
}
XnStatus XnSensorStreamHelper::AfterSettingDataProcessorProperty()
{
	XnStatus nRetVal = XN_STATUS_OK;

	if (m_pStream->IsOpen())
	{
		XnDataProcessor* pProcessor = NULL;
		nRetVal = m_pSensorStream->CreateDataProcessor(&pProcessor);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = GetFirmware()->GetStreams()->ReplaceStreamProcessor(m_pStream->GetType(), m_pStream, pProcessor);
		XN_IS_STATUS_OK(nRetVal);

		// and unlock
		nRetVal = GetFirmware()->GetStreams()->UnlockStreamProcessor(m_pStream->GetType(), m_pStream);
		XN_IS_STATUS_OK(nRetVal);
	}

	return (XN_STATUS_OK);
}
XnStatus XnSensorStreamHelper::BeforeSettingDataProcessorProperty()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	if (m_pStream->IsOpen())
	{
		nRetVal = GetFirmware()->GetStreams()->LockStreamProcessor(m_pStream->GetType(), m_pStream);
		XN_IS_STATUS_OK(nRetVal);
	}
	
	return (XN_STATUS_OK);
}
XnStatus XnSensorStreamHelper::Configure()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	XnResolutions nRes;
	XnUInt32 nFPS;
	m_pSensorStream->GetFirmwareStreamConfig(&nRes, &nFPS);

	// claim the stream
	nRetVal = GetFirmware()->GetStreams()->ClaimStream(m_pStream->GetType(), nRes, nFPS, m_pStream);
	XN_IS_STATUS_OK(nRetVal);

	// configure the stream
	nRetVal = m_pSensorStream->ConfigureStreamImpl();
	if (nRetVal != XN_STATUS_OK)
	{
		GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream);
		return (nRetVal);
	}

	// create data processor
	XnDataProcessor* pProcessor;
	nRetVal = m_pSensorStream->CreateDataProcessor(&pProcessor);
	if (nRetVal != XN_STATUS_OK)
	{
		GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream);
		return (nRetVal);
	}

	// and register it
	nRetVal = GetFirmware()->GetStreams()->ReplaceStreamProcessor(m_pStream->GetType(), m_pStream, pProcessor);
	if (nRetVal != XN_STATUS_OK)
	{
		GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream);
		return (nRetVal);
	}

	return (XN_STATUS_OK);
}
XnStatus XnSensorStreamHelper::FinalOpen()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	nRetVal = m_pSensorStream->OpenStreamImpl();
	if (nRetVal != XN_STATUS_OK)
	{
		GetFirmware()->GetStreams()->ReleaseStream(m_pStream->GetType(), m_pStream);
		return (nRetVal);
	}

	return (XN_STATUS_OK);
}
Beispiel #10
0
XnStatus XnSensor::InitImpl(const XnDeviceConfig *pDeviceConfig)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Initializing device sensor...");


	// Frame Sync
	XnCallbackHandle hCallbackDummy;
	nRetVal = m_FrameSync.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, hCallbackDummy);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = GetFirmware()->GetParams()->m_Stream0Mode.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, hCallbackDummy);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = GetFirmware()->GetParams()->m_Stream1Mode.OnChangeEvent().Register(FrameSyncPropertyChangedCallback, this, hCallbackDummy);
	XN_IS_STATUS_OK(nRetVal);

	// other stuff
	m_FrameSyncDump = xnDumpFileOpen(XN_DUMP_FRAME_SYNC, "FrameSync.csv");
	xnDumpFileWriteString(m_FrameSyncDump, "HostTime(us),DepthNewData,DepthTimestamp(ms),ImageNewData,ImageTimestamp(ms),Diff(ms),Action\n");

	nRetVal = XnDeviceBase::InitImpl(pDeviceConfig);
	XN_IS_STATUS_OK(nRetVal);

	// now that everything is configured, open the sensor
	nRetVal = InitSensor(pDeviceConfig);
	if (nRetVal != XN_STATUS_OK)
	{
		Destroy();
		return (nRetVal);
	}

	xnLogInfo(XN_MASK_DEVICE_SENSOR, "Device sensor initialized");

	return (XN_STATUS_OK);
}
Beispiel #11
0
void registerOpenTxFirmwares()
{
  OpenTxFirmware * openTx;

  Option ext_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "telemetrez", QObject::tr("Support for telemetry easy board"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } };
  Option nav_options[] = { { "rotenc", QObject::tr("Rotary Encoder use in menus navigation") }, { "potscroll", QObject::tr("Pots use in menus navigation") }, { NULL } };
  Option extr_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } };
  Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } };

  /* 9x board */
  openTx = new OpenTxFirmware("opentx-9x", QObject::tr("OpenTX for 9X board"), BOARD_STOCK);
  openTx->addOptions(ext_options);
  openTx->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
  openTx->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
  openTx->addOption("nosplash", QObject::tr("No splash screen"));
  openTx->addOption("nofp", QObject::tr("No flight modes"));
  openTx->addOption("nocurves", QObject::tr("Disable curves menus"));
  openTx->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
  openTx->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
  openTx->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
  // NOT TESTED openTx->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
  openTx->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
  openTx->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
  openTx->addOption("symlimits", QObject::tr("Symetrical Limits"));
  openTx->addOptions(nav_options);
  openTx->addOption("sp22", QObject::tr("SmartieParts 2.2 Backlight support"));
  openTx->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
  openTx->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
  openTx->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
  openTx->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
  openTx->addOption("battgraph", QObject::tr("Battery graph"));
  openTx->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
  openTx->addOption("pgbar", QObject::tr("EEprom write progress bar"));
  openTx->addOption("imperial", QObject::tr("Imperial units"));
  openTx->addOption("nowshh", QObject::tr("No Winged Shadow How High support"));
  openTx->addOption("novario", QObject::tr("No vario support"));
  openTx->addOption("nogps", QObject::tr("No GPS support"));
  openTx->addOption("nogauges", QObject::tr("No gauges in the custom telemetry screen"));
  openTx->addOption("fasoffset", QObject::tr("Allow compensating for offset errors in FrSky FAS current sensors"));
  openTx->addOption("stickrev", QObject::tr("Add support for reversing stick inputs (e.g. needed for FrSky gimbals)"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);

  /* 9x board with M128 chip */
  openTx = new OpenTxFirmware("opentx-9x128", QObject::tr("OpenTX for M128 / 9X board"), BOARD_M128);
  openTx->addOptions(ext_options);
  openTx->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
  openTx->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
  openTx->addOption("nosplash", QObject::tr("No splash screen"));
  openTx->addOption("nofp", QObject::tr("No flight modes"));
  openTx->addOption("nocurves", QObject::tr("Disable curves menus"));
  openTx->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
  openTx->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
  openTx->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
  // NOT TESTED openTx->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
  openTx->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
  openTx->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
  openTx->addOption("symlimits", QObject::tr("Symetrical Limits"));
  openTx->addOptions(nav_options);
  openTx->addOption("sp22", QObject::tr("SmartieParts 2.2 Backlight support"));
  openTx->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
  openTx->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
  openTx->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
  openTx->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
  openTx->addOption("battgraph", QObject::tr("Battery graph"));
  openTx->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
  openTx->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
  openTx->addOption("imperial", QObject::tr("Imperial units"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);

  /* 9XR board */
  openTx = new OpenTxFirmware("opentx-9xr", QObject::tr("OpenTX for 9XR"), BOARD_STOCK);
  openTx->addOptions(extr_options);
  openTx->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
  openTx->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
  openTx->addOption("nosplash", QObject::tr("No splash screen"));
  openTx->addOption("nofp", QObject::tr("No flight modes"));
  openTx->addOption("nocurves", QObject::tr("Disable curves menus"));
  openTx->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
  openTx->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
  openTx->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
  // NOT TESTED openTx->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
  openTx->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
  openTx->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
  openTx->addOption("symlimits", QObject::tr("Symetrical Limits"));
  openTx->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
  openTx->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
  openTx->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
  openTx->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
  openTx->addOption("battgraph", QObject::tr("Battery graph"));
  openTx->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
  openTx->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
  openTx->addOption("imperial", QObject::tr("Imperial units"));
  openTx->addOption("nowshh", QObject::tr("No Winged Shadow How High support"));
  openTx->addOption("novario", QObject::tr("No vario support"));
  openTx->addOption("nogps", QObject::tr("No GPS support"));
  openTx->addOption("nogauges", QObject::tr("No gauges in the custom telemetry screen"));
  openTx->addOption("stickrev", QObject::tr("Add support for reversing stick inputs (e.g. needed for FrSky gimbals)"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);

  /* 9XR board with M128 chip */
  openTx = new OpenTxFirmware("opentx-9xr128", QObject::tr("OpenTX for 9XR with M128 chip"), BOARD_M128);
  openTx->addOptions(extr_options);
  openTx->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
  openTx->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
  openTx->addOption("nosplash", QObject::tr("No splash screen"));
  openTx->addOption("nofp", QObject::tr("No flight modes"));
  openTx->addOption("nocurves", QObject::tr("Disable curves menus"));
  openTx->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
  openTx->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
  openTx->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
  // NOT TESTED openTx->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
  openTx->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
  openTx->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
  openTx->addOption("symlimits", QObject::tr("Symetrical Limits"));
  openTx->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
  openTx->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
  openTx->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
  openTx->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
  openTx->addOption("battgraph", QObject::tr("Battery graph"));
  openTx->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
  openTx->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
  openTx->addOption("imperial", QObject::tr("Imperial units"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);

  /* Gruvin9x board */
  openTx = new OpenTxFirmware("opentx-gruvin9x", QObject::tr("OpenTX for Gruvin9x board / 9X"), BOARD_GRUVIN9X);
  openTx->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
  openTx->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
  openTx->addOption("nofp", QObject::tr("No flight modes"));
  openTx->addOption("nocurves", QObject::tr("Disable curves menus"));
  openTx->addOption("sdcard", QObject::tr("Support for SD memory card"));
  openTx->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
  openTx->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
  Option dsm2_options[] = { { "DSM2", QObject::tr("Support for DSM2 modules"), 0 }, { "DSM2PPM", QObject::tr("Support for DSM2 modules using ppm instead of true serial"), 0 }, { NULL } };
  openTx->addOptions(dsm2_options);
  openTx->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
  openTx->addOption("symlimits", QObject::tr("Symetrical Limits"));
  openTx->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
  openTx->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
  openTx->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
  openTx->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
  openTx->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
  openTx->addOption("battgraph", QObject::tr("Battery graph"));
  openTx->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
  openTx->addOption("imperial", QObject::tr("Imperial units"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);

  /* Sky9x board */
  openTx = new OpenTxFirmware("opentx-sky9x", QObject::tr("OpenTX for Sky9x board / 9X"), BOARD_SKY9X);
  openTx->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
  openTx->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
  openTx->addOption("nofp", QObject::tr("No flight modes"));
  openTx->addOption("nocurves", QObject::tr("Disable curves menus"));
  openTx->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
  openTx->addOption("symlimits", QObject::tr("Symetrical Limits"));
  openTx->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
  openTx->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
  openTx->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
  openTx->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
  openTx->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
  openTx->addOption("battgraph", QObject::tr("Battery graph"));
  openTx->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOption("tsticks", QObject::tr("Use FrSky Taranis sticks in a 9X/9XR"));
  openTx->addOption("bluetooth", QObject::tr("Bluetooth interface"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);
  
  /* 9XR-Pro */
  openTx = new OpenTxFirmware("opentx-9xrpro", QObject::tr("OpenTX for 9XR-PRO"), BOARD_9XRPRO);
  openTx->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
  openTx->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
  openTx->addOption("nofp", QObject::tr("No flight modes"));
  openTx->addOption("nocurves", QObject::tr("Disable curves menus"));
  openTx->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
  openTx->addOption("symlimits", QObject::tr("Symetrical Limits"));
  openTx->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
  openTx->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
  openTx->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
  openTx->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
  openTx->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
  openTx->addOption("battgraph", QObject::tr("Battery graph"));
  openTx->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOption("tsticks", QObject::tr("Use FrSky Taranis sticks in a 9X/9XR"));
  openTx->addOption("bluetooth", QObject::tr("Bluetooth interface"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);
  
  /* Taranis board */
  openTx = new OpenTxFirmware("opentx-taranis", QObject::tr("OpenTX for FrSky Taranis"), BOARD_TARANIS);
  openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
  openTx->addOption("nogvars", QObject::tr("Disable Global variables"));
  openTx->addOption("haptic", QObject::tr("Haptic module installed"));
  openTx->addOption("lua", QObject::tr("Support for Lua model scripts"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);
  
  /* Taranis Plus board */
  openTx = new OpenTxFirmware("opentx-taranisplus", QObject::tr("OpenTX for FrSky Taranis Plus"), BOARD_TARANIS_PLUS);
  openTx->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
  openTx->addOption("nogvars", QObject::tr("Disable Global variables"));
  openTx->addOption("lua", QObject::tr("Support for Lua model scripts"));
  openTx->addOption("ppmus", QObject::tr("Channel values displayed in us"));
  openTx->addOption("sqt5font", QObject::tr("Use alternative SQT5 font"));
  openTx->addOptions(fai_options);
  firmwares.push_back(openTx);

  default_firmware_variant = GetFirmware("opentx-9x-heli-templates-en");
  current_firmware_variant = default_firmware_variant;
}
Beispiel #12
0
XnStatus XnSensor::InitSensor(const XnDeviceConfig* pDeviceConfig)
{
	XnStatus nRetVal = XN_STATUS_OK;
	XnDevicePrivateData* pDevicePrivateData = GetDevicePrivateData();

	pDevicePrivateData->pSensor = this;

	pDevicePrivateData->nDepthFramePos = 0;
	pDevicePrivateData->nImageFramePos = 0;
	xnOSMemCopy(&pDevicePrivateData->DeviceConfig, pDeviceConfig, sizeof(XnDeviceConfig));

	xnOSMemSet(pDevicePrivateData->cpSensorID, 0, XN_SENSOR_PROTOCOL_SENSOR_ID_LENGTH);

	switch (pDeviceConfig->DeviceMode)
	{
	case XN_DEVICE_MODE_READ:
		break;
	case XN_DEVICE_MODE_WRITE:
		return (XN_STATUS_IO_DEVICE_MODE_NOT_SUPPORTED);
	default: 
		return (XN_STATUS_IO_DEVICE_INVALID_MODE);
	}

	// Register USB event callback
	#if WIN32
	nRetVal = m_SensorIO.SetCallback(&USBEventCallback, this);
	XN_IS_STATUS_OK(nRetVal);
	#endif

	// open IO
	nRetVal = m_SensorIO.OpenDevice(pDeviceConfig->cpConnectionString, (XnBool)m_LeanInit.GetValue());
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = m_USBPath.UnsafeUpdateValue(m_SensorIO.GetDevicePath());
	XN_IS_STATUS_OK(nRetVal);

	// initialize
	nRetVal = XnDeviceSensorInit(pDevicePrivateData);
	XN_IS_STATUS_OK(nRetVal);

	// init firmware
	nRetVal = m_Firmware.Init((XnBool)m_ResetSensorOnStartup.GetValue(), (XnBool)m_LeanInit.GetValue());
	XN_IS_STATUS_OK(nRetVal);
	m_bInitialized = TRUE;

	m_ResetSensorOnStartup.UpdateSetCallback(NULL, NULL);
	m_LeanInit.UpdateSetCallback(NULL, NULL);

	// update device info properties
	nRetVal = m_DeviceName.UnsafeUpdateValue(GetFixedParams()->GetDeviceName());
	XN_IS_STATUS_OK(nRetVal);
	nRetVal = m_VendorSpecificData.UnsafeUpdateValue(GetFixedParams()->GetVendorData());
	XN_IS_STATUS_OK(nRetVal);
	nRetVal = m_ID.UnsafeUpdateValue(GetFixedParams()->GetSensorSerial());
	XN_IS_STATUS_OK(nRetVal);
	nRetVal = m_PlatformString.UnsafeUpdateValue(GetFixedParams()->GetPlatformString());
	XN_IS_STATUS_OK(nRetVal);

	// Add supported streams
	AddSupportedStream(XN_STREAM_TYPE_DEPTH);
	AddSupportedStream(XN_STREAM_TYPE_IR);

	if (GetFirmware()->GetInfo()->bImageSupported)
	{
		AddSupportedStream(XN_STREAM_TYPE_IMAGE);
	}

	if (GetFirmware()->GetInfo()->bAudioSupported)
	{
		AddSupportedStream(XN_STREAM_TYPE_AUDIO);
	}

	return XN_STATUS_OK;
}
Beispiel #13
0
int main(int argc, char *argv[])
{
    Q_INIT_RESOURCE(companion);
    QApplication app(argc, argv);
    app.setApplicationName("OpenTX Simulator");
    app.setOrganizationName("OpenTX");
    app.setOrganizationDomain("open-tx.org");

#ifdef __APPLE__
    app.setStyle(new MyProxyStyle);
#endif

    QString dir;
    if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang";

    /* QTranslator companionTranslator;
    companionTranslator.load(":/companion_" + locale);
    QTranslator qtTranslator;
    qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app.installTranslator(&companionTranslator);
    app.installTranslator(&qtTranslator);
    */

    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
    uint32_t sdlFlags = 0;
#ifdef JOYSTICKS
    sdlFlags |= SDL_INIT_JOYSTICK;
#endif
#ifdef SIMU_AUDIO
    sdlFlags |= SDL_INIT_AUDIO;
#endif
    SDL_Init(sdlFlags);
#endif

    RegisterEepromInterfaces();
    registerOpenTxFirmwares();

    SimulatorDialog *dialog;
    const char * eepromFileName;
    QString fileName;
    QByteArray path;
    QDir eedir;
    QFile file;

    QMessageBox msgBox;
    msgBox.setWindowTitle("Radio type");
    msgBox.setText("Which radio type do you want to simulate?");
    msgBox.setIcon(QMessageBox::Question);
    QAbstractButton *taranisButton = msgBox.addButton("Taranis", QMessageBox::ActionRole);
    QAbstractButton *sky9xButton = msgBox.addButton("9X-Sky9X", QMessageBox::ActionRole);
    QAbstractButton *gruvinButton = msgBox.addButton("9X-Gruvin9X", QMessageBox::ActionRole);
    QAbstractButton *proButton = msgBox.addButton("9XR-Pro", QMessageBox::ActionRole);
    msgBox.addButton("9X-M128", QMessageBox::ActionRole);
    QPushButton *exitButton = msgBox.addButton(QMessageBox::Close);

    eedir = QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
    if (!eedir.exists("OpenTX")) {
        eedir.mkdir("OpenTX");
    }
    eedir.cd("OpenTX");

    msgBox.exec();

    if (msgBox.clickedButton() == exitButton)
        return 0;
    else if (msgBox.clickedButton() == taranisButton) {
        current_firmware_variant = GetFirmware("opentx-taranis-haptic-en");
        fileName = eedir.filePath("eeprom-taranis.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialogTaranis();
    }
    else if (msgBox.clickedButton() == sky9xButton) {
        current_firmware_variant = GetFirmware("opentx-sky9x-heli-templates-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-bluetooth-en");
        fileName = eedir.filePath("eeprom-sky9x.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }
    else if (msgBox.clickedButton() == gruvinButton) {
        current_firmware_variant = GetFirmware("opentx-gruvin9x-heli-templates-sdcard-voice-DSM2PPM-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-ttsen-en");
        fileName = eedir.filePath("eeprom-gruvin9x.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }
    else if (msgBox.clickedButton() == proButton) {
        current_firmware_variant = GetFirmware("opentx-9xrpro-heli-templates-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-en");
        fileName = eedir.filePath("eeprom-9xrpro.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }
    else {
        current_firmware_variant = GetFirmware("opentx-9x128-frsky-heli-templates-audio-voice-haptic-DSM2-ppmca-gvars-symlimits-autosource-autoswitch-battgraph-thrtrace-en");
        fileName = eedir.filePath("eeprom-9x128.bin");
        path = fileName.toAscii();
        eepromFileName = path.data();
        dialog = new SimulatorDialog9X();
    }

    dialog->show();
    dialog->start(eepromFileName);

    int result = app.exec();

    delete dialog;

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
    SDL_Quit();
#endif

    return result;
}
Beispiel #14
0
int main(int argc, char *argv[])
{
  Q_INIT_RESOURCE(companion);
  QApplication app(argc, argv);
  app.setApplicationName("OpenTX Companion");
  app.setOrganizationName("OpenTX");
  app.setOrganizationDomain("open-tx.org");
  app.setAttribute(Qt::AA_DontShowIconsInMenus, false);

#ifdef __APPLE__
  app.setStyle(new MyProxyStyle);
#endif

  QTranslator companionTranslator;
  companionTranslator.load(":/companion_" + g.locale());
  QTranslator qtTranslator;
  qtTranslator.load((QString)"qt_" + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  app.installTranslator(&companionTranslator);
  app.installTranslator(&qtTranslator);

  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
  uint32_t sdlFlags = 0;
  #ifdef JOYSTICKS
    sdlFlags |= SDL_INIT_JOYSTICK;
  #endif
  #ifdef SIMU_AUDIO
    sdlFlags |= SDL_INIT_AUDIO;
  #endif
  if (SDL_Init(sdlFlags) < 0) {
    fprintf(stderr, "ERROR: couldn't initialize SDL: %s\n", SDL_GetError());
  }
#endif

  RegisterEepromInterfaces();
  registerOpenTxFirmwares();

  if (g.profile[g.id()].fwType().isEmpty()){
    g.profile[g.id()].fwType(default_firmware_variant->getId());
    g.profile[g.id()].fwName("");
  }

  QString splashScreen;
  if ( g.profile[g.id()].fwType().contains("taranis"))     splashScreen = ":/images/splasht.png";
  else if ( g.profile[g.id()].fwType().contains("9xrpro")) splashScreen = ":/images/splashp.png";
  else if ( g.profile[g.id()].fwType().contains("9xr"))    splashScreen = ":/images/splashr.png";
  else  splashScreen = ":/images/splash.png";

  QPixmap pixmap = QPixmap(splashScreen);
  QSplashScreen *splash = new QSplashScreen(pixmap);

  current_firmware_variant = GetFirmware(g.profile[g.id()].fwType());

  MainWindow *mainWin = new MainWindow();
  if (g.showSplash()) {
    splash->show();
    QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close()));
    QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show()));
  }
  else {
    mainWin->show();
  }

  int result = app.exec();

  delete splash;
  delete mainWin;

  UnregisterFirmwares();
  UnregisterEepromInterfaces();

#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
  SDL_Quit();
#endif

  return result;
}