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

Fix: make efficient use of available display area #1729

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

schlimmchen
Copy link
Contributor

Fixes calculation of the text baselines, using getAscent() in favor of getMaxCharHeight(), which includes ascent and descent. This moves the first text up and allows to insert margin between the lines until the display area is fully utilized.

On large displays, if the small diagram is selected, keep the first line rather low to avoid collision with the diagram y-axis label. in this mode, there is still more space between the text lines as before, allowing for improved readability.

I always thought that the display was quite crammed, especially the last line. While implementing hoylabs#658 I noticed that something was off with the baselines and that we could do better without compromising, since the previous implementation wastes lines mainly on the bottom of the display, also on the top if no diagram is drawn. The y of today nearly touches the l of total.

image

I found that especially the baseline (_lineOffsets) for the first line was off. The reason is that getMaxCharHeight() returns a value greater than the font's ascent, i.e., it includes the font's descent. The value which should be used is getAscent(). The next line's baseline is then advanced by the previous line's descent, making sure that they will not collide.

image
image

The placement is such that even when using the screensaver with the small diagram, the solar power will not collide with the diagram y-axis label.

Using this code

    if (!_isLarge) {
        _display->drawBox(84, 0, 1, 49);
        _display->drawBox(0, 48, 84, 1);
    }
    _isLarge = (_mExtra % 40 < 20);
    calcLineHeights();

I made sure that the change works for small displays as well.

image

fix calculation of the text baselines, using getAscent() in favor of
getMaxCharHeight(), which includes ascent and descent. this moves the
first text up and allows to insert margin between the lines until the
display area is fully utilized.

on large displays, if the small diagram is selected, keep the first line
rather low to avoid collision with the diagram y-axis label. in this mode,
there is still more space between the text lines as before, allowing for
improved readability.
@tbnobody tbnobody merged commit d635a9b into tbnobody:master Feb 12, 2024
8 checks passed
@schlimmchen schlimmchen deleted the efficient-use-of-display-area branch February 12, 2024 18:55
Copy link

github-actions bot commented Apr 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants