LCD Display Moving Objects

The ultimate goal is to be able to display some image and move the whole image fluidly in any cardinal direction or diagonally.

If the LCD display could be controlled like a 2D array it would very simple to implement. You simply take the image's coordinates and make necessary shifts in the array index to move the image. With the only tricky part being figuring out how to wrap the image on boundaries.

However, with having to first specify a page, column, then writing a chunk of data at once I am not certain how to go about effectively moving an image.

My first idea is to generate a 2D array to keep track of the 128x64 pixel display (can only write to LCD anyway through serial with my display), then make all adjustments to this array. From here I can take this array and write all of its contents to the LCD display. Therefore, I am effectively refreshing the ENTIRE screen at a certain rate or when I need to make a change. The problems with this method is any update to the screen (even like a pixel) will be 1024 data writes (8 pages and 128 columns with auto-column address increments).

I am using the hardware SPI to have access to a data transfer rate of 84 MHz to 0.329 MHz. I believe with 128x64 and black and white this is not that much of an issue. However, if I ever had to use a display with a larger resolution or transmit more data like color I believe this process becomes incredibly slow. It would be preferred if I could somehow update the screen only when a change was made.

I guess I could have 2 2D arrays. One of the present image and one to be updated. I could somehow compare the two arrays and flag any page/column that needs to be updated. Then, use this to generate a list of data writes. However, this might be hardware resource heavy doing all of those compares and keeping track of all of this stuff.

So, I am asking for any feedback on what might be a better idea or alternative method.

In other words, sprites and blitting? It's really a whole subject in itself. As far as buffering and selective updating goes, it is so dependent on the actual application and hardware, that there is no general solution or recommendation that would apply.

I take it you have no code? Try brute force first and then refine it.

I have no code written out, but I have some explicit ideas. I think the simplest implementation would be this.

1) Set-up a 2D uint8_t array of 128x64 to represent the pixels of the LCD. 0x00 is a white pixel and 0x01 represents a black pixel. 2) Have some image (text or sprite) and create a struct which has a corresponding look-up table (another 2D uint8_t array), size of array, layering priority, and position.

The layering priority idea is if I have multiple objects which might overlap I update the 128x64 2D array with the lowest priority images first. The position takes say the (0)(0) of the object 2D array and corresponds to a location on the 128x64 2D array from which to draw the rest of the image onto the 2D array.

In which case, rather than refreshing the entire screen I only changes areas which were updated. This I think would have less memory and less time overall and therefore would work will less powerful hardware or more data heavy graphical LCDs.

3) Generate a function to handle the updating of objects on the 2D array. 4) Finally, use a function to take the 2D array and generate a list of data writes to update the LCD RAM.

I believe with the Due having a 84 MHz clock and using say a 500 kHz data transfer rate in SPI I could consistently have a 20-60 frames per second for any application I want. However, this would work I feel because of the hardware and low amount of data I am transferring. However, if I were to use say the Arduino Uno with less memory overall and a slower clock cycle or a more say a colored graphical LCD I am not certain this method would be too portable.