I'm using the HID Keyboard example - espruino.com/Puck.js+Keyboard plus simple LED on/off with button press/release - to try to send a single keypress to an iPad.
While it sometimes works, once it's cut off it does nothing: the LED still lights when pressed so the code's still working, but there's no effect on the iPad. The Puck is still paired and connected with the iPad.
Now, I've noticed github.com/espruino/Espruino/issues/1101 and some other ideas, but what's really tricky is the limitation that the Puck must be disconnected from the IDE to pair it with the iPad: only one connection at a time. It means I have no error messages visible to debug the problem.
My NoName™ FT232 USB-to-serial board is not working for some reason - probably lack of flow control - and the wiring is unwieldy, so I was thinking the other Puck I got from Kickstarter might be an easy way to do it. Failing that, I might rope a spare Pico in to act as a dumb serial converter.
So, I guess my question is, what's a straightforward way to cross-connect the serials of one Puck with another Puck, so the IDE (or at least the command-line errors) can be viewed while still connected as a HID device? Or, any other approaches to try?
Wow, that's pretty extreme! I'd say try using a Pico if your USB-TTL converter doesn't work - the flashing code for espruino.com/ESP8266 actually sets a Pico up as a pass-through.
With Puck-Puck there's a bit of a catch-22. The serial port takes power, so won't initialise itself if the Puck is powered on without serial connected (the RX pin pulled high). Obviously if you connect 2 Pucks together neither will initialise, so you'd have to manually enable serial on one first with Serial1.setup.
I actually fixed a whole bunch of HID-related bugs just recently, so first it might be worth trying the attached zip file.
I'm still trying to get it working stably, but the attached build just happens to work fine by the look of it. There are 2 issues that might cause problems that the recent build fixes:
Ah, okay... I'm DFU'ing that build now, thanks.
I was thinking exactly of that Pico pass-through code before I wondered if I could use a second puck. I see what you mean about the Catch-22.
Anyway, I'll try this out. FYI, this is how it's being used:
Cool - what's the idea? Is that some kind of rubbery gauntlet thing?
It's actually rigid: Thermomorph / Polymorph, ie. polyester plastic that melts in hot water.
It's so that when I'm relaxing and recovering from back pain, lying down, I can just turn page on iBooks on iPad by sending a "right" keypress. That way I don't have to hold the iPad or reach up to turn page, thus saving my shoulder and upper back muscles from unnecessary tension.
Incidentally, I haven't managed to get the new firmware talking yet. In fact, it's having trouble connecting to the Web IDE. I think my Mac needs a reboot. Still trying.
Nope.. this build seems to just do a full reset (RGB LEDs all to full for about a second, then off, then a short red blink) when I try to connect to it via Web IDE, or pair it with the iPad.
I'm going to DFU it again to make sure it's not my code, but I doubt it.
That's really neat! I'd love to see Puck.js used for some more stuff like this!
I guess you could detect long presses (or maybe even use the magnetometer) and mimic other keypresses with it.
That's odd - maybe it's an issue with saved code (I had to move the saved code location and it might be messing up the pairing).
Can you try this on a working firmware, and then uploading the new one?
var f = require("Flash");
Okay, that did the trick: I DFU'ed to 1.91, did the lines above, and then DFU'ed to 1.91.715. It now pairs more successfully.
However, it hasn't been entirely successful. It took about three goes of code tweaking, re-upload, resets, unpair/pair before the iPad would actually do the "page right" function. It's working okay now, even after an NRF.disconnect(). I'll keep an eye on it and see if it stops working again.
FYI: at least with this firmware, onInit() doesn't seem to work. Once reconnected, dump() yields garbage.
Thanks for checking - I'll make sure I do something about wiping the old saved code in the final version.
Odd about the dump() problems though. I'll take another look - it's all really flaky at the moment for some reason - I've had a lot of problems with the Nordic peer management stuff :(
(Incidentally, I've just written up the project)
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem