-
Hah, brilliant! I built a little library to make it a little simpler for myself – I kept mixing up pixel index and the fact that each one is made of 3 array elements.
-
-
-
I've got a Neopixel Ring (12 LEDs), and two Pucks. I know they run on different voltages, so I've connected the Neopixel to a 5v USB supply, and used an opto-isolator to drive the data pin at 5v from the Puck.
I can't figure out how to make it work, though.
I've cobbled this together from various posts that I've found, but I assume I'm doing something wrong (or the Puck can't do the data rate I need perhaps?):
const PIN = D30; const LEDS = 3; function main() { pinMode(PIN, 'output'); // I'm using 400000 here because I read they need a 4- or 8kHz stream, but no dice. SPI1.setup({ baud: 400000, mosi: PIN }); let arr = new Uint8ClampedArray(3 * LEDS); let idx = 0; for (let i = 0; i < LEDS; ++i) { arr[idx++] = 255; arr[idx++] = 0; arr[idx++] = 0; } console.log(arr); SPI1.send4bit(arr, 0b0001, 0b0011); } main();
I've confirmed that the isolator can do upwards of 50kHz, and that it's working (by using a plain LED and setting D30 high – it lights from the 5v rail).
Help! Thanks in advance.
-
-
I don't know what 'bias' means in this context.
I'm a developer, so confident of my code, but an electronics noob. Pretty sure it's working sensibly now, but either my breadboard has a bad connection with a wire, or I've soldered a wire badly. I wouldn't know how to share a schematic either, other than to take a picture of what I've got!
Thanks for your help though. 👍🏼
-
-
Oh! Well, that's interesting.
I've switched to using
SPI1.write(0b01000000, PINS.LATCH)
and that almost works perfectly, except when I turn two adjacent LEDs on, one of them is extremely dim. I suspect that's just bad wiring or low battery, since if I turn them on individually, they work fine.I can't believe it was such a simple mess up on my part. Thanks!
-
I've been trying to light a few LEDs using the above shift register without success. I'm having to translate from Arduino guides to Espruino/Puck.js, so undoubtedly I've got something wrong.
I've tried using
SPI1.setup()
as well aslet s = new SPI(); s.setup();
, but neither work.The options I'm passing to setup are:
let options = { sck: PINS.CLOCK, // miso: PINS.LATCH, mosi: PINS.DATA, order: 'lsb', mode: 0, };
And I've tried using
s.write([0, 1, 0, 0, 0, 0, 0, 0], PINS.LATCH)
as well as manually setting the latch low/high around the write.Wiring is as follows (the comment is the pin number on the shift register itself):
const PINS = { DATA: D28, // 14 LATCH: D29, // 12 CLOCK: D30, // 11 };
And finally, I've supplied power and ground where required (I think!), at pin 1 for ground, and pins 10 (SRCLR) and 16 (VCC) are high.
Absolutely any help at all will be massively appreciated. Thanks!
-
-
-
Amazing, thanks again!
I had a quick look but there don't appear to be docs specifically for building for the Puck, are there any special steps required? If I get it wrong, am I likely to brick my puck(s)?
If it's risky, I'm happy to wait for the next release – is there a release schedule, or just as and when there's enough fixes and features to warrant a new one?
-
This one causes the Puck to immediately crash and disconnect from BLE!
function go() { var users = [ { name: "Bob" }, { name: "Alice" }, { name: "Eva" } ]; console.log(users.map((u, i) => u.name)); }
It seems as follows:
u => u.name
works perfectly
(u) => u.name
isn't correctly passed its arguments (?)
(u, i) => u.name
crashes the device -
Oh, and another weird one with arrow functions: they don't seem to be passed values if defined with parentheses:
function go() { var p1 = new Promise(function (res, rej) { setTimeout(() => res(1), 250); }); p1.then(x => { console.log('Bare arrow:', x); }); p1.then((x) => { console.log('Parentheses arrow:', x); }); p1.then(function (x) { console.log('Regular:', x); }); }
Output:
Bare arrow: 1 Parentheses arrow: undefined Regular: 1
-
Interesting! You're right that wrapping into a function works, thanks!
This works:
function go() { var p1 = new Promise(function (res, rej) { setTimeout(() => res(1), 250); }); var p2 = new Promise(function (res, rej) { setTimeout(() => res(2), 300); }); Promise.all([p1, p2]).then(function () { console.log('done', arguments); }).catch(function () { console.log('FAIL'); }); console.log('Promise test'); } go();
Output:
Promise test =undefined done [ [ 1, 2 ] ]
But attempting to use ES6 arrow functions as the Promise executor causes the Puck to completely stop responding and require a powercycle before I can interact with it?
function go() { var p1 = new Promise((res, rej) => { setTimeout(() => res(1), 250); }); var p2 = new Promise((res, rej) => { setTimeout(() => res(2), 300); }); Promise.all([p1, p2]).then(function () { console.log('done', arguments); }).catch(function () { console.log('FAIL'); }); console.log('Promise test'); } go();
There's no output after the Espruino logo and version text, the console on the left stops working (can't type any text), and attempting to upload code seems to work, but doesn't execute.
I can disconnect and attempt to reconnect via BLE, which hangs at "Connecting..." – super weird! -
Huh, weird. I updated both my Pucks to the latest available (1v89 – I just checked my downloads folder).
@MaBe: interesting that your log messages are in a different order, too!
-
The following code demonstrates that
Promise.all()
never resolves:var p1 = Promise.resolve(1).then(function () { console.log('p1'); }); var p2 = Promise.resolve(2).then(function () { console.log('p2'); }); var all = Promise.all([p1, p2]).then(function () { console.log('done'); }).catch(function () { console.log('FAIL'); }); console.log('Promise test');
The output is:
p1 p2 > Promise test =undefined
-
-
-
-
I can't figure out how to upgrade the firmware. I've tried nRF Connect for iOS (no upload option), and for OS X desktop (it needs a "serial port" and can see none).
Do I need to borrow an Android phone, or is there some software I can use to get this done?
Edit: Aha, you have to use nRF Toolbox on iOS, not nRF Connect!
It's also not reasonable for them to reject app submissions that are merely bug fixes, but they do that, too…