Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display buffer returned by getBuffer() method #200

Closed
alexpeissel opened this issue Jan 15, 2021 · 1 comment
Closed

Display buffer returned by getBuffer() method #200

alexpeissel opened this issue Jan 15, 2021 · 1 comment

Comments

@alexpeissel
Copy link

Hi all!

Is there a canonical way of 'restoring' display contents from a dumped buffer?

My current attempt looks like the following, (from an STM32 board connected to an 128x32 OLED over I2C):

// Our duplicate buffer
static uint8_t displayBuffer[(SCREEN_WIDTH * SCREEN_HEIGHT + 7) / 8];

// ...draw bitmaps, images, etc and show with display.display();...

// Copy over the contents of the display buffer to the duplicate
memcpy(displayBuffer, display.getBuffer(), sizeof(displayBuffer));

// Write out the buffer
display.drawBitmap(0, 0, displayBuffer, 128, 32, WHITE);

I then get garbled output on the screen, but it seems to be consistent based on the display content at the time memcpy is called.

My first take on this would be if there should be some way to set the buffer directly, similar to this PR: here. Alternately, does something need to be done with the displayBuffer to play nicely with the drawBitmap method?

To close, I believe this is worthy of an issue as it would close/complement the getBuffer use-case.

Any pointers or suggestions would be great; thanks!

@alexpeissel
Copy link
Author

alexpeissel commented Jan 24, 2021

This was solved for me by a friendly redditor, (thanks ferrybig!):

// Our duplicate buffer
static uint8_t displayBuffer[(SCREEN_WIDTH * SCREEN_HEIGHT + 7) / 8];

// ...draw bitmaps, images, etc and show with display.display();...

// Copy over the contents of the display buffer to the duplicate
memcpy(displayBuffer, display.getBuffer(), sizeof(displayBuffer));

// Copy back from the duplicate buffer
memcpy(display.getBuffer(), displayBuffer, sizeof(displayBuffer));

// Display it
display.display();

Closing the issue, hopefully someone else may find this useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant