Skip to content

Instantly share code, notes, and snippets.

@tomgidden
Last active Nov 24, 2017
Embed
What would you like to do?
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

tomgidden commented Jun 20, 2017

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

tomgidden commented Jun 27, 2017

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