/* $Id: drv_MatrixOrbital.c 1140 2011-01-05 03:49:07Z michael $ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_MatrixOrbital.c $ * * new style driver for Matrix Orbital serial display modules * * Copyright (C) 1999, 2000 Michael Reinelt * Copyright (C) 2004 The LCD4Linux Team * * 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. * */ /* * * exported fuctions: * * struct DRIVER drv_MatrixOrbital * */ #include "config.h" #include #include #include #include #include #include "debug.h" #include "cfg.h" #include "plugin.h" #include "widget.h" #include "widget_text.h" #include "widget_icon.h" #include "widget_bar.h" #include "drv.h" #include "drv_generic_text.h" #include "drv_generic_gpio.h" #include "drv_generic_serial.h" static char Name[] = "MatrixOrbital"; static int Model; static int Protocol; static char dispBuffer[4][20]; typedef struct { int type; char *name; int rows; int cols; int gpis; int gpos; int protocol; } MODEL; /* Fixme #1: number of gpo's should be verified */ /* Fixme #2: protocol should be verified */ static MODEL Models[] = { {0x01, "LCD0821", 2, 8, 0, 1, 1}, {0x03, "LCD2021", 2, 20, 0, 1, 1}, {0x04, "LCD1641", 4, 16, 0, 1, 1}, {0x05, "LCD2041", 4, 20, 0, 1, 1}, {0x06, "LCD4021", 2, 40, 0, 1, 1}, {0x07, "LCD4041", 4, 40, 0, 1, 1}, {0x08, "LK202-25", 2, 20, 8, 8, 2}, {0x09, "LK204-25", 4, 20, 8, 8, 2}, {0x0a, "LK404-55", 4, 40, 8, 8, 2}, {0x0b, "VFD2021", 2, 20, 0, 1, 1}, {0x0c, "VFD2041", 4, 20, 0, 1, 1}, {0x0d, "VFD4021", 2, 40, 0, 1, 1}, {0x0e, "VK202-25", 2, 20, 0, 1, 1}, {0x0f, "VK204-25", 4, 20, 0, 1, 1}, {0x10, "GLC12232", -1, -1, 0, 1, 1}, {0x13, "GLC24064", -1, -1, 0, 1, 1}, {0x15, "GLK24064-25", -1, -1, 0, 1, 1}, {0x22, "GLK12232-25", -1, -1, 0, 1, 1}, {0x31, "LK404-AT", 4, 40, 8, 8, 2}, {0x32, "VFD1621", 2, 16, 0, 1, 1}, {0x33, "LK402-12", 2, 40, 8, 8, 2}, {0x34, "LK162-12", 2, 16, 8, 8, 2}, {0x35, "LK204-25PC", 4, 20, 8, 8, 2}, {0x36, "LK202-24-USB", 2, 20, 8, 8, 2}, {0x38, "LK204-24-USB", 4, 20, 8, 8, 2}, {0x39, "VK204-24-USB", 4, 20, 8, 8, 2}, {0x40, "DE-LD011", 2, 16, 0, 0, 3}, /* Sure electronics USB LCD board Rev.I */ {0x41, "DE-LD021", 4, 20, 0, 0, 3}, {0xff, "Unknown", -1, -1, 0, 0, 0} }; /****************************************/ /*** hardware dependant functions ***/ /****************************************/ static void drv_MO_write(const int row, const int col, co
c8:198500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_NONE:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:161:82
c22:482000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:161:82
c34:578000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:161:82
c54:738000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:161:82
c57:762000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:161:82
c64:818000000:INVERSION_OFF:BANDWIDTH_8_MHZ:FEC_2_3:FEC_NONE:QAM_16:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_4:HIERARCHY_NONE:161:82
drv_generic_serial_write("\376K", 2); /* cursor off */ drv_generic_serial_write("\376T", 2); /* blink off */ drv_generic_serial_write("\376D", 2); /* line wrapping off */ drv_generic_serial_write("\376R", 2); /* auto scroll off */ /* set contrast */ if (cfg_number(section, "Contrast", 0, 0, 255, &i) > 0) { drv_MO_contrast(i); } /* set backlight */ if (cfg_number(section, "Backlight", 0, 0, 255, &i) > 0) { drv_MO_backlight(i); } if (!quiet) { if (drv_generic_text_greet(Models[Model].name, "MatrixOrbital")) { sleep(3); drv_MO_clear(); } } return 0; } /****************************************/ /*** plugins ***/ /****************************************/ static void plugin_contrast(RESULT * result, const int argc, RESULT * argv[]) { double contrast; switch (argc) { case 0: contrast = drv_MO_contrast(-1); SetResult(&result, R_NUMBER, &contrast); break; case 1: contrast = drv_MO_contrast(R2N(argv[0])); SetResult(&result, R_NUMBER, &contrast); break; default: error("%s::contrast(): wrong number of parameters", Name); SetResult(&result, R_STRING, ""); } } static void plugin_backlight(RESULT * result, const int argc, RESULT * argv[]) { double backlight; switch (argc) { case 0: backlight = drv_MO_backlight(-1); SetResult(&result, R_NUMBER, &backlight); break; case 1: backlight = drv_MO_backlight(R2N(argv[0])); SetResult(&result, R_NUMBER, &backlight); break; default: error("%s::backlight(): wrong number of parameters", Name); SetResult(&result, R_STRING, ""); } } /****************************************/ /*** widget callbacks ***/ /****************************************/ /* using drv_generic_text_draw(W) */ /* using drv_generic_text_icon_draw(W) */ /* using drv_generic_text_bar_draw(W) */ /* using drv_generic_gpio_draw(W) */ /****************************************/ /*** exported functions ***/ /****************************************/ /* list models */ int drv_MO_list(void) { int i; for (i = 0; Models[i].type != 0xff; i++) { printf("%s ", Models[i].name); } return 0; } /* initialize driver & display */ int drv_MO_init(const char *section, const int quiet) { WIDGET_CLASS wc; int ret; int asc255bug; info("%s: %s", Name, "$Rev: 1140 $"); /* 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 = 4; /* number of bytes a goto command requires */ /* real worker functions */ drv_generic_text_real_write = drv_MO_write; drv_generic_text_real_defchar = drv_MO_defchar; drv_generic_gpio_real_get = drv_MO_GPI; drv_generic_gpio_real_set = drv_MO_GPO; /* start display */ if ((ret = drv_MO_start(section, quiet)) != 0) return ret; /* 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 */ /* most displays have a full block on ascii 255, but some have kind of */ /* an 'inverted P'. If you specify 'asc255bug 1 in the config, this */ /* char will not be used, but rendered by the bar driver */ cfg_number(section, "asc255bug", 0, 0, 1, &asc255bug); drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */ if (!asc255bug) drv_generic_text_bar_add_segment(255, 255, 255, 255); /* ASCII 255 = block */ /* initialize generic GPIO driver */ if ((ret = drv_generic_gpio_init(section, Name)) != 0) return ret; /* 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::backlight", -1, plugin_backlight); return 0; } /* close driver & display */ int drv_MO_quit(const int quiet) { info("%s: shutting down display.", Name); drv_generic_text_quit(); drv_generic_gpio_quit(); /* clear display */ drv_MO_clear(); usleep(300000); /* say goodbye... */ if (!quiet) { drv_generic_text_greet("goodbye!", NULL); } usleep(300000); drv_generic_serial_close(); return (0); } DRIVER drv_MatrixOrbital = { .name = Name, .list = drv_MO_list, .init = drv_MO_init, .quit = drv_MO_quit, };