I'm currently helping a friend building an animated "mask" from the LoL game, as seen on the following picture:
We plan to have a total of 8 different "mouths", and the idea is to use a set of daisy-chained leds positioned within different "cavities" to represent each desired "leds combo": by turning on or off leds in different "cavities", we display the mouth n ( more or less like a "segment display", but using LEDs )
The goal is to be able to start scheduled transitions betweens mouths at the press of the start button
Now, onto the needy greedy:
POC BOM:
currently using an Original Espruino board as controller
2 x tactile switches to act as 'start' & 'reset' buttons
a PowerBoost 500C to boost [3.7V .. 4.2V] to 5V ( to power the LEDs & the Espruino board )
a 18650 12000mAh Li-Ion battery
APA102 ( or is it APA102C or another clone ? ) LEDS strip ( 25 of them )
The charger/booster may be replaced by the 1000C version ( allowing up to 2A, in contrary to the 500C which is said to provide 1A from 3.7V batteries - although I'm driving 16 LEDs while testing since it shall draw max (60mA/led)*16= 960mA )
It seems I'm getting somewhere in driving the LEDs thanks to this posts:
Thing is, I'm now sure these HAVE to be driven at 5V ( else I got erratic colors powering 1, 3 or 16 of those through the 'Bat' pin on the original Espruino board) so powering those from 3.7V battery directly is a no-go, but I'm unsure of the best setup to control them: the SPI seems to be 'somewhat glitchy', and I'm guessing sure this comes from the pin config and not the spi.write calls themselves.
I tried with a level shifter, no success
I tried with 'af_opendrain' & 1.5k pullup resistors to 5v, no success
I tried with directly wiring Espruino pin ( B3 sck & B5 mosi ), success ONLY with software SPI
I had some relative success driving 16 LEDs ( powered from BoostCharger 5V - actually 4.87V ) directly wired to B3 & B5, but in my tests, 'setInterval' wasn't 'as precise' as in my earlier test sketch ( in which I was using an OLED screen to display the mouth index & the timeout before a mouth update ). As the goal is to have 'somewhat precise' schedule for mouth updates, I think I have some things to pack right for this goal to be met ..
So here goes the questions:
1: IYO, what 'd be the best way to wire to those Sck & Data pins ?
2: any way to get hardware SPI working to increase the refresh rate & lessen cpu usage ?
3: would 'compiled' code helps in getting more precise & faster 'scheduled updates' ?
4: am I driving these correctly at all ? ( or what may the 'spi behavior'* come from ? )
*I find it quite weird that software spin kinda works but hardware doesn't
The debug code currently used to drive the LEDs is the following
// -- extracts from APA102 test code --
var spi = undefined;
// ...
spi = new SPI();
spi.setup({miso:B4, mosi:B5, sck:B3, mode:1,order:"msb", baud: 4000000}); // seems ok for software spi
// ...
// driving 3 LEDS
// syntax
//spi.write(0,0,0,0, 0xe0+31,255,0,0, 0xe0+31,0,255,0, 0xe0+31,0,0,255, 0xFF ); // 1st R 2nd B 3rd G
// ..
var myArr = [
new Uint8Array([0,0,0,0, 0xe0+31,255,255,255, 0xe0+31,255,0,0, 0xe0+31,0,10,0, 0xFF]),
new Uint8Array([0,0,0,0, 0xe0+31,255,255,255, 0xe0+31,255,0,0, 0xe0+31,255,255,255, 0xFF]),
new Uint8Array([0,0,0,0, 0xe0+31,0,0,255, 0xe0+31,255,0,0, 0xe0+31,255,255,255, 0xFF]),
new Uint8Array([0,0,0,0, 0xe0+31,255,0,255, 0xe0+31,255,255,255, 0xe0+31,255,255,255, 0xFF]),
new Uint8Array([0,0,0,0, 0xe0+31,255,0,0, 0xe0+31,0,0,0, 0xe0+31,255,255,255, 0xFF]),
new Uint8Array([0,0,0,0, 0xe0+31,255,0,0, 0xe0+31,0,255,0, 0xe0+31,0,0,255, 0xFF])
];
var idx = 0;
var max = myArr.length;
function loopOver(){
//console.log(idx);
if(idx+1 < max) idx++;
else idx = 0;
spi.write(myArr[idx]);
}
//var timr = setInterval(loopOver, 200);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi there !
I'm currently helping a friend building an animated "mask" from the LoL game, as seen on the following picture:
We plan to have a total of 8 different "mouths", and the idea is to use a set of daisy-chained leds positioned within different "cavities" to represent each desired "leds combo": by turning on or off leds in different "cavities", we display the mouth n ( more or less like a "segment display", but using LEDs )
The goal is to be able to start scheduled transitions betweens mouths at the press of the start button
Now, onto the needy greedy:
POC BOM:
The charger/booster may be replaced by the 1000C version ( allowing up to 2A, in contrary to the 500C which is said to provide 1A from 3.7V batteries - although I'm driving 16 LEDs while testing since it shall draw max (60mA/led)*16= 960mA )
It seems I'm getting somewhere in driving the LEDs thanks to this posts:
Thing is, I'm now sure these HAVE to be driven at 5V ( else I got erratic colors powering 1, 3 or 16 of those through the 'Bat' pin on the original Espruino board) so powering those from 3.7V battery directly is a no-go, but I'm unsure of the best setup to control them: the SPI seems to be 'somewhat glitchy', and I'm guessing sure this comes from the pin config and not the spi.write calls themselves.
I had some relative success driving 16 LEDs ( powered from BoostCharger 5V - actually 4.87V ) directly wired to B3 & B5, but in my tests, 'setInterval' wasn't 'as precise' as in my earlier test sketch ( in which I was using an OLED screen to display the mouth index & the timeout before a mouth update ). As the goal is to have 'somewhat precise' schedule for mouth updates, I think I have some things to pack right for this goal to be met ..
So here goes the questions:
*I find it quite weird that software spin kinda works but hardware doesn't
The debug code currently used to drive the LEDs is the following