Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SENSOR_DELAY_GAME: how much is it?

I'm working on a game and I need to synchronize two player object controlling mechanisms: one is an on-screen touch controller and second is the G-Sensor. On-screen controller must be initialized with a value in seconds, so I need to know how much seconds does SENSOR_DELAY_GAME mean. Thanks in advance.

like image 785
Egor Avatar asked Jul 27 '12 09:07

Egor


2 Answers

Taken from http://developer.android.com/guide/topics/sensors/sensors_overview.html

The default data delay is suitable for monitoring typical screen orientation changes and uses a delay of 200,000 microseconds. You can specify other data delays, such as SENSOR_DELAY_GAME (20,000 microsecond delay), SENSOR_DELAY_UI (60,000 microsecond delay), or SENSOR_DELAY_FASTEST (0 microsecond delay). As of Android 3.0 (API Level 11) you can also specify the delay as an absolute value (in microseconds).

The delay that you specify is only a suggested delay. The Android system and other applications can alter this delay. As a best practice, you should specify the largest delay that you can because the system typically uses a smaller delay than the one you specify (that is, you should choose the slowest sampling rate that still meets the needs of your application). Using a larger delay imposes a lower load on the processor and therefore uses less power.

like image 172
Makibo Avatar answered Oct 03 '22 19:10

Makibo


I don't think there is a definite answer into your question, in a meaning that this is device depended. Except from that, keep in mind that even if you define a certain delay for your sensor, the Sensor Manager may return results faster or slower than what you specified. For your case, i think the best approach is to take the average time (in seconds) between two consecutive polls after a certain amount of time that your sensor is running, initialized with the SENSOR_DELAY_GAME flag, and pass that time to your on-screen controller initialization.

like image 35
Angelo Avatar answered Oct 03 '22 19:10

Angelo