#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long *//* $Id: drv_PHAnderson.c 840 2008-11-19 23:56:42 guimli $
* $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/drv_PHAnderson.c $
*
* driver for the PHAnderson serial-to-HD44780 adapter boards
* http://www.phanderson.com/lcd106/lcd107.html
* http://moderndevice.com/Docs/LCD117CommandSummary.doc
* http://wulfden.org/TheShoppe/k107/index.shtml
*
* Copyright (C) 2008 Nicolas Weill <guimli@free.fr>
* Copyright (C) 2005 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* 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_PHAnderson
*
*/
#include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#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"
#include "drv_generic_text.h"
#include "drv_generic_serial.h"
#define PHAnderson_CMD '?'
static char Name[] = "PHAnderson";
static int T_READ, T_WRITE, T_BOOT;
/****************************************/
/*** hardware dependant functions ***/
/****************************************/
static int drv_PHAnderson_open(const char *section)
{
if (drv_generic_serial_open(section, Name, 0) < 0)
return -1;
return 0;
}
static int drv_PHAnderson_close(void)
{
drv_generic_serial_close();
return 0;
}
static void drv_PHAnderson_send(const char *data, const unsigned int len)
{
char buffer[255];
unsigned int i, j;
j = 0;
for (i = 0; i < len; i++) {
if (data[i] < 8) {
buffer[j++] = '?';
buffer[j++] = '0' + data[i];
drv_generic_serial_write(buffer, j);
udelay(T_READ);
j = 0;
} else {
buffer[j++] = data[i];
}
}
if (j > 0) {
drv_generic_serial_write(buffer, j);
}
}
static void drv_PHAnderson_clear(void)
{
char cmd[2];
cmd[0] = '?';
cmd[1] = 'f';
drv_PHAnderson_send(cmd, 2);
}
static void drv_PHAnderson_write(const int row, const int col, const char *data, int len)
{
char cmd[7];
cmd[0] = '?';
cmd[1] = 'y';
cmd[2] = row + '0';
cmd[3] = '?';
cmd[4] = 'x';
cmd[5] = col / 10 + '0';
cmd[6] = col % 10 + '0';
drv_PHAnderson_send(cmd, 7);
drv_PHAnderson_send(data, len);
}
static void drv_PHAnderson_defchar(const int ascii, const unsigned char *matrix)
{
char cmd[19];
int i;
cmd[0] = '?';
cmd[1] = 'D';
cmd[2] = ascii + '0';
for (i = 0; i < 8; i++) {
cmd[i * 2 + 3] = ((matrix[i] >> 4) & 1) + '0';
cmd[i * 2 + 4] = (((matrix[i] & 0x0F) < 10) ? (matrix[i] & 0x0F) + '0' : (matrix[i] & 0x0F) + '7');
}
drv_PHAnderson_send(cmd, 19);
udelay(T_WRITE);
}
static int drv_PHAnderson_blacklight(int blacklight)
{
char cmd[4];
if (blacklight < 0)
blacklight = 0;
if (blacklight > 255)
blacklight = 255;
cmd[0] = '?';
cmd[1] = 'B';
cmd[2] = (((blacklight >> 4) < 10) ? (blacklight >> 4) + '0' : (blacklight >> 4) + '7');
cmd[3] = (((blacklight & 0x0F) < 10) ? (blacklight & 0x0F) + '0' : (blacklight & 0x0F) + '7');
drv_PHAnderson_send(cmd