/* $Id: drv_Newhaven.c 1157 2011-07-27 05:58:08Z michael $ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_Newhaven.c $ * * Newhaven lcd4linux driver * * Copyright (C) 2005 Michael Reinelt * Copyright (C) 2005, 2006, 2007 The LCD4Linux Team * Copyright (C) 2011 Rusty Clarkson * * This file is part of LCD4Linux. * * LCD4Linux is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * LCD4Linux is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * *** Newhaven NHD‐0420D3Z‐FL‐GBW *** * A 20x4 LCD (Liquid Crystal Display). * * The display supports text mode provide 4 rows of 20 characters. This display * also supports many functions. The documentation for this display can be found * online easily. http://www.newhavendisplay.com/ would be a good place to start. * This driver was designed with the NHD-0420D3Z-FL-GBW in mind, but I'm sure * similar Newhaven displays will work with little to no effort. * * This driver is released under the GPL. */ /* * * exported fuctions: * * struct DRIVER drv_Newhaven * */ #include "config.h" #include #include #include #include #include #include "debug.h" #include "cfg.h" #include "qprintf.h" #include "udelay.h" #include "plugin.h" #include "widget.h" #include "widget_text.h" #include "widget_icon.h" #include "widget_bar.h" #include "drv.h" /* text mode display? */ #include "drv_generic_text.h" /* serial port? */ //#include "drv_generic_serial.h" /* i2c bus? */ #ifdef WITH_I2C #include "drv_generic_i2c.h" #endif static char Name[] = "Newhaven"; /* Newhaven Constants */ /* Line 1 */ #define NEWHAVEN_R1_C1 0x00 /* Line 2 */ #define NEWHAVEN_R2_C1 0x40 /* Line 3 */ #define NEWHAVEN_R3_C1 0x14 /* Line 4 */ #define NEWHAVEN_R4_C1 0x54 #define NEWHAVEN_ROW_MAX 4 #define NEWHAVEN_COL_MAX 20 #define NEWHAVEN_COMMAND 0xFE #define NEWHAVEN_DISPLAY_ON 0x41 #define NEWHAVEN_DISPLAY_OFF 0x42 #define NEWHAVEN_BAUD_RATE_SET 0x61 #define NEWHAVEN_BAUD_RATE_SHOW 0x71 #define NEWHAVEN_I2C_ADDR_SET 0x62 #define NEWHAVEN_I2C_ADDR_SHOW 0x72 #define NEWHAVEN_I2C_ADDR_DEFAULT 0x28 #define NEWHAVEN_DISPLAY_FIRMWARE_VER 0x70 #define NEWHAVEN_CONTRAST_SET 0x52 #define NEWHAVEN_CONTRAST_MIN 1 #define NEWHAVEN_CONTRAST_MAX 50 #define NEWHAVEN_CONTRAST_DEFAULT 25 #define NEWHAVEN_BRIGHTNESS_SET 0x53 #define NEWHAVEN_BRIGHTNESS_MIN 1 #define NEWHAVEN_BRIGHTNESS_MAX 8 #define NEWHAVEN_BRIGHTNESS_DEFAULT 6 #define NEWHAVEN_CLEAR_SCREEN 0x51 #define NEWHAVEN_DISPLAY_SHIFT_LEFT 0x55 #define NEWHAVEN_DISPLAY_SHIFT_RIGHT 0x56 #define NEWHAVEN_CURSOR_SET_POS 0x45 #define NEWHAVEN_CURSOR_HOME 0x46 #define NEWHAVEN_CURSOR_UNDERLINE_ON 0x47 #define NEWHAVEN_CURSOR_UNDERLINE_OFF 0x48 #define NEWHAVEN_CURSOR_LEFT_ONE 0x49 #define NEWHAVEN_CURSOR_RIGHT_ONE 0x4A #define NEWHAVEN_CURSOR_BLINKING_ON 0x4B #define NEWHAVEN_CURSOR_BLINKING_OFF 0x4C #define NEWHAVEN_BACKSPACE 0x4E #define NEWHAVEN_LOAD_CUSTOM_CHAR 0x54 /******************
# Rzeszow / Sucha Gora, South-East Poland
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
T 642000000 8MHz 2/3 NONE QAM64 8k 1/32 NONE
sleep(1); return 0; } /****************************************/ /*** plugins ***/ /****************************************/ static void plugin_contrast(RESULT * result, RESULT * arg1) { double contrast; contrast = drv_Newhaven_contrast(R2N(arg1)); SetResult(&result, R_NUMBER, &contrast); } static void plugin_brightness(RESULT * result, RESULT * arg1) { double brightness; brightness = drv_Newhaven_brightness(R2N(arg1)); SetResult(&result, R_NUMBER, &brightness); } /****************************************/ /*** widget callbacks ***/ /****************************************/ /* using drv_generic_text_draw(W) */ /* using drv_generic_text_icon_draw(W) */ /* using drv_generic_text_bar_draw(W) */ /****************************************/ /*** exported functions ***/ /****************************************/ /* list models */ int drv_Newhaven_list(void) { printf("%s driver", Name); return 0; } /* initialize driver & display */ /* use this function for a text display */ int drv_Newhaven_init(const char *section, const int quiet) { WIDGET_CLASS wc; int ret; info("%s: %s", Name, "$Rev: 1157 $"); /* display preferences */ XRES = 5; /* pixel width of one char */ YRES = 8; /* pixel height of one char */ CHARS = 8; /* number of user-defineable characters */ CHAR0 = 0; /* ASCII of first user-defineable char */ GOTO_COST = 2; /* number of bytes a goto command requires */ /* real worker functions */ drv_generic_text_real_write = drv_Newhaven_write; drv_generic_text_real_defchar = drv_Newhaven_defchar; /* start display */ if ((ret = drv_Newhaven_start(section)) != 0) return ret; if (!quiet) { char buffer[40]; qprintf(buffer, sizeof(buffer), "%s %dx%d", Name, DCOLS, DROWS); if (drv_generic_text_greet(buffer, "www.bwct.de")) { sleep(3); drv_Newhaven_clear(); } } /* initialize generic text driver */ if ((ret = drv_generic_text_init(section, Name)) != 0) return ret; /* initialize generic icon driver */ if ((ret = drv_generic_text_icon_init()) != 0) return ret; /* initialize generic bar driver */ if ((ret = drv_generic_text_bar_init(0)) != 0) return ret; /* add fixed chars to the bar driver */ drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */ /* register text widget */ wc = Widget_Text; wc.draw = drv_generic_text_draw; widget_register(&wc); /* register icon widget */ wc = Widget_Icon; wc.draw = drv_generic_text_icon_draw; widget_register(&wc); /* register bar widget */ wc = Widget_Bar; wc.draw = drv_generic_text_bar_draw; widget_register(&wc); /* register plugins */ AddFunction("LCD::contrast", 1, plugin_contrast); AddFunction("LCD::brightness", 1, plugin_brightness); return 0; } /* close driver & display */ /* use this function for a text display */ int drv_Newhaven_quit(const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); /* clear display */ drv_Newhaven_clear(); /* say goodbye... */ if (!quiet) { drv_generic_text_greet("goodbye!", NULL); } debug("closing connection"); drv_Newhaven_close(); return (0); } /* use this one for a text display */ DRIVER drv_Newhaven = { .name = Name, .list = drv_Newhaven_list, .init = drv_Newhaven_init, .quit = drv_Newhaven_quit, };