Java Code Examples for com.google.android.gms.wearable.DataMap#getFloatArray()

The following examples show how to use com.google.android.gms.wearable.DataMap#getFloatArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidWear.java    From ibm-wearables-android-sdk with Apache License 2.0 6 votes vote down vote up
private void triggerAccelerometerUpdate(DataMap dataMap){

        final String ACCELEROMETER_KEY = "accelerometer";

        if (dataMap.containsKey(ACCELEROMETER_KEY)){
            ArrayList<DataMap> accelerometerDataArrayList = dataMap.getDataMapArrayList(ACCELEROMETER_KEY);

            for (DataMap accelerometerDataMap : accelerometerDataArrayList){

                float[] values = accelerometerDataMap.getFloatArray("values");

                AccelerometerData data = new AccelerometerData();
                data.x = values[0];
                data.y = values[1];
                data.z = values[2];

                accelerometerSensorEvents.dataEvent.trigger(data);
            }
        }
    }
 
Example 2
Source File: Message.java    From DronesWear with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static AccelerometerData decodeAcceleroMessage(DataItem dataItem) {
    AccelerometerData accelerometerData = null;
    if (MESSAGE_TYPE.ACC.equals(getMessageType(dataItem))) {
        DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
        float sensordataArray[] = dataMap.getFloatArray(VALUE_STR);
        if (sensordataArray != null)
        {
            accelerometerData = new AccelerometerData(sensordataArray[0], sensordataArray[1], sensordataArray[2]);
        }
    }

    return accelerometerData;
}
 
Example 3
Source File: Message.java    From DronesWear with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static JoystickData decodeJoystickMessage(DataItem dataItem) {
    JoystickData joystickData = null;
    if (MESSAGE_TYPE.JOYSTICK.equals(getMessageType(dataItem))) {
        DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
        float joystickArray[] = dataMap.getFloatArray(VALUE_STR);
        if (joystickArray != null)
        {
            joystickData = new JoystickData(joystickArray[0], joystickArray[1]);
        }
    }

    return joystickData;
}
 
Example 4
Source File: SensorReceiverService.java    From wearabird with MIT License 5 votes vote down vote up
private void unpackSensorData(@SuppressWarnings("UnusedParameters") int sensorType, DataMap dataMap) {
	float[] values = dataMap.getFloatArray(DataMapKeys.VALUES);
	if (values.length >= 3) {
		int val = (int) values[2];

		if (Math.abs(val - lastSensorValue) > 1) {
			remoteSensorManager.wave();
		}

		lastSensorValue = val;
	}
	remoteSensorManager.ping();
}
 
Example 5
Source File: SensorReceiverService.java    From SensorDashboard with Apache License 2.0 5 votes vote down vote up
private void unpackSensorData(int sensorType, DataMap dataMap) {
    int accuracy = dataMap.getInt(DataMapKeys.ACCURACY);
    long timestamp = dataMap.getLong(DataMapKeys.TIMESTAMP);
    float[] values = dataMap.getFloatArray(DataMapKeys.VALUES);

    Log.d(TAG, "Received sensor data " + sensorType + " = " + Arrays.toString(values));

    sensorManager.addSensorData(sensorType, accuracy, timestamp, values);
}
 
Example 6
Source File: AndroidWear.java    From ibm-wearables-android-sdk with Apache License 2.0 4 votes vote down vote up
private void triggerGyroscopeUpdate(DataMap dataMap) {

        final String GYROSCOPE_KEY = "gyroscope";

        if (dataMap.containsKey(GYROSCOPE_KEY)){
            ArrayList<DataMap> gyroscopeDataArrayList = dataMap.getDataMapArrayList(GYROSCOPE_KEY);

            for (DataMap gyroscopeDataMap : gyroscopeDataArrayList){

                float[] values = gyroscopeDataMap.getFloatArray("values");

                GyroscopeData data = new GyroscopeData();

                data.x = values[0];
                data.y = values[1];
                data.z = values[2];

                gyroscopeSensorEvents.dataEvent.trigger(data);
            }
        }
    }
 
Example 7
Source File: DataBundleUtil.java    From android_external_GmsLib with Apache License 2.0 4 votes vote down vote up
@Override
float[] load(DataMap dataMap, String key) {
    return dataMap.getFloatArray(key);
}