~siretart/lcd4linux/debian

« back to all changes in this revision

Viewing changes to drv_BeckmannEgle.c

  • Committer: Reinhard Tartler
  • Date: 2011-04-27 17:24:15 UTC
  • mto: This revision was merged to the branch mainline in revision 750.
  • Revision ID: siretart@tauware.de-20110427172415-6n4aptmvmz0eztvm
Tags: upstream-0.11.0~svn1143
ImportĀ upstreamĀ versionĀ 0.11.0~svn1143

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: drv_BeckmannEgle.c 840 2007-09-09 12:17:42Z michael $
 
2
 * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_BeckmannEgle.c $
 
3
 *
 
4
 * driver for Beckmann+Egle "Mini Terminals" and "Compact Terminals"
 
5
 * Copyright (C) 2000 Michael Reinelt <michael@reinelt.co.at>
 
6
 * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 
7
 *
 
8
 * This file is part of LCD4Linux.
 
9
 *
 
10
 * LCD4Linux is free software; you can redistribute it and/or modify
 
11
 * it under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation; either version 2, or (at your option)
 
13
 * any later version.
 
14
 *
 
15
 * LCD4Linux is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU General Public License
 
21
 * along with this program; if not, write to the Free Software
 
22
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
23
 *
 
24
 */
 
25
 
 
26
/* 
 
27
 *
 
28
 * exported fuctions:
 
29
 *
 
30
 * struct DRIVER drv_BeckmannEgle
 
31
 *
 
32
 */
 
33
 
 
34
#include "config.h"
 
35
 
 
36
#include <stdlib.h>
 
37
#include <stdio.h>
 
38
#include <string.h>
 
39
#include <unistd.h>
 
40
#include <termios.h>
 
41
 
 
42
#include "debug.h"
 
43
#include "cfg.h"
 
44
#include "qprintf.h"
 
45
#include "plugin.h"
 
46
#include "widget.h"
 
47
#include "widget_text.h"
 
48
#include "widget_icon.h"
 
49
#include "widget_bar.h"
 
50
#include "drv.h"
 
51
#include "drv_generic_text.h"
 
52
#include "drv_generic_serial.h"
 
53
 
 
54
 
 
55
#define ESC "\033"
 
56
 
 
57
static char Name[] = "Beckmann+Egle";
 
58
 
 
59
 
 
60
typedef struct {
 
61
    char *name;
 
62
    int rows;
 
63
    int cols;
 
64
    int protocol;
 
65
    int type;
 
66
} MODEL;
 
67
 
 
68
 
 
69
static MODEL Models[] = {
 
70
 
 
71
    /* MultiTerminals */
 
72
    {"MT16x1", 1, 16, 1, 0},
 
73
    {"MT16x2", 2, 16, 1, 1},
 
74
    {"MT16x4", 4, 16, 1, 2},
 
75
    {"MT20x1", 1, 20, 1, 3},
 
76
    {"MT20x2", 2, 20, 1, 4},
 
77
    {"MT20x4", 4, 20, 1, 5},
 
78
    {"MT24x1", 1, 24, 1, 6},
 
79
    {"MT24x2", 2, 24, 1, 7},
 
80
    {"MT32x1", 1, 32, 1, 8},
 
81
    {"MT32x2", 2, 32, 1, 9},
 
82
    {"MT40x1", 1, 40, 1, 10},
 
83
    {"MT40x2", 2, 40, 1, 11},
 
84
    {"MT40x4", 4, 40, 1, 12},
 
85
 
 
86
    /* CompactTerminal */
 
87
    {"CT20x4", 4, 20, 2, 0},
 
88
 
 
89
    {NULL, 0, 0, 0, 0},
 
90
};
 
91
 
 
92
 
 
93
static int Model;
 
94
static int Protocol;
 
95
 
 
96
 
 
97
 
 
98
/****************************************/
 
99
/***  hardware dependant functions    ***/
 
100
/****************************************/
 
