From 639346b53e199077b6b562adca0a8bbd3193d7f1 Mon Sep 17 00:00:00 2001 From: izilzty Date: Wed, 6 Jul 2022 23:07:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=98=BE=E7=A4=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AD=97=E8=8A=82=E9=A1=BA=E5=BA=8F=E4=BA=A4=E6=8D=A2?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cppsrc/U8g2lib.cpp | 12 --- cppsrc/U8g2lib.h | 4 - csrc/u8g2.h | 5 -- csrc/u8g2_buffer.c | 14 --- csrc/u8g2_d_setup.c | 12 +-- csrc/u8g2_ll_hvline.c | 171 ------------------------------------ csrc/u8x8.h | 4 - csrc/u8x8_capture.c | 16 ---- csrc/u8x8_d_gp1247ai.c | 13 ++- csrc/u8x8_d_gp1287ai.c | 13 ++- tools/codebuild/codebuild.c | 4 +- 11 files changed, 20 insertions(+), 248 deletions(-) diff --git a/cppsrc/U8g2lib.cpp b/cppsrc/U8g2lib.cpp index f1532ce9..4f3c3121 100644 --- a/cppsrc/U8g2lib.cpp +++ b/cppsrc/U8g2lib.cpp @@ -71,18 +71,6 @@ void U8G2::writeBufferXBM2(Print &p) u8g2_print_for_screenshot = &p; u8g2_WriteBufferXBM2(getU8g2(), u8g2_print_callback); } - -void U8G2::writeBufferPBM3(Print &p) -{ - u8g2_print_for_screenshot = &p; - u8g2_WriteBufferPBM3(getU8g2(), u8g2_print_callback); -} - -void U8G2::writeBufferXBM3(Print &p) -{ - u8g2_print_for_screenshot = &p; - u8g2_WriteBufferXBM3(getU8g2(), u8g2_print_callback); -} #endif diff --git a/cppsrc/U8g2lib.h b/cppsrc/U8g2lib.h index 5fb06794..792ef1b9 100644 --- a/cppsrc/U8g2lib.h +++ b/cppsrc/U8g2lib.h @@ -309,10 +309,6 @@ u8g2_uint_t u8g2_GetUTF8Width(u8g2_t *u8g2, const char *str); /* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */ void writeBufferPBM2(Print &p); void writeBufferXBM2(Print &p); - /* vertical top msb memory architecture */ - /* GP12x7AI */ - void writeBufferPBM3(Print &p); - void writeBufferXBM3(Print &p); #endif /* virtual function for print base class */ diff --git a/csrc/u8g2.h b/csrc/u8g2.h index b97805c1..48b7902b 100644 --- a/csrc/u8g2.h +++ b/csrc/u8g2.h @@ -1466,9 +1466,6 @@ void u8g2_WriteBufferXBM(u8g2_t *u8g2, void (*out)(const char *s)); /* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */ void u8g2_WriteBufferPBM2(u8g2_t *u8g2, void (*out)(const char *s)); void u8g2_WriteBufferXBM2(u8g2_t *u8g2, void (*out)(const char *s)); -/* GP12x7AI */ -void u8g2_WriteBufferPBM3(u8g2_t *u8g2, void (*out)(const char *s)); -void u8g2_WriteBufferXBM3(u8g2_t *u8g2, void (*out)(const char *s)); /*==========================================*/ @@ -1486,8 +1483,6 @@ void u8g2_WriteBufferXBM3(u8g2_t *u8g2, void (*out)(const char *s)); void u8g2_ll_hvline_vertical_top_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); /* ST7920 */ void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); -/* GP12x7AI */ -void u8g2_ll_hvline_vertical_top_msb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir); /*==========================================*/ diff --git a/csrc/u8g2_buffer.c b/csrc/u8g2_buffer.c index 371f0a78..9aee96d4 100644 --- a/csrc/u8g2_buffer.c +++ b/csrc/u8g2_buffer.c @@ -211,17 +211,3 @@ void u8g2_WriteBufferXBM2(u8g2_t *u8g2, void (*out)(const char *s)) u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_2, out); } -/* vertical_top msb memory architecture */ -/* GP12x7AI */ -void u8g2_WriteBufferPBM3(u8g2_t *u8g2, void (*out)(const char *s)) -{ - u8x8_capture_write_pbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out); - u8x8_capture_write_pbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_3, out); -} - -void u8g2_WriteBufferXBM3(u8g2_t *u8g2, void (*out)(const char *s)) -{ - u8x8_capture_write_xbm_pre(u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), out); - u8x8_capture_write_xbm_buffer(u8g2_GetBufferPtr(u8g2), u8g2_GetBufferTileWidth(u8g2), u8g2_GetBufferTileHeight(u8g2), u8x8_capture_get_pixel_3, out); -} - diff --git a/csrc/u8g2_d_setup.c b/csrc/u8g2_d_setup.c index 3ef6c9ab..8e2f25d1 100644 --- a/csrc/u8g2_d_setup.c +++ b/csrc/u8g2_d_setup.c @@ -7095,7 +7095,7 @@ void u8g2_Setup_gp1287ai_256x50_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ uint8_t *buf; u8g2_SetupDisplay(u8g2, u8x8_d_gp1287ai_256x50, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); buf = u8g2_m_32_7_1(&tile_buf_height); - u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_msb, rotation); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); } /* gp1287ai 2 */ void u8g2_Setup_gp1287ai_256x50_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) @@ -7104,7 +7104,7 @@ void u8g2_Setup_gp1287ai_256x50_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ uint8_t *buf; u8g2_SetupDisplay(u8g2, u8x8_d_gp1287ai_256x50, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); buf = u8g2_m_32_7_2(&tile_buf_height); - u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_msb, rotation); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); } /* gp1287ai f */ void u8g2_Setup_gp1287ai_256x50_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) @@ -7113,7 +7113,7 @@ void u8g2_Setup_gp1287ai_256x50_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ uint8_t *buf; u8g2_SetupDisplay(u8g2, u8x8_d_gp1287ai_256x50, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); buf = u8g2_m_32_7_f(&tile_buf_height); - u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_msb, rotation); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); } /* gp1247ai */ /* gp1247ai 1 */ @@ -7123,7 +7123,7 @@ void u8g2_Setup_gp1247ai_253x63_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ uint8_t *buf; u8g2_SetupDisplay(u8g2, u8x8_d_gp1247ai_253x63, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); buf = u8g2_m_32_8_1(&tile_buf_height); - u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_msb, rotation); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); } /* gp1247ai 2 */ void u8g2_Setup_gp1247ai_253x63_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) @@ -7132,7 +7132,7 @@ void u8g2_Setup_gp1247ai_253x63_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ uint8_t *buf; u8g2_SetupDisplay(u8g2, u8x8_d_gp1247ai_253x63, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); buf = u8g2_m_32_8_2(&tile_buf_height); - u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_msb, rotation); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); } /* gp1247ai f */ void u8g2_Setup_gp1247ai_253x63_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) @@ -7141,7 +7141,7 @@ void u8g2_Setup_gp1247ai_253x63_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_ uint8_t *buf; u8g2_SetupDisplay(u8g2, u8x8_d_gp1247ai_253x63, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); buf = u8g2_m_32_8_f(&tile_buf_height); - u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_msb, rotation); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_vertical_top_lsb, rotation); } /* a2printer */ /* a2printer 1 */ diff --git a/csrc/u8g2_ll_hvline.c b/csrc/u8g2_ll_hvline.c index 0e8d694a..59ab4d17 100644 --- a/csrc/u8g2_ll_hvline.c +++ b/csrc/u8g2_ll_hvline.c @@ -368,175 +368,4 @@ void u8g2_ll_hvline_horizontal_right_lsb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_ } } -#endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */ - -/*=================================================*/ -/* - u8g2_ll_hvline_vertical_top_msb - GP12x7AI -*/ - - -#ifdef U8G2_WITH_HVLINE_SPEED_OPTIMIZATION - -/* - x,y Upper left position of the line within the local buffer (not the display!) - len length of the line in pixel, len must not be 0 - dir 0: horizontal line (left to right) - 1: vertical line (top to bottom) - asumption: - all clipping done -*/ -void u8g2_ll_hvline_vertical_top_msb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) -{ - uint16_t offset; - uint8_t *ptr; - uint8_t bit_pos, mask; - uint8_t or_mask, xor_mask; -#ifdef __unix - uint8_t *max_ptr = u8g2->tile_buf_ptr + u8g2_GetU8x8(u8g2)->display_info->tile_width*u8g2->tile_buf_height*8; -#endif - - //assert(x >= u8g2->buf_x0); - //assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8); - //assert(y >= u8g2->buf_y0); - //assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8); - - /* bytes are vertical, msb on top (y=0), lsb at bottom (y=7) */ - bit_pos = y; /* overflow truncate is ok here... */ - bit_pos &= 7; /* ... because only the lowest 3 bits are needed */ - mask = 0x80; /* LSB -> MSB */ - mask >>= bit_pos; /* LSB -> MSB */ - - or_mask = 0; - xor_mask = 0; - if ( u8g2->draw_color <= 1 ) - or_mask = mask; - if ( u8g2->draw_color != 1 ) - xor_mask = mask; - - - offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */ - offset &= ~7; - offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width; - ptr = u8g2->tile_buf_ptr; - ptr += offset; - ptr += x; - - if ( dir == 0 ) - { - do - { -#ifdef __unix - assert(ptr < max_ptr); -#endif - *ptr |= or_mask; - *ptr ^= xor_mask; - ptr++; - len--; - } while( len != 0 ); - } - else - { - do - { -#ifdef __unix - assert(ptr < max_ptr); -#endif - *ptr |= or_mask; - *ptr ^= xor_mask; - - bit_pos++; - bit_pos &= 7; - - len--; - - if ( bit_pos == 0 ) - { - ptr+=u8g2->pixel_buf_width; /* 6 Jan 17: Changed u8g2->width to u8g2->pixel_buf_width, issue #148 */ - - if ( u8g2->draw_color <= 1 ) - or_mask = 0x80; /* LSB -> MSB */ - if ( u8g2->draw_color != 1 ) - xor_mask = 0x80; /* LSB -> MSB */ - } - else - { - or_mask >>= 1; /* LSB -> MSB */ - xor_mask >>= 1; /* LSB -> MSB */ - } - } while( len != 0 ); - } -} - - - -#else /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */ - -/* - x,y position within the buffer -*/ -static void u8g2_draw_pixel_vertical_top_msb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y) -{ - uint16_t offset; - uint8_t *ptr; - uint8_t bit_pos, mask; - - //assert(x >= u8g2->buf_x0); - //assert(x < u8g2_GetU8x8(u8g2)->display_info->tile_width*8); - //assert(y >= u8g2->buf_y0); - //assert(y < u8g2_GetU8x8(u8g2)->display_info->tile_height*8); - - /* bytes are vertical, msb on top (y=0), lsb at bottom (y=7) */ - bit_pos = y; /* overflow truncate is ok here... */ - bit_pos &= 7; /* ... because only the lowest 3 bits are needed */ - mask = 0x80; /* LSB -> MSB */ - mask >>= bit_pos; /* LSB -> MSB */ - - offset = y; /* y might be 8 or 16 bit, but we need 16 bit, so use a 16 bit variable */ - offset &= ~7; - offset *= u8g2_GetU8x8(u8g2)->display_info->tile_width; - ptr = u8g2->tile_buf_ptr; - ptr += offset; - ptr += x; - - - if ( u8g2->draw_color <= 1 ) - *ptr |= mask; - if ( u8g2->draw_color != 1 ) - *ptr ^= mask; - -} - -/* - x,y Upper left position of the line within the local buffer (not the display!) - len length of the line in pixel, len must not be 0 - dir 0: horizontal line (left to right) - 1: vertical line (top to bottom) - asumption: - all clipping done -*/ -void u8g2_ll_hvline_vertical_top_msb(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir) -{ - if ( dir == 0 ) - { - do - { - u8g2_draw_pixel_vertical_top_msb(u8g2, x, y); - x++; - len--; - } while( len != 0 ); - } - else - { - do - { - u8g2_draw_pixel_vertical_top_msb(u8g2, x, y); - y++; - len--; - } while( len != 0 ); - } -} - - #endif /* U8G2_WITH_HVLINE_SPEED_OPTIMIZATION */ diff --git a/csrc/u8x8.h b/csrc/u8x8.h index 50d733c0..8ad7c281 100644 --- a/csrc/u8x8.h +++ b/csrc/u8x8.h @@ -1082,10 +1082,6 @@ uint8_t u8x8_capture_get_pixel_1(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint /* SH1122, LD7032, ST7920, ST7986, LC7981, T6963, SED1330, RA8835, MAX7219, LS0 */ uint8_t u8x8_capture_get_pixel_2(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width); -/* vertical_top msb memory architecture */ -/* GP12x7AI */ -uint8_t u8x8_capture_get_pixel_3(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width); - void u8x8_capture_write_pbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s)); diff --git a/csrc/u8x8_capture.c b/csrc/u8x8_capture.c index f1b0b1fd..78014e84 100644 --- a/csrc/u8x8_capture.c +++ b/csrc/u8x8_capture.c @@ -72,22 +72,6 @@ uint8_t u8x8_capture_get_pixel_2(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint return 1; } -/* vertical top msb memory architecture */ -/* GP12x7AI */ -uint8_t u8x8_capture_get_pixel_3(uint16_t x, uint16_t y, uint8_t *dest_ptr, uint8_t tile_width) -{ - //uint8_t *dest_ptr = capture->buffer; - //if ( dest_ptr == NULL ) - //return 0; - //dest_ptr += (y/8)*capture->tile_width*8; - dest_ptr += (y/8)*tile_width*8; - y &= 7; - dest_ptr += x; - if ( (*dest_ptr & (0x80>>y)) == 0 ) /* LSB -> MSB */ - return 0; - return 1; -} - void u8x8_capture_write_pbm_pre(uint8_t tile_width, uint8_t tile_height, void (*out)(const char *s)) { out("P1\n"); diff --git a/csrc/u8x8_d_gp1247ai.c b/csrc/u8x8_d_gp1247ai.c index 66373f04..8df20f45 100644 --- a/csrc/u8x8_d_gp1247ai.c +++ b/csrc/u8x8_d_gp1247ai.c @@ -141,6 +141,7 @@ uint8_t u8x8_d_gp1247ai_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void uint8_t *ptr; uint8_t x, y; uint16_t tx_cnt; + uint8_t swapped_byte; switch (msg) { case U8X8_MSG_DISPLAY_SET_POWER_SAVE: @@ -172,14 +173,12 @@ uint8_t u8x8_d_gp1247ai_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void u8x8_cad_SendArg(u8x8, SWAP8(0x007)); /* Y方向每8像素自动折返 */ do { - if (tx_cnt > 255) + while (tx_cnt > 0) { - u8x8_cad_SendData(u8x8, 255, ptr); /* u8x8_cad_SendData() 一次最多只能发送255 Byte,所以分两次发 */ - u8x8_cad_SendData(u8x8, tx_cnt - 255, ptr + 255); - } - else - { - u8x8_cad_SendData(u8x8, tx_cnt, ptr); + swapped_byte = SWAP8(*ptr); + u8x8_cad_SendData(u8x8, 1, &swapped_byte); + ptr += 1; + tx_cnt -= 1; } arg_int--; } while (arg_int > 0); diff --git a/csrc/u8x8_d_gp1287ai.c b/csrc/u8x8_d_gp1287ai.c index 8447e5a9..43b44915 100644 --- a/csrc/u8x8_d_gp1287ai.c +++ b/csrc/u8x8_d_gp1287ai.c @@ -149,6 +149,7 @@ uint8_t u8x8_d_gp1287ai_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void uint8_t *ptr; uint8_t x, y; uint16_t tx_cnt; + uint8_t swapped_byte; switch (msg) { case U8X8_MSG_DISPLAY_SET_POWER_SAVE: @@ -180,14 +181,12 @@ uint8_t u8x8_d_gp1287ai_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void u8x8_cad_SendArg(u8x8, SWAP8(0x007)); /* Y方向每8像素自动折返 */ do { - if (tx_cnt > 255) + while (tx_cnt > 0) { - u8x8_cad_SendData(u8x8, 255, ptr); /* u8x8_cad_SendData() 一次最多只能发送255 Byte,所以分两次发 */ - u8x8_cad_SendData(u8x8, tx_cnt - 255, ptr + 255); - } - else - { - u8x8_cad_SendData(u8x8, tx_cnt, ptr); + swapped_byte = SWAP8(*ptr); + u8x8_cad_SendData(u8x8, 1, &swapped_byte); + ptr += 1; + tx_cnt -= 1; } arg_int--; } while (arg_int > 0); diff --git a/tools/codebuild/codebuild.c b/tools/codebuild/codebuild.c index 4a91d079..86b2c736 100644 --- a/tools/codebuild/codebuild.c +++ b/tools/codebuild/codebuild.c @@ -1879,7 +1879,7 @@ struct controller controller_list[] = }, { - "gp1287ai", 32, 7, "u8g2_ll_hvline_vertical_top_msb", "u8x8_cad_empty", "", COM_4WSPI, /* DC pin is not used */ + "gp1287ai", 32, 7, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_empty", "", COM_4WSPI, /* DC pin is not used */ "", /* is_generate_u8g2_class= */ 1, { { "256x50" }, @@ -1888,7 +1888,7 @@ struct controller controller_list[] = }, { - "gp1247ai", 32, 8, "u8g2_ll_hvline_vertical_top_msb", "u8x8_cad_empty", "", COM_4WSPI, /* DC pin is not used */ + "gp1247ai", 32, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_empty", "", COM_4WSPI, /* DC pin is not used */ "", /* is_generate_u8g2_class= */ 1, { { "253x63" },