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

u8g_DrawBox() with h=0 corrupts display #488

Open
francescolavra opened this issue Oct 29, 2018 · 4 comments
Open

u8g_DrawBox() with h=0 corrupts display #488

francescolavra opened this issue Oct 29, 2018 · 4 comments

Comments

@francescolavra
Copy link

If the u8g_DrawBox() function in csrc/u8g_rect.c is called with the h argument set to 0, it corrupts the display by drawing a box that covers the entire height of the screen. This is because the body in the while() loop in u8g_draw_box() is executed before checking the value of the h argument.
This can be fixed by replacing the do {} while() construct with a simple while() loop:

while( h != 0 )
{
  u8g_draw_hline(u8g, x, y, w);
  y++;    
  h--;
}
@olikraus
Copy link
Owner

True, but Code size will be higher.

@olikraus
Copy link
Owner

Well... I can add this...

@AnHardt
Copy link

AnHardt commented Oct 29, 2018

A box with height 0 is still a line. For that, at least one line is required. How about changing the condition to h > 0

@francescolavra
Copy link
Author

A box with height 0 is still a line

Why? This wouldn't be consistent with the current implementation, where a line corresponds to a box with height 1, not 0. Also, u8g_DrawBox() doesn't draw anything when called with width 0.

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