Menu

PiFace Control and Display LCDproc Driver

Help
2013-11-28
2014-03-06
  • Thomas Preston

    Thomas Preston - 2013-11-28

    Hello,
    I'm trying to write an LCDproc driver for the PiFace Control and Display Raspberry Pi extension board. It uses an 16x2 HD44780 display connected to the Raspberry Pi via the SPI bus through an MCP23S17 port expander. The HD44780 is set up in 4-bit mode and connected to Port B on the MCP23S17 like so:

    HD44780 Data 4 | PortB0 |
    HD44780 Data 5 | PortB1 |
    HD44780 Data 6 | PortB2 |
    HD44780 Data 7 | PortB3 | --- MCP23S17 -- SPI -- Raspberry Pi
    HD44780 Enable | PortB4 |
    HD44780 RW     | PortB5 |
    HD44780 RS     | PortB6 |
    Backlight      | PortB7 |
    

    So far, I've created server/drivers/hd44780-pifacecad.{c,h} files (based on hd44780-i2c.{c,h}) which implements:

    int hd_init_pifacecad(Driver *drvthis);
    void pifacecad_HD44780_senddata(PrivateData *p, unsigned char displayID, unsigned char flags, unsigned char ch);
    void pifacecad_HD44780_backlight(PrivateData *p, unsigned char state);
    void pifacecad_HD44780_close(PrivateData *p);
    

    I've also added to line 244 in acinclude.m4 (just below the Raspberry Pi ARM check):

    dnl         While PiFace Control and Display is only intended for the
    dnl         Raspberry Pi, the hd4470-pifacecad driver works through SPI.
    dnl         Therefore any SPI connection will do.
                if test "$x_ac_have_spi" = yes; then
                    HD44780_DRIVERS="$HD44780_DRIVERS hd44780-hd44780-pifacecad.o"
                fi
    

    and to EXTRA_hd44780_SOURCES in server/drivers/Makefile.am I've added:

    hd44780-pifacecad.c hd44780-pifacecad.h
    

    As per: http://lcdproc.sourceforge.net/docs/current-dev.html#add-your-driver

    Finally, I've added to line 169 in configure.ac:

    x_ac_have_spi=no
    AC_CHECK_HEADERS([linux/spi/spidev.h], [x_ac_have_spi=yes])
    if test "$x_ac_have_spi" = yes; then
        AC_DEFINE(HAVE_SPI,[1],[Define to 1 if you have the spi headers])
    fi
    

    And to server/drivers/hd44780-driver.h:

    #ifdef HAVE_SPI
    # include "hd44780-pifacecad.h"
    #endif
    

    When I run make, everything compiles and I can SPI checks and pifacecad go by but when I configure the driver to be hd44780 in LCDd.conf and ran the server with:

    sudo server/LCDd -c LCDd.conf -d server/drivers/hd44780
    

    I get the following error:

    $ sudo server/LCDd -c LCDd.conf -d server/drivers/hd44780
    server/drivers/hd44780: cannot get IO-permission for 0x378: No such device
    Driver [server/drivers/hd44780] init failed, return code -1
    Could not load driver server/drivers/hd44780
    There is no output driver
    Critical error while initializing, abort.
    

    Which appears to be coming from hd44780-4bit.c.

    I'm not sure what to do next.

    P.s. I did not realise there was a forum. Sorry for posting to the mailing list too.

     
  • Thomas Preston

    Thomas Preston - 2013-11-29

    Solution

    I also had to add to server/drivers/hd44780-driver.h:

    #ifdef HAVE_SPI
        { "pifacecad",   HD44780_CT_PIFACECAD,   IF_TYPE_PIFACECAD,, hd_init_pifacecad      },
    #endif
    

    And add to hd44780-low.h:

    #define HD44780_CT_PIFACECAD        24
    
    #define IF_TYPE_PIFACECAD       6
    

    And configure LCDd.conf correctly:

    [hd44780]
    ConnectionType=pifacecad
    Device=/dev/spidev0.1
    Port=
    Size=16x2
    Backlight=yes
    
    Keypad=yes
    KeyDirect_1=Left
    KeyDirect_2=Down
    KeyDirect_3=Up
    KeyDirect_4=Right
    KeyDirect_5=Enter
    

    The driver now works correctly. I've submitted the patch to the mailing list and attached it here.

     

    Last edit: Thomas Preston 2013-11-29
  • Markus Dolze

    Markus Dolze - 2014-03-06

    This driver has been committed to LCDproc on 2014-02-10.

     

Log in to post a comment.