⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hd44780.docbook

📁 linux下LCD驱动的例子代码
💻 DOCBOOK
📖 第 1 页 / 共 4 页
字号:
                                  | I2C-Port- |                            HD44780                                  | Expander  |                            display                                  |           |4                                  |         P0|----------------------------o 11 D4                                  |           |5           I2C-Bus              14|         P1|----------------------------o 12 D5    SCL o-------------------------|SCL        |6                                  |         P2|----------------------------o 13 D6                                15|           |7    SDA o-------------------------|SDA      P3|----------------------------o 14 D7                                  |           |9                                  |1        P4|----------------------------o 4  RS           Set I2C-Address  +-----|A0         |10           here:            |     |2        P5|----------------------------o 5  RW           GND: Bit:=0      +-----|A1         |11           VCC: Bit:=1      |     |3        P6|----------------------------o 6  EN                            +-----|A1         |                      ___           Here: 0x00       |     |           |                 +---|___|--o 15 backlight                           ===    |           |                 |c   10R                                  |           |12    ___       b|/                                   |13       P7|-----|___|-----|                                 -|INT        |      1k       |\                                  |           |           bc557 |e                                   -----------                  |                                                                |    +5V o-----------+------------------+---------------------+--+----------o 2  VCC                    |                  |                     |                    |                  |                     |                    |10uF              O 16                 .-.                   ---                IC1                   | |<-----------o 3  Vlcd                   ---                 O 8                  | |10k                    |                  |                    '-'                    |                  |                     |    GND o-----------+-------+----------+---------------------+-------+-----o 1  GND                            |                                        |                           === GND                                   +-----o 16 GND Backlight]]></screen></figure><sect4 id="hd44780-i2c-config"><title>Configuration</title> <figure><title>HD44780: Configuration for I<superscript>2</superscript>C with port expander</title><screen><![CDATA[[HD44780]ConnectionType=i2cDevice=/dev/i2c-0Port=0x20Backlight=yesSize=40x2DelayBus=falseDelayMult=1Keypad=no]]></screen></figure><para>Device is the device file for your I<superscript>2</superscript>C bus (here /dev/i2c-0).You have to load the kernel standard module i2c-dev andthe bus driver, but NO i2c chip modules (e.g. pcf8574)!</para><para>Port contains the i2c address of the i2c port expander(here 0x20, the PCF8574 from the example above, with all address bits set to 0).Bit 8 of the address (normally 0 in I2C addresses) given in port is special:It tells the driver to treat the device as PCA9554 or similar,a device that needs a 2-byte command, and it will be strippedoff the address.</para><figure><title>HD44780: Examples of I<superscript>2</superscript>C port expander adresses</title><screen><![CDATA[port=0x20..0x27   PCF8574  with A[012]=0..7port=0x38..0x3f   PCF8574A with A[012]=0..7port=0xa0..0xa7   PCA9554  with A[012]=0..7port=0xa0..0xa7   PCA9554A with A[012]=0..7]]></screen></figure></sect4></sect3></sect2><sect2 id="hd44780-compiling"><title>Compiling</title><para>Make sure that the HD44780 files are built when you run configure. Thiscan be done by specifying "--enable-drivers=all" or by"--enable-drivers=hd44780".</para></sect2><!-- ## Hitachi HD44780 driver ## --><sect2 id="hd44780-config"><title>Configuration in LCDd.conf</title><sect3 id="hd44780-config-section"><title>[hd44780]</title><variablelist><varlistentry>  <term>    <command>Port=</command>    <arg choice="plain"><replaceable>PORT</replaceable></arg>  </term>  <listitem><para>    Specify the address of the parallel port the LCD is connected to.    Common values for <replaceable>PORT</replaceable> are <literal>0x278</literal>,    <literal>0x378</literal> and <literal>0x3BC</literal>.    If not given, the default is <literal>0x378</literal>.  </para></listitem></varlistentry><varlistentry>  <term>    <command>Device=</command>    <arg choice="plain"><replaceable>DEVICE</replaceable></arg>  </term>  <listitem><para>    If you are using a serial connection, you must    set this parameter to the device your lcd is connected to. For    example, if it's connected to the first serial port, you have to    set Device to /dev/ttyS0. The default value is /dev/lcd.  </para></listitem></varlistentry><varlistentry>  <term>    <command>ConnectionType=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal><emphasis>4bit</emphasis></literal></arg>      <arg choice="plain"><literal>8bit</literal></arg>      <arg choice="plain"><literal>serialLpt</literal></arg>      <arg choice="plain"><literal>winamp</literal></arg>      <arg choice="plain"><literal>picanlcd</literal></arg>      <arg choice="plain"><literal>bwctusb</literal></arg>      <arg choice="plain"><literal>lcdserializer</literal></arg>      <arg choice="plain"><literal>lis2</literal></arg>      <arg choice="plain"><literal>i2c</literal></arg>    </group>    </arg>  </term>  <listitem>    <para>    Select the type of the wiring / display connection.    </para>    <informaltable>    <tgroup cols="2">      <thead>        <row>          <entry>ConnectionType</entry>          <entry>Wiring / Display Type</entry>        </row>      </thead>      <tbody>        <row>          <entry><literal>4bit</literal></entry>          <entry>HD44780 4bit Wiring (default)</entry>        </row>        <row>          <entry><literal>8bit</literal></entry>          <entry>HD44780 8bit Wiring ("lcdtime")</entry>        </row>        <row>          <entry><literal>serialLpt</literal></entry>          <entry>HD44780 Serial LPT Wiring</entry>        </row>        <row>          <entry><literal>winamp</literal></entry>          <entry>HD44780 8bit Wiring "winamp" Style</entry>        </row>        <row>          <entry><literal>picanlcd</literal></entry>          <entry>PIC-an-LCD serial device "picanlcd"</entry>        </row>        <row>          <entry><literal>bwctusb</literal></entry>          <entry>BWCT USB device "bwctusb"</entry>        </row>        <row>          <entry><literal>lcdserializer</literal></entry>          <entry>LCD serializer "lcdserializer"</entry>        </row>        <row>          <entry><literal>lis2</literal></entry>          <entry>LIS2 from VLSystem (http://www.vlsys.co.kr)</entry>        </row>        <row>          <entry><literal>i2c</literal></entry>          <entry>LCD driven by PCF8574(A)/PCA9554(A) connected via I<superscript>2</superscript>C</entry>        </row>      </tbody>    </tgroup>    </informaltable>    <tip>      <para>      The above table might be outdated, when you read this.      If you suspect the table above to be outdated, you might want to have a look at      <filename>server/drivers/hd44780-drivers.h</filename>      which contains the actual translation code.      </para>    </tip>  </listitem></varlistentry><varlistentry>  <term>    <command>Speed=</command>    <arg choice="plain"><replaceable>BITRATE</replaceable></arg>  </term>  <listitem><para>      For a serial connection, set to the serial port bitrate. To use      the default value for the chosen interface, just set to 0.  </para></listitem></varlistentry><varlistentry>  <term>    <command>Charmap=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal><emphasis>hd44780_default</emphasis></literal></arg>      <arg choice="plain"><literal>ea_ks0073</literal></arg>    </group>    </arg>  </term>  <listitem><para>      You need to set this parameter only if you don't have a standard      hd44780 display. ea_ks0073 is the charmap for Electronic      Assembly's KS0073 based displays. These devices have a richer      charset, including many icons and many more characters of the      ISO-8859-1 than standard hd44780s. Refer to hd44780-charset.h      for more informations.  </para></listitem></varlistentry><varlistentry>  <term>    <command>Keypad=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal>yes</literal></arg>      <arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>    </group>    </arg>  </term>  <listitem><para>    Tell whether you have a keypad connected.    You may also need to configure the keypad layout further on in this file.  </para></listitem></varlistentry><varlistentry>  <term>    <command>Contrast=</command>    <arg choice="plain"><replaceable>CONTRAST</replaceable></arg>  </term>  <listitem><para>    Set the initial contrast for the <literal>bwctusb</literal> connection type.    Legal values for <replaceable>CONTRAST</replaceable> are <literal>0</literal> - <literal>1000</literal>.    If not given, it defaults to <literal>300</literal>.  </para></listitem></varlistentry><varlistentry>  <term>    <command>Backlight=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal>yes</literal></arg>      <arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>    </group>    </arg>  </term>  <listitem><para>    Specifiy if you have a switchable backlight.  </para></listitem></varlistentry><varlistentry>  <term>    <command>OutputPort=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal>yes</literal></arg>      <arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>    </group>    </arg>  </term>  <listitem><para>    Tell if you have the additional output port ("bargraph") and you want to    be able to control it with the lcdproc OUTPUT command  </para></listitem></varlistentry><varlistentry>  <term>    <command>Lastline=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal><emphasis>yes</emphasis></literal></arg>      <arg choice="plain"><literal>no</literal></arg>    </group>    </arg>  </term>  <listitem><para>    Specifies if the last line is pixel addressable or it controls an    underline effect. [default: <literal>yes</literal> (= pixel addressable); legal: <literal>yes</literal>, <literal>no</literal>]  </para></listitem></varlistentry><varlistentry>  <term>    <command>Size=</command>    <arg choice="plain">      <replaceable>WIDTH</replaceable>      <literal>x</literal>      <replaceable>HEIGHT</replaceable>    </arg>  </term>  <listitem><para>    Specifies the size of the LCD.    Default: <literal>20x4</literal>    In case of multiple combined displays, this should be the total size.  </para></listitem></varlistentry><varlistentry>  <term>    <command>vspan=</command>    <arg choice="plain">      <replaceable>HEIGHT</replaceable>      <literal>,</literal>&hellip;    </arg>  </term>  <listitem><para>    For multiple combined displays: how many lines does each display have.    E.g. <literal>Vrspan=2,2</literal> means you have two displays and    each has two lines.  </para></listitem></varlistentry><varlistentry>  <term>    <command>ExtendedMode=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal>yes</literal></arg>      <arg choice="plain"><literal><emphasis>no</emphasis></literal></arg>    </group>    </arg>  </term>  <listitem><para>    If you have a KS0073 or an other 'almost HD44780-compatible', set this    flag to get into extended mode (4-line linear).    This flag is NOT the old obsolete Extended option.  </para></listitem></varlistentry><varlistentry>  <term>    <command>DelayMult=</command>    <arg choice="plain"><replaceable>DELAY</replaceable></arg>  </term>  <listitem><para>    If your display is slow and cannot keep up with the flow of data from    LCDd, garbage can appear on the LCDd. Set this delay factor to 2 or 4    to increase the delays. Default: 1.  </para></listitem></varlistentry><varlistentry>  <term>    <command>DelayBus=</command>    <arg choice="plain">    <group choice="req">      <arg choice="plain"><literal><emphasis>yes</emphasis></literal></arg>      <arg choice="plain"><literal>no</literal></arg>    </group>    </arg>  </term>  <listitem><para>    You can reduce the inserted delays by setting this to <literal>no</literal>.    On fast PCs it is possible your LCD does not respond correctly.    Default: <literal>yes</literal>.  </para></listitem></varlistentry><varlistentry>  <term>    <command>KeyMatrix_4_1=</command>    <arg choice="plain"><replaceable>KEY</replaceable></arg>  </term>  <term>    <command>KeyMatrix_4_2=</command>    <arg choice="plain"><replaceable>KEY</replaceable></arg>  </term>  <term>    <command>KeyMatrix_4_3=</command>    <arg choice="plain"><replaceable>KEY</replaceable></arg>  </term>  <term>    <command>KeyMatrix_4_4=</command>    <arg choice="plain"><replaceable>KEY</replaceable></arg>  </term>  <listitem><para>    If you have a keypad you can assign keystrings to the keys.    See documentation for used terms and how to wire it.    For example to give directly connected key 4 the string "Enter", use:    KeyDirect_4=Enter    For matrix keys use the X and Y coordinates of the key:    KeyMatrix_1_3=Enter  </para></listitem></varlistentry></variablelist></sect3></sect2><sect2 id="hd44780-configuration"><title>Configuration</title></sect2><sect2 id="hd44780-running"><title>Running</title><para>Modify the LCDd.conf file before you run LCDd. In this config file aredetailed instructions on how to configure the HD44780 driver.</para><para>Then as usual, start LCDd with the correct config file:</para><para>E.g. <command>LCDd -c ./LCDd.conf</command></para><para>If you want to override the driver selection in LCDd.conf then use:</para><para><command>LCDd -c ./LCDd.conf -d HD44780</command></para><para>If you use this, the HD44780 driver will read the options from the configfile anyway.</para></sect2><sect2 id="hd44780-miscellania"><title>Miscellania</title><para>This text has originally been taken from a message by Bill Farrow<email>bfarrow@arrow.bsee.swin.edu.au</email>.</para><para>Updated February 2000, Benjamin Tse <email>blt@ComPorts.com</email></para><para>Updated October 2001, Joris Robijn <email>joris@robijn.net</email></para><para>Converted to docbook March 2002, Rene Wagner <email>reenoo@gmx.de</email></para><para>Updated April 2002, Rene Wagner <email>reenoo@gmx.de</email></para><para>Updated and extended April 2006, Peter Marschall <email>peter@adpm.de</email></para></sect2></sect1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -