Exemplo n.º 1
0
void
Compass::Run(const String& command) {
	if (!command.IsEmpty()) {
		String args;
		String delim(L"/");
		command.SubString(String(L"gap://").GetLength(), args);
		StringTokenizer strTok(args, delim);
		if(strTok.GetTokenCount() < 2) {
			AppLogDebug("Not Enough Params");
			return;
		}
		String method;
		strTok.GetNextToken(method);
		// Getting callbackId
		strTok.GetNextToken(callbackId);
		AppLogDebug("Method %S, callbackId: %S", method.GetPointer(), callbackId.GetPointer());
		// used to determine callback ID
		if(method == L"com.phonegap.Compass.watchHeading" && !callbackId.IsEmpty() && !IsStarted()) {
			AppLogDebug("watching compass...");
			StartSensor();
		}
		if(method == L"com.phonegap.Compass.clearWatch" && !callbackId.IsEmpty() && IsStarted()) {
			AppLogDebug("stop watching compass...");
			StopSensor();
		}
		if(method == L"com.phonegap.Compass.getCurrentHeading" && !callbackId.IsEmpty() && !IsStarted()) {
			AppLogDebug("getting current compass...");
			GetLastHeading();
		}
		AppLogDebug("Compass command %S completed", command.GetPointer());
	} else {
		AppLogDebug("Can't run empty command");
	}
}
Exemplo n.º 2
0
void
Accelerometer::Run(const String& command) {
	if (!command.IsEmpty()) {
		Uri commandUri;
		commandUri.SetUri(command);
		String method = commandUri.GetHost();
		StringTokenizer strTok(commandUri.GetPath(), L"/");
		if(strTok.GetTokenCount() == 1) {
			strTok.GetNextToken(callbackId);
			AppLogDebug("Method %S, CallbackId: %S", method.GetPointer(), callbackId.GetPointer());
		}
		if(method == L"com.cordova.Accelerometer.watchAcceleration" && !callbackId.IsEmpty() && !IsStarted()) {
			StartSensor();
		}
		if(method == L"com.cordova.Accelerometer.clearWatch" && IsStarted()) {
			StopSensor();
		}
		if(method == L"com.cordova.Accelerometer.getCurrentAcceleration" && !callbackId.IsEmpty() && !IsStarted()) {
			GetLastAcceleration();
		}
		AppLogDebug("Acceleration command %S completed", command.GetPointer());
	} else {
		AppLogDebug("Can't run empty command");
	}
}
Exemplo n.º 3
0
/**
 * Process the next main command.
 */
