Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tap_callback bug during sleep() #220

Open
kjjohnsen opened this issue Jun 13, 2024 · 1 comment
Open

tap_callback bug during sleep() #220

kjjohnsen opened this issue Jun 13, 2024 · 1 comment

Comments

@kjjohnsen
Copy link

kjjohnsen commented Jun 13, 2024

Currently, the tap callback appears to "queue" one callback while the frame is sleeping.

function handle_tap()
    print('got tap')
    if can_tap then
        can_tap=false
        print('allowed tap')
        frame.sleep(5)
        can_tap=true
    end
end

can_tap=true
frame.imu.tap_callback(handle_tap)

When tapping again (anytime during the roughly 5 second period), this code will result in a print of 'got tap', 'allowed tap', 5 second delay, then 'got tap', 'allowed tap' again. It only appears to queue one tap callback, such that tapping 3 times has no additional effect.

[Edit] I believe that this functionality is somewhat normal, but could be better explained. I think what is happening is that frame.sleep() is designed to wake on tap. But, frame.sleep(5) requires at least 5 seconds before waking up. So, it must still listen for tap, still wait the 5 seconds, then give the second tap immediately after wakeup. I was able to "detect" this by checking the time of the tap against the time it last woke up from sleep, but would prefer that you have some way to detect if the tap is waking the frame from sleep or if it's a tap while awake already.

@siliconwitch
Copy link
Member

Interesting bug. Will check this out thanks!

@siliconwitch siliconwitch changed the title tap_callback behavior tap_callback bug during sleep() Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants