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

how to draw? #45

Open
mraeclo opened this issue Jun 13, 2022 · 1 comment
Open

how to draw? #45

mraeclo opened this issue Jun 13, 2022 · 1 comment

Comments

@mraeclo
Copy link

mraeclo commented Jun 13, 2022

Hi, I found this lib when asking on arduino forum about how to make fast changes in an SSD1306 screen and the buffering works great. Problem is that I cant figure out how to draw, even a rectangle, none of the examples have it..

How could I draw a white rectangle?

Sorry for such a stupid question!

Thanks!

@datacute
Copy link
Owner

Hi @mraeclo

Unfortunately, since this library is targeting microprocessors with extremely limited RAM, it doesn't write to a RAM buffer, then send that buffer to the SSD1306, instead it writes to the SSD1306's display memory directly. The SSD1306's I2C communication is write-only, you can't read what is in its memory. Writing to its memory sets 8 pixels at once. (The SSD1306 calls 8 rows of pixels a "page".)
For these reasons, pixel/line/rectangle drawing functions are not available.

The "buffering" that this library supports is with the SSD1306 screens that have only 128x32 pixels. As the SSD1306's graphics memory is always 128x64, it can fit two 128x32 screens in its memory, and it can switch which is displayed.

If you have memory to spare available to your microcontroller, you can create your own in-memory buffer to build up with the image you want to display, then copy it to the SSD1306. You will need to get/create line drawing routines of your own.

One of the examples does draw a rectangle (with bevelled/chamfered corners) around the screen. The example program then leaves those parts of the SSD1306's memory untouched, only ever updating within the rectangle:

void setupInitialDisplay() {

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

2 participants