C++ driver for the Philips PCD8544 LCD controller, based on Fandi Gunawan’s C driver. Ported to C++ for object-orientation and template support. Supports multiple LCD controllers with separate DC/CE/RST pins, screen caches, etc. Other enhancements include support for any resolution (not just 84 x 48) and templated pin and SPI bus access for easy porting to new architectures. Code is GPL’d in the GitHub repository Philips_PCD8544_driver.
The MDFly model MD8448B boards pictured here provide a backlit breakout of a Nokia 3310-style 84×48 monochrome LCD, requiring only a 3.3VDC power source.
The driver package includes two MapOS servers:
- StringServer: Upon receiving a packet, clears the screen and writes the text contents the packet. Especially useful as a line-based console output.
- CommandServer: A general control server which takes an opcode command (e.g. write bitmap) and arguments (e.g. offset and bitmap content). Can clear the screen, set contrast, write a monochrome bitmap image at a desired offset, etc.
These two servers are implemented in a MapOS kernel released at GitHub’s Philips_PCD8544_Server. This implementation executes on an ATmega328P 20MHz core (pictured at right). The LCD driver and servers instantiate from template classes, utilizing the AVR_Object library’s OutputPin classes, and sacrifice several kB of (otherwise unused) Flash space in exchange for faster processing. Memory footprint: 16.5kB Flash, 91B Eeprom.
Below, an example bash script to control this server. $sendPack should contain the path to the sendPacket utility (compiled in MapOS/arch/linux/utilities/sendPacket), whereas $uartDev points to the /dev/ttyUSBx device feeding the ATmega UART-RX. This script will clear the screen, set the contrast, and draw two horizontal lines in the upper left corner.
# Set device address: 4-20. echo "0 2 1 iu 1 iu 1 iu 1 iu 3 iu 4 iu 20 iu 255 e" | $sendPack > $uartDev # Bind LCD-1 Command server to port 8-24. echo "0 2 1 iu 1 iu 5 iu 0 iu 3 iu 8 iu 24 iu 255 e" | $sendPack > $uartDev # LCD-1: Set contrast to 64. (Opcode 3, argument 64.) echo "0 8 24 iu 3 iu 64 e" | $sendPack > $uartDev # LCD-1: Clear screen. (Opcode 0.) echo "0 8 24 iu 0 e" | $sendPack > $uartDev # LCD-1: Write bitmap. (Opcode 1.) # Second byte is data offset, in bytes, which corresponds to a horizontal pixel offset. # The following bytes define the on/off status of pixels in a vertical stripe. echo -e "0 8 24 iu 1 sr -\x00\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F- e" | $sendPack > $uartDev echo -e "0 8 24 iu 1 sr -\x08\x0F\x0F\x0F\x0F\x0F\x0F\x0F\x0F- e" | $sendPack > $uartDev echo -e "0 8 24 iu 1 sr -\x10\xF0\xF0\xF0\xF0\xF0\xF0\xF0\xF0- e" | $sendPack > $uartDev echo -e "0 8 24 iu 1 sr -\x18\xF0\xF0\xF0\xF0\xF0\xF0\xF0\xF0- e" | $sendPack > $uartDev