101
 
 
102
static void drv_BuE_clear(void)
 
103
{
 
104
    switch (Protocol) {
 
105
    case 1:
 
106
        drv_generic_serial_write(ESC "&#", 3);  /* clear display */
 
107
        break;
 
108
    case 2:
 
109
        drv_generic_serial_write(ESC "LL", 3);  /* clear display */
 
110
        break;
 
111
    }
 
112
}
 
113
 
 
114
 
 
115
static void drv_BuE_MT_write(const int row, const int col, const char *data, const int len)
 
116
{
 
117
    char cmd[] = ESC "[y;xH";
 
118
 
 
119
    cmd[2] = (char) row;
 
120
    cmd[4] = (char) col;
 
121
 
 
122
    drv_generic_serial_write(cmd, 6);
 
123
    drv_generic_serial_write(data, len);
 
124
}
 
125
 
 
126
 
 
127
static void drv_BuE_MT_defchar(const int ascii, const unsigned char *matrix)
 
128
{
 
129
    int i;
 
130
    char cmd[22] = ESC "&T";    /* enter transparent mode */
 
131
 
 
132
    cmd[3] = '\0';              /* write cmd */
 
133
    cmd[4] = 0x40 | 8 * ascii;  /* write CGRAM */
 
134
 
 
135
    for (i = 0; i < 8; i++) {
 
136
        cmd[2 * i + 5] = '\1';  /* write data */
 
137
        cmd[2 * i + 6] = matrix[i] & 0x1f;      /* character bitmap */
 
138
    }
 
139
    cmd[21] = '\377';           /* leave transparent mode */
 
140
 
 
141
    drv_generic_serial_write(cmd, 22);
 
142
}
 
143
 
 
144
 
 
145
static void drv_BuE_CT_write(const int row, const int col, const char *data, const int len)
 
146
{
 
147
    char cmd[] = ESC "LCzs\001";
 
148
    cmd[3] = (char) row + 1;
 
149
    cmd[4] = (char) col + 1;
 
150
 
 
151
    drv_generic_serial_write(cmd, 6);
 
152
    drv_generic_serial_write(data, len);
 
153
 
 
154
}
 
155
 
 
156
 
 
157
static void drv_BuE_CT_defchar(const int ascii, const unsigned char *matrix)
 
158
{
 
159
    int i;
 
160
    char cmd[13] = ESC "LZ";    /* set custom char */
 
161
 
 
162
    /* number of user-defined char (0..7) */
 
163
    cmd[3] = (char) ascii - CHAR0;
 
164
 
 
165
    /* ASCII code to replace */
 
166
    cmd[4] = (char) ascii;
 
167
 
 
168
    for (i = 0; i < 8; i++) {
 
169
        cmd[i + 5] = matrix[i] & 0x1f;
 
170
    }
 
171
 
 
172
    drv_generic_serial_write(cmd, 13);
 
173
}
 
174
 
 
175
 
 
176
static int drv_BuE_CT_contrast(int contrast)
 
177
{
 
178
    static char Contrast = 7;
 
179
    char cmd[4] = ESC "LKn";
 
180
 
 
181
    /* -1 is used to query the current contrast */
 
182
    if (contrast == -1)
 
183
        return Contrast;
 
184
 
 
185
    if (contrast < 0)
 
186
        contrast = 0;
 
187
    if (contrast > 15)
 
188
        contrast = 15;
 
189
    Contrast = contrast;
 
190
 
 
191
    cmd[3] = Contrast;
 
192
 
 
193
    drv_generic_serial_write(cmd, 4);
 
194
 
 
195
    return Contrast;
 
196
}
 
197
 
 
198
 
 
199
static int drv_BuE_CT_backlight(int backlight)
 
