/* $Id: drv_BeckmannEgle.c,v 1.14 2005/01/18 06:30:22 reinelt Exp $ * * driver for Beckmann+Egle "Mini Terminals" and "Compact Terminals" * Copyright (C) 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. * * * $Log: drv_BeckmannEgle.c,v $ * Revision 1.14 2005/01/18 06:30:22 reinelt * added (C) to all copyright statements * * Revision 1.13 2004/07/14 04:44:44 reinelt * * Beckmann+Egle fix * added smaple widget for the PPP plugin * * Revision 1.12 2004/06/29 04:49:30 reinelt * * B+E enhanced port detection * * Revision 1.11 2004/06/26 12:04:59 reinelt * * uh-oh... the last CVS log message messed up things a lot... * * Revision 1.10 2004/06/26 09:27:20 reinelt * * added '-W' to CFLAGS * changed all C++ comments to C ones * cleaned up a lot of signed/unsigned mistakes * * Revision 1.9 2004/06/26 06:12:15 reinelt * * support for Beckmann+Egle Compact Terminals * some mostly cosmetic changes in the MatrixOrbital and USBLCD driver * added debugging to the generic serial driver * fixed a bug in the generic text driver where icons could be drawn outside * the display bounds * * Revision 1.8 2004/06/20 10:09:54 reinelt * * 'const'ified the whole source * * Revision 1.7 2004/06/06 06:51:59 reinelt * * do not display end splash screen if quiet=1 * * Revision 1.6 2004/06/05 06:41:39 reinelt * * chancged splash screen again * * Revision 1.5 2004/06/05 06:13:11 reinelt * * splash screen for all text-based display drivers * * Revision 1.4 2004/06/02 09:41:19 reinelt * * prepared support for startup splash screen * * Revision 1.3 2004/06/02 05:14:16 reinelt * * fixed models listing for Beckmann+Egle driver * some cosmetic changes * * Revision 1.2 2004/05/31 05:38:02 reinelt * * fixed possible bugs with user-defined chars (clear high bits) * thanks to Andy Baxter for debugging the MilfordInstruments driver! * * Revision 1.1 2004/05/28 14:36:10 reinelt * * added drv_BeckmannEgle.c (forgotten at first check in :-) * */ /* * * exported fuctions: * * struct DRIVER drv_BeckmannEgle * */ #include "config.h" #include #include #include #include #include
# automatically generated from http://www.digitv.fi/sivu.asp?path=1;8224;9519
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
T 546000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
T 786000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
T 634000000 8MHz 2/3 NONE QAM64 8k 1/8 NONE
read version */ drv_generic_serial_write (ESC "?V", 3); usleep(100000); if ((len = drv_generic_serial_read (buffer, -sizeof(buffer))) > 0) { int v, r, s; if (sscanf(buffer, "V:%d.%d,%d;", &v, &r, &s) != 3) { error ("%s: error parsing display identification <%*s>", Name, len, buffer); } else { info ("%s: display identified as version %d.%d, S/N %d", Name, v, r, s); } } /* set parameter mode 'byte' */ drv_generic_serial_write (ESC "KM\072", 4); /* the CT20x4 can control smaller displays, too */ size = cfg_get(section, "Size", NULL); if (size != NULL && *size != '\0') { int r, c; char cmd[6] = ESC "LArc"; if (sscanf(size, "%dx%d", &c, &r) != 2 || r < 1 || c < 1) { error ("%s: bad %s.Size '%s' from %s", Name, section, size, cfg_source()); return -1; } info ("%s: display size: %d rows %d columns", Name, r, c); /* set display size */ cmd[3] = (char) r; cmd[4] = (char) c; drv_generic_serial_write (cmd, 5); DCOLS = c; DROWS = r; } /* set contrast */ if (cfg_number(section, "Contrast", 7, 0, 15, &i) > 0) { drv_BuE_CT_contrast(i); } /* set backlight */ if (cfg_number(section, "Backlight", 0, 0, 1, &i) > 0) { drv_BuE_CT_backlight(i); } /* identify modules */ for (i = 0; i < 8; i++) { char cmd[5] = ESC "K?Pn"; cmd[4] = (char)i; drv_generic_serial_write (cmd, 5); /* query I/O port */ usleep(10000); if ((len = drv_generic_serial_read (buffer, 4)) == 4) { char *type = NULL; if (i == 0) { if( buffer[3] == 8) { /* internal port */ type = "CT 20x4 internal port"; } else { error ("%s: internal error: port 0 type %d should be type 8", Name, buffer[3]); continue; } } else { switch (buffer[3]) { case 1: /* Key Module */ type = "XM-KEY-2x4-LED"; break; case 8: /* I/O Module */ type = "XM-IO8-T"; break; case 9: /* I/O Module */ type = "XM-IO4-R"; break; case 15: /* nothing */ continue; default: /* unhandled */ type = NULL; break; } } if (type != NULL) { info ("%s: Port %d: %s", Name, i, type); } else { error ("%s: internal error: port % unknown type %d", Name, i, cmd[3]); } } else { error ("%s: error fetching type of port %d", Name, i); } } return 0; } static int drv_BuE_start (const char *section) { int i, ret; char *model; model = cfg_get(section, "Model", NULL); if (model == NULL && *model == '\0') { error ("%s: no '%s.Model' entry from %s", Name, section, cfg_source()); return -1; } for (i = 0; Models[i].name != NULL; i++) { if (strcasecmp(Models[i].name, model) == 0) break; } if (Models[i].name == NULL) { error ("%s: %s.Model '%s' is unknown from %s", Name, section, model, cfg_source()); return -1; } Model = i; Protocol = Models[Model].protocol; info ("%s: using model '%s'", Name, Models[Model].name); /* initialize global variables */ DROWS = Models[Model].rows; DCOLS = Models[Model].cols; ret = 0; switch (Protocol) { case 1: ret = drv_BuE_MT_start(section); break; case 2: ret = drv_BuE_CT_start(section); break; } if (ret != 0) { return ret; } drv_BuE_clear(); return 0; } /****************************************/ /*** plugins ***/ /****************************************/ static void plugin_contrast (RESULT *result, const int argc, RESULT *argv[]) { double contrast; switch (argc) { case 0: contrast = drv_BuE_CT_contrast(-1); SetResult(&result, R_NUMBER, &contrast); break; case 1: contrast = drv_BuE_CT_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_BuE_CT_backlight(-1); SetResult(&result, R_NUMBER, &backlight); break; case 1: backlight = drv_BuE_CT_backlight(R2N(argv[0])); SetResult(&result, R_NUMBER, &backlight); break; default: error ("%s::backlight(): wrong number of parameters", Name); SetResult(&result, R_STRING, ""); } } static void plugin_gpo (RESULT *result, const int argc, RESULT *argv[]) { double gpo; switch (argc) { case 1: gpo = drv_BuE_CT_gpo(R2N(argv[0]), -1); SetResult(&result, R_NUMBER, &gpo); break; case 2: gpo = drv_BuE_CT_gpo(R2N(argv[0]), R2N(argv[1])); SetResult(&result, R_NUMBER, &gpo); break; default: error ("%s::gpo(): wrong number of parameters", Name); SetResult(&result, R_STRING, ""); } } static void plugin_gpi (RESULT *result, RESULT *arg1) { double gpi; gpi = drv_BuE_CT_gpi(R2N(arg1)); SetResult(&result, R_NUMBER, &gpi); } static void plugin_adc (RESULT *result) { double adc; adc = drv_BuE_CT_adc(); SetResult(&result, R_NUMBER, &adc); } static void plugin_pwm (RESULT *result, const int argc, RESULT *argv[]) { double pwm; switch (argc) { case 0: pwm = drv_BuE_CT_pwm(-1); SetResult(&result, R_NUMBER, &pwm); break; case 1: pwm = drv_BuE_CT_pwm(R2N(argv[0])); SetResult(&result, R_NUMBER, &pwm); break; default: error ("%s::pwm(): 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) */ /****************************************/ /*** exported functions ***/ /****************************************/ /* list models */ int drv_BuE_list (void) { int i; for (i = 0; Models[i].name != NULL; i++) { printf ("%s ", Models[i].name); } return 0; } /* initialize driver & display */ int drv_BuE_init (const char *section, const int quiet) { WIDGET_CLASS wc; int ret; /* start display */ if ((ret=drv_BuE_start (section)) != 0) { return ret; } /* display preferences */ XRES = 5; /* pixel width of one char */ YRES = 8; /* pixel height of one char */ CHARS = 8; /* number of user-defineable characters */ /* real worker functions */ switch (Protocol) { case 1: CHAR0 = 0; /* ASCII of first user-defineable char */ GOTO_COST = 6; /* number of bytes a goto command requires */ drv_generic_text_real_write = drv_BuE_MT_write; drv_generic_text_real_defchar = drv_BuE_MT_defchar; break; case 2: CHAR0 = 128; /* ASCII of first user-defineable char */ GOTO_COST = 6; /* number of bytes a goto command requires */ drv_generic_text_real_write = drv_BuE_CT_write; drv_generic_text_real_defchar = drv_BuE_CT_defchar; break; } if (!quiet) { char buffer[40]; qprintf(buffer, sizeof(buffer), "%s %s", Name, Models[Model].name); if (drv_generic_text_greet (buffer, "www.bue.com")) { sleep (3); drv_BuE_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 */ drv_generic_text_bar_add_segment (255,255,255,255); /* ASCII 255 = block */ /* 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); AddFunction ("LCD::gpo", -1, plugin_gpo); AddFunction ("LCD::gpi", 1, plugin_gpi); AddFunction ("LCD::adc", 0, plugin_adc); AddFunction ("LCD::pwm", -1, plugin_pwm); return 0; } /* close driver & display */ int drv_BuE_quit (const int quiet) { info("%s: shutting down.", Name); drv_generic_text_quit(); /* clear display */ drv_BuE_clear(); /* say goodbye... */ if (!quiet) { drv_generic_text_greet ("goodbye!", NULL); } drv_generic_serial_close(); return (0); } DRIVER drv_BeckmannEgle = { name: Name, list: drv_BuE_list, init: drv_BuE_init, quit: drv_BuE_quit, };