This repository include gForce SDK dll files and some simple examples.
How to get accelerate speed data of the
gForce
by gForceSDK?
- Implement
HubListener
interface
class HubListenerImpl : public HubListener{...}
- Config Accelerate(optional)
Call DeviceSetting::setAccelerateConfig(...)
to configure ACC
- Open ACC Data Notification
Call DeviceSetting::setDataNotifySwitch(...)
to open ACC
- Extract the data of acceleration
void onExtendedDeviceData(SPDEVICE device, DeviceDataType dataType, gfsPtr<const vector<GF_UINT8>> data) override
{
switch (dataType) {
case DeviceDataType::DDT_ACCELERATE:
//... extract accelerate speed from 'data'
// Data format accelerate speed
// *--------------------------------*---------------*---------------*
// |ACC_X(data type = long(4 Byte)) | ACC_Y(...) | ACC_Z(...) |
// *--------------------------------*---------------*---------------*
// |accelerate speed at X axis |... |... |
// *--------------------------------*---------------*---------------*
//
auto ptr = data->data();
long acc_x = *(reinterpret_cast<const long*>(ptr));
long acc_y = *(reinterpret_cast<const long*>(ptr + 4));
long acc_z = *(reinterpret_cast<const long*>(ptr + 8));
break;
case DeviceDataType::DDT_GYROSCOPE:
//... extract gyroscope data form 'data'
break;
default:
break;
}
}