1
/* $Id: drv_FW8888.c 1123 2010-06-21 02:07:13Z michael $
2
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_FW8888.c $
4
* driver for Allnet FW8888 display
6
* Copyright (C) 2005 Michael Reinelt <michael@reinelt.co.at>
7
* Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
8
* Copyright (C) 2010 Linum Software GmbH <support@linum.com>
10
* This file is part of LCD4Linux.
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)
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.
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.
32
* struct DRIVER drv_FW8888
50
#include "widget_text.h"
51
#include "widget_icon.h"
52
#include "widget_bar.h"
55
/* text mode display? */
56
#include "drv_generic_text.h"
59
#include "drv_generic_serial.h"
61
static char Name[] = "FW8888";
64
/****************************************/
65
/*** hardware dependant functions ***/
66
/****************************************/
68
static int drv_FW8888_open(const char *section)
70
/* open serial port */
71
/* don't mind about device, speed and stuff, this function will take care of */
73
if (drv_generic_serial_open(section, Name, 0) < 0)
80
static int drv_FW8888_close(void)
82
/* close whatever port you've opened */
83
drv_generic_serial_close();
89
static void drv_FW8888_send_cmd(const unsigned int cmd)
95
drv_generic_serial_write(cmd_str, 2);
99
static void drv_FW8888_send_text(const char *text, const unsigned int len)
106
for (i = 0; i < len; i++) {
107
cmd_str[1] = text[i];
108
drv_generic_serial_write(cmd_str, 2);
112
/* text mode displays only */
113
static void drv_FW8888_clear(void)
115
drv_FW8888_send_cmd(0x01);
118
static void drv_FW8888_home(void)
120
drv_FW8888_send_cmd(0x02);
123
static void drv_FW8888_display_off(void)
125
drv_FW8888_send_cmd(0x08);
128
static void drv_FW8888_display_on_cursor_off(void)
130
drv_FW8888_send_cmd(0x0C);
133
static void drv_FW8888_display_on_cursor_on(void)
135
drv_FW8888_send_cmd(0x0E);
138
static void drv_FW8888_backlight_off(void)
140
drv_FW8888_send_cmd(0x38);
143
static void drv_FW8888_backlight_on(void)
145
drv_FW8888_send_cmd(0x39);
148
static void drv_FW8888_set_cursor(int row, int col)
159
error("%s: invalid row(%d) or col(%d)", Name, row, col);
162
drv_FW8888_send_cmd(pos);
166
/* text mode displays only */
167
static void drv_FW8888_write(const int row, const int col, const char *data, int len)
169
/* do the cursor positioning here */
170
drv_FW8888_set_cursor(row, col);
172
/* send string to the display */
173
drv_FW8888_send_text(data, len);
177
/* start text mode display */
178
static int drv_FW8888_start(const char *section)
180
/* display preferences */
181
XRES = 5; /* pixel width of one char */
182
YRES = 8; /* pixel height of one char */
183
CHARS = 0; /* number of user-defineable characters */
184
CHAR0 = 0; /* ASCII of first user-defineable char */
188
GOTO_COST = -1; /* number of bytes a goto command requires */
190
/* open communication with the display */
191
if (drv_FW8888_open(section) < 0) {
195
drv_FW8888_clear(); /* clear display */
202
/****************************************/
204
/****************************************/
208
/****************************************/
209
/*** widget callbacks ***/
210
/****************************************/
213
/* using drv_generic_text_draw(W) */
214
/* using drv_generic_text_icon_draw(W) */
215
/* using drv_generic_text_bar_draw(W) */
216
/* using drv_generic_gpio_draw(W) */
219
/****************************************/
220
/*** exported functions ***/
221
/****************************************/
225
int drv_FW8888_list(void)
227
printf("Allnet-FW8888");
232
/* initialize driver & display */
233
/* use this function for a text display */
234
int drv_FW8888_init(const char *section, const int quiet)
239
info("%s: %s", Name, "$Rev: 1123 $");
241
/* display preferences */
242
XRES = 5; /* pixel width of one char */
243
YRES = 7; /* pixel height of one char */
244
CHARS = 0; /* number of user-defineable characters */
245
CHAR0 = 0; /* ASCII of first user-defineable char */
247
/* real worker functions */
248
drv_generic_text_real_write = drv_FW8888_write;
251
if ((ret = drv_FW8888_start(section)) != 0)
256
qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS);
257
if (drv_generic_text_greet(buffer, "www.linum.com")) {
263
/* initialize generic text driver */
264
if ((ret = drv_generic_text_init(section, Name)) != 0)
267
/* register text widget */
269
wc.draw = drv_generic_text_draw;
270
widget_register(&wc);
272
/* register plugins */
273
// AddFunction("LCD::contrast", 1, plugin_contrast);
279
/* close driver & display */
280
/* use this function for a text display */
281
int drv_FW8888_quit(const int quiet)
284
info("%s: shutting down.", Name);
286
drv_generic_text_quit();
293
drv_generic_text_greet("goodbye!", NULL);
296
debug("closing connection");
303
/* use this one for a text display */
304
DRIVER drv_FW8888 = {
306
.list = drv_FW8888_list,
307
.init = drv_FW8888_init,
308
.quit = drv_FW8888_quit,