From 0d1431ad798607137128097efb6b9f7052a2ba4a Mon Sep 17 00:00:00 2001 From: olikraus Date: Sat, 23 Jul 2016 11:26:33 +0200 Subject: [PATCH] towards a2 printer support --- csrc/u8g2.h | 6 ++++++ csrc/u8g2_d_memory.c | 18 ++++++++++++++++++ csrc/u8g2_d_setup.c | 28 +++++++++++++++++++++++++++ csrc/u8x8.h | 2 ++ csrc/u8x8_cad.c | 22 +++++++++++++++++++++ tools/codebuild/codebuild.c | 38 +++++++++++++++++++++++++++++++++++-- 6 files changed, 112 insertions(+), 2 deletions(-) diff --git a/csrc/u8g2.h b/csrc/u8g2.h index 4df1571d..0d1046e5 100644 --- a/csrc/u8g2.h +++ b/csrc/u8g2.h @@ -405,6 +405,9 @@ uint8_t *u8g2_m_t6963_16_f(uint8_t *page_cnt); uint8_t *u8g2_m_ssd1322_32_1(uint8_t *page_cnt); uint8_t *u8g2_m_ssd1322_32_2(uint8_t *page_cnt); uint8_t *u8g2_m_ssd1322_32_f(uint8_t *page_cnt); +uint8_t *u8g2_m_a2printer_48_1(uint8_t *page_cnt); +uint8_t *u8g2_m_a2printer_48_2(uint8_t *page_cnt); +uint8_t *u8g2_m_a2printer_48_f(uint8_t *page_cnt); /* u8g2_d_memory.c generated code end */ @@ -470,6 +473,9 @@ void u8g2_Setup_t6963_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg void u8g2_Setup_ssd1322_256x64_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_ssd1322_256x64_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); void u8g2_Setup_ssd1322_256x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_a2printer_384x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_a2printer_384x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); +void u8g2_Setup_a2printer_384x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb); /* u8g2_d_setup.c generated code end */ diff --git a/csrc/u8g2_d_memory.c b/csrc/u8g2_d_memory.c index bb7a24d4..1d1b3685 100644 --- a/csrc/u8g2_d_memory.c +++ b/csrc/u8g2_d_memory.c @@ -201,4 +201,22 @@ uint8_t *u8g2_m_ssd1322_32_f(uint8_t *page_cnt) *page_cnt = 8; return buf; } +uint8_t *u8g2_m_a2printer_48_1(uint8_t *page_cnt) +{ + static uint8_t buf[384]; + *page_cnt = 1; + return buf; +} +uint8_t *u8g2_m_a2printer_48_2(uint8_t *page_cnt) +{ + static uint8_t buf[768]; + *page_cnt = 2; + return buf; +} +uint8_t *u8g2_m_a2printer_48_f(uint8_t *page_cnt) +{ + static uint8_t buf[11520]; + *page_cnt = 30; + return buf; +} /* end of generated code */ diff --git a/csrc/u8g2_d_setup.c b/csrc/u8g2_d_setup.c index 8279b5fc..9f606a14 100644 --- a/csrc/u8g2_d_setup.c +++ b/csrc/u8g2_d_setup.c @@ -563,4 +563,32 @@ void u8g2_Setup_ssd1322_256x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_m buf = u8g2_m_ssd1322_32_f(&tile_buf_height); u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation); } +/* a2printer */ +/* a2printer 1 */ +void u8g2_Setup_a2printer_384x240_1(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_a2printer_384x240, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_a2printer_48_1(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation); +} +/* a2printer 2 */ +void u8g2_Setup_a2printer_384x240_2(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_a2printer_384x240, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_a2printer_48_2(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation); +} +/* a2printer f */ +void u8g2_Setup_a2printer_384x240_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) +{ + uint8_t tile_buf_height; + uint8_t *buf; + u8g2_SetupDisplay(u8g2, u8x8_d_a2printer_384x240, u8x8_cad_empty, byte_cb, gpio_and_delay_cb); + buf = u8g2_m_a2printer_48_f(&tile_buf_height); + u8g2_SetupBuffer(u8g2, buf, tile_buf_height, u8g2_ll_hvline_horizontal_right_lsb, rotation); +} /* end of generated code */ diff --git a/csrc/u8x8.h b/csrc/u8x8.h index 64acd8e9..1012b995 100644 --- a/csrc/u8x8.h +++ b/csrc/u8x8.h @@ -516,6 +516,7 @@ uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8) U8X8_NOINLINE; #define U8X8_END() (0xff) void u8x8_cad_SendSequence(u8x8_t *u8x8, uint8_t const *data); +uint8_t u8x8_cad_empty(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_110(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_001(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_cad_011(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); @@ -675,6 +676,7 @@ uint8_t u8x8_d_t6963_240x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a uint8_t u8x8_d_t6963_128x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_ssd1322_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); uint8_t u8x8_d_t6963_256x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); +uint8_t u8x8_d_a2printer_384x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); /*==========================================*/ diff --git a/csrc/u8x8_cad.c b/csrc/u8x8_cad.c index 790051e7..9429e1ba 100644 --- a/csrc/u8x8_cad.c +++ b/csrc/u8x8_cad.c @@ -158,6 +158,28 @@ void u8x8_cad_SendSequence(u8x8_t *u8x8, uint8_t const *data) } +uint8_t u8x8_cad_empty(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) +{ + switch(msg) + { + case U8X8_MSG_CAD_SEND_CMD: + u8x8_byte_SendByte(u8x8, arg_int); + break; + case U8X8_MSG_CAD_SEND_ARG: + u8x8_byte_SendByte(u8x8, arg_int); + break; + case U8X8_MSG_CAD_SEND_DATA: + case U8X8_MSG_CAD_INIT: + case U8X8_MSG_CAD_START_TRANSFER: + case U8X8_MSG_CAD_END_TRANSFER: + return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr); + default: + return 0; + } + return 1; +} + + /* convert to bytes by using dc = 1 for commands and args and diff --git a/tools/codebuild/codebuild.c b/tools/codebuild/codebuild.c index f8343ff9..07044929 100644 --- a/tools/codebuild/codebuild.c +++ b/tools/codebuild/codebuild.c @@ -22,8 +22,9 @@ #define COM_3WSPI 0x0002 #define COM_6800 0x0004 #define COM_8080 0x0008 -#define COM_I2C 0x0010 +#define COM_I2C 0x0010 #define COM_ST7920SPI 0x0020 /* mostly identical to COM_4WSPI, but does not use DC */ +#define COM_UART 0x0040 struct interface { @@ -59,6 +60,8 @@ struct controller const char *cad; const char *cad_shortname; unsigned com; + char *note; + unsigned is_generate_u8g2_class; /* currently not used, instead conrolled by COM_UART */ struct display display_list[10]; /* usually not used completly, but space does not matter much here */ }; @@ -66,6 +69,7 @@ struct controller controller_list[] = { { "ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "128x64_noname" }, { NULL } @@ -73,6 +77,7 @@ struct controller controller_list[] = }, { "ssd1306", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, + "", /* is_generate_u8g2_class= */ 1, { { "128x64_noname" }, { NULL } @@ -81,6 +86,7 @@ struct controller controller_list[] = { "sh1106", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080, + "Not tested", /* is_generate_u8g2_class= */ 1, { { "128x64_noname" }, { NULL } @@ -88,6 +94,7 @@ struct controller controller_list[] = }, { "sh1106", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, + "Not tested", /* is_generate_u8g2_class= */ 1, { { "128x64_noname" }, { NULL } @@ -96,6 +103,7 @@ struct controller controller_list[] = { "ssd1306", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080|COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "128x32_univision" }, { NULL } @@ -103,6 +111,7 @@ struct controller controller_list[] = }, { "ssd1306", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_ssd13xx_i2c", "i2c", COM_I2C, + "", /* is_generate_u8g2_class= */ 1, { { "128x32_univision" }, { NULL } @@ -110,6 +119,7 @@ struct controller controller_list[] = }, { "ld7032", 8, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_011", "", COM_4WSPI, + "", /* is_generate_u8g2_class= */ 1, { { "60x32" }, { NULL } @@ -117,6 +127,7 @@ struct controller controller_list[] = }, { "ld7032", 8, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_ld7032_i2c", "i2c", COM_I2C, + "", /* is_generate_u8g2_class= */ 1, { { "60x32" }, { NULL } @@ -124,6 +135,7 @@ struct controller controller_list[] = }, { "st7920", 24, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "p", COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "192x32" }, { NULL } @@ -131,6 +143,7 @@ struct controller controller_list[] = }, { "st7920", 24, 4, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_st7920_spi", "s", COM_ST7920SPI, + "", /* is_generate_u8g2_class= */ 1, { { "192x32" }, { NULL } @@ -138,6 +151,7 @@ struct controller controller_list[] = }, { "st7920", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "p", COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "128x64" }, { NULL } @@ -145,6 +159,7 @@ struct controller controller_list[] = }, { "st7920", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_st7920_spi", "s", COM_ST7920SPI, + "", /* is_generate_u8g2_class= */ 1, { { "128x64" }, { NULL } @@ -152,6 +167,7 @@ struct controller controller_list[] = }, { "ls013b7dh03", 16, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_001", "", COM_4WSPI, /* cad procedure is not required (no DC for this display) so it could be a dummy procedure here */ + "", /* is_generate_u8g2_class= */ 1, { { "128x128" }, { NULL } @@ -159,6 +175,7 @@ struct controller controller_list[] = }, { "uc1701", 13, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "ea_dogs102" }, { NULL } @@ -166,6 +183,7 @@ struct controller controller_list[] = }, { "st7565", 16, 8, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "ea_dogm128" }, { NULL } @@ -173,6 +191,7 @@ struct controller controller_list[] = }, { "st7565", 16, 4, "u8g2_ll_hvline_vertical_top_lsb", "u8x8_cad_001", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "nhd_c12832" }, { NULL } @@ -180,6 +199,7 @@ struct controller controller_list[] = }, { "t6963", 30, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080, + "", /* is_generate_u8g2_class= */ 1, { { "240x128" }, { NULL } @@ -187,6 +207,7 @@ struct controller controller_list[] = }, { "t6963", 30, 16, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080, + "not tested", /* is_generate_u8g2_class= */ 1, { { "256x64" }, { NULL } @@ -194,6 +215,7 @@ struct controller controller_list[] = }, { "t6963", 16, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_100", "", COM_8080, + "not tested", /* is_generate_u8g2_class= */ 1, { { "128x64" }, { NULL } @@ -201,10 +223,19 @@ struct controller controller_list[] = }, { "ssd1322", 32, 8, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_011", "", COM_4WSPI|COM_3WSPI|COM_6800|COM_8080, + "not tested", /* is_generate_u8g2_class= */ 1, { { "256x64" }, { NULL } } + }, + { + "a2printer", 48, 30, "u8g2_ll_hvline_horizontal_right_lsb", "u8x8_cad_empty", "", COM_UART, + "", /* is_generate_u8g2_class= */ 0, + { + { "384x240" }, + { NULL } + } } }; @@ -662,7 +693,10 @@ void do_display(int controller_idx, int display_idx, const char *postfix) do_display_interface(controller_idx, display_idx, postfix, 8); /* ST7920 SW SPI */ do_display_interface(controller_idx, display_idx, postfix, 9); /* HW SPI (not yet implemented) */ } - + if ( controller_list[controller_idx].com & COM_UART ) + { + /* currently there is no Arduino C++ interface, instead the interface is created manually in the example */ + } }