Skip to content

Commit

Permalink
samples: drivers: display: support small displays
Browse files Browse the repository at this point in the history
With extremely small displays (much smaller than 64x24), the
calculation of the blocks in the four corners fails. These
might then be too large and no longer fit into the available
area of the small displays.

Signed-off-by: Stephan Linz <linz@li-pro.net>
  • Loading branch information
rexut authored and MaureenHelm committed Jan 12, 2024
1 parent 2fdea6b commit 162a8f0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions samples/drivers/display/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,17 @@ int main(void)
rect_h = 1;
}

h_step = rect_h;
scale = (capabilities.x_resolution / 8) / rect_h;
if ((capabilities.x_resolution < 3 * rect_w) ||
(capabilities.y_resolution < 3 * rect_h) ||
(capabilities.x_resolution < 8 * rect_h)) {
rect_w = capabilities.x_resolution * 40 / 100;
rect_h = capabilities.y_resolution * 40 / 100;
h_step = capabilities.y_resolution * 20 / 100;
scale = 1;
} else {
h_step = rect_h;
scale = (capabilities.x_resolution / 8) / rect_h;
}

rect_w *= scale;
rect_h *= scale;
Expand Down

0 comments on commit 162a8f0

Please sign in to comment.