200
{
 
201
    static char Backlight = 0;
 
202
    char cmd[4] = ESC "LBn";
 
203
 
 
204
    /* -1 is used to query the current backlight */
 
205
    if (backlight == -1)
 
206
        return Backlight;
 
207
 
 
208
    if (backlight < 0)
 
209
        backlight = 0;
 
210
    if (backlight > 1)
 
211
        backlight = 1;
 
212
    Backlight = backlight;
 
213
 
 
214
    cmd[3] = Backlight;
 
215
 
 
216
    drv_generic_serial_write(cmd, 4);
 
217
 
 
218
    return Backlight;
 
219
}
 
220
 
 
221
 
 
222
static int drv_BuE_CT_gpo(int num, int val)
 
223
{
 
224
    static int GPO[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };
 
225
    char cmd[4] = ESC "Pnx";
 
226
 
 
227
    if (num < 0)
 
228
        num = 0;
 
229
    if (num > 7)
 
230
        num = 7;
 
231
 
 
232
    /* -1 is used to query the current GPO */
 
233
    if (val == -1)
 
234
        return GPO[num];
 
235
 
 
236
    if (val < 0)
 
237
        val = 0;
 
238
    if (val > 255)
 
239
        val = 255;
 
240
    GPO[num] = val;
 
241
 
 
242
    cmd[2] = (char) num;
 
243
    cmd[3] = (char) val;
 
244
 
 
245
    drv_generic_serial_write(cmd, 4);
 
246
 
 
247
    return GPO[num];
 
248
}
 
249
 
 
250
 
 
251
static int drv_BuE_CT_gpi(int num)
 
252
{
 
253
    char cmd[4] = ESC "?Pn";
 
254
    char buffer[4];
 
255
 
 
256
    if (num < 0)
 
257
        num = 0;
 
258
    if (num > 7)
 
259
        num = 7;
 
260
 
 
261
    cmd[3] = (char) num;
 
262
    drv_generic_serial_write(cmd, 4);
 
263
 
 
264
    usleep(10000);
 
265
 
 
266
    if (drv_generic_serial_read(buffer, 4) != 4) {
 
267
        error("%s: error reading port %d", Name, num);
 
268
        return -1;
 
269
    }
 
270
 
 
271
    return buffer[3];
 
272
}
 
273
 
 
274
 
 
275
static int drv_BuE_CT_adc(void)
 
276
{
 
277
    char buffer[4];
 
278
 
 
279
    drv_generic_serial_write(ESC "?A", 3);
 
280
 
 
281
    usleep(10000);
 
282
 
 
283
    if ((drv_generic_serial_read(buffer, 4) != 4) || (buffer[0] != 'A') || (buffer[1] != ':')
 
284
        ) {
 
285
        error("%s: error reading ADC", Name);
 
286
        return -1;
 
287
    }
 
288
 
 
289
    /* 10 bit value: 8 bit high, 2 bit low */
 
290
    return 4 * (unsigned char) buffer[2] + (unsigned char) buffer[3];
 
291
}
 
292
 
 
293
 
 
294
static int drv_BuE_CT_pwm(int val)
 
295
{
 
296
    static int PWM = -1;
 
297
    char cmd[4] = ESC "Adm";
 
298
 
 
299
    /* -1 is used to query the current PWM */
 
300
    if (val == -1)
 
301
        return PWM;
 
302
 
 
303
    if (val < 0)
 
304
        val = 0;
 
305
    if (val > 255)
 
306
        val = 255;
 
307
    PWM = val;
 
308
 
 
309
    cmd[2] = (char) val;
 
310
    cmd[3] = val == 0 ? 1 : 2;
 
311
    drv_generic_serial_write(cmd, 4);
 
312
 
 
313
    return val;
 
314
}
 
315
 
 
316
 
 
317
static int drv_BuE_MT_start(const char *section)
 
318
{
 
319
    char cmd[] = ESC "&sX";
 
320
 
 
321
    /* CSTOPB: 2 stop bits */
 
322
    if (drv_generic_serial_open(section, Name, CSTOPB) < 0)
 
323
        return -1;
 
324
 
 
325
    cmd[4] = Models[Model].type;
 
326
    drv_generic_serial_write(cmd, 4);   /* select display type */
 
327
    drv_generic_serial_write(ESC "&D", 3);      /* cursor off */
 
328
 
 
329
    return 0;
 
330
}
 
