| 1 | /* $Id$ |
|---|
| 2 | * $URL$ |
|---|
| 3 | * |
|---|
| 4 | * Driver for Electronic Assembly serial graphic display |
|---|
| 5 | * |
|---|
| 6 | * Copyright (C) 2007 Stefan Gmeiner <stefangmeiner@solnet.ch> |
|---|
| 7 | * Copyright (C) 2005 Michael Reinelt <reinelt@eunet.at> |
|---|
| 8 | * Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> |
|---|
| 9 | * |
|---|
| 10 | * This file is part of LCD4Linux. |
|---|
| 11 | * |
|---|
| 12 | * LCD4Linux is free software; you can redistribute it and/or modify |
|---|
| 13 | * it under the terms of the GNU General Public License as published by |
|---|
| 14 | * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 15 | * any later version. |
|---|
| 16 | * |
|---|
| 17 | * LCD4Linux is distributed in the hope that it will be useful, |
|---|
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 20 | * GNU General Public License for more details. |
|---|
| 21 | * |
|---|
| 22 | * You should have received a copy of the GNU General Public License |
|---|
| 23 | * along with this program; if not, write to the Free Software |
|---|
| 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 25 | * |
|---|
| 26 | */ |
|---|
| 27 | |
|---|
| 28 | /* |
|---|
| 29 | * Electronic Assembly RS232 Graphic Displays |
|---|
| 30 | * |
|---|
| 31 | * This driver supports some of the Electronic Assembly serial graphic displays. Although |
|---|
| 32 | * most of this display support higher level operation like text and graphic command, non of |
|---|
| 33 | * these are used. Instead the lcd4linux graphic routines creates the graphic which is then |
|---|
| 34 | * transferd to the display. |
|---|
| 35 | * |
|---|
| 36 | * FIXME: Some display have addition features such as GPI which are not yet implemented. |
|---|
| 37 | * |
|---|
| 38 | * Display Protocol Output Contrast |
|---|
| 39 | * ============================================ |
|---|
| 40 | * GE120-5NV24 1 8 yes |
|---|
| 41 | * GE128-6N3V24 1 8 no |
|---|
| 42 | * GE128-6N9V24 2 0 yes |
|---|
| 43 | * GE128-7KV24 3 8 no |
|---|
| 44 | * GE240-6KV24 3 8 no |
|---|
| 45 | * GE240-6KCV24 3 8 no |
|---|
| 46 | * GE240-7KV24 3 8 no |
|---|
| 47 | * GE240-7KLWV24 3 8 no |
|---|
| 48 | * GE240-6KLWV24 3 8 no |
|---|
| 49 | * |
|---|
| 50 | * Supported protocol commands: |
|---|
| 51 | * |
|---|
| 52 | * Clear |
|---|
| 53 | * Protocol Display Set Output Set Contrast Bitmap Orientation |
|---|
| 54 | * ======================================================================================= |
|---|
| 55 | * 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 |
|---|
| 57 | * 3 DL Y(0..7)(0..1) -- U(x)(y)(w)(h)(...) Horizontal |
|---|
| 58 | * |
|---|
| 59 | * Bitmap orientation: |
|---|
| 60 | * |
|---|
| 61 | * Vertical: Byte-No. |
|---|
| 62 | * 123456789.... |
|---|
| 63 | * Bit 0 ********* |
|---|
| 64 | * Bit 1 ********* |
|---|
| 65 | * Bit 2 ********* |
|---|
| 66 | * Bit 3 ********* |
|---|
| 67 | * Bit 4 ********* |
|---|
| 68 | * Bit 5 ********* |
|---|
| 69 | * Bit 6 ********* |
|---|
| 70 | * Bit 7 ********* |
|---|
| 71 | * |
|---|
| 72 | * Horizontal: Bit-No. |
|---|
| 73 | * 76543210 |
|---|
| 74 | * Byte 0 ******** |
|---|
| 75 | * Byte 1 ******** |
|---|
| 76 | * Byte 3 ******** |
|---|
| 77 | * ... |
|---|
| 78 | * |
|---|
| 79 | * |
|---|
| 80 | */ |
|---|
| 81 | |
|---|
| 82 | /* |
|---|
| 83 | * |
|---|
| 84 | * exported fuctions: |
|---|
| 85 | * |
|---|
| 86 | * struct DRIVER drv_EA232graphic |
|---|
| 87 | * |
|---|
| 88 | */ |
|---|
| 89 | |
|---|
| 90 | #include "config.h" |
|---|
| 91 | |
|---|
| 92 | #include <stdlib.h> |
|---|
| 93 | #include <stdio.h> |
|---|
| 94 | #include <string.h> |
|---|
| 95 | #include <errno.h> |
|---|
| 96 | #include <sys/time.h> |
|---|
| 97 | #include <unistd.h> |
|---|
| 98 | |
|---|
| 99 | #include "debug.h" |
|---|
| 100 | #include "cfg.h" |
|---|
| 101 | #include "qprintf.h" |
|---|
| 102 | #include "udelay.h" |
|---|
| 103 | #include "plugin.h" |
|---|
| 104 | #include "widget.h" |
|---|
| 105 | #include "widget_text.h" |
|---|
| 106 | #include "widget_icon.h" |
|---|
| 107 | #include "widget_bar.h" |
|---|
| 108 | #include "drv.h" |
|---|
| 109 | |
|---|
| 110 | /* graphic display */ |
|---|
| 111 | #include "drv_generic_graphic.h" |
|---|
| 112 | |
|---|
| 113 | /* serial port */ |
|---|
| 114 | #include "drv_generic_serial.h" |
|---|
| 115 | |
|---|
| 116 | /* GPO */ |
|---|
| 117 | #include "drv_generic_gpio.h" |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | #define ESC ((char)27) |
|---|
| 122 | #define MSB_BYTE 0x80 |
|---|
| 123 | #define LSB_BYTE 0x01 |
|---|
| 124 | |
|---|
| 125 | static char Name[] = "EA232graphic"; |
|---|
| 126 | |
|---|
| 127 | typedef struct { |
|---|
| 128 | char *name; |
|---|
| 129 | int columns; |
|---|
| 130 | int rows; |
|---|
| 131 | int max_contrast; |
|---|
| 132 | int default_contrast; |
|---|
| 133 | int gpo; |
|---|
| 134 | int protocol; |
|---|
| 135 | } MODEL; |
|---|
| 136 | |
|---|
| 137 | static MODEL Models[] = { |
|---|
| 138 | /* Protocol 1 models */ |
|---|
| 139 | {"GE120-5NV24", 120, 32, 20, 8, 8, 1}, |
|---|
| 140 | {"GE128-6N3V24", 128, 64, 0, 0, 8, 1}, |
|---|
| 141 | |
|---|
| 142 | /* Protocol 2 models */ |
|---|
| 143 | {"GE128-6N9V24", 128, 64, 63, 40, 0, 2}, |
|---|
| 144 | |
|---|
| 145 | /* Protocol 3 models */ |
|---|
| 146 | {"GE128-7KV24", 128, 128, 0, 0, 8, 3}, |
|---|
| 147 | {"GE240-6KV24", 240, 64, 0, 0, 8, 3}, |
|---|
| 148 | {"GE240-6KCV24", 240, 64, 0, 0, 8, 3}, |
|---|
| 149 | {"GE240-7KV24", 240, 128, 0, 0, 8, 3}, |
|---|
| 150 | {"GE240-7KLWV24", 240, 128, 0, 0, 8, 3}, |
|---|
| 151 | {"GE240-6KLWV24", 240, 64, 0, 0, 8, 3}, |
|---|
| 152 | |
|---|
| 153 | {NULL, 0, 0, 0, 0, 0, 0} |
|---|
| 154 | }; |
|---|
| 155 | |
|---|
| 156 | static MODEL *Model; |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | /****************************************/ |
|---|
| 160 | /*** hardware dependant functions ***/ |
|---|
| 161 | /****************************************/ |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | static int drv_EA232graphic_open(const char *section) |
|---|
| 165 | { |
|---|
| 166 | /* open serial port */ |
|---|
| 167 | /* don't mind about device, speed and stuff, this function will take care of */ |
|---|
| 168 | if (drv_generic_serial_open(section, Name, 0) < 0) |
|---|
| 169 | return -1; |
|---|
| 170 | |
|---|
| 171 | return 0; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | static int drv_EA232graphic_close(void) |
|---|
| 176 | { |
|---|
| 177 | drv_generic_serial_close(); |
|---|
| 178 | |
|---|
| 179 | return 0; |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | /* write data to the display */ |
|---|
| 184 | static void drv_EA232graphic_send(const char *data, const int len) |
|---|
| 185 | { |
|---|
| 186 | drv_generic_serial_write(data, len); |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | /* delete Display */ |
|---|
| 191 | static void drv_EA232graphic_clear_display() |
|---|
| 192 | { |
|---|
| 193 | char cmd[3]; |
|---|
| 194 | |
|---|
| 195 | switch (Model->protocol) { |
|---|
| 196 | case 1: |
|---|
| 197 | case 3: |
|---|
| 198 | cmd[0] = 'D'; |
|---|
| 199 | cmd[1] = 'L'; |
|---|
| 200 | drv_EA232graphic_send(cmd, 2); |
|---|
| 201 | break; |
|---|
| 202 | |
|---|
| 203 | case 2: |
|---|
| 204 | cmd[0] = ESC; |
|---|
| 205 | cmd[1] = 'D'; |
|---|
| 206 | cmd[2] = 'L'; |
|---|
| 207 | drv_EA232graphic_send(cmd, 3); |
|---|
| 208 | break; |
|---|
| 209 | default: |
|---|
| 210 | error("%s: undefined protocol type", Name); |
|---|
| 211 | return; |
|---|
| 212 | } |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | /* copy framebuffer to display */ |
|---|
| 218 | static void drv_EA232graphic_blit(const int row, const int col, const int height, const int width) |
|---|
| 219 | { |
|---|
| 220 | |
|---|
| 221 | int r, c, l, p; |
|---|
| 222 | char *cmd; |
|---|
| 223 | |
|---|
| 224 | /* calculate length of command */ |
|---|
| 225 | l = 0; |
|---|
| 226 | switch (Model->protocol) { |
|---|
| 227 | case 1: |
|---|
| 228 | case 2: |
|---|
| 229 | l = ((height + 7) / 8) * width; |
|---|
| 230 | break; |
|---|
| 231 | case 3: |
|---|
| 232 | l = ((width + 7) / 8) * height; |
|---|
| 233 | break; |
|---|
| 234 | default: |
|---|
| 235 | error("%s: undefined protocol type", Name); |
|---|
| 236 | return; |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | /* add maximum length of command header */ |
|---|
| 240 | cmd = (char *) malloc(l + 10); |
|---|
| 241 | if (cmd == NULL) { |
|---|
| 242 | error("%s: allocation of buffer failed: %s", Name, strerror(errno)); |
|---|
| 243 | return; |
|---|
| 244 | } |
|---|
| 245 | p = 0; |
|---|
| 246 | |
|---|
| 247 | /* write command header */ |
|---|
| 248 | switch (Model->protocol) { |
|---|
| 249 | case 1: |
|---|
| 250 | case 3: |
|---|
| 251 | cmd[p++] = 'U'; |
|---|
| 252 | cmd[p++] = col; |
|---|
| 253 | cmd[p++] = row; |
|---|
| 254 | cmd[p++] = width; |
|---|
| 255 | cmd[p++] = height; |
|---|
| 256 | break; |
|---|
| 257 | case 2: |
|---|
| 258 | cmd[p++] = ESC; |
|---|
| 259 | cmd[p++] = 'U'; |
|---|
| 260 | cmd[p++] = 'L'; |
|---|
| 261 | cmd[p++] = col; |
|---|
| 262 | cmd[p++] = row; |
|---|
| 263 | cmd[p++] = width; |
|---|
| 264 | cmd[p++] = height; |
|---|
| 265 | break; |
|---|
| 266 | default: |
|---|
| 267 | error("%s: undefined protocol type", Name); |
|---|
| 268 | free(cmd); |
|---|
| 269 | return; |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | /* clear all pixels */ |
|---|
| 273 | memset(cmd + p, 0, l); |
|---|
| 274 | |
|---|
| 275 | /* set pixels */ |
|---|
| 276 | switch (Model->protocol) { |
|---|
| 277 | case 1: |
|---|
| 278 | case 2: |
|---|
| 279 | for (r = 0; r < height; r++) { |
|---|
| 280 | for (c = 0; c < width; c++) { |
|---|
| 281 | if (drv_generic_graphic_black(r + row, c + col)) { |
|---|
| 282 | cmd[(r / 8) * width + c + p] |= (LSB_BYTE << (r % 8)); |
|---|
| 283 | } |
|---|
| 284 | } |
|---|
| 285 | } |
|---|
| 286 | break; |
|---|
| 287 | case 3: |
|---|
| 288 | for (c = 0; c < width; c++) { |
|---|
| 289 | for (r = 0; r < height; r++) { |
|---|
| 290 | if (drv_generic_graphic_black(r + row, c + col)) { |
|---|
| 291 | cmd[(c / 8) * height + r + p] |= (MSB_BYTE >> (c % 8)); |
|---|
| 292 | } |
|---|
| 293 | } |
|---|
| 294 | } |
|---|
| 295 | break; |
|---|
| 296 | default: |
|---|
| 297 | error("%s: undefined protocol type", Name); |
|---|
| 298 | free(cmd); |
|---|
| 299 | return; |
|---|
| 300 | } |
|---|
| 301 | |
|---|
| 302 | drv_EA232graphic_send(cmd, p + l); |
|---|
| 303 | |
|---|
| 304 | free(cmd); |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | static int drv_EA232graphic_GPO(const int num, const int val) |
|---|
| 309 | { |
|---|
| 310 | char cmd[4]; |
|---|
| 311 | |
|---|
| 312 | if (Model->gpo == 0) { |
|---|
| 313 | error("%s: GPO not supported on this model.", Name); |
|---|
| 314 | return -1; |
|---|
| 315 | } |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | if (Model->gpo < num) { |
|---|
| 319 | error("%s: GPO %d is not available.", Name, num); |
|---|
| 320 | return -1; |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | cmd[0] = 'Y'; |
|---|
| 324 | cmd[1] = num; |
|---|
| 325 | cmd[2] = (val > 0) ? 1 : 0; |
|---|
| 326 | |
|---|
| 327 | drv_EA232graphic_send(cmd, 3); |
|---|
| 328 | |
|---|
| 329 | return 0; |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | /* adjust contast */ |
|---|
| 334 | static int drv_EA232graphic_contrast(int contrast) |
|---|
| 335 | { |
|---|
| 336 | char cmd[4]; |
|---|
| 337 | |
|---|
| 338 | if (Model->max_contrast == 0) { |
|---|
| 339 | error("%s: contrast setting not support by model", Name); |
|---|
| 340 | return -1; |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | /* adjust limits according to the display */ |
|---|
| 344 | if (contrast < 0) |
|---|
| 345 | contrast = 0; |
|---|
| 346 | if (contrast > Model->max_contrast) |
|---|
| 347 | contrast = Model->max_contrast; |
|---|
| 348 | |
|---|
| 349 | |
|---|
| 350 | switch (Model->protocol) { |
|---|
| 351 | case 1: |
|---|
| 352 | cmd[0] = 'K'; |
|---|
| 353 | cmd[1] = contrast; |
|---|
| 354 | drv_EA232graphic_send(cmd, 2); |
|---|
| 355 | break; |
|---|
| 356 | case 2: |
|---|
| 357 | cmd[0] = ESC; |
|---|
| 358 | cmd[1] = 'D'; |
|---|
| 359 | cmd[2] = 'K'; |
|---|
| 360 | cmd[3] = contrast; |
|---|
| 361 | drv_EA232graphic_send(cmd, 4); |
|---|
| 362 | break; |
|---|
| 363 | default: |
|---|
| 364 | error("%s: undefined protocol type", Name); |
|---|
| 365 | return -1; |
|---|
| 366 | } |
|---|
| 367 | |
|---|
| 368 | return contrast; |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | |
|---|
| 372 | /* start graphic display */ |
|---|
| 373 | static int drv_EA232graphic_start(const char *section) |
|---|
| 374 | { |
|---|
| 375 | char *s; |
|---|
| 376 | int contrast; |
|---|
| 377 | int i; |
|---|
| 378 | |
|---|
| 379 | /* read model from configuration */ |
|---|
| 380 | s = cfg_get(section, "Model", NULL); |
|---|
| 381 | if (s == NULL || *s == '\0') { |
|---|
| 382 | error("%s: no '%s.Model' entry from %s", Name, section, cfg_source()); |
|---|
| 383 | return -1; |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | for (i = 0; Models[i].name != NULL; i++) { |
|---|
| 387 | if (strcasecmp(Models[i].name, s) == 0) |
|---|
| 388 | break; |
|---|
| 389 | } |
|---|
| 390 | if (!Models[i].name) { |
|---|
| 391 | error("%s: %s.Model '%s' is unknown from %s", Name, section, s, cfg_source()); |
|---|
| 392 | free(s); |
|---|
| 393 | return -1; |
|---|
| 394 | } |
|---|
| 395 | Model = &Models[i]; |
|---|
| 396 | info("%s: using model '%s'", Name, Model->name); |
|---|
| 397 | free(s); |
|---|
| 398 | |
|---|
| 399 | /* read display size from model configuration */ |
|---|
| 400 | DROWS = Model->rows; |
|---|
| 401 | DCOLS = Model->columns; |
|---|
| 402 | |
|---|
| 403 | /* set number of GPO's from model */ |
|---|
| 404 | GPOS = Model->gpo; |
|---|
| 405 | |
|---|
| 406 | /* read font size from configuration */ |
|---|
| 407 | s = cfg_get(section, "Font", "6x8"); |
|---|
| 408 | if (s == NULL || *s == '\0') { |
|---|
| 409 | error("%s: no '%s.Font' entry from %s", Name, section, cfg_source()); |
|---|
| 410 | return -1; |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | XRES = -1; |
|---|
| 414 | YRES = -1; |
|---|
| 415 | if (sscanf(s, "%dx%d", &XRES, &YRES) != 2 || XRES < 1 || YRES < 1) { |
|---|
| 416 | error("%s: bad Font '%s' from %s", Name, s, cfg_source()); |
|---|
| 417 | free(s); |
|---|
| 418 | return -1; |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | /* Fixme: provider other fonts someday... */ |
|---|
| 422 | if (XRES != 6 && YRES != 8) { |
|---|
| 423 | error("%s: bad Font '%s' from %s (only 6x8 at the moment)", Name, s, cfg_source()); |
|---|
| 424 | free(s); |
|---|
| 425 | return -1; |
|---|
| 426 | } |
|---|
| 427 | free(s); |
|---|
| 428 | |
|---|
| 429 | /* open communication with the display */ |
|---|
| 430 | if (drv_EA232graphic_open(section) < 0) { |
|---|
| 431 | return -1; |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | /* reset & initialize display */ |
|---|
| 435 | drv_EA232graphic_clear_display(); |
|---|
| 436 | |
|---|
| 437 | if (cfg_number(section, "Contrast", Model->default_contrast, 0, Model->max_contrast, &contrast) > 0) { |
|---|
| 438 | drv_EA232graphic_contrast(contrast); |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | return 0; |
|---|
| 442 | } |
|---|
| 443 | |
|---|
| 444 | |
|---|
| 445 | /****************************************/ |
|---|
| 446 | /*** plugins ***/ |
|---|
| 447 | /****************************************/ |
|---|
| 448 | |
|---|
| 449 | static void plugin_contrast(RESULT * result, RESULT * arg1) |
|---|
| 450 | { |
|---|
| 451 | double contrast; |
|---|
| 452 | |
|---|
| 453 | contrast = drv_EA232graphic_contrast(R2N(arg1)); |
|---|
| 454 | SetResult(&result, R_NUMBER, &contrast); |
|---|
| 455 | } |
|---|
| 456 | |
|---|
| 457 | |
|---|
| 458 | /****************************************/ |
|---|
| 459 | /*** widget callbacks ***/ |
|---|
| 460 | /****************************************/ |
|---|
| 461 | |
|---|
| 462 | |
|---|
| 463 | /* using drv_generic_text_draw(W) */ |
|---|
| 464 | /* using drv_generic_text_icon_draw(W) */ |
|---|
| 465 | /* using drv_generic_text_bar_draw(W) */ |
|---|
| 466 | /* using drv_generic_gpio_draw(W) */ |
|---|
| 467 | |
|---|
| 468 | |
|---|
| 469 | /****************************************/ |
|---|
| 470 | /*** exported functions ***/ |
|---|
| 471 | /****************************************/ |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | /* list models */ |
|---|
| 475 | int drv_EA232graphic_list(void) |
|---|
| 476 | { |
|---|
| 477 | int i; |
|---|
| 478 | |
|---|
| 479 | for (i = 0; Models[i].name; i++) { |
|---|
| 480 | printf("%s ", Models[i].name); |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | return 0; |
|---|
| 484 | } |
|---|
| 485 | |
|---|
| 486 | |
|---|
| 487 | /* initialize driver & display */ |
|---|
| 488 | int drv_EA232graphic_init(const char *section, const int quiet) |
|---|
| 489 | { |
|---|
| 490 | int ret; |
|---|
| 491 | |
|---|
| 492 | /* real worker functions */ |
|---|
| 493 | drv_generic_graphic_real_blit = drv_EA232graphic_blit; |
|---|
| 494 | drv_generic_gpio_real_set = drv_EA232graphic_GPO; |
|---|
| 495 | |
|---|
| 496 | /* start display */ |
|---|
| 497 | if ((ret = drv_EA232graphic_start(section)) != 0) |
|---|
| 498 | return ret; |
|---|
| 499 | |
|---|
| 500 | /* initialize generic graphic driver */ |
|---|
| 501 | if ((ret = drv_generic_graphic_init(section, Name)) != 0) |
|---|
| 502 | return ret; |
|---|
| 503 | |
|---|
| 504 | /* initialize GPO */ |
|---|
| 505 | if (Model->gpo > 0 && (ret = drv_generic_gpio_init(section, Name)) != 0) |
|---|
| 506 | return ret; |
|---|
| 507 | |
|---|
| 508 | if (!quiet) { |
|---|
| 509 | char buffer[40]; |
|---|
| 510 | qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS); |
|---|
| 511 | if (drv_generic_graphic_greet(buffer, NULL)) { |
|---|
| 512 | sleep(3); |
|---|
| 513 | drv_generic_graphic_clear(); |
|---|
| 514 | } |
|---|
| 515 | } |
|---|
| 516 | |
|---|
| 517 | /* register plugins */ |
|---|
| 518 | AddFunction("LCD::contrast", 1, plugin_contrast); |
|---|
| 519 | |
|---|
| 520 | return 0; |
|---|
| 521 | } |
|---|
| 522 | |
|---|
| 523 | /* close driver & display */ |
|---|
| 524 | int drv_EA232graphic_quit(const int quiet) |
|---|
| 525 | { |
|---|
| 526 | |
|---|
| 527 | info("%s: shutting down.", Name); |
|---|
| 528 | |
|---|
| 529 | /* clear display */ |
|---|
| 530 | drv_generic_graphic_clear(); |
|---|
| 531 | |
|---|
| 532 | /* say goodbye... */ |
|---|
| 533 | if (!quiet) { |
|---|
| 534 | drv_generic_graphic_greet("goodbye!", NULL); |
|---|
| 535 | } |
|---|
| 536 | |
|---|
| 537 | drv_generic_graphic_quit(); |
|---|
| 538 | |
|---|
| 539 | if (Model->gpo > 0) |
|---|
| 540 | drv_generic_gpio_quit(); |
|---|
| 541 | |
|---|
| 542 | debug("%s: closing connection", Name); |
|---|
| 543 | drv_EA232graphic_close(); |
|---|
| 544 | |
|---|
| 545 | return (0); |
|---|
| 546 | } |
|---|
| 547 | |
|---|
| 548 | /* use this one for a graphic display */ |
|---|
| 549 | DRIVER drv_EA232graphic = { |
|---|
| 550 | .name = Name, |
|---|
| 551 | .list = drv_EA232graphic_list, |
|---|
| 552 | .init = drv_EA232graphic_init, |
|---|
| 553 | .quit = drv_EA232graphic_quit, |
|---|
| 554 | }; |
|---|