static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
    struct engine* engine = (struct engine*)app->userData;
    switch (cmd) {
        case APP_CMD_SAVE_STATE:
            // The system has asked us to save our current state.  Do so.
            engine->app->savedState = malloc(sizeof(struct saved_state));
            *((struct saved_state*)engine->app->savedState) = engine->state;
            engine->app->savedStateSize = sizeof(struct saved_state);
            break;
        case APP_CMD_INIT_WINDOW:
            // The window is being shown, get it ready.
            if (engine->app->window != NULL) {
                engine_init_display(engine);

				setupGraphics(engine->width, engine->height);

				InitSensor();
				
                engine_draw_frame(engine);
            }
            break;
        case APP_CMD_TERM_WINDOW:
            // The window is being hidden or closed, clean it up.
            engine_term_display(engine);
            break;
        case APP_CMD_GAINED_FOCUS:
			//_EnableSensor();
			StartSensor();
			engine->animating = 1;
            break;
        case APP_CMD_LOST_FOCUS:
			//_DisableSensor();
            // Also stop animating.
            engine->animating = 0;
			PauseSensor();
            //engine_draw_frame(engine);
            break;
    }
}
Exemplo n.º 4
0
/**
 \if INCLUDE_IN_HTML_ONLY
 \fn        void StartResource(uint8_t e_StreamResource)
 \brief     Low level function to handle starting of a resource
 \param     e_StreamResource    :   The resource which is to be started, possible values are StreamResource_e_Sensor and StreamResource_e_Rx
 \return    None
 \ingroup   Stream
 \callgraph
 \callergraph
 \endif
*/
void
StartResource(
uint8_t e_StreamResource)
{
    if (StreamResource_e_Rx == e_StreamResource)
    {
        // In case of CSI2, Rx is started before sensor to enable grabbing of the first frame.
        // This is done in the context of StartResource for sensor.
        // But the stream state machine still follows the following order, start sensor --> start Rx
        // As a result in case of normal start streming sequence(RUN command from user), Rx is already
        // started when the code hits this point. But in case of RUN command after ISP_STOP command,
        // sensor is not restarted, only Rx is started. This check is added to start Rx in such condition.
        if(SystemConfig_IsInputInterfaceCCP() || (!Is_ISP_SMIARX_ISP_SMIARX_STATUS_rx_state_GEN_RUNNING()))
        {
            OstTraceInt0(TRACE_FLOW, "SystemConfig_IsInputInterfaceCCP : StartRx()");
            StartRx();
        }
        else if(g_Stream_InputStatus.e_StreamResourceStatus_Sensor == StreamResourceStatus_e_Running)
        {
            StartRx();
        }
    }
    else if (StreamResource_e_Sensor == e_StreamResource)
    {
        if (SystemConfig_IsInputInterfaceCCP())
        {
            // Disable Interrupts in CRM
            ITM_Disable_Clock_Detect_LOSS_Interrupt_CRM();

            // For CCP sensor, after starting sensor, wait for some time so that the clocks
            // available from the sensor are good.
            StartSensor();

            //GPIOManager_Toggle_GPIO_Pin();
            GPIOManager_Delay_us(g_SystemSetup.f_SensorStartDelay_us);

            if (SystemConfig_IPPSetupRequired())
            {
                // enable IPP_SD_STATIC_CCP_EN
                Set_IPP_IPP_SD_STATIC_CCP_EN(STATIC_SD_CCP_EN_B_0x1);

                // enable the IPP_DPHY_TOP_IF
                Set_IPP_IPP_DPHY_TOP_IF_EN(1);

                // enable IPP internal CCP clock
                Set_IPP_IPP_INTERNAL_EN_CLK_CCP(INTERNAL_EN_CLK_CCP_B_0x1);
            }


            // switch to real sensor clocks as sensor has started & clocks are good.
            CRM_SwitchToRealSensorClocks();

            // set sensor clock available in the Clock Manager.
            CRM_SetSensorClockAvailable();
        }
        else
        {
#if CRM_CSI2_CLOCK_DETECTION
            CRM_PreRunUpdate();
            g_CRM_Status.e_Flag_StartEnabled = Flag_e_TRUE;
            // Rx start can be done before starting Sensor for CSI2 sensor
            // Reference : section 7.2 of "x500 start and stop sequence" document
            OstTraceInt0(TRACE_FLOW, "calling StartRx()");
            StartRx();
#endif

            // For CSI sensor, after starting sensor, no need to wait for
            // before enabling the IPP_DPHY
            if (SystemConfig_IPPSetupRequired())
            {
                // enable the IPP_DPHY_TOP_IF
                Set_IPP_IPP_DPHY_TOP_IF_EN(1);
            }


            StartSensor();

#if CRM_CSI2_CLOCK_DETECTION
         OstTraceInt0(TRACE_FLOW, "Waiting for clocks to be available");
         while(CRM_GetIsSensorClockUnavailable());
#else
            //GPIOManager_Toggle_GPIO_Pin();
            GPIOManager_Delay_us(g_SystemSetup.f_SensorStartDelay_us);

            // switch to real sensor clocks as sensor has started & clocks are good.
            CRM_SwitchToRealSensorClocks();

            // set sensor clock available in the Clock Manager.
            CRM_SetSensorClockAvailable();
#endif
        }
    }


    return;
}