331
 
 
332
 
 
333
static int drv_BuE_CT_start(const char *section)
 
334
{
 
335
    char buffer[16];
 
336
    char *size;
 
337
    int i, len;
 
338
 
 
339
    if (drv_generic_serial_open(section, Name, 0) < 0)
 
340
        return -1;
 
341
 
 
342
#if 0
 
343
    /* restart terminal */
 
344
    drv_generic_serial_write(ESC "Kr", 3);
 
345
    usleep(10000);
 
346
#endif
 
347
 
 
348
    /* Fixme: the CT does not return a serial number in byte mode */
 
349
    /* set parameter mode 'decimal' */
 
350
    drv_generic_serial_write(ESC "KM\073", 4);
 
351
 
 
352
    /* read version */
 
353
    drv_generic_serial_write(ESC "?V", 3);
 
354
    usleep(100000);
 
355
    if ((len = drv_generic_serial_read(buffer, -1 * (int) sizeof(buffer))) > 0) {
 
356
        int v, r, s;
 
357
        if (sscanf(buffer, "V:%d.%d,%d;", &v, &r, &s) != 3) {
 
358
            error("%s: error parsing display identification <%*s>", Name, len, buffer);
 
359
        } else {
 
360
            info("%s: display identified as version %d.%d, S/N %d", Name, v, r, s);
 
361
        }
 
362
    }
 
363
 
 
364
    /* set parameter mode 'byte' */
 
365
    drv_generic_serial_write(ESC "KM\072", 4);
 
366
 
 
367
    /* the CT20x4 can control smaller displays, too */
 
368
    size = cfg_get(section, "Size", NULL);
 
369
    if (size != NULL && *size != '\0') {
 
370
        int r, c;
 
371
        char cmd[6] = ESC "LArc";
 
372
        if (sscanf(size, "%dx%d", &c, &r) != 2 || r < 1 || c < 1) {
 
373
            error("%s: bad %s.Size '%s' from %s", Name, section, size, cfg_source());
 
374
            return -1;
 
375
        }
 
376
        info("%s: display size: %d rows %d columns", Name, r, c);
 
377
        /* set display size */
 
378
        cmd[3] = (char) r;
 
379
        cmd[4] = (char) c;
 
380
        drv_generic_serial_write(cmd, 5);
 
381
        DCOLS = c;
 
382
        DROWS = r;
 
383
    }
 
384
 
 
385
    /* set contrast */
 
386
    if (cfg_number(section, "Contrast", 7, 0, 15, &i) > 0) {
 
387
        drv_BuE_CT_contrast(i);
 
388
    }
 
389
 
 
390
    /* set backlight */
 
391
    if (cfg_number(section, "Backlight", 0, 0, 1, &i) > 0) {
 
392
        drv_BuE_CT_backlight(i);
 
393
    }
 
394
 
 
395
 
 
396
    /* identify modules */
 
397
 
 
398
    for (i = 0; i < 8; i++) {
 
399
        char cmd[5] = ESC "K?Pn";
 
400
        cmd[4] = (char) i;
 
401
        drv_generic_serial_write(cmd, 5);       /* query I/O port */
 
402
        usleep(10000);
 
403
        if ((len = drv_generic_serial_read(buffer, 4)) == 4) {
 
404
            char *type = NULL;
 
405
            if (i == 0) {
 
406
                if (buffer[3] == 8) {
 
407
                    /* internal port */
 
408
                    type = "CT 20x4 internal port";
 
409
                } else {
 
410
                    error("%s: internal error: port 0 type %d should be type 8", Name, buffer[3]);
 
411
                    continue;
 
412
                }
 
413
            } else {
 
414
                switch (buffer[3]) {
 
415
                case 1: /* Key Module */
 
416
                    type = "XM-KEY-2x4-LED";
 
417
                    break;
 
418
                case 8: /* I/O Module */
 
419
                    type = "XM-IO8-T";
 
420
                    break;
 
421
                case 9: /* I/O Module */
 
422
                    type = "XM-IO4-R";
 
423
                    break;
 
424
                case 15:        /* nothing */
 
425
                    continue;
 
426
                default:        /* unhandled */
 
427
                    type = NULL;
 
428
                    break;
 
429
                }
 
430
            }
 
431
            if (type != NULL) {
 
432
                info("%s: Port %d: %s", Name, i, type);
 
433
            } else {
 
434
                error("%s: internal error: port %d unknown type %d", Name, i, cmd[3]);
 
435
            }
 
436
        } else {
 
437
            error("%s: error fetching type of port %d", Name, i);
 
438
        }
 
439
    }
 
440
 
 
441
    return 0;
 
442
}
 
