Bugzilla – Bug 5501
Motion sensor should have some hysteresis
Last modified: 2008-12-15 12:37:43 UTC
I've noticed that the motion sensor tends to wake up the device with a little motion (like when I put something down on the table where the device is in its stand), but sometimes will sleep when I'm holding it. Waking up should require a bit more motion, but to stay awake should require less motion.
for recording purposes, I've created a patch locally that restarts the screensaver timer on any motion, but only breaks out if there are 4 events each within 100ms of each other. This needs more thought overall as the events can be sporadic. One clue is that a pick up usually triggers multiple axis events, while a bump is very heavily weighted to just ONE acis. It might also make sense to handle this deeper into the code such that events are reported only when there is a real movement, while also allowing raw access for things that need it. It also might only be needed for clocks, as opposed to all screensavers. Clearly a need for a meeting for sort this out. anyway, I'll leave my working patch here for the record (in case I lose it at home). Index: ScreenSaversApplet.lua =================================================================== --- ScreenSaversApplet.lua (revision 534) +++ ScreenSaversApplet.lua (working copy) @@ -22,6 +22,7 @@ local ipairs, pairs, tostring = ipairs, pairs, tostring local oo = require("loop.simple") +local math = require("math") local Applet = require("jive.Applet") local AppletManager = require("jive.AppletManager") @@ -70,8 +71,47 @@ Framework:addListener( EVENT_KEY_PRESS | EVENT_SCROLL | EVENT_MOTION, function(event) - self.timer:restart(self.timeout) + + -- accumulate and check motion events when screensaver active + -- one event above min thresholds will reset screensvaer timer + if event:getType() == EVENT_MOTION then + local x, y, z = event:getMotion() + -- threshold values for motion sensing + local minx, miny, minz = 30, 30, 30 + + x,y,z = math.abs(x),math.abs(y),math.abs(z) + + -- short circuit for low motion events + if (x < minx and y < miny and z < minz) then + log:debug('Motion event below thresholds') + return EVENT_UNUSED + end + + self.timer:restart(self.timeout) + + local time = Framework:getTicks() + local interval= time - (self.lasttime or time) + + -- count up events within 100ms of each other + if interval < 100 and self.motioncount != nil then + self.motioncount = self.motioncount + 1 + else + self.motioncount = 0 + end + + self.lasttime = time; + + -- only pass if we have 4 events within 100ms of each other + if (self.motioncount < 4) then + log:warn('Tracking motion events ',self.motioncount,' interval=',interval); + return EVENT_UNUSED + end + + else + self.timer:restart(self.timeout) + end + -- allow active screensaver to process events if -- it is on top of the window stack if self.active == Framework.windowStack[1] then
side effect of a patch like that above is that the screensaver becomes re-entrant. Some other routine (wakeup maybe?) is watching MOTION events and causing the screensaver to be able to activate multiple times. thus, when you do really exit, you end up having to exit several layers of screensavers. Definite hint that this should be controlled at a lower level as part of the motion event itself.
Richard may update the status of this later today
I have changed the configuration of the motion sensor, so the gravity is removed with a high-pass filter before the threshold for the irq. These seems to work much better (along with the application changes from kdf in jive_bsp.c). I'll mark this as fixed for now, but if after trying the latest binary you still think this is a problem please reopen the bug.
This bug has now been fixed in the 7.1 release version of SqueezeCenter! Please download the new version from http://www.slimdevices.com if you haven't already. If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.
This bug has been fixed in the 7.3.0 release version of SqueezeCenter! Please download the new version from http://www.slimdevices.com/su_downloads.html if you haven't already. If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.