示例#1
0
        private async Task UpdateStepsAsync()
        {
            if (_stepCounter != null)
            {
                StepCounterReading reading = null;

                bool res = await CallSensorCoreApiAsync(async() => { reading = await _stepCounter.GetCurrentReadingAsync(); });

                if (reading != null && res)
                {
                    _mainModel.StepsToday   = reading.WalkingStepCount + reading.RunningStepCount - _firstRunningSteps - _firstWalkingSteps;
                    _mainModel.WalkingSteps = reading.WalkingStepCount - _firstWalkingSteps;
                    _mainModel.RunningSteps = reading.RunningStepCount - _firstRunningSteps;
                }
            }
        }
示例#2
0
 /// <summary>
 /// Displays current step counter reading
 /// </summary>
 /// <returns>Asynchronous task</returns>
 private async Task ShowCurrentReading()
 {
     await CallSensorcoreApiAsync(async() =>
     {
         // Get current reading from the sensor and display it in UI
         var reading = await _stepCounter.GetCurrentReadingAsync();
         SensorcoreList.Items.Add("Current step counter reading");
         if (reading != null)
         {
             SensorcoreList.Items.Clear();
             SensorcoreList.Items.Add(reading.Timestamp.ToString());
             SensorcoreList.Items.Add("Walk steps = " + reading.WalkingStepCount);
             SensorcoreList.Items.Add("Walk time = " + reading.WalkTime.ToString());
             SensorcoreList.Items.Add("Run steps = " + reading.RunningStepCount);
             SensorcoreList.Items.Add("Run time = " + reading.RunTime.ToString());
         }
         else
         {
             SensorcoreList.Items.Add("Data not available");
         }
     });
 }