Memcpy/memmove do make a horizontal movement

First I want to apologise for writing or grammar mistakes, english is not my first language.

Basically I need to make a horizontal movement on a LCD Display. This is for a game where the walls have to move, so it looks like the spaceship is floating in between.

 >  memmove(framebuffer, framebuffer+1, sizeof framebuffer);
>   x=XMAX;
>   y=getNextY();
>   framebuffer[x +((y-width)/8*84)] |= (1<<((y-width)%8));
>   framebuffer[x +((y+width)/8*84)] |= (1<<((y+width)%8));

The last two lines make the dot on the right coordinates for the walls. The other two lines make the x and y coordinates for the middle line between the walls. This is why I am using -width and +width. This does work fine.

The problem is, if i print the array on the screen it does work, but somehow the first walls also copy into the array again, but with a different y coordinate.
To show you what I mean:

You can see that the actual walls still generate, but also the walls which were there on the start (at x=0 and so on) are there aswell but at a higher y coordinate (which is the same on every try).

Can somebody tell me, why it does not work?

Start here

memcpy() copies blindly e.g. overlapping areas.
memmove() will copy intelligently.

I assume your framebuffer is 84x48 bits i.e. 504 bytes.
I assume there are 84 horizontal bytes in 6 pages.

So you want to move 83 bytes per page. Leaving the left hand 1x48 column free for your new data.
Yes you can move 503 bytes in one go. And fill in the 1x48 column of pixels.

But first off you should solder the header pins on your display. The photo looks like the header is just pushed in the holes.

Which PCD8544 library are you using ?

David.

The pins are actually soldered, it just looks weird.

The library I am using is PCD8544 library, but I am not allowe dto change this, because the game is a project from school, and I have to use this library.

Well, it also looks like there is nothing connected to any of those pins, and yet there is an image on the LCD!

That's what I would expect to happen, because you are not blanking the right-most column of pixels after you scroll with memmove(). Without blanking, everything that is scrolled off the left of the screen will scroll on to the right of the screen but 8 pixels higher than before.

memmove(framebuffer, framebuffer+1, sizeof framebuffer);
x=XMAX;
for(byte z = x; z < 6*84; z += 84) framebuffer[z] = 0;
y=getNextY();
framebuffer[x +((y-width)/8*84)] |= (1<<((y-width)%8));
framebuffer[x +((y+width)/8*84)] |= (1<<((y+width)%8));

Your link shows a non-framebuffer library.

I suggest that you use https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library

That library gives you methods for drawing graphics and for accessing the framebuffer.

David.

Your code does not work, because it does not scroll anymore. I just changed your loop a little bit and it does work. So still thanks for your help, everything is working as it should now.

I managed to solve my problem with my current library, so I am not changing it now. Still, thanks alot.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.