Hi all.
Due to very limited space I'm considering using the APA102-2020 LED's on a project, no great amount, just 8 of them in the end of 3mm diameter plastic tubes.
I've looked at the datasheet & see how each [LED frame] comprises 32 bits - I'm aware of start & end frames.
<8-brightness> <8-blue> <8-green> <8-red>)
My query is, if I want to change, as an example, say, just LED 4 - in my line of 8 - how do I write [specifically] to that LED, or do I need to update them all, to change LED number 4?
, just LED 4 - in my line of 8 - how do I write [specifically] to that LED,
The exact code depends on the library you are using. For example in the AdaFruit library you use the setPixelColor method of the library. So assuming you have created an instant of the library called pixels you would use:-
pixels.setPixelColor(4, pixels.Color(120, 160, 64)); // where this numbers are the brightness of green, red, blue
pixels.show();
Note all the pixels are updated but you only change the ones you want to change, the rest stay the same.
This is because all the LED frames are stored in an array in the memory and the show method goes through them all and sends them out to the strip or chain of LEDs.
There is no way of changing one LED in the strip because they are not individually addressable, but the show method achieves exactly the same effect.
From further investigations last night I found that each LED removes an LED-frame from the data sequence, then pass along to the next LED .
My application will be PIC based, written in assembler, being synchronous led's they should prove easier than the time-critical asynchronous WS2812 family, although I chose these due to their size.
They're for a model same as this, the next one needs three colours in each engine air-intake pipe.
So you need to create an array to hold all the data, and write a function to place and replace your data frames in the correct slot in the array. The preamble and postamble can be written as functions there is no need to store these.
I did write some code to do this but it is in Python.
Yes, the programming's quite simple, just a data table and using the RETLW instruction, , or, as I enjoy compacting my programs as small as possible I could assign each of the 8 intake pipes as D7-D0, then decode an 8 bit literal from a table, in bytes of three [for each colour], and maybe a fourth byte to hold the delay routine's 'repeat' number, that would really compact it down...
I may use the 6-pin PIC10F322 device, with just 896 bytes of program memory it'll be the lowest size I've used, albeit it sufficient for my needs with either of the above programming approaches.