I want to calculate the acceleration sensor sample rate on a Samsung Gear S2. Using the following code as example https://developer.tizen.org/ko/community/code-snippet/native-code-snippet/simple-sensors-application-wearable?langredirect=1, I created the app.
I register the callback with 10ms
/* Register a callback if a sensor event is detected (sensor value changed) */
ret = sensor_listener_set_event_cb((ad->listener), 10, on_sensor_event, ad);
and I calculate the sampling rate with
unsigned long long int timestampArray[1000000];
int i = 1;
unsigned int samplingFreq = 1;
/* Callback for whenever a sensor event is detected (such as value changed). It is called whenever such an event is detected */
void on_sensor_event(sensor_h sensor, sensor_event_s *event, void *data) {
appdata_s *ad = data;
char buf[1024]={0};
char tempbuf[1024]={0};
sensor_type_e type;
sensor_get_type(sensor, &type);
//Check the sensor type of the sensor event
if(type == (ad->type)){
timestampArray[i] = event->timestamp/1000;
if(i == 2)
{
samplingFreq = timestampArray[i]-timestampArray[i-1];
}
i++;
snprintf(tempbuf, 1023, "F= %d<br/>", samplingFreq);
strcat(buf, tempbuf);
elm_object_text_set(ad->label, buf);
}
}
With this, the acceleration sampling frequency stays at around 50Hz (so one sample every 19-20 ms).
Do you know why I can't get lower than that? (My goal would be 1 sample every 10ms - minimum supported)
Thank you.
This is my first question so I would be glad to receive improvement ideas as well.
Knowledge: C - beginner, Tizen - beginner