/* $Id$ * $URL$ * * LED matrix driver for LCD4Linux * (see http://www.harbaum.org/till/ledmatrix for hardware) * * Copyright (C) 2006 Till Harbaum * * 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_LEDMatrix * */ /* * Options: * IPAddress */ #include "config.h" #include #include #include #include #include #include #include #include /* include network specific headers */ #include #include #include #include #include #include "debug.h" #include "cfg.h" #include "qprintf.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_graphic.h" /* display command bytes */ #define DSP_CMD_ECHO 0 #define DSP_CMD_NOP 1 #define DSP_CMD_IMAGE 2 #define DSP_CMD_ACK 3 #define DSP_CMD_IR 4 #define DSP_CMD_BEEP 5 #define DSP_DEFAULT_PORT 4711 #define DSP_MEM (80 * 32 * 2 / 8) #define DEFAULT_X_OFFSET 1 /* with a font width of 6 */ static char Name[] = "LEDMatrix"; static char *IPAddress = NULL; static int sock = -1; static struct sockaddr_in dsp_addr; static unsigned char tx_buffer[DSP_MEM + 1]; static int port = DSP_DEFAULT_PORT; static void drv_LEDMatrix_blit(const int row, const int col, const int height, const int width) { int r, c, i; fd_set rfds; struct timeval tv; unsigned char reply[256]; struct sockaddr_in cli_addr; socklen_t fromlen; int ack = 0; int timeout = 10; for (r = row; r < row + height; r++) { for (c = col; c < col + width; c++) { /* LEDMATRIX supports three colors: 10b == green, 01b == red, 11b == amber */ unsigned char color = 0; RGBA p = drv_generic_graphic_rgb(r, c); if (p.G >= 128) color |= 0x80; if (p.R >= 128) color |= 0x40; /* ignore blue ... */ tx_buffer[1 + 20 * r + c / 4] &= ~(0xc0 >> (2 * (c & 3))); tx_buffer[1 + 20 * r + c / 4] |= color >> (2 * (c & 3)); } } /* scan entire display */ tx_buffer[0] = DSP_CMD_IMAGE; do { if ((sendto(sock, tx_buffer, DSP_MEM + 1, 0, (struct sockaddr *) &dsp_addr, sizeof(dsp_addr))) != DSP_MEM + 1) error("%s: sendto error on socket", Name); /* now wait for reply */ FD_ZERO(&rfds); FD_SET(sock, &rfds); tv.tv_sec = 0; tv.tv_usec = 100000; /* wait 1 sec for ack */ if ((i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv)) < 0) { info("%s: Select error: %s", Name, strerror(errno)); } if (FD_ISSET(sock, &rfds)) { /* wait for ack */ fromlen = sizeof(dsp_addr); i = recvfrom(sock, reply, sizeof(reply), 0, (struct sockaddr *) &cli_addr, &fromlen); if (i < 0) { info("%s: Receive error: %s", Name, strerror(errno)); } else { if ((i == 2) && (reply[0] == DSP_CMD_ACK) && (reply[1] == DSP_CMD_IMAGE)) { ack = 1; } else if ((i > 1) && (reply[0] == DSP_CMD_IR)) { /* maybe used later: */ /* ir_receive(reply+1, i-1); */ } else { info("%s: Unexpected reply message", Name); } } } timeout--; } while ((!ack) && (timeout > 0)); if (timeout == 0) { error("%s: display reply timeout", Name); } } static int drv_LEDMatrix_start(const char *section) { char *s; struct sockaddr_in cli_addr; struct hostent *hp; int val; IPAddress = cfg_get(section, "IPAddress", NULL); if (IPAddress == NULL || *IPAddress == '\0') { error("%s: no '%s.IPAddress' entry from %s", Name, section, cfg_source()); return -1; } if (cfg_number(section,
# UK, The Wrekin
# Auto-generated from http://www.dtg.org.uk/retailer/dtt_channels.html
# and http://www.ofcom.org.uk/static/reception_advice/index.asp.html
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy
T 474000000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
T 554000000 8MHz 2/3 NONE QAM64 2k 1/32 NONE
T 498167000 8MHz 2/3 NONE QAM64 2k 1/32 NONE
T 522167000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
T 730000000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
T 762000000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
# UK, The Wrekin B
T 618167000 8MHz 3/4 NONE QAM16 2k 1/32 NONE
T 698000000 8MHz 2/3 NONE QAM64 2k 1/32 NONE
T 642000000 8MHz 2/3 NONE QAM64 2k 1/32 NONE
T 666000000 8MHz 3/4 NONE QAM16 2k 1/32 NONE