Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

accelerator updaterate

hi everyone
im new to appcelerator titanium and i wonder if its possible to increase the updaterate of the accelerometer. if im right im getting only all 91ms an update from the axis and i need more.
is it possibl to push the rate of measuring? or do i need to work with that info i got from it?

— asked September 20th 2010 by Ramona Vincenti
  • accelerator
  • mobile
  • update
0 Comments

2 Answers

  • I encountered similar problem and here is my own solution.

    Open your project by Xcode.
    Update AccelerometerModule.m
    Search
    [[UIAccelerometer sharedAccelerometer] setDelegate:self];

    ABOVE the line, add the following code;

    [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0/ [SAMPLING HZ])];

    [SAMPLING HZ] is the rate you want to use ; e.g. SAMPLING HZ = 50 = 20ms

    BUILD and RUN ; test it on your device.

    — answered October 28th 2010 by Tom Hui
    permalink
    1 Comment
    • This worked great! Thanks. And I'll add — if you modify the SDK's Titanium project, the changes will be reflected every time you build in Titanium Studio (need to clean your projects first). Here's the path:

      ~/Library/Application Support/Titanium/mobilesdk/osx/[YOUR-SDK-VERSION]/iphone/iphone/Titanium.xcodeproj

      — commented October 21st 2012 by Jonathan Beebe
  • hi guys,
    is there a way to pass a variable from javascript to object-c code?

    i'd like to have something like that in javascript code:

    var setUpdateInterval = 50;

    and in object-c code have this:
    [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0/50)];

    so i can change the update interval from javascript.

    thx

    — answered March 16th 2011 by Enrico Vedovo
    permalink
    1 Comment
    • Has anything happened with this? It would be great to have control of the update rate from JS.

      — commented July 10th 2013 by Joseph Beuckman
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.