443
 
 
444
 
 
445
static int drv_BuE_start(const char *section)
 
446
{
 
447
    int i, ret;
 
448
    char *model;
 
449
 
 
450
    model = cfg_get(section, "Model", NULL);
 
451
    if (model == NULL && *model == '\0') {
 
452
        error("%s: no '%s.Model' entry from %s", Name, section, cfg_source());
 
453
        return -1;
 
454
    }
 
455
 
 
456
    for (i = 0; Models[i].name != NULL; i++) {
 
457
        if (strcasecmp(Models[i].name, model) == 0)
 
458
            break;
 
459
    }
 
460
 
 
461
    if (Models[i].name == NULL) {
 
462
        error("%s: %s.Model '%s' is unknown from %s", Name, section, model, cfg_source());
 
463
        return -1;
 
464
    }
 
465
 
 
466
    Model = i;
 
467
    Protocol = Models[Model].protocol;
 
468
 
 
469
    info("%s: using model '%s'", Name, Models[Model].name);
 
470
 
 
471
    /* initialize global variables */
 
472
    DROWS = Models[Model].rows;
 
473
    DCOLS = Models[Model].cols;
 
474
 
 
475
    ret = 0;
 
476
    switch (Protocol) {
 
477
    case 1:
 
478
        ret = drv_BuE_MT_start(section);
 
479
        break;
 
480
    case 2:
 
481
        ret = drv_BuE_CT_start(section);
 
482
        break;
 
483
    }
 
484
    if (ret != 0) {
 
485
        return ret;
 
486
    }
 
487
 
 
488
    drv_BuE_clear();
 
489
 
 
490
    return 0;
 
491
}
 
492
 
 
493
 
 
494
/****************************************/
 
495
/***            plugins               ***/
 
496
/****************************************/
 
497
 
 
498
static void plugin_contrast(RESULT * result, const int argc, RESULT * argv[])
 
499
{
 
500
    double contrast;
 
501
 
 
502
    switch (argc) {
 
503
    case 0:
 
504
        contrast = drv_BuE_CT_contrast(-1);
 
505
        SetResult(&result, R_NUMBER, &contrast);
 
506
        break;
 
507
    case 1:
 
508
        contrast = drv_BuE_CT_contrast(R2N(argv[0]));
 
509
        SetResult(&result, R_NUMBER, &contrast);
 
510
        break;
 
511
    default:
 
512
        error("%s::contrast(): wrong number of parameters", Name);
 
513
        SetResult(&result, R_STRING, "");
 
514
    }
 
515
}
 
516
 
 
517
 
 
518
static void plugin_backlight(RESULT * result, const int argc, RESULT * argv[])
 
519
{
 
520
    double backlight;
 
521
 
 
522
    switch (argc) {
 
523
    case 0:
 
524
        backlight = drv_BuE_CT_backlight(-1);
 
525
        SetResult(&result, R_NUMBER, &backlight);
 
526
        break;
 
527
    case 1:
 
528
        backlight = drv_BuE_CT_backlight(R2N(argv[0]));
 
529
        SetResult(&result, R_NUMBER, &backlight);
 
530
        break;
 
531
    default:
 
532
        error("%s::backlight(): wrong number of parameters", Name);
 
533
        SetResult(&result, R_STRING, "");
 
534
    }
 
535
}
 
