| 1 | /* $Id$ |
|---|
| 2 | * $URL$ |
|---|
| 3 | * |
|---|
| 4 | * NULL driver (for testing) |
|---|
| 5 | * |
|---|
| 6 | * Copyright (C) 2004 Michael Reinelt <reinelt@eunet.at> |
|---|
| 7 | * Copyright (C) 2004 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net> |
|---|
| 8 | * |
|---|
| 9 | * This file is part of LCD4Linux. |
|---|
| 10 | * |
|---|
| 11 | * LCD4Linux is free software; you can redistribute it and/or modify |
|---|
| 12 | * it under the terms of the GNU General Public License as published by |
|---|
| 13 | * the Free Software Foundation; either version 2, or (at your option) |
|---|
| 14 | * any later version. |
|---|
| 15 | * |
|---|
| 16 | * LCD4Linux is distributed in the hope that it will be useful, |
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 19 | * GNU General Public License for more details. |
|---|
| 20 | * |
|---|
| 21 | * You should have received a copy of the GNU General Public License |
|---|
| 22 | * along with this program; if not, write to the Free Software |
|---|
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 24 | * |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | /* |
|---|
| 28 | * |
|---|
| 29 | * exported fuctions: |
|---|
| 30 | * |
|---|
| 31 | * struct DRIVER drv_NULL |
|---|
| 32 | * |
|---|
| 33 | */ |
|---|
| 34 | |
|---|
| 35 | #include "config.h" |
|---|
| 36 | |
|---|
| 37 | #include <stdlib.h> |
|---|
| 38 | #include <stdio.h> |
|---|
| 39 | #include <string.h> |
|---|
| 40 | |
|---|
| 41 | #include "debug.h" |
|---|
| 42 | #include "cfg.h" |
|---|
| 43 | #include "plugin.h" |
|---|
| 44 | #include "widget.h" |
|---|
| 45 | #include "widget_text.h" |
|---|
| 46 | #include "widget_bar.h" |
|---|
| 47 | #include "drv.h" |
|---|
| 48 | #include "drv_generic_text.h" |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | static char Name[] = "NULL"; |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | /****************************************/ |
|---|
| 55 | /*** hardware dependant functions ***/ |
|---|
| 56 | /****************************************/ |
|---|
| 57 | |
|---|
| 58 | static void drv_NULL_write(const __attribute__ ((unused)) |
|---|
| 59 | int row, const __attribute__ ((unused)) |
|---|
| 60 | int col, const __attribute__ ((unused)) |
|---|
| 61 | char *data, const __attribute__ ((unused)) |
|---|
| 62 | int len) |
|---|
| 63 | { |
|---|
| 64 | /* empty */ |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | static void drv_NULL_defchar(const __attribute__ ((unused)) |
|---|
| 69 | int ascii, const __attribute__ ((unused)) |
|---|
| 70 | unsigned char *matrix) |
|---|
| 71 | { |
|---|
| 72 | /* empty */ |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | static int drv_NULL_start(const char *section) |
|---|
| 77 | { |
|---|
| 78 | char *s; |
|---|
| 79 | |
|---|
| 80 | s = cfg_get(section, "Size", "20x4"); |
|---|
| 81 | if (s == NULL || *s == '\0') { |
|---|
| 82 | error("%s: no '%s.Size' entry from %s", Name, section, cfg_source()); |
|---|
| 83 | free(s); |
|---|
| 84 | return -1; |
|---|
| 85 | } |
|---|
| 86 | if (sscanf(s, "%dx%d", &DCOLS, &DROWS) != 2 || DROWS < 1 || DCOLS < 1) { |
|---|
| 87 | error("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source()); |
|---|
| 88 | free(s); |
|---|
| 89 | return -1; |
|---|
| 90 | } |
|---|
| 91 | free(s); |
|---|
| 92 | |
|---|
| 93 | return 0; |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | /****************************************/ |
|---|
| 98 | /*** plugins ***/ |
|---|
| 99 | /****************************************/ |
|---|
| 100 | |
|---|
| 101 | /* none at the moment... */ |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | /****************************************/ |
|---|
| 105 | /*** widget callbacks ***/ |
|---|
| 106 | /****************************************/ |
|---|
| 107 | |
|---|
| 108 | /* using drv_generic_text_draw(W) */ |
|---|
| 109 | /* using drv_generic_text_bar_draw(W) */ |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | /****************************************/ |
|---|
| 113 | /*** exported functions ***/ |
|---|
| 114 | /****************************************/ |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | /* list models */ |
|---|
| 118 | int drv_NULL_list(void) |
|---|
| 119 | { |
|---|
| 120 | printf("generic"); |
|---|
| 121 | return 0; |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | /* initialize driver & display */ |
|---|
| 126 | int drv_NULL_init(const char *section, const __attribute__ ((unused)) |
|---|
| 127 | int quiet) |
|---|
| 128 | { |
|---|
| 129 | WIDGET_CLASS wc; |
|---|
| 130 | int ret; |
|---|
| 131 | |
|---|
| 132 | info("%s: %s", Name, "$Rev$"); |
|---|
| 133 | |
|---|
| 134 | /* display preferences */ |
|---|
| 135 | XRES = 6; /* pixel width of one char */ |
|---|
| 136 | YRES = 8; /* pixel height of one char */ |
|---|
| 137 | CHARS = 8; /* number of user-defineable characters */ |
|---|
| 138 | CHAR0 = 0; /* ASCII of first user-defineable char */ |
|---|
| 139 | GOTO_COST = 2; /* number of bytes a goto command requires */ |
|---|
| 140 | |
|---|
| 141 | /* real worker functions */ |
|---|
| 142 | drv_generic_text_real_write = drv_NULL_write; |
|---|
| 143 | drv_generic_text_real_defchar = drv_NULL_defchar; |
|---|
| 144 | |
|---|
| 145 | /* start display */ |
|---|
| 146 | if ((ret = drv_NULL_start(section)) != 0) |
|---|
| 147 | return ret; |
|---|
| 148 | |
|---|
| 149 | /* initialize generic text driver */ |
|---|
| 150 | if ((ret = drv_generic_text_init(section, Name)) != 0) |
|---|
| 151 | return ret; |
|---|
| 152 | |
|---|
| 153 | /* initialize generic bar driver */ |
|---|
| 154 | if ((ret = drv_generic_text_bar_init(1)) != 0) |
|---|
| 155 | return ret; |
|---|
| 156 | |
|---|
| 157 | /* add fixed chars to the bar driver */ |
|---|
| 158 | drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */ |
|---|
| 159 | drv_generic_text_bar_add_segment(255, 255, 255, '*'); /* asterisk */ |
|---|
| 160 | |
|---|
| 161 | /* register text widget */ |
|---|
| 162 | wc = Widget_Text; |
|---|
| 163 | wc.draw = drv_generic_text_draw; |
|---|
| 164 | widget_register(&wc); |
|---|
| 165 | |
|---|
| 166 | /* register bar widget */ |
|---|
| 167 | wc = Widget_Bar; |
|---|
| 168 | wc.draw = drv_generic_text_bar_draw; |
|---|
| 169 | widget_register(&wc); |
|---|
| 170 | |
|---|
| 171 | /* register plugins */ |
|---|
| 172 | /* none at the moment... */ |
|---|
| 173 | |
|---|
| 174 | return 0; |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | /* close driver & display */ |
|---|
| 179 | int drv_NULL_quit(const __attribute__ ((unused)) |
|---|
| 180 | int quiet) |
|---|
| 181 | { |
|---|
| 182 | |
|---|
| 183 | info("%s: shutting down.", Name); |
|---|
| 184 | drv_generic_text_quit(); |
|---|
| 185 | |
|---|
| 186 | return (0); |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | DRIVER drv_NULL = { |
|---|
| 191 | .name = Name, |
|---|
| 192 | .list = drv_NULL_list, |
|---|
| 193 | .init = drv_NULL_init, |
|---|
| 194 | .quit = drv_NULL_quit, |
|---|
| 195 | }; |
|---|