| 1 | /* $Id: drv_NULL.c,v 1.8 2005/05/08 04:32:44 reinelt Exp $ |
|---|
| 2 | * |
|---|
| 3 | * NULL driver (for testing) |
|---|
| 4 | * |
|---|
| 5 | * Copyright (C) 2004 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_NULL.c,v $ |
|---|
| 26 | * Revision 1.8 2005/05/08 04:32:44 reinelt |
|---|
| 27 | * CodingStyle added and applied |
|---|
| 28 | * |
|---|
| 29 | * Revision 1.7 2005/01/18 06:30:23 reinelt |
|---|
| 30 | * added (C) to all copyright statements |
|---|
| 31 | * |
|---|
| 32 | * Revision 1.6 2004/06/26 12:04:59 reinelt |
|---|
| 33 | * |
|---|
| 34 | * uh-oh... the last CVS log message messed up things a lot... |
|---|
| 35 | * |
|---|
| 36 | * Revision 1.5 2004/06/26 09:27:21 reinelt |
|---|
| 37 | * |
|---|
| 38 | * added '-W' to CFLAGS |
|---|
| 39 | * changed all C++ comments to C ones |
|---|
| 40 | * cleaned up a lot of signed/unsigned mistakes |
|---|
| 41 | * |
|---|
| 42 | * Revision 1.4 2004/06/20 10:09:54 reinelt |
|---|
| 43 | * |
|---|
| 44 | * 'const'ified the whole source |
|---|
| 45 | * |
|---|
| 46 | * Revision 1.3 2004/06/06 06:51:59 reinelt |
|---|
| 47 | * |
|---|
| 48 | * do not display end splash screen if quiet=1 |
|---|
| 49 | * |
|---|
| 50 | * Revision 1.2 2004/06/02 09:41:19 reinelt |
|---|
| 51 | * |
|---|
| 52 | * prepared support for startup splash screen |
|---|
| 53 | * |
|---|
| 54 | * Revision 1.1 2004/05/31 16:39:06 reinelt |
|---|
| 55 | * |
|---|
| 56 | * added NULL display driver (for debugging/profiling purposes) |
|---|
| 57 | * added backlight/contrast initialisation for matrixOrbital |
|---|
| 58 | * added Backlight initialisation for Cwlinux |
|---|
| 59 | * |
|---|
| 60 | */ |
|---|
| 61 | |
|---|
| 62 | /* |
|---|
| 63 | * |
|---|
| 64 | * exported fuctions: |
|---|
| 65 | * |
|---|
| 66 | * struct DRIVER drv_NULL |
|---|
| 67 | * |
|---|
| 68 | */ |
|---|
| 69 | |
|---|
| 70 | #include "config.h" |
|---|
| 71 | |
|---|
| 72 | #include <stdlib.h> |
|---|
| 73 | #include <stdio.h> |
|---|
| 74 | #include <string.h> |
|---|
| 75 | |
|---|
| 76 | #include "debug.h" |
|---|
| 77 | #include "cfg.h" |
|---|
| 78 | #include "plugin.h" |
|---|
| 79 | #include "widget.h" |
|---|
| 80 | #include "widget_text.h" |
|---|
| 81 | #include "widget_bar.h" |
|---|
| 82 | #include "drv.h" |
|---|
| 83 | #include "drv_generic_text.h" |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | static char Name[] = "NULL"; |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | /****************************************/ |
|---|
| 90 | /*** hardware dependant functions ***/ |
|---|
| 91 | /****************************************/ |
|---|
| 92 | |
|---|
| 93 | static void drv_NULL_write(const __attribute__ ((unused)) |
|---|
| 94 | int row, const __attribute__ ((unused)) |
|---|
| 95 | int col, const __attribute__ ((unused)) |
|---|
| 96 | char *data, const __attribute__ ((unused)) |
|---|
| 97 | int len) |
|---|
| 98 | { |
|---|
| 99 | /* empty */ |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | static void drv_NULL_defchar(const __attribute__ ((unused)) |
|---|
| 104 | int ascii, const __attribute__ ((unused)) |
|---|
| 105 | unsigned char *matrix) |
|---|
| 106 | { |
|---|
| 107 | /* empty */ |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | static int drv_NULL_start(const char *section) |
|---|
| 112 | { |
|---|
| 113 | char *s; |
|---|
| 114 | |
|---|
| 115 | s = cfg_get(section, "Size", "20x4"); |
|---|
| 116 | if (s == NULL || *s == '\0') { |
|---|
| 117 | error("%s: no '%s.Size' entry from %s", Name, section, cfg_source()); |
|---|
| 118 | free(s); |
|---|
| 119 | return -1; |
|---|
| 120 | } |
|---|
| 121 | if (sscanf(s, "%dx%d", &DCOLS, &DROWS) != 2 || DROWS < 1 || DCOLS < 1) { |
|---|
| 122 | error("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source); |
|---|
| 123 | free(s); |
|---|
| 124 | return -1; |
|---|
| 125 | } |
|---|
| 126 | free(s); |
|---|
| 127 | |
|---|
| 128 | return 0; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | /****************************************/ |
|---|
| 133 | /*** plugins ***/ |
|---|
| 134 | /****************************************/ |
|---|
| 135 | |
|---|
| 136 | /* none at the moment... */ |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | /****************************************/ |
|---|
| 140 | /*** widget callbacks ***/ |
|---|
| 141 | /****************************************/ |
|---|
| 142 | |
|---|
| 143 | /* using drv_generic_text_draw(W) */ |
|---|
| 144 | /* using drv_generic_text_bar_draw(W) */ |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | /****************************************/ |
|---|
| 148 | /*** exported functions ***/ |
|---|
| 149 | /****************************************/ |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | /* list models */ |
|---|
| 153 | int drv_NULL_list(void) |
|---|
| 154 | { |
|---|
| 155 | printf("generic"); |
|---|
| 156 | return 0; |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | /* initialize driver & display */ |
|---|
| 161 | int drv_NULL_init(const char *section, const __attribute__ ((unused)) |
|---|
| 162 | int quiet) |
|---|
| 163 | { |
|---|
| 164 | WIDGET_CLASS wc; |
|---|
| 165 | int ret; |
|---|
| 166 | |
|---|
| 167 | /* display preferences */ |
|---|
| 168 | XRES = 6; /* pixel width of one char */ |
|---|
| 169 | YRES = 8; /* pixel height of one char */ |
|---|
| 170 | CHARS = 8; /* number of user-defineable characters */ |
|---|
| 171 | CHAR0 = 0; /* ASCII of first user-defineable char */ |
|---|
| 172 | GOTO_COST = 2; /* number of bytes a goto command requires */ |
|---|
| 173 | |
|---|
| 174 | /* real worker functions */ |
|---|
| 175 | drv_generic_text_real_write = drv_NULL_write; |
|---|
| 176 | drv_generic_text_real_defchar = drv_NULL_defchar; |
|---|
| 177 | |
|---|
| 178 | /* start display */ |
|---|
| 179 | if ((ret = drv_NULL_start(section)) != 0) |
|---|
| 180 | return ret; |
|---|
| 181 | |
|---|
| 182 | /* initialize generic text driver */ |
|---|
| 183 | if ((ret = drv_generic_text_init(section, Name)) != 0) |
|---|
| 184 | return ret; |
|---|
| 185 | |
|---|
| 186 | /* initialize generic bar driver */ |
|---|
| 187 | if ((ret = drv_generic_text_bar_init(1)) != 0) |
|---|
| 188 | return ret; |
|---|
| 189 | |
|---|
| 190 | /* add fixed chars to the bar driver */ |
|---|
| 191 | drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */ |
|---|
| 192 | drv_generic_text_bar_add_segment(255, 255, 255, '*'); /* asterisk */ |
|---|
| 193 | |
|---|
| 194 | /* register text widget */ |
|---|
| 195 | wc = Widget_Text; |
|---|
| 196 | wc.draw = drv_generic_text_draw; |
|---|
| 197 | widget_register(&wc); |
|---|
| 198 | |
|---|
| 199 | /* register bar widget */ |
|---|
| 200 | wc = Widget_Bar; |
|---|
| 201 | wc.draw = drv_generic_text_bar_draw; |
|---|
| 202 | widget_register(&wc); |
|---|
| 203 | |
|---|
| 204 | /* register plugins */ |
|---|
| 205 | /* none at the moment... */ |
|---|
| 206 | |
|---|
| 207 | return 0; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | /* close driver & display */ |
|---|
| 212 | int drv_NULL_quit(const __attribute__ ((unused)) |
|---|
| 213 | int quiet) |
|---|
| 214 | { |
|---|
| 215 | |
|---|
| 216 | info("%s: shutting down.", Name); |
|---|
| 217 | drv_generic_text_quit(); |
|---|
| 218 | |
|---|
| 219 | return (0); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | DRIVER drv_NULL = { |
|---|
| 224 | name:Name, |
|---|
| 225 | list:drv_NULL_list, |
|---|
| 226 | init:drv_NULL_init, |
|---|
| 227 | quit:drv_NULL_quit, |
|---|
| 228 | }; |
|---|