536
 
 
537
 
 
538
static void plugin_gpo(RESULT * result, const int argc, RESULT * argv[])
 
539
{
 
540
    double gpo;
 
541
 
 
542
    switch (argc) {
 
543
    case 1:
 
544
        gpo = drv_BuE_CT_gpo(R2N(argv[0]), -1);
 
545
        SetResult(&result, R_NUMBER, &gpo);
 
546
        break;
 
547
    case 2:
 
548
        gpo = drv_BuE_CT_gpo(R2N(argv[0]), R2N(argv[1]));
 
549
        SetResult(&result, R_NUMBER, &gpo);
 
550
        break;
 
551
    default:
 
552
        error("%s::gpo(): wrong number of parameters", Name);
 
553
        SetResult(&result, R_STRING, "");
 
554
    }
 
555
}
 
556
 
 
557
 
 
558
static void plugin_gpi(RESULT * result, RESULT * arg1)
 
559
{
 
560
    double gpi;
 
561
 
 
562
    gpi = drv_BuE_CT_gpi(R2N(arg1));
 
563
    SetResult(&result, R_NUMBER, &gpi);
 
564
}
 
565
 
 
566
 
 
567
static void plugin_adc(RESULT * result)
 
568
{
 
569
    double adc;
 
570
 
 
571
    adc = drv_BuE_CT_adc();
 
572
    SetResult(&result, R_NUMBER, &adc);
 
573
}
 
574
 
 
575
 
 
576
static void plugin_pwm(RESULT * result, const int argc, RESULT * argv[])
 
577
{
 
578
    double pwm;
 
579
 
 
580
    switch (argc) {
 
581
    case 0:
 
582
        pwm = drv_BuE_CT_pwm(-1);
 
583
        SetResult(&result, R_NUMBER, &pwm);
 
584
        break;
 
585
    case 1:
 
586
        pwm = drv_BuE_CT_pwm(R2N(argv[0]));
 
587
        SetResult(&result, R_NUMBER, &pwm);
 
588
        break;
 
589
    default:
 
590
        error("%s::pwm(): wrong number of parameters", Name);
 
591
        SetResult(&result, R_STRING, "");
 
592
    }
 
593
}
 
594
 
 
595
 
 
596
/****************************************/
 
597
/***        widget callbacks          ***/
 
598
/****************************************/
 
599
 
 
600
/* using drv_generic_text_draw(W) */
 
601
/* using drv_generic_text_icon_draw(W) */
 
602
/* using drv_generic_text_bar_draw(W) */
 
603
 
 
604
 
 
605
/****************************************/
 
606
/***        exported functions        ***/
 
607
/****************************************/
 
608
 
 
609
 
 
610
/* list models */
 
611
int drv_BuE_list(void)
 
612
{
 
613
    int i;
 
614
 
 
615
    for (i = 0; Models[i].name != NULL; i++) {
 
616
        printf("%s ", Models[i].name);
 
617
    }
 
618
    return 0;
 
619
}
 
620
 
 
621
 
 
622
/* initialize driver & display */
 
623
int drv_BuE_init(const char *section, const int quiet)
 
