当前位置: 首页>>代码示例>>Java>>正文


Java DataMap.getFloatArray方法代码示例

本文整理汇总了Java中com.google.android.gms.wearable.DataMap.getFloatArray方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.getFloatArray方法的具体用法?Java DataMap.getFloatArray怎么用?Java DataMap.getFloatArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.wearable.DataMap的用法示例。


在下文中一共展示了DataMap.getFloatArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: triggerAccelerometerUpdate

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
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);
            }
        }
    }
 
开发者ID:ibm-wearables-sdk-for-mobile,项目名称:ibm-wearables-android-sdk,代码行数:21,代码来源:AndroidWear.java

示例2: decodeAcceleroMessage

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
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;
}
 
开发者ID:Parrot-Developers,项目名称:DronesWear,代码行数:14,代码来源:Message.java

示例3: decodeJoystickMessage

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
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;
}
 
开发者ID:Parrot-Developers,项目名称:DronesWear,代码行数:14,代码来源:Message.java

示例4: unpackSensorData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
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();
}
 
开发者ID:Drippler,项目名称:wearabird,代码行数:14,代码来源:SensorReceiverService.java

示例5: triggerGyroscopeUpdate

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
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);
            }
        }
    }
 
开发者ID:ibm-wearables-sdk-for-mobile,项目名称:ibm-wearables-android-sdk,代码行数:22,代码来源:AndroidWear.java

示例6: unpackSensorData

import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
 * Method to extract sensor data
 *
 * @param dataMap map of decrypted data
 */
public void unpackSensorData(DataMap dataMap) {

    if (mInternalHandler == null) {
        return;
    }

    if (!mConnected) {
        return;
    }

    Log.d(TAG, "unpackSensorData()");

    int sensorType;
    int accuracy;
    int timestamp;

    float[] data = dataMap.getFloatArray("sensors");

    int max = (int) (data.length / mDataEntriesPerSensor);

    for (int i = 0; i < max; i++) {

        sensorType = (int) data[i * mDataEntriesPerSensor];
        accuracy = (int) data[i * mDataEntriesPerSensor + 1];
        timestamp = (int) data[i * mDataEntriesPerSensor + 2];

        SmartWatchSensorDataFrame frame = new SmartWatchSensorDataFrame(this, timestamp);

        if (sensorType == Sensor.TYPE_ACCELEROMETER) {
            frame.ax = data[i * mDataEntriesPerSensor + 3];
            frame.ay = data[i * mDataEntriesPerSensor + 4];
            frame.az = data[i * mDataEntriesPerSensor + 5];
            Log.i(TAG, Double.toString(frame.ax) + " " + Double.toString(frame.ay) + " " + Double.toString(frame.az) + " " + Integer.toString(timestamp));
            sendNewData(frame);
        }
        if (sensorType == Sensor.TYPE_GYROSCOPE) {
            frame.gx = data[i * mDataEntriesPerSensor + 3];
            frame.gy = data[i * mDataEntriesPerSensor + 4];
            frame.gz = data[i * mDataEntriesPerSensor + 5];
            sendNewData(frame);
        }
        if (sensorType == Sensor.TYPE_MAGNETIC_FIELD) {
            frame.mx = data[i * mDataEntriesPerSensor + 3];
            frame.my = data[i * mDataEntriesPerSensor + 4];
            frame.mz = data[i * mDataEntriesPerSensor + 5];
            sendNewData(frame);
        }


    }
}
 
开发者ID:gradlman,项目名称:SensorLib,代码行数:57,代码来源:SmartWatch.java


注:本文中的com.google.android.gms.wearable.DataMap.getFloatArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。