diff --git a/ChangeLog b/ChangeLog index a2aa9659..5ba17579 100644 --- a/ChangeLog +++ b/ChangeLog @@ -256,4 +256,6 @@ https://github.com/olikraus/u8g2 ChangeLog * Added support for KS0713 controller (issue 1314) * Added support for ST7567_HEM6432 (issue 1159) * U8g2 16 Bit Mode enabled by default for ARM and ESP Systems (issue 1222) +2021-04-18 v2.28.11 mattnutsch@gmail.com + * Added vertical mirror option for u8g2. \ No newline at end of file diff --git a/csrc/u8g2.h b/csrc/u8g2.h index d7769741..0feace15 100644 --- a/csrc/u8g2.h +++ b/csrc/u8g2.h @@ -411,12 +411,14 @@ extern const u8g2_cb_t u8g2_cb_r1; extern const u8g2_cb_t u8g2_cb_r2; extern const u8g2_cb_t u8g2_cb_r3; extern const u8g2_cb_t u8g2_cb_mirror; +extern const u8g2_cb_t u8g2_cb_mirror_vertical; #define U8G2_R0 (&u8g2_cb_r0) #define U8G2_R1 (&u8g2_cb_r1) #define U8G2_R2 (&u8g2_cb_r2) #define U8G2_R3 (&u8g2_cb_r3) #define U8G2_MIRROR (&u8g2_cb_mirror) +#define U8G2_MIRROR_VERTICAL (&u8g2_cb_mirror_vertical) /* u8g2: A new, not yet initialized u8g2 memory areay buf: Memory are of size tile_buf_height* diff --git a/csrc/u8g2_setup.c b/csrc/u8g2_setup.c index 0e71a707..2b725e44 100644 --- a/csrc/u8g2_setup.c +++ b/csrc/u8g2_setup.c @@ -328,6 +328,22 @@ void u8g2_draw_l90_mirrorr_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_u u8g2_draw_hv_line_2dir(u8g2, xx, y, len, dir); } +void u8g2_draw_mirror_vertical_r0(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) +{ + u8g2_uint_t yy; + yy = u8g2->height; + yy -= y; + if ( (dir & 1) == 0 ) + { + yy -= len; + } + else + { + yy--; + } + u8g2_draw_hv_line_2dir(u8g2, x, yy, len, dir); +} + /* dir = 0 or 1 */ void u8g2_draw_l90_r1(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) { @@ -434,6 +450,7 @@ const u8g2_cb_t u8g2_cb_r2 = { u8g2_update_dimension_r2, u8g2_update_page_win_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_update_page_win_r0, u8g2_draw_l90_mirrorr_r0 }; +const u8g2_cb_t u8g2_cb_mirror_vertical = { u8g2_update_dimension_r0, u8g2_update_page_win_r0, u8g2_draw_mirror_vertical_r0 }; /*============================================*/ /* setup for the null device */