Skip to content

Commit 2a553a0

Browse files
author
michael
committed
Patch for Driver EA232Graphic by Robert Resch
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1171 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
1 parent c98cf9a commit 2a553a0

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed

drv_EA232graphic.c

+33-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Driver for Electronic Assembly serial graphic display
55
*
6+
* Copyright (C) 2012 Robert Resch <[email protected]>
67
* Copyright (C) 2007 Stefan Gmeiner <[email protected]>
78
* Copyright (C) 2005 Michael Reinelt <[email protected]>
89
* Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <[email protected]>
@@ -46,14 +47,19 @@
4647
* GE240-7KV24 3 8 no
4748
* GE240-7KLWV24 3 8 no
4849
* GE240-6KLWV24 3 8 no
50+
* KIT160-6 2 8 no
51+
* KIT160-7 2 8 no
52+
* KIT240-6 2 8 no
53+
* KIT240-7 2 8 no
54+
* KIT320-8 2 8 no
4955
*
5056
* Supported protocol commands:
5157
*
5258
* Clear
5359
* Protocol Display Set Output Set Contrast Bitmap Orientation
5460
* =======================================================================================
5561
* 1 DL Y(0..7)(0..1) K(0..20) U(x)(y)(w)(h)(...) Vertical
56-
* 2 <ESC>DL -- <ESC>DK(0..63) <ESC>UL(x)(y)(w)(h)(...) Vertical
62+
* 2 <ESC>DL -- <ESC>DK(0..63) <ESC>UL(x)(y)(w)(h)(...) Horizontal
5763
* 3 DL Y(0..7)(0..1) -- U(x)(y)(w)(h)(...) Horizontal
5864
*
5965
* Bitmap orientation:
@@ -141,6 +147,11 @@ static MODEL Models[] = {
141147

142148
/* Protocol 2 models */
143149
{"GE128-6N9V24", 128, 64, 63, 40, 0, 2},
150+
{"KIT160-6", 160, 80, 0, 0, 0, 2},
151+
{"KIT160-7", 160, 128, 0, 0, 0, 2},
152+
{"KIT240-6", 240, 64, 0, 0, 0, 2},
153+
{"KIT240-7", 240, 128, 0, 0, 0, 2},
154+
{"KIT320-8", 320, 240, 0, 0, 0, 2},
144155

145156
/* Protocol 3 models */
146157
{"GE128-7KV24", 128, 128, 0, 0, 8, 3},
@@ -165,7 +176,7 @@ static int drv_EA232graphic_open(const char *section)
165176
{
166177
/* open serial port */
167178
/* don't mind about device, speed and stuff, this function will take care of */
168-
if (drv_generic_serial_open(section, Name, 0) < 0)
179+
if (drv_generic_serial_open_handshake(section, Name, 0) < 0)
169180
return -1;
170181

171182
return 0;
@@ -183,14 +194,14 @@ static int drv_EA232graphic_close(void)
183194
/* write data to the display */
184195
static void drv_EA232graphic_send(const char *data, const int len)
185196
{
186-
drv_generic_serial_write(data, len);
197+
drv_generic_serial_write_rts(data, len);
187198
}
188199

189200

190201
/* delete Display */
191202
static void drv_EA232graphic_clear_display()
192203
{
193-
char cmd[3];
204+
char cmd[4];
194205

195206
switch (Model->protocol) {
196207
case 1:
@@ -205,6 +216,12 @@ static void drv_EA232graphic_clear_display()
205216
cmd[1] = 'D';
206217
cmd[2] = 'L';
207218
drv_EA232graphic_send(cmd, 3);
219+
usleep(500000);
220+
cmd[0] = ESC;
221+
cmd[1] = 'Q';
222+
cmd[2] = 'C';
223+
cmd[3] = '0';
224+
drv_EA232graphic_send(cmd, 4);
208225
break;
209226
default:
210227
error("%s: undefined protocol type", Name);
@@ -218,16 +235,16 @@ static void drv_EA232graphic_clear_display()
218235
static void drv_EA232graphic_blit(const int row, const int col, const int height, const int width)
219236
{
220237

221-
int r, c, l, p;
238+
int r, c, l, p, d;
222239
char *cmd;
223240

224241
/* calculate length of command */
225242
l = 0;
226243
switch (Model->protocol) {
227244
case 1:
228-
case 2:
229245
l = ((height + 7) / 8) * width;
230246
break;
247+
case 2:
231248
case 3:
232249
l = ((width + 7) / 8) * height;
233250
break;
@@ -275,7 +292,6 @@ static void drv_EA232graphic_blit(const int row, const int col, const int height
275292
/* set pixels */
276293
switch (Model->protocol) {
277294
case 1:
278-
case 2:
279295
for (r = 0; r < height; r++) {
280296
for (c = 0; c < width; c++) {
281297
if (drv_generic_graphic_black(r + row, c + col)) {
@@ -284,6 +300,16 @@ static void drv_EA232graphic_blit(const int row, const int col, const int height
284300
}
285301
}
286302
break;
303+
case 2:
304+
d = ((width + 7) / 8);
305+
for (r = 0; r < height; r++) {
306+
for (c = 0; c < width; c++) {
307+
if (drv_generic_graphic_black(r + row, c + col)) {
308+
cmd[(c / 8) + (d * r) + p] |= (MSB_BYTE >> (c % 8));
309+
}
310+
}
311+
}
312+
break;
287313
case 3:
288314
for (c = 0; c < width; c++) {
289315
for (r = 0; r < height; r++) {

drv_generic_serial.c

+37
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
#include <fcntl.h>
5959
#include <time.h>
6060
#include <signal.h>
61+
#include <linux/serial.h>
62+
#include <sys/ioctl.h>
6163
#include <sys/types.h>
6264
#include <sys/stat.h>
6365

@@ -205,6 +207,25 @@ static pid_t drv_generic_serial_unlock_port(const char *Port)
205207
return 0;
206208
}
207209

210+
int drv_generic_serial_open_handshake(const char *section, const char *driver, const unsigned int flags)
211+
{
212+
int fd;
213+
struct termios portset;
214+
struct serial_struct serinfo;
215+
fd = drv_generic_serial_open(section, driver, flags); /* Open the Port with the original function */
216+
217+
/* We activate the Usage of the Handshake Pins */
218+
tcgetattr(fd, &portset); /* Get Port Attributes */
219+
portset.c_cflag |= CRTSCTS; /* Set Handshake */
220+
tcsetattr(fd, TCSANOW, &portset); /* Set Port Attrributes */
221+
222+
/* This sets the UART-Type to the simplest one: 8250. No Fifos or other Features */
223+
/* Fifo destroys Handshake so needs to be disabled */
224+
ioctl(fd, TIOCGSERIAL, &serinfo); /* Get Serial Info */
225+
serinfo.type = PORT_8250; /* Set to super-simple Port Type */
226+
ioctl(fd, TIOCSSERIAL, &serinfo); /* Write Back modified Info */
227+
return fd;
228+
}
208229

209230
int drv_generic_serial_open(const char *section, const char *driver, const unsigned int flags)
210231
{
@@ -330,6 +351,22 @@ int drv_generic_serial_read(char *string, const int len)
330351
return ret;
331352
}
332353

354+
void drv_generic_serial_write_rts(const char *string, const int len)
355+
{
356+
int serial, p, tocnt;
357+
358+
for (p = 0; p < len; p++) { /* Send Byte-by-Byte checking RTS-Line */
359+
/* Timeout is 500ms */
360+
tocnt = 250; /* 250 * 2 */
361+
ioctl(Device, TIOCMGET, &serial); /* Get status of Control Lines */
362+
while (!(serial & TIOCM_RTS) && tocnt) { /* Wait until RTS is set or timeout */
363+
tocnt--; /* decrease timeout counter */
364+
usleep(2000); /* Wait two milliseconds */
365+
ioctl(Device, TIOCMGET, &serial);
366+
}
367+
drv_generic_serial_write(&string[p], 1); /* Actually send one byte */
368+
}
369+
}
333370

334371
void drv_generic_serial_write(const char *string, const int len)
335372
{

0 commit comments

Comments
 (0)