Copyright (C) 2013 RS Tecnologia.
This project aims to create a driver for communication and manipulation of a 16x2 and 16x4 lcd display via I2C protocol. Using a PCF8574 IO expander (IC)..
- Use - This driver creates a file structure to facilitate its use as described below:
- line1
- /sys/class/display/lcdxy/device/line1 - Write only.
- Writing a text on line 1 of the display. Command: echo "Text" > /sys/class/display/lcdxy/device/line1.
- line2
- /sys/class/display/lcdxy/device/line2 - Write only.
- Writing a text on line 2 of the display. Command: echo "Text" > /sys/class/display/lcdxy/device/line2.
- line3 - Only LCD16x4
- /sys/class/display/lcdxy/device/line3 - Write only.
- Writing a text on line 2 of the display. Command: echo "Text" > /sys/class/display/lcdxy/device/line3.
- line4 - Only LCD16x4
- /sys/class/display/lcdxy/device/line4 - Write only.
- Writing a text on line 2 of the display. Command: echo "Text" > /sys/class/display/lcdxy/device/line4.
- clear
- /sys/class/display/lcdxy/device/clear - Write only.
- Clears all text display. Command: echo 0 > /sys/class/display/lcdxy/device/clear.
- backlight
- /sys/class/display/lcdxy/device/backlightr - Write only.
- Turns off the Backlight. Command: echo 0 > /sys/class/display/lcdxy/device/backlight.
- Turns on the Backlight. Command: echo 1 > /sys/class/display/lcdxy/device/backlight.
- command
- /sys/class/display/lcdxy/device/command - Write only.
- Sends a byte of command to the display. Command: echo 192 > /sys/class/display/lcdxy/device/command.
- data
- /sys/class/display/lcdxy/device/data - Write only.
- Sends a byte of data to the display. Command: echo 192 > /sys/class/display/lcdxy/device/data.
- new_caracter
- /sys/class/display/lcdxy/device/new_caracter - Write only.
- Sends a new character into CGRAM of the display. Command: echo char_file.chr > /sys/class/display/lcdxy/device/new_caracter.
- The file should contain 9 bytes. The first is the character position in the CGRAM and the next eight bytes form the character.
- To print the character set, the cursor must be positioned using COMMAND file and then sent to the CGRAM position to be printed on the display using the DATA file.
- line1
- Download the lcd folder and copy the path to the kernel source code BEAGLEBONE or Raspberry Pi: /usr/src/beagle-3.8/KERNEL/drivers/misc/
- Change the Makefile that is on the way: /usr/src/beagle-3.8/KERNEL/drivers/misc/Makefile
- Add: "obj-y + = lcd/"
- Change the Makefile that is on the way: /usr/src/beagle-3.8/KERNEL/drivers/misc/Kconfig
- Add: source "drivers/misc/lcd/Kconfig"
- Compile the kernel, generating modules lcd16x2.ko and lcd16x4.ko
To instantiate the device lcd16x2 or lcd16x4, just run the following command respecting the device address, coforme below:
LCD 16x2 - address 0x27:
echo lcd16x2 0x27 > /sys/bus/i2c/devices/i2c-1/new_device
LCD 16x4 - address 0x27:
echo lcd16x4 0x27 > /sys/bus/i2c/devices/i2c-1/new_device
Edit the file: /usr/src/beagle-3.8/KERNEL/arch/arm/boot/dts/am335x-bone-common.dtsi and add the following code before the SLOT@3:
slot@4 {
lcd16x2 = <&cape_lcd16x2_1>;
};
Edit the file: /usr/src/beagle-3.8/KERNEL/arch/arm/boot/dts/am335x-bone-common.dtsi and add the following code before the CAPE_EEPROM3:
cape_lcd16x2_1: cape_lcd16x2_1@27 {
compatible = "at,lcd16x2";
reg = <0x27>;
};
Compile the kernel
Developer: Tiago Sousa Rocha - [email protected] - +558396541382 and +558381115793