Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

System.timer not updating during accelerometer events
Started by tap32 Jan 29 2020 03:20 AM

No replies to this topic
ios system.gettimer accelerometer
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

tap32

[GLOBAL: userInfoPane.html]
tap32
  • Contributor

  • 257 posts
  • Corona SDK

A rare issue: I have an app which records accelerometer data to a CSV file. After about 23000 rows I have noticed something strange in the recorded data: the value returned by system.getTimer() stops changing. My code roughly looks like this:

system.setAccelerometerInterval(100)
local startMillis=system.getTimer()

local function logData(event)
  logValues(system.getTimer()-startMillis ....-- log accelerometer event data)
end

Runtime:addEventListener("accelerometer", logData)

The value logged (system.getTimer() - startMillis) for about 300 events is the same. As startMillis is not written to after it is set, and the value continues to increment sensibly after this block of 300 events, I assume that the system.getTimer() returned the same value for 300 calls. I log all the accelerometer event fields and the gravity values are not duplicated, so a single accelerometer event was being repeated. The deltaTime fields are also relatively constant during this block of events.

 

So in short: for 300 calls system.getTimer seems to have returned a constant value. Either 300 individual accelerometer events were processed during the same frame, or something funny happened to the system clock.

 

During these 300 rows I see two suspects: a big jump in the value returned by os.date("%H:%M:%S") (about 6 seconds) and a deltaTime value of 11 seconds.

 

I am assuming that something went wrong with the device's clock. Has anyone else come across this or know what might influence the value returned by system.getTimer(), or is it possible that 300 accelerometer events were batched together an processed in the same frame?




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: ios, system.gettimer, accelerometer