Skip to content

Instantly share code, notes, and snippets.

@tomgidden
Last active November 24, 2017 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomgidden/875b5a5522deeabd9d1ef389607e434a to your computer and use it in GitHub Desktop.
Save tomgidden/875b5a5522deeabd9d1ef389607e434a to your computer and use it in GitHub Desktop.
Espruino Puck.js code for Page-Turn-O-Matic 4000™
@tomgidden
Copy link
Author

tomgidden commented Jun 10, 2017

As mentioned in the comment, this is currently broken on both my pucks.

Gordon's suggestions incl. setLowPowerConnection(true): this decreases the frequency of polling of the puck by the computer from 50Hz to <1Hz. However, it makes debugging hard and messes with the double-click, so it's currently disabled.

The alternative is to modify the advertisement. That's what's probably causing (or at least, catalyzing) the NRF ERROR 0x8.

NRF.sleep() and NRF.wake() play with advertisement; I think the key is understanding how the process works (which I'm currently getting to grips with)

Getting the tablet/desktop to stop listening is a problem; as this works by polling, the process is largely one way. The tablet must listen (connect and then wait for advertisement) if it is to resume clicking. I'm not sure how best to get this going. I wonder if the book might help... hmm.

@tomgidden
Copy link
Author

This new commit (5) is back to basics (again). It just does an NRF.disconnect(), which should perform NRF.sleep(). It doesn't mess with advertising or anything. It seems to work.

@tomgidden
Copy link
Author

Problems with multiple events led to encapsulating the entire thing in init, adding E.removeAllListeners() and NRF.removeAllListeners(), clearWatch(), etc.

Serial console helped diagnose some issues, but also heisenberged it a bit.

Seems to work now; going to try battery usage again next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment