GetCurrentReading() public method

public GetCurrentReading ( ) : AccelerometerReading
return AccelerometerReading
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     accelerometer = Accelerometer.GetDefault();
     if (accelerometer == null)
     {
         MessageBox.Show("不支持加速度计传感器");
         return;
     }
     Debug.WriteLine(accelerometer.MinimumReportInterval);
     accelerometer.ReportInterval = accelerometer.MinimumReportInterval * 2;
     accelerometer.ReadingChanged += accelerometer_ReadingChanged;
     accelerometer.Shaken += accelerometer_Shaken;
     accelerometerReading = accelerometer.GetCurrentReading();
     ShowData();
 }
        // Connect to the BLE device and send the data
        private async Task UpdateAllData()
        {
            if (device == null)
            {
                Debug.WriteLine("Device NULL");
                return;
            }


            // Heartbeat Data
            var heartRateHex = bs.GetHeartRateHexForMioty();

            // Configure and send Heartbeat data using the AT command
            var HeartbeatData = ATCMGS.Concat(HEARTBEAT_SIZE_CR).Concat(HEARTBEAT_ID).Concat(heartRateHex).Concat(AT_SUFFIX).ToArray();

            await MiotyTransmitter(character, HeartbeatData, "Heartbeat");

            // Accelerometer Data
            _accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault();
            if (_accelerometer == null)
            {
                Debug.WriteLine("No accelerometer found");
            }

            // Configure and send Accelerometer data using the AT command
            AccelerometerReading reading = _accelerometer.GetCurrentReading();

            _accelerometer = null;

            var AccelerometerHex = ConvertAccelerometerForMioty(reading);
            var AccelData        = ATCMGS.Concat(ACCEL_SIZE_CR).Concat(ACCEL_ID).Concat(AccelerometerHex).Concat(AT_SUFFIX).ToArray();

            await MiotyTransmitter(character, AccelData, "Accelerometer");

            // NFC Data
            if (bNFCText)
            {
                var NFCHex = StringIntoHexForMioty(NFCText);
                var Size   = IntIntoHexForMioty(NFCHex.Count() + 2);

                var NFCData = ATCMGS.Concat(Size).Concat(CR).Concat(NFC_ID).Concat(NFCHex).Concat(AT_SUFFIX).ToArray();

                bNFCText = false;
                await MiotyTransmitter(character, NFCData, "NFC");
            }
            return;
        }
Beispiel #3
0
 private void A_Changed(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
 {
     calcDirection(sender.GetCurrentReading());
 }
Beispiel #4
0
 void accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
 {
     AccelerometerReading ar = sender.GetCurrentReading();
     AccelerometerVect = new Vector3((float)ar.AccelerationX, (float)ar.AccelerationY, (float)ar.AccelerationZ);
 }