LCD1602 Support¶
There is an optional driver for I2C LCD1602 displays. The LCD1602 is a 2 row by 16 character text LCD display.
LCD1602 support using an AiP31068L driver is in extra/rp_common/lcd1602.fs, which can be compiled either to RAM or to flash as needed. There is a demo program which uses it in extra/rp_common/lcd1602_demo.fs.
LCD1602 support using a PCF8574 I/O expander is in extra/rp_common/lcd1602_pcf8574.fs, which can be compiled either to RAM or to flash as needed. There is a demo program which uses it in extra/rp_common/lcd1602_pcf8574_demo.fs.
lcd1602¶
Configuring the LCD1602 using an AiP31068L driver is in the form of two steps. The first step is configuring the I2C bus, for which a convenience word init-lcd-i2c is provided; if the user manually configures the I2C bus or previously has used it to access another device, the user must manually call lcd-i2c-device! to set the I2C bus to use with the LCD1602 and then activate-lcd-i2c. The second step is initializing the LCD1602 device, which is done through calling init-lcd. These steps must be carried out before using the LCD1602 device.
The lcd1602 module contains the following words:
init-lcd-i2c¶
( pin1 pin2 i2c-device – )
Configure the I2C bus i2c-device to use GPIO’s pin1 and pin2 and set it up to communicate with the LCD1602 device on that bus.
init-lcd¶
( – )
Initialize the LCD1602 device. The I2C bus must be set up to communicate with the LCD1602 device first.
lcd-i2c-device!¶
( i2c-device – )
Manually set the I2C bus i2c-device to use with the LCD1602 without initializing the I2C bus itself.
activate-lcd-i2c¶
( – )
Manually set the I2C bus configured with init-lcd-i2c or lcd-i2c-device! to communicate with the LCD1602 device. This is necessary if the I2C bus has been configured manually or if another device has been previously used on the I2C bus.
clear-display¶
( – )
Clear the LCD1602 display.
put-text¶
( row col c-addr bytes – )
Write the specified string to the LCD1602 display at the specified row and column.
lcd1602-pcf8574¶
The lcd1602-pcf8574 module contains the following words:
LCD1602_PCF8574_I2C_ADDR¶
( – i2c-addr )
The default I2C address for LCD1602 PCF8574-based displays, $27. A common alternate address is $3F.
<lcd1602-pcf8574>¶
( – class )
The <lcd1602-pcf8574> class is the class for I2C LCD1602 PCF8574-based displays.
The <lcd1602-pcf8574> class includes the following constructor:
new¶
( pin0 pin1 columns rows oled? i2c-addr i2c-device lcd1602-pcf8574 – )
This constructor initializes an I2C LCD1602 display using a PCF8574 interface with the SDA and SCK pins specified as GPIO pins pin0 and pin1 (it does not matter which is which), columns columns, rows rows, the I2C address i2c-addr, the I2C device index i2c-device (note that this must match the I2C device index for pins pin0 and pin1), and the <lcd1602-pcf8574> instance being initialized, lcd1602-pcf8574.
LCD1602 devices might be LCD or OLED based; pass false or true as oled? to select the correct cursor movements.
The <lcd1602-pcf8574> class includes the following methoda:
put-text¶
( row col c-addr u lcd1602-pcf8574 – )
Display the text string at the specified row and column.
set-cursor¶
( row col lcd1602-pcf8574 – )
Move the cursor to the specified location.
set-text¶
( c-addr u lcd1602-pcf8574 – )
Display the text string at the current cursor position.
home¶
( lcd1602-pcf8574 – )
Clear display and move the cursor to 0,0.
clear¶
( lcd1602-pcf8574 – )
Clear display and move the cursor to 0,0.
display!¶
( flag lcd1602-pcf8574 – )
Enable display if true.
backlight!¶
( flag lcd1602-pcf8574 – )
Enable backlight if true.
blink!¶
( flag lcd1602-pcf8574 – )
Show blinking block cursor if true.
cursor!¶
( flag lcd1602-pcf8574 – )
Show underline cursor if true.
autoscroll!¶
( flag lcd1602-pcf8574 – )
Right-justify text from cursor if true. Left-justify if false.
scroll-display-left¶
( lcd1602-pcf8574 – )
Move text left 1 position.
scroll-display-right¶
( lcd1602-pcf8574 – )
Move text right 1 position.
left-to-right¶
( lcd1602-pcf8574 – )
Configure left-to-right script.
right-to-left¶
( lcd1602-pcf8574 – )
Configure right-to-left script.