bugfix: Display with height not a multiple of 8 and rotation R2 and R3 do not show the lower four rows. This is fixed. Issue #469

This commit is contained in:
olikraus 2018-02-18 19:43:40 +01:00
parent 20eba44a43
commit 71fb12ba6e
3 changed files with 25 additions and 8 deletions

View File

@ -173,7 +173,11 @@ void u8g2_update_dimension_r2(u8g2_t *u8g2)
u8g2->user_x0 = 0;
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
/* there are ases where the height is not a multiple of 8. */
/* in such a case u8g2->buf_y1 might be heigher than u8g2->height */
u8g2->user_y0 = 0;
if ( u8g2->height >= u8g2->buf_y1 )
u8g2->user_y0 = u8g2->height - u8g2->buf_y1;
u8g2->user_y1 = u8g2->height - u8g2->buf_y0;
// printf("x0=%d x1=%d y0=%d y1=%d\n",
@ -187,7 +191,11 @@ void u8g2_update_dimension_r3(u8g2_t *u8g2)
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
u8g2->user_x0 = u8g2->width - u8g2->buf_y1;
/* there are ases where the height is not a multiple of 8. */
/* in such a case u8g2->buf_y1 might be heigher than u8g2->width */
u8g2->user_x0 = 0;
if ( u8g2->width >= u8g2->buf_y1 )
u8g2->user_x0 = u8g2->width - u8g2->buf_y1;
u8g2->user_x1 = u8g2->width - u8g2->buf_y0;
u8g2->user_y0 = 0;

View File

@ -4,9 +4,10 @@
#include <stdlib.h>
#include <string.h>
//#define CHGR_WIDTH 96
#define CHGR_WIDTH 102
#define CHGR_HEIGHT 32
#define CHGR_WIDTH 96
//#define CHGR_WIDTH 102
//#define CHGR_HEIGHT 32
#define CHGR_HEIGHT 68
unsigned char chgr_bitmap[CHGR_HEIGHT/2][CHGR_WIDTH/2];
unsigned char *chgr_bitmap_pos(unsigned x, unsigned y)

View File

@ -16,7 +16,7 @@ u8g2_t u8g2;
int main(void)
{
u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R1);
u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R3);
u8g2_InitDisplay(&u8g2);
@ -27,10 +27,18 @@ int main(void)
u8g2_FirstPage(&u8g2);
do
{
{
printf("u8g2.tile_curr_row=%d\n", u8g2.tile_curr_row);
printf("u8g2.pixel_curr_row=%d\n", u8g2.pixel_curr_row);
printf("u8g2.buf_y0=%d\n", u8g2.buf_y0);
printf("u8g2.buf_y1=%d\n", u8g2.buf_y1);
printf("u8g2.user_x0=%d\n", u8g2.user_x0);
printf("u8g2.user_x1=%d\n", u8g2.user_x1);
printf("u8g2.user_y0=%d\n", u8g2.user_y0);
printf("u8g2.user_y1=%d\n", u8g2.user_y1);
u8g2_DrawFrame(&u8g2, 0, 0,
u8g2_GetDisplayWidth(&u8g2), u8g2_GetDisplayHeight(&u8g2));
u8g2_DrawPixel(&u8g2, 3, 3);
//u8g2_DrawHLine(&u8g2, 0, 0, u8g2_GetDisplayWidth(&u8g2));
//u8g2_DrawHLine(&u8g2, 0, u8g2_GetDisplayHeight(&u8g2)-1, u8g2_GetDisplayWidth(&u8g2));
//u8g2_DrawHLine(&u8g2, 0, 32, 10);