root/tags/0.10.0/drv.c

Revision 548, 8.0 kB (checked in by reinelt, 4 years ago)

[lcd4linux @ 2005-05-10 13:20:10 by reinelt]
added serdisplib driver

Line 
1/* $Id: drv.c,v 1.32 2005/05/10 13:20:14 reinelt Exp $
2 *
3 * new framework for display drivers
4 *
5 * Copyright (C) 2003 Michael Reinelt <reinelt@eunet.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 * $Log: drv.c,v $
26 * Revision 1.32  2005/05/10 13:20:14  reinelt
27 * added serdisplib driver
28 *
29 * Revision 1.31  2005/05/08 04:32:43  reinelt
30 * CodingStyle added and applied
31 *
32 * Revision 1.30  2005/05/04 05:42:38  reinelt
33 * Noritake driver added
34 *
35 * Revision 1.29  2005/04/24 04:33:46  reinelt
36 * driver for TREFON USB LCD's added
37 *
38 * Revision 1.28  2005/02/24 07:06:48  reinelt
39 * SimpleLCD driver added
40 *
41 * Revision 1.27  2005/01/30 06:43:22  reinelt
42 * driver for LCD-Linux finished
43 *
44 * Revision 1.26  2005/01/22 22:57:57  reinelt
45 * LCD-Linux driver added
46 *
47 * Revision 1.25  2005/01/18 06:30:22  reinelt
48 * added (C) to all copyright statements
49 *
50 * Revision 1.24  2005/01/15 13:10:15  reinelt
51 * LCDTerm driver added
52 *
53 * Revision 1.23  2004/09/24 21:41:00  reinelt
54 * new driver for the BWCT USB LCD interface board.
55 *
56 * Revision 1.22  2004/08/29 13:03:41  reinelt
57 *
58 * added RouterBoard driver
59 *
60 * Revision 1.21  2004/06/26 12:04:59  reinelt
61 *
62 * uh-oh... the last CVS log message messed up things a lot...
63 *
64 * Revision 1.20  2004/06/26 09:27:20  reinelt
65 *
66 * added '-W' to CFLAGS
67 * changed all C++ comments to C ones
68 * cleaned up a lot of signed/unsigned mistakes
69 *
70 * Revision 1.19  2004/06/20 10:09:54  reinelt
71 *
72 * 'const'ified the whole source
73 *
74 * Revision 1.18  2004/06/06 06:51:59  reinelt
75 *
76 * do not display end splash screen if quiet=1
77 *
78 * Revision 1.17  2004/06/02 10:09:22  reinelt
79 *
80 * splash screen for HD44780
81 *
82 * Revision 1.16  2004/06/02 09:41:19  reinelt
83 *
84 * prepared support for startup splash screen
85 *
86 * Revision 1.15  2004/05/31 16:39:06  reinelt
87 *
88 * added NULL display driver (for debugging/profiling purposes)
89 * added backlight/contrast initialisation for matrixOrbital
90 * added Backlight initialisation for Cwlinux
91 *
92 * Revision 1.14  2004/05/28 13:51:42  reinelt
93 *
94 * ported driver for Beckmann+Egle Mini-Terminals
95 * added 'flags' parameter to serial_init()
96 *
97 * Revision 1.13  2004/05/26 11:37:36  reinelt
98 *
99 * Curses driver ported.
100 *
101 * Revision 1.12  2004/05/26 05:03:27  reinelt
102 *
103 * MilfordInstruments driver ported
104 *
105 * Revision 1.11  2004/05/25 19:54:15  reinelt
106 *
107 * 'make distcheck' bugs fixed
108 * release number changed to 0.10.0-RC1
109 *
110 * Revision 1.10  2004/05/25 14:26:29  reinelt
111 *
112 * added "Image" driver (was: Raster.c) for PPM and PNG creation
113 * fixed some glitches in the X11 driver
114 *
115 * Revision 1.9  2004/02/24 05:55:04  reinelt
116 *
117 * X11 driver ported
118 *
119 * Revision 1.8  2004/02/15 21:43:43  reinelt
120 * T6963 driver nearly finished
121 * framework for graphic displays done
122 * i2c_sensors patch from Xavier
123 * some more old generation files removed
124 *
125 * Revision 1.7  2004/02/15 08:22:47  reinelt
126 * ported USBLCD driver to NextGeneration
127 * added drv_M50530.c (I forgot yesterday, sorry)
128 * removed old drivers M50530.c and USBLCD.c
129 *
130 * Revision 1.6  2004/02/14 11:56:17  reinelt
131 * M50530 driver ported
132 * changed lots of 'char' to 'unsigned char'
133 *
134 * Revision 1.5  2004/01/27 06:34:14  reinelt
135 * Cwlinux driver portet to NextGeneration (compiles, but not tested!)
136 *
137 * Revision 1.4  2004/01/21 12:36:19  reinelt
138 * Crystalfontz NextGeneration driver added
139 *
140 * Revision 1.3  2004/01/20 15:32:49  reinelt
141 * first version of Next Generation HD44780 (untested! but it compiles...)
142 * some cleanup in the other drivers
143 *
144 * Revision 1.2  2004/01/10 10:20:22  reinelt
145 * new MatrixOrbital changes
146 *
147 * Revision 1.1  2004/01/09 17:03:07  reinelt
148 * initiated transfer to new driver architecture
149 * new file 'drv.c' will someday replace 'display.c'
150 * new file 'drv_MatrixOrbital.c' will replace 'MatrixOrbital.c'
151 * due to this 'soft' transfer lcd4linux should stay usable during the switch
152 * (at least I hope so)
153 *
154 */
155
156/*
157 * exported functions:
158 *
159 * drv_list (void)
160 *   lists all available drivers to stdout
161 *
162 * drv_init (char *driver)
163 *    initializes the named driver
164 *
165 * drv_query (int *rows, int *cols, int *xres, int *yres, int *bars, int *gpos)
166 *    queries the attributes of the selected driver
167 *
168 * drv_clear ()
169 *    clears the display
170 *
171 * int drv_put (int row, int col, char *text)
172 *    writes text at row, col
173 *
174 * int drv_bar (int type, int row, int col, int max, int len1, int len2)
175 *    draws a specified bar at row, col with len
176 *
177 * int drv_icon (int num, int seq, int row, int col)
178 *    draws icon #num sequence #seq at row, col
179 *
180 * int drv_gpo (int num, int val)
181 *    sets GPO #num to val
182 *
183 * int drv_flush (void)
184 *    flushes the framebuffer to the display
185 *
186 * int drv_quit (void)
187 *    de-initializes the driver
188 */
189
190#include "config.h"
191
192#include <stdlib.h>
193#include <stdio.h>
194#include <string.h>
195
196#include "debug.h"
197#include "cfg.h"
198#include "drv.h"
199
200extern DRIVER drv_BeckmannEgle;
201extern DRIVER drv_BWCT;
202extern DRIVER drv_Crystalfontz;
203extern DRIVER drv_Curses;
204extern DRIVER drv_Cwlinux;
205extern DRIVER drv_HD44780;
206extern DRIVER drv_Image;
207extern DRIVER drv_LCDLinux;
208extern DRIVER drv_LCDTerm;
209extern DRIVER drv_M50530;
210extern DRIVER drv_MatrixOrbital;
211extern DRIVER drv_MilfordInstruments;
212extern DRIVER drv_Noritake;
213extern DRIVER drv_NULL;
214extern DRIVER drv_RouterBoard;
215extern DRIVER drv_serdisplib;
216extern DRIVER drv_SimpleLCD;
217extern DRIVER drv_T6963;
218extern DRIVER drv_Trefon;
219extern DRIVER drv_USBLCD;
220extern DRIVER drv_X11;
221
222/* output file for Image driver
223 * has to be defined here because it's referenced
224 * even if the raster driver is not included!
225 */
226char *output = NULL;
227
228DRIVER *Driver[] = {
229#ifdef WITH_BECKMANNEGLE
230    &drv_BeckmannEgle,
231#endif
232#ifdef WITH_BWCT
233    &drv_BWCT,
234#endif
235#ifdef WITH_CRYSTALFONTZ
236    &drv_Crystalfontz,
237#endif
238#ifdef WITH_CWLINUX
239    &drv_Cwlinux,
240#endif
241#ifdef WITH_CURSES
242    &drv_Curses,
243#endif
244#ifdef WITH_HD44780
245    &drv_HD44780,
246#endif
247#if defined (WITH_PNG) || defined(WITH_PPM)
248    &drv_Image,
249#endif
250#ifdef WITH_LCDLINUX
251    &drv_LCDLinux,
252#endif
253#ifdef WITH_LCDTERM
254    &drv_LCDTerm,
255#endif
256#ifdef WITH_M50530
257    &drv_M50530,
258#endif
259#ifdef WITH_MATRIXORBITAL
260    &drv_MatrixOrbital,
261#endif
262#ifdef WITH_MILINST
263    &drv_MilfordInstruments,
264#endif
265#ifdef WITH_NORITAKE
266    &drv_Noritake,
267#endif
268#ifdef WITH_NULL
269    &drv_NULL,
270#endif
271#ifdef WITH_ROUTERBOARD
272    &drv_RouterBoard,
273#endif
274#ifdef WITH_SERDISPLIB
275    &drv_serdisplib,
276#endif
277#ifdef WITH_SIMPLELCD
278    &drv_SimpleLCD,
279#endif
280#ifdef WITH_T6963
281    &drv_T6963,
282#endif
283#ifdef WITH_TREFON
284    &drv_Trefon,
285#endif
286#ifdef WITH_USBLCD
287    &drv_USBLCD,
288#endif
289#ifdef WITH_X11
290    &drv_X11,
291#endif
292
293    NULL,
294};
295
296
297static DRIVER *Drv = NULL;
298
299
300int drv_list(void)
301{
302    int i;
303
304    printf("available display drivers:");
305
306    for (i = 0; Driver[i]; i++) {
307  printf("\n   %-20s: ", Driver[i]->name);
308  if (Driver[i]->list)
309      Driver[i]->list();
310    }
311    printf("\n");
312    return 0;
313}
314
315
316int drv_init(const char *section, const char *driver, const int quiet)
317{
318    int i;
319    for (i = 0; Driver[i]; i++) {
320  if (strcmp(Driver[i]->name, driver) == 0) {
321      Drv = Driver[i];
322      if (Drv->init == NULL)
323    return 0;
324      return Drv->init(section, quiet);
325  }
326    }
327    error("drv_init(%s) failed: no such driver", driver);
328    return -1;
329}
330
331
332int drv_quit(const int quiet)
333{
334    if (Drv->quit == NULL)
335  return 0;
336    return Drv->quit(quiet);
337}
Note: See TracBrowser for help on using the browser.