Created
April 12, 2014 21:04
-
-
Save jamesmontemagno/10556784 to your computer and use it in GitHub Desktop.
Sensor Changed Logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int stepCounter = 0; | |
private int counterSteps = 0; | |
private int stepDetector = 0; | |
public void OnSensorChanged (SensorEvent e) | |
{ | |
switch (e.Sensor.Type) { | |
case SensorType.StepDetector: | |
stepDetector++; | |
break; | |
case SensorType.StepCounter: | |
//Since it will return the total number since we registered we need to subtract the initial amount | |
//for the current steps since we opened app | |
if (counterSteps < 1) { | |
// initial value | |
counterSteps = (int)e.Values [0]; | |
} | |
// Calculate steps taken based on first counter value received. | |
stepCounter = (int)e.Values [0] - counterSteps; | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment