From d0b266cf85d3c7733259c76831de0cfd4c1731a1 Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Thu, 8 Mar 2012 21:03:40 +0000 Subject: Import upstream version 0.11.0~svn1180 --- drv_EA232graphic.c | 108 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 86 insertions(+), 22 deletions(-) (limited to 'drv_EA232graphic.c') diff --git a/drv_EA232graphic.c b/drv_EA232graphic.c index 680ffe9..bec5fc9 100644 --- a/drv_EA232graphic.c +++ b/drv_EA232graphic.c @@ -1,8 +1,9 @@ -/* $Id: drv_EA232graphic.c 840 2007-09-09 12:17:42Z michael $ +/* $Id: drv_EA232graphic.c 1172 2012-02-10 16:04:36Z michael $ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_EA232graphic.c $ * * Driver for Electronic Assembly serial graphic display * + * Copyright (C) 2012 Robert Resch * Copyright (C) 2007 Stefan Gmeiner * Copyright (C) 2005 Michael Reinelt * Copyright (C) 2005, 2006, 2007 The LCD4Linux Team @@ -46,6 +47,13 @@ * GE240-7KV24 3 8 no * GE240-7KLWV24 3 8 no * GE240-6KLWV24 3 8 no + * KIT120-5 4 5 no + * KIT129-6 4 8 no + * KIT160-6 2 8 no + * KIT160-7 2 8 no + * KIT240-6 2 8 no + * KIT240-7 2 8 no + * KIT320-8 2 8 no * * Supported protocol commands: * @@ -53,8 +61,9 @@ * Protocol Display Set Output Set Contrast Bitmap Orientation * ======================================================================================= * 1 DL Y(0..7)(0..1) K(0..20) U(x)(y)(w)(h)(...) Vertical - * 2 DL -- DK(0..63) UL(x)(y)(w)(h)(...) Vertical + * 2 DL YW... DK(0..63) UL(x)(y)(w)(h)(...) Horizontal * 3 DL Y(0..7)(0..1) -- U(x)(y)(w)(h)(...) Horizontal + * 4 DL YW... -- UL(x)(y)(w)(h)(...) Vertical * * Bitmap orientation: * @@ -141,6 +150,11 @@ static MODEL Models[] = { /* Protocol 2 models */ {"GE128-6N9V24", 128, 64, 63, 40, 0, 2}, + {"KIT160-6", 160, 80, 0, 0, 8, 2}, + {"KIT160-7", 160, 128, 0, 0, 8, 2}, + {"KIT240-6", 240, 64, 0, 0, 8, 2}, + {"KIT240-7", 240, 128, 0, 0, 8, 2}, + {"KIT320-8", 320, 240, 0, 0, 8, 2}, /* Protocol 3 models */ {"GE128-7KV24", 128, 128, 0, 0, 8, 3}, @@ -150,6 +164,10 @@ static MODEL Models[] = { {"GE240-7KLWV24", 240, 128, 0, 0, 8, 3}, {"GE240-6KLWV24", 240, 64, 0, 0, 8, 3}, + /* Protocol 4 models */ + {"KIT120-5", 120, 32, 0, 0, 5, 4}, + {"KIT129-6", 128, 64, 0, 0, 8, 4}, + {NULL, 0, 0, 0, 0, 0, 0} }; @@ -165,7 +183,7 @@ static int drv_EA232graphic_open(const char *section) { /* open serial port */ /* don't mind about device, speed and stuff, this function will take care of */ - if (drv_generic_serial_open(section, Name, 0) < 0) + if (drv_generic_serial_open_handshake(section, Name, 0) < 0) return -1; return 0; @@ -183,28 +201,56 @@ static int drv_EA232graphic_close(void) /* write data to the display */ static void drv_EA232graphic_send(const char *data, const int len) { - drv_generic_serial_write(data, len); + drv_generic_serial_write_rts(data, len); } /* delete Display */ static void drv_EA232graphic_clear_display() { - char cmd[3]; + char cmd[4]; switch (Model->protocol) { case 1: case 3: + /* Clear Display */ cmd[0] = 'D'; cmd[1] = 'L'; drv_EA232graphic_send(cmd, 2); break; - case 2: + /* Clear Display */ + cmd[0] = ESC; + cmd[1] = 'D'; + cmd[2] = 'L'; + drv_EA232graphic_send(cmd, 3); + usleep(500000); + /* Disable Cursor */ + cmd[0] = ESC; + cmd[1] = 'Q'; + cmd[2] = 'C'; + cmd[3] = '0'; + drv_EA232graphic_send(cmd, 4); + break; + case 4: + /* Set all GPIO to Output */ + cmd[0] = ESC; + cmd[1] = 'Y'; + cmd[2] = 'M'; + cmd[3] = 8; + drv_EA232graphic_send(cmd, 4); + /* Clear Display */ cmd[0] = ESC; cmd[1] = 'D'; cmd[2] = 'L'; drv_EA232graphic_send(cmd, 3); + usleep(500000); + /* Disable Cursor */ + cmd[0] = ESC; + cmd[1] = 'Q'; + cmd[2] = 'C'; + cmd[3] = '0'; + drv_EA232graphic_send(cmd, 4); break; default: error("%s: undefined protocol type", Name); @@ -218,16 +264,17 @@ static void drv_EA232graphic_clear_display() static void drv_EA232graphic_blit(const int row, const int col, const int height, const int width) { - int r, c, l, p; + int r, c, l, p, d; char *cmd; /* calculate length of command */ l = 0; switch (Model->protocol) { case 1: - case 2: + case 4: l = ((height + 7) / 8) * width; break; + case 2: case 3: l = ((width + 7) / 8) * height; break; @@ -255,6 +302,7 @@ static void drv_EA232graphic_blit(const int row, const int col, const int height cmd[p++] = height; break; case 2: + case 4: cmd[p++] = ESC; cmd[p++] = 'U'; cmd[p++] = 'L'; @@ -275,7 +323,7 @@ static void drv_EA232graphic_blit(const int row, const int col, const int height /* set pixels */ switch (Model->protocol) { case 1: - case 2: + case 4: for (r = 0; r < height; r++) { for (c = 0; c < width; c++) { if (drv_generic_graphic_black(r + row, c + col)) { @@ -284,6 +332,16 @@ static void drv_EA232graphic_blit(const int row, const int col, const int height } } break; + case 2: + d = ((width + 7) / 8); + for (r = 0; r < height; r++) { + for (c = 0; c < width; c++) { + if (drv_generic_graphic_black(r + row, c + col)) { + cmd[(c / 8) + (d * r) + p] |= (MSB_BYTE >> (c % 8)); + } + } + } + break; case 3: for (c = 0; c < width; c++) { for (r = 0; r < height; r++) { @@ -307,7 +365,7 @@ static void drv_EA232graphic_blit(const int row, const int col, const int height static int drv_EA232graphic_GPO(const int num, const int val) { - char cmd[4]; + char cmd[5]; if (Model->gpo == 0) { error("%s: GPO not supported on this model.", Name); @@ -320,11 +378,24 @@ static int drv_EA232graphic_GPO(const int num, const int val) return -1; } - cmd[0] = 'Y'; - cmd[1] = num; - cmd[2] = (val > 0) ? 1 : 0; - - drv_EA232graphic_send(cmd, 3); + switch (Model->protocol) { + case 1: + case 3: + cmd[0] = 'Y'; + cmd[1] = num; + cmd[2] = (val > 0) ? 1 : 0; + drv_EA232graphic_send(cmd, 3); + break; + case 2: + case 4: + cmd[0] = ESC; + cmd[1] = 'Y'; + cmd[2] = 'W'; + cmd[3] = num + 1; + cmd[4] = (val > 0) ? 1 : 0; + drv_EA232graphic_send(cmd, 5); + break; + } return 0; } @@ -417,13 +488,6 @@ static int drv_EA232graphic_start(const char *section) free(s); return -1; } - - /* Fixme: provider other fonts someday... */ - if (XRES != 6 && YRES != 8) { - error("%s: bad Font '%s' from %s (only 6x8 at the moment)", Name, s, cfg_source()); - free(s); - return -1; - } free(s); /* open communication with the display */ -- cgit v1.2.3