1

Samsung Gear S2 で加速度センサーのサンプル レートを計算したいと考えています。次のコードを例として https://developer.tizen.org/ko/community/code-snippet/native-code-snippet/simple-sensors-application-wearable?langredirect=1を使用して、アプリを作成しました。

コールバックを 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);

そして私はサンプリングレートを計算します

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);
}
}

これにより、加速度のサンプリング周波数は約 50Hz にとどまります (つまり、19 ~ 20 ミリ秒ごとに 1 つのサンプル)。

なぜ私がそれ以下になれないのか知っていますか?(私の目標は 10ms ごとに 1 つのサンプルになります - 最小サポート)

ありがとうございました。

これは私の最初の質問なので、改善のアイデアもいただければ幸いです。

知識: C - 初心者、Tizen - 初心者

4

1 に答える 1