Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

freshking

macrumors newbie
Original poster
Feb 15, 2009
8
0
Hi,

in my app I use acceleration values. I have no problem reading and using them.
But now I want to read maximum acceleration values and store them. And if a new value which is larger pops up the old one gets updated. Just like a max needle in one of those acceleration meter apps.
I kind of have no idea how i'm supposed to do that. I always end up recieving the current values the accelerometer is recieving.
If somebody could show me how to do this, that would be really great. I think I have tried everything and have gotten nowhere.
Thanks alot!
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I think you'll need to create a variable to store the maximum acceleration value. When you read the current value, compare it to your stored value. If it's greater, update the max to the new value.
 

freshking

macrumors newbie
Original poster
Feb 15, 2009
8
0
Thats also how I would do it but there still are some issues. Some code to get started would be a really big help!
 

freshking

macrumors newbie
Original poster
Feb 15, 2009
8
0
Thats kind of also what I have been working on.
Assuming your maxX is a float value these are the values i get for maxX:

2009-02-15 20:42:15.402 G-Meter[645:20b] Acceleration value: 0.962936
2009-02-15 20:42:15.464 G-Meter[645:20b] Acceleration value: 0.999273
2009-02-15 20:42:15.500 G-Meter[645:20b] Acceleration value: 0.054506
2009-02-15 20:42:15.688 G-Meter[645:20b] Acceleration value: 0.181686
2009-02-15 20:42:15.742 G-Meter[645:20b] Acceleration value: 0.763081
2009-02-15 20:42:15.774 G-Meter[645:20b] Acceleration value: 0.526890
2009-02-15 20:42:15.827 G-Meter[645:20b] Acceleration value: 0.018169
2009-02-15 20:42:16.127 G-Meter[645:20b] Acceleration value: 0.181686
2009-02-15 20:42:16.171 G-Meter[645:20b] Acceleration value: 0.962936

They constantly change up or down but I only want the maximum value.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.