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

OverLays are written on top of each other #59

Closed
nicof38 opened this issue Jul 5, 2016 · 8 comments
Closed

OverLays are written on top of each other #59

nicof38 opened this issue Jul 5, 2016 · 8 comments

Comments

@nicof38
Copy link

nicof38 commented Jul 5, 2016

While using the SSD1306UiDemo, I've modified this one in order to have:

`void msOverlay1(OLEDDisplay display, OLEDDisplayUiState state) {
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->setFont(ArialMT_Plain_10);
display->drawString(128, 0, String(millis()));
}

void msOverlay2(OLEDDisplay display, OLEDDisplayUiState state) {
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->setFont(ArialMT_Plain_10);
display->drawString(128, 0, String("TESTTESTTEST"));
}`

Then:

// Overlays are statically drawn on top of a frame eg. a clock OverlayCallback overlays[] = { msOverlay1,msOverlay2 }; int overlaysCount = 2;

Running the example with these modifications, and you can see that "TESTTESTTEST" is written on top of the current milliseconds.

@FWeinb
Copy link
Collaborator

FWeinb commented Jul 5, 2016

That is the expected behaviour. What is your expectations with doing this? A overlay is a way to define frame independent data on the display (like a clock). If you draw to the same pixels they sure overwrite what is currently there.

@nicof38
Copy link
Author

nicof38 commented Jul 5, 2016

So in this case what is the aim of having multiple overlay defined?
It does not work the same way as frames? Frames does not overwrite on each
others so I was expecting to have the same behavior for multiple overlays.

One overlay should only overlay frames but I would not expect each overlay
to overlay any others.

Anyway if it is the way it is designed, how should we use the multiple
overlays callback in order to have something readable?

Thanks

@FWeinb
Copy link
Collaborator

FWeinb commented Jul 5, 2016

In an overlay you can draw anywhere on the display. You can do something like this:

void msOverlay2(OLEDDisplay display, OLEDDisplayUiState state) {
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(ArialMT_Plain_10);
display->drawString(0, 0, String("TESTTESTTEST"));
}

That would draw the string "TESTTESTTEST" in the upper left corner

@nicof38
Copy link
Author

nicof38 commented Jul 5, 2016

Yes, this is what I've done next. Anyway still surprised that 2 overlays
callback can overwrite on each others whereas frames clear everything
between.

What should be the best option to update information on an overlay area
(with different information type, not a timestamp for example)? Should I
add a third overlay in order to clear the selected area ? Should i use an
empty graphic to do so ?

@FWeinb
Copy link
Collaborator

FWeinb commented Jul 6, 2016

Sorry but I don't understand what you would like to achieve. Maybe @squix78 can help?
Overlays are information that are rendered always (even in a frame transition) so they can be used for status indicators like wifi signals or time, we choose to implement the ability to add more overlays so one can separate different aspects of the ui (not everyone want's to e.g. display an wifi signal indicator).

@nicof38
Copy link
Author

nicof38 commented Jul 9, 2016

OK, so based on your latest explanation, I think I get it.

Adding more overlays does not behave like adding multiple frames. Every defined overlays are rendered all the time, and that is why they can interfere on each others.

Maybe you should add the way it has to be used with multiple overlays in the UI demo code ?

@FWeinb
Copy link
Collaborator

FWeinb commented Jul 15, 2016

Yeah, we could really improve on example code for this library.

@FWeinb FWeinb closed this as completed Jul 15, 2016
@hallard
Copy link

hallard commented Jul 16, 2016

Moved to #69

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

3 participants