代码之家  ›  专栏  ›  技术社区  ›  Johannes Jensen

iPhone : Does a rapidly updating (60Hz) accelerometer drain battery?

  •  7
  • Johannes Jensen  · 技术社区  · 14 年前

    I'm making an accelerometer-based app using cocos2d, and I noticed that it's possible to set the accelerometer update interval.

    [[UIAccelerometer sharedAccelerometer] setUpdateInterval: (1.0f / 60.0f)];
    

    Is updating the accelerometer very often like this (60 times a second) a significant battery drain?

    4 回复  |  直到 11 年前
        1
  •  9
  •   johne    14 年前

    According to the LIS302DL 加速度计数据表,在100Hz的更新率下消耗约0.75 mwatts的功率,在待机模式下消耗0.0025 mwatts的功率(即没有读数)。

    So, the short answer is "Yes", but off the top of my head, I can't put those numbers in perspective to give you an idea of, say, "how many minutes of on time" it drains from the battery.

    My recommendation would be to do a bit of testing. 找到提供满意结果的最低更新率。

        2
  •  15
  •   Donnie    11 年前

    Given the numbers in the accepted answer the power usage by the actual accelerometer is trivial. Your real hit will come from your app having to process the events and thus making the CPU not sleep more often.

    3GS有一个4.51瓦时的电池。当以100赫兹的频率运行时,只有加速度计的放电会在(大约)6000小时内(假设0.75毫瓦的值是正确的)杀死电池。

    (Also, the iPhone 4 has a 5.25 Watt-hour battery, 4S 5.3 Whr and 5 5.45 Whr, in case you're curious)

        3
  •  2
  •   Brad Larson    14 年前

    Event Handling Guide for iPhone OS :

    When configuring the update interval for acceleration events, it is best to choose an interval that minimizes the number of delivered events and still meets the needs of your application. Few applications need acceleration events delivered 100 times a second. Using a lower frequency prevents your application from running as often and can therefore improve battery life.

    根据这一点,更新频率较高的代价可能是应用程序必须处理每个加速度计事件,而不是长时间闲置。

    此外,从 iPhone Application Programming Guide :

    If you use the UIAccelerometer class to receive regular accelerometer events, disable the delivery of those events when you do not need them. 同样,设置事件频率 delivery to the smallest value that is suitable for your needs.

        4
  •  1
  •   VOX    14 年前