624
{
 
625
    WIDGET_CLASS wc;
 
626
    int ret;
 
627
 
 
628
    info("%s: %s", Name, "$Rev: 840 $");
 
629
 
 
630
    /* start display */
 
631
    if ((ret = drv_BuE_start(section)) != 0) {
 
632
        return ret;
 
633
    }
 
634
 
 
635
    /* display preferences */
 
636
    XRES = 5;                   /* pixel width of one char  */
 
637
    YRES = 8;                   /* pixel height of one char  */
 
638
    CHARS = 8;                  /* number of user-defineable characters */
 
639
 
 
640
    /* real worker functions */
 
641
    switch (Protocol) {
 
642
    case 1:
 
643
        CHAR0 = 0;              /* ASCII of first user-defineable char */
 
644
        GOTO_COST = 6;          /* number of bytes a goto command requires */
 
645
        drv_generic_text_real_write = drv_BuE_MT_write;
 
646
        drv_generic_text_real_defchar = drv_BuE_MT_defchar;
 
647
        break;
 
648
    case 2:
 
649
        CHAR0 = 128;            /* ASCII of first user-defineable char */
 
650
        GOTO_COST = 6;          /* number of bytes a goto command requires */
 
651
        drv_generic_text_real_write = drv_BuE_CT_write;
 
652
        drv_generic_text_real_defchar = drv_BuE_CT_defchar;
 
653
        break;
 
654
    }
 
655
 
 
656
    if (!quiet) {
 
657
        char buffer[40];
 
658
        qprintf(buffer, sizeof(buffer), "%s %s", Name, Models[Model].name);
 
659
        if (drv_generic_text_greet(buffer, "www.bue.com")) {
 
660
            sleep(3);
 
661
            drv_BuE_clear();
 
662
        }
 
663
    }
 
664
 
 
665
    /* initialize generic text driver */
 
666
    if ((ret = drv_generic_text_init(section, Name)) != 0)
 
667
        return ret;
 
668
 
 
669
    /* initialize generic icon driver */
 
670
    if ((ret = drv_generic_text_icon_init()) != 0)
 
671
        return ret;
 
672
 
 
673
    /* initialize generic bar driver */
 
674
    if ((ret = drv_generic_text_bar_init(0)) != 0)
 
675
        return ret;
 
676
 
 
677
    /* add fixed chars to the bar driver */
 
678
    drv_generic_text_bar_add_segment(0, 0, 255, 32);    /* ASCII  32 = blank */
 
679
    drv_generic_text_bar_add_segment(255, 255, 255, 255);       /* ASCII 255 = block */
 
680
 
 
681
    /* register text widget */
 
682
    wc = Widget_Text;
 
683
    wc.draw = drv_generic_text_draw;
 
684
    widget_register(&wc);
 
685
 
 
686
    /* register icon widget */
 
687
    wc = Widget_Icon;
 
688
    wc.draw = drv_generic_text_icon_draw;
 
689
    widget_register(&wc);
 
690
 
 
691
    /* register bar widget */
 
692
    wc = Widget_Bar;
 
693
    wc.draw = drv_generic_text_bar_draw;
 
694
    widget_register(&wc);
 
695
 
 
696
    /* register plugins */
 
697
    AddFunction("LCD::contrast", -1, plugin_contrast);
 
698
    AddFunction("LCD::backlight", -1, plugin_backlight);
 
699
    AddFunction("LCD::gpo", -1, plugin_gpo);
 
700
    AddFunction("LCD::gpi", 1, plugin_gpi);
 
701
    AddFunction("LCD::adc", 0, plugin_adc);
 
702
    AddFunction("LCD::pwm", -1, plugin_pwm);
 
703
 
 
704
    return 0;
 
705
}
 
706
 
 
707
 
 
708
/* close driver & display */
 
709
int drv_BuE_quit(const int quiet)
 
710
{
 
711
 
 
712
    info("%s: shutting down.", Name);
 
713
 
 
714
    drv_generic_text_quit();
 
715
 
 
716
    /* clear display  */
 
717
    drv_BuE_clear();
 
718
 
 
719
    /* say goodbye... */
 
720
    if (!quiet) {
 
721
        drv_generic_text_greet("goodbye!", NULL);
 
722
    }
 
723
 
 
724
    drv_generic_serial_close();
 
725
 
 
726
    return (0);
 
727
}
 
728
 
 
729
 
 
730
DRIVER drv_BeckmannEgle = {
 
731
    .name = Name,
 
732
    .list = drv_BuE_list,
 
733
    .init = drv_BuE_init,
 
734
    .quit = drv_BuE_quit,
 
735
};