Doing simple linear from the 1st sample:

When we start we will have:
originalX at time originalTime

When a sample arrives we will have:
currentX at time currentTime

Therefore the rate of change of X to now is given by:
rateX = (currentX – originalX) / (currentTime – originalTime)

So time needed to get to endX (your value 40) from currentX
timeNeeded = (endX – currentX) * rateX

However if currentX is fluctuating a large amount then so will
timeNeeded.  You can use this approach with more points (taking their
average) for a more stable approximation.



On Oct 3, 6:08 pm, Lance Nanek <[email protected]> wrote:
> When you first go above the start threshold then set a member variable
> to the time. When you go above the end threshold then subtract that
> from the current time to get the time elapsed.
>
> On Oct 3, 11:43 am, Sonic <[email protected]> wrote:
>
> > Hi All,
>
> > I'm wondering how I would go about the following:
>
> > An int value is sent to a textview called X for example, the value of
> > X is constantly changing, so x could equal any int. Now what Im unsure
> > how to implement is, if we say X equals 10, I want to be able to time
> > how long it takes inbetween the time X would be equal to 40 for
> > example. The values of X = 10 and X = 40 are not going to be constant
> > it will be gradually increasing, so all as I want to do is time how
> > long it takes in seconds to reach a predefined value of X.
>
> > Any ideas chaps?
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to