Sets the frequency of accelerometer events. The min frequency is 10 Hz and the max is 100 Hz on the iPhone. Accelerometer events are a significant drain on battery, so only increase the frequency when you need faster responses as in games. Always try to lower the frequency whenever possible to conserve battery life.
Related Items:
Accelerometer Events
system.setAccelerometerInterval( frequency )
-- Set the measurement interval to 50 Hz. -- This makes the system take 50 measurements per second. system.setAccelerometerInterval( 50 )
frequency
Sets the sample interval in Hertz.
Hertz is cycles per second, or in this case, the number of measurements to take per second. So, if you set the frequency to 10, then the system will take 10 measurements per second.
Maximum value allowed: 100 Hz
Minimum value allowed: 10 Hz
Nothing.
im using system.setAccelerometerInterval( 65 ) and im getting the same warning as caprica 13
Reset when I close my app?
I am setting it to 90 for my app. Before I close my app, should I reset this to a lower number or will iOS do the automatically to conserve power when my app closes?
I'm not using the accelerometer at all in my app, except to automatically adjust based on landscapeLeft and landscapeRight orientation. Do I need to set this value or is the default already set to infrequent polling?
system.setAccelerometerInterval( 100 )
Ok, I tried only 1 line code
on the latest version corona sdk: 2011.704. And the warnings occurred ,
WARNING: Accelerometer events are only available on the device.
WARNING: Accelerometer frequency on iPhone must be in the range [10,100] Hz
Why?
fatalita,
It turns out that the setAccelerometerInterval() was logging a warning for valid values. This is a bug and will be fixed in the next daily build. That said, this warning message is harmless and Corona will still use the value you gave it as is.
The following warning message only happens on the simulator. This is by design and is not a bug. This is because the accelerometer is only supported on iOS and Android.
>> WARNING: Accelerometer events are only available on the device.
Hey guys,
Any chance we could get some feedback from the multi-touch and accelerometer inputs on a device connected to the Corona SDK, like in Unity and the Unity Remote App? I'm not talking about sending a screen grab to the device, I just want input feedback, it is kinda crucial during all stages of development.
You have to agree it is a virtual nightmare trying to develop accelerometer interactions with what amounts to complete guess work where the accelerometer events are concerned.
I have no idea how it does it, but the Unity Remote App running on a device connected to the dev kit, it provides instant feedback to any input on the device ( such as tilt, shake, touch, multi-touch) even though the code is running on the development kit (not running on the device, just the dev kit).
So rather than build, wait and install into iTunes then to a test device to get any result, as is necessary in Corona SDK, can't your tech guys come up with a slick solution to input responses, such as touch, multi-touch and accelerometer? Please? :)
IPete2.
[edit] okay I have found the apps with code to help here, but is this the only way to work with the varied input mechanisms ? ]
Peter,
We do not have a means of testing an app's accelerometer handling on the desktop simulator. I do like your idea of using an iOS/Android app for providing accelerometer input to the simulator, but I don't see that happening anytime soon.
In the meantime, my best recommendation is to add print statements to your accelerometer Lua listener, build/install the app onto your device, and then monitor the device's log to make sure it is working correctly. I know on Android, it is easy to install the app onto the device and view a real-time log via USB. You should be able to do the same on iOS.
Hi Joshua,
Thank you for the detailed reply.
For the iOS devices I have come across a couple of apps which help monitor the inputs, which is a great start. I only found it this afternoon, but I would still be at the beginning of the Accelerometer input development for my app without it. It has helped me explore the options and find which are not suited to what I want.
Now I just have to find the method which will work properly for me, which should take a lot less time now.
I love Corona SDK. :)
IPete2.
Peter,
If it helps you any, the Corona SDK includes a sample app "Hardware\Accelerometer1" that displays real-time raw accelerometer data onscreen. Also, I'll make sure to write up a feature request for your app idea for feeding sensor input to the simulator.
Good luck with your app!
It would be helpful to list the default frequency on this API page.
On iOS, the default is not documented by Apple (Please see the link below). Based on past observations, the frequency is low; like around 10 Hz.
https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIAccelerometer_Class/Reference/UIAccelerometer.html
On Android, the default is about 10 Hz (exact timing is definitely not guaranteed).
To be safe, you should set this yourself.
whether I use system.setAccelerometerInterval( 10 ) or system.setAccelerometerInterval( 60 ) I get the following warning: "WARNING: Accelerometer frequency on iPhone must be in the range [10,100] Hz" ... is this normal, do I need to change anything ?