issue #364, added second update function for the clip window

This commit is contained in:
kraus 2018-10-28 07:59:04 +01:00
parent 8307e00d2e
commit 6425d2f179
5 changed files with 40 additions and 22 deletions

View File

@ -187,6 +187,7 @@ typedef struct u8g2_struct u8g2_t;
typedef struct u8g2_cb_struct u8g2_cb_t;
typedef void (*u8g2_update_dimension_cb)(u8g2_t *u8g2);
typedef void (*u8g2_update_page_win_cb)(u8g2_t *u8g2);
typedef void (*u8g2_draw_l90_cb)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
typedef void (*u8g2_draw_ll_hvline_cb)(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
@ -269,7 +270,8 @@ typedef struct _u8g2_kerning_t u8g2_kerning_t;
struct u8g2_cb_struct
{
u8g2_update_dimension_cb update;
u8g2_update_dimension_cb update_dimension;
u8g2_update_page_win_cb update_page_win;
u8g2_draw_l90_cb draw_l90;
};

View File

@ -100,7 +100,8 @@ void u8g2_SendBuffer(u8g2_t *u8g2)
void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row)
{
u8g2->tile_curr_row = row;
u8g2->cb->update(u8g2);
u8g2->cb->update_dimension(u8g2);
u8g2->cb->update_page_win(u8g2);
}
void u8g2_FirstPage(u8g2_t *u8g2)

View File

@ -49,7 +49,8 @@ void u8g2_SetMaxClipWindow(u8g2_t *u8g2)
u8g2->clip_y0 = 0;
u8g2->clip_x1 = (u8g2_uint_t)~(u8g2_uint_t)0;
u8g2->clip_y1 = (u8g2_uint_t)~(u8g2_uint_t)0;
u8g2->cb->update(u8g2);
u8g2->cb->update_page_win(u8g2);
}
void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0, u8g2_uint_t clip_x1, u8g2_uint_t clip_y1 )
@ -58,7 +59,7 @@ void u8g2_SetClipWindow(u8g2_t *u8g2, u8g2_uint_t clip_x0, u8g2_uint_t clip_y0,
u8g2->clip_y0 = clip_y0;
u8g2->clip_x1 = clip_x1;
u8g2->clip_y1 = clip_y1;
u8g2->cb->update(u8g2);
u8g2->cb->update_page_win(u8g2);
}
#endif
@ -88,10 +89,11 @@ void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_
u8g2->is_auto_page_clear = 1;
u8g2->cb = u8g2_cb;
u8g2->cb->update_dimension(u8g2);
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_SetMaxClipWindow(u8g2); /* assign a clip window and call the update() procedure */
#else
u8g2->cb->update(u8g2);
u8g2->cb->update_page_win(u8g2);
#endif
u8g2_SetFontPosBaseline(u8g2); /* issue 195 */
@ -108,7 +110,8 @@ void u8g2_SetupBuffer(u8g2_t *u8g2, uint8_t *buf, uint8_t tile_buf_height, u8g2_
void u8g2_SetDisplayRotation(u8g2_t *u8g2, const u8g2_cb_t *u8g2_cb)
{
u8g2->cb = u8g2_cb;
u8g2->cb->update(u8g2);
u8g2->cb->update_dimension(u8g2);
u8g2->cb->update_page_win(u8g2);
}
@ -198,8 +201,11 @@ static void u8g2_apply_clip_window(u8g2_t *u8g2)
void u8g2_update_dimension_r0(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
u8g2_update_dimension_common(u8g2);
}
void u8g2_update_page_win_r0(u8g2_t *u8g2)
{
u8g2->user_x0 = 0;
u8g2->user_x1 = u8g2->pixel_buf_width; /* pixel_buf_width replaced with width */
@ -209,11 +215,9 @@ void u8g2_update_dimension_r0(u8g2_t *u8g2)
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
// printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}
void u8g2_update_dimension_r1(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
@ -221,6 +225,10 @@ void u8g2_update_dimension_r1(u8g2_t *u8g2)
u8g2->height = u8g2_GetU8x8(u8g2)->display_info->pixel_width;
u8g2->width = u8g2_GetU8x8(u8g2)->display_info->pixel_height;
}
void u8g2_update_page_win_r1(u8g2_t *u8g2)
{
u8g2->user_x0 = u8g2->buf_y0;
u8g2->user_x1 = u8g2->buf_y1;
@ -230,14 +238,15 @@ void u8g2_update_dimension_r1(u8g2_t *u8g2)
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
//printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}
void u8g2_update_dimension_r2(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
}
void u8g2_update_page_win_r2(u8g2_t *u8g2)
{
u8g2->user_x0 = 0;
u8g2->user_x1 = u8g2->width; /* pixel_buf_width replaced with width */
@ -251,10 +260,9 @@ void u8g2_update_dimension_r2(u8g2_t *u8g2)
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
// printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}
void u8g2_update_dimension_r3(u8g2_t *u8g2)
{
u8g2_update_dimension_common(u8g2);
@ -262,6 +270,10 @@ 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;
}
void u8g2_update_page_win_r3(u8g2_t *u8g2)
{
/* 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;
@ -275,10 +287,9 @@ void u8g2_update_dimension_r3(u8g2_t *u8g2)
#ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
u8g2_apply_clip_window(u8g2);
#endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
// printf("x0=%d x1=%d y0=%d y1=%d\n",
// u8g2->user_x0, u8g2->user_x1, u8g2->user_y0, u8g2->user_y1);
}
/*============================================*/
extern void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
@ -407,12 +418,12 @@ void u8g2_draw_l90_r3(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t le
/*============================================*/
const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_draw_l90_r0 };
const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_draw_l90_r1 };
const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_draw_l90_r2 };
const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_draw_l90_r3 };
const u8g2_cb_t u8g2_cb_r0 = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_r0 };
const u8g2_cb_t u8g2_cb_r1 = { u8g2_update_dimension_r1, u8g2_update_page_win_r1, u8g2_draw_l90_r1 };
const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_update_page_win_r2, u8g2_draw_l90_r2 };
const u8g2_cb_t u8g2_cb_r3 = { u8g2_update_dimension_r3, u8g2_update_page_win_r3, u8g2_draw_l90_r3 };
const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_draw_l90_mirrorr_r0 };
const u8g2_cb_t u8g2_cb_mirror = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_l90_mirrorr_r0 };
/*============================================*/
/* setup for the null device */

View File

@ -238,6 +238,10 @@
U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI Uno Clip=2.7 Box=2.9 @=1.8 Pix=2.2 issue 586, before optimization
U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI Uno Clip=23.4 Box=40.8 @=4.4 Pix=8.1 issue 586, after optimization
28 Oct 2018, Arduino 1.8.4, 8 Bit Mode
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI Uno 8MHz Clip=34.0 Box=88.4 @=4.5 Pix=8.2 issue 364, clip window
*/

View File

@ -48,7 +48,7 @@ int main(void)
u8g2_SetFontDirection(&u8g2, 0);
u8g2_SetClipWindow(&u8g2, 10, 10, 50, 60 );
//u8g2_SetClipWindow(&u8g2, 10, 10, 50, 60 );
u8g2_SetDisplayRotation(&u8g2, U8G2_R0);