Looks good - I think you actually want to leave out repeat:8 though - since what you want is to only output once per byte. [Pr1,Pr2,Pb1,Pb2,Pg1,Pg2] may be better off as [Pr2,Pb2,Pg2,Pr1,Pg1,Pb1] as well (see the 16 row comment below).
Also scan will need to be called repeatedly for you to see anything.
The code in the module is designed to run really quickly - so it uses a few hacks (most of which I think you picked up on!)
we only have 4 address bytes, how would we control 32 rows ? Seems to be a non Espruino questions, but may be you have some ideas
:) These RGB LED arrays scan out two rows at once. That's why you have R1 and R2, G1,G2,B1,B2.
Address 0 = row 0 and 16, 1 = 1 and 17, etc.
I think I mentioned in my email, but it means that you'll have to precalculate a new array that contains the image of the first 16 rows plus the image in the next 16 rows shifted left by 3 bits (and then use [Pr2,Pb2,Pg2,Pr1,Pg1,Pb1]).
However for testing the current code should work, and will drive the top or bottom 16 rows depending on what colours you use.
should we init enable to 1 ?
It looks like a good idea - but I doubt it'll matter too much as it'll get sorted once scan is called.
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.
Looks good - I think you actually want to leave out
repeat:8
though - since what you want is to only output once per byte.[Pr1,Pr2,Pb1,Pb2,Pg1,Pg2]
may be better off as[Pr2,Pb2,Pg2,Pr1,Pg1,Pb1]
as well (see the 16 row comment below).Also
scan
will need to be called repeatedly for you to see anything.The code in the module is designed to run really quickly - so it uses a few hacks (most of which I think you picked up on!)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
is the same as:
Except that it's significantly faster when you're calling it multiple times, since all the arguments that don't change have already been precalculated
There's an explanation in http://www.espruino.com/Reference#l__global_digitalWrite - again, it's a very fast way of pulsing the pin on and off while also setting the address pins.
:) These RGB LED arrays scan out two rows at once. That's why you have R1 and R2, G1,G2,B1,B2.
Address 0 = row 0 and 16, 1 = 1 and 17, etc.
I think I mentioned in my email, but it means that you'll have to precalculate a new array that contains the image of the first 16 rows plus the image in the next 16 rows shifted left by 3 bits (and then use
[Pr2,Pb2,Pg2,Pr1,Pg1,Pb1]
).However for testing the current code should work, and will drive the top or bottom 16 rows depending on what colours you use.
It looks like a good idea - but I doubt it'll matter too much as it'll get sorted once scan is called.