MyNixOS website logo
Description

Control an Adafruit character LCD and keypad kit on a Raspberry Pi.

This package allows using an Adafruit character LCD and keypad kit on a Raspberry Pi from Haskell. Everything you need to use one of these LCDs is exposed in the System.Hardware.PiLcd module. The submodules are only exposed because they might be useful to reuse for other types of hardware, such as if you are using an MCP23017 port expander or an HD44780 display controller in some other context. But if you're using the Adafruit character LCD and keypad kit, all you need is System.Hardware.PiLcd.

Hackage Build Status

This package allows using an Adafruit character LCD and keypad kit on a Raspberry Pi from Haskell. The LCD+Keypad Kit has a 16x2 character LCD, an RGB LED backlight, and five buttons. It works on all models of Raspberry Pi, and plugs into the GPIO header. It only uses the I²C pins on the header.

This library automatically handles Unicode, using the LCD controller's built-in characters where possible, and using the "custom characters" feature, along with a 5x8 font bundled with this package, to emulate Unicode characters which are not built-in. The user of the library can also define their own custom characters.

Everything you need to use one of these LCDs is exposed in the System.Hardware.PiLcd module. The submodules are only exposed because they might be useful to reuse for other types of hardware, such as if you are using an MCP23017 port expander or an HD44780 display controller in some other context. But if you're using the Adafruit character LCD and keypad kit, all you need is System.Hardware.PiLcd.

Before using this package, you'll need to make sure that I²C is enabled on your Raspberry Pi, under "Advanced Options" in raspi-config.

Using PiLcd is as easy as:

{-# LANGUAGE OverloadedStrings #-}

import System.Hardware.PiLcd

main = do
  lcd <- openPiLcd defaultLcdAddress defaultLcdOptions
  updateDisplay lcd ["Hello,", "World!"]
  setBacklightColor lcd Cyan
  closePiLcd lcd

There are additional examples in the examples directory.

This library is specifically designed to work with GHC 7.6.3 and up, and to not use Template Haskell, so it will work with the system-supplied version of GHC on Raspbian "Jessie." Just do sudo apt-get install ghc cabal-install and you're good to go. (You should also increase the swap space by editing /etc/dphys-swapfile.) There are other ways to install more recent versions of GHC if you want; see the wiki page for details.

This is a fairly early release, and there might be breaking changes in the future. Please contact me, by filing a GitHub issue, or by email, if you have any feedback on the library. I'd also be curious to hear how the library is being used!

LCD with Haskell logo

Metadata

Version

0.1.1.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows