working with buffers

Can any one point me to some simple examples of working with buffers?

What I mean by this is if I have a 16bit buffer as below

0000111100001111

and i want to update the 10th and 11th bit to 11 to result in

0000111101101111

or i have 10 X 8bit values that I want to join in to a 80bit buffer and then take take the last 20bits and move it to the start.

I have been playing with LED light strips and at the moment if I want to update the 10th LED in a 60LED stip my current way of doing it is to use variables and loops, but this means that if i change a single LED I have am looping though the entire strip to recreate the buffer ready to output it to the strip.

I would like to lean how to do this more efficiently by editing the buffer directly and just swapping the bits needed.

Buffers might not be the correct term I should be using for asking this but hopefully its enough to get the point across of what I am looking for.

And just looking for some simple examples to play with. And its not just for this project but just leaning better methods of handling memory.

Thank you

Hi DevilWAH,

I am learning this as well right now. Some bookmarks I have that might be of interest...

For manipulating bits research the terms bitwise and bitshift.
Also the function list under "Bits and Bytes" on the Arduino Reference page,

For receiving bytes through serial Function List and explanations and Serial Input Basics - updated

Cheers for that. it lead me on to this.

http://playground.arduino.cc/Code/BitMath#binary

seems to be very reverent to what I am looking for, and lots of examples of bitwise operations.

The arduino environment allows to a double, 32 bits unsigned.

Your need for 80 bits is an issue, unless you say store the first 32, next 32 and the remaining 16 in separate doubles?

Johnny010:
The arduino environment allows to a double, 32 bits unsigned.

Your need for 80 bits is an issue, unless you say store the first 32, next 32 and the remaining 16 in separate doubles?

Is this not talking about how mach data you can carry out a single operation on.

I am looking at direct memory access, and in this particular case sending data via SPI using SPI.h

so to be able to write and arbitrary length of data in to memory, and then send it in 8bit chunks (as this is what the SPI.h library does, takes the first location in memory and the length of the date)

So using pointers I should be able to write any length of data to the memory by writing a bit at a time. You should be able to write 4000bits of data concurrently in memory as long as your write / read them in <64 bit operations. using direct memory access.

DevilWAH:
Is this not talking about how mach data you can carry out a single operation on.

I am looking at direct memory access, and in this particular case sending data via SPI using SPI.h

so to be able to write and arbitrary length of data in to memory, and then send it in 8bit chunks (as this is what the SPI.h library does, takes the first location in memory and the length of the date)

So using pointers I should be able to write any length of data to the memory by writing a bit at a time. You should be able to write 4000bits of data concurrently in memory as long as your write / read them in <64 bit operations. using direct memory access.

I am unsure about what is stopping you then?
I am also unsure as to what you mean by "Direct memory access" in this case. It sounds very much like you want the CPU to use the data to send via SPI...Direct Memory Access (DMA) would suggest otherwise...

so to be able to write and arbitrary length of data in to memory

Code? The only way to "write arbitrary data" in to memory (RAM) is by declaring a byte array...which sort of already sorts your issue...

PS: "a bit at a time" sounds like you have a protocol issue. Packets should be of known length and structure.