import lcd
The lcd module drives HD44780-style character displays through firmware. Use it for status screens, numeric readouts, simple menus, and device-local feedback. Create an LCD object for each physical screen, then call display operations on that object.
Quick example
import lcd screen = lcd.LCD(0x27, 16, 2) screen.print_at(0, 0, "Generator") screen.print_at(0, 1, "RPM: 1800") engine = lcd.LCD(0x27, 16, 2) status = lcd.LCD(0x3F, 20, 4) engine.print_at(0, 0, "Engine") status.print_at(0, 0, "System online") battery = [0x0E, 0x1F, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x00] screen.create_char(0, battery) screen.print_at(12, 0, "BAT ") screen.write_char(0)
importlcd
Character LCD native Berry module.
The lcd module drives HD44780-style character displays through firmware. Use it for status screens, numeric readouts, simple menus, and device-local feedback. Create an LCD object for each physical screen, then call display operations on that object.
lcd.LCD(address: int, columns: int = None, rows: int = None, sda: int = None, scl: int = None, frequency: int = None, port: int = None, rs_bit: int = None, en_bit: int = None, bl_bit: int = None) -> lcd_screen
lcd.LCD(address: int, columns: int = None, rows: int = None, sda: int = None, scl: int = None, frequency: int = None, port: int = None, rs_bit: int = None, en_bit: int = None, bl_bit: int = None) -> lcd_screenCreate and initialize an independent character LCD screen.
Each returned object owns its own I2C address, geometry, backpack bit mapping, and display state. Multiple LCD objects can share the same I2C bus when their addresses are different.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
address |
int |
positional or keyword | Yes | I2C address, usually 0x27 or 0x3f. |
columns |
int |
positional or keyword | No | Optional number of text columns. Defaults to 16. |
rows |
int |
positional or keyword | No | Optional number of text rows. Defaults to 2. |
sda |
int |
positional or keyword | No | No description yet. |
scl |
int |
positional or keyword | No | No description yet. |
frequency |
int |
positional or keyword | No | No description yet. |
port |
int |
positional or keyword | No | No description yet. |
rs_bit |
int |
positional or keyword | No | No description yet. |
en_bit |
int |
positional or keyword | No | No description yet. |
bl_bit |
int |
positional or keyword | No | No description yet. |
lcd_screen lcd_screen object.
lcd.LCD().clear() -> None
lcd.LCD().clear() -> NoneClear the whole display and move the cursor home.
lcd.LCD().clear_line(row) -> None
lcd.LCD().clear_line(row) -> NoneClear one zero-based row and leave the cursor at its start.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
row |
int |
positional or keyword | Yes | Required value. |
lcd.LCD().home() -> None
lcd.LCD().home() -> NoneMove the cursor to column 0, row 0 without clearing text.
lcd.LCD().set_cursor(column, row) -> None
lcd.LCD().set_cursor(column, row) -> NoneMove the text cursor using zero-based coordinates.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
column |
int |
positional or keyword | Yes | Required value. |
row |
int |
positional or keyword | Yes | Required value. |
lcd.LCD().print(text) -> None
lcd.LCD().print(text) -> NonePrint text at the current cursor position.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
text |
str |
positional or keyword | Yes | Required value. |
lcd.LCD().print_at(column, row, text) -> None
lcd.LCD().print_at(column, row, text) -> NoneMove the cursor and print text in one call.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
column |
int |
positional or keyword | Yes | Required value. |
row |
int |
positional or keyword | Yes | Required value. |
text |
str |
positional or keyword | Yes | Required value. |
lcd.LCD().backlight(enabled) -> None
lcd.LCD().backlight(enabled) -> NoneTurn the LCD backlight on or off.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Required value. |
lcd.LCD().display(enabled) -> None
lcd.LCD().display(enabled) -> NoneShow or hide LCD text without clearing stored text.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Required value. |
lcd.LCD().cursor(enabled) -> None
lcd.LCD().cursor(enabled) -> NoneShow or hide the hardware text cursor.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Required value. |
lcd.LCD().blink(enabled) -> None
lcd.LCD().blink(enabled) -> NoneEnable or disable cursor blinking.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Required value. |
lcd.LCD().create_char(index, data) -> None
lcd.LCD().create_char(index, data) -> NoneDefine one custom character slot, 0 through 7.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
index |
any |
positional or keyword | Yes | Required value. |
data |
any |
positional or keyword | Yes | Required value. |
lcd.LCD().write_char(index) -> None
lcd.LCD().write_char(index) -> NoneWrite a custom character at the current cursor position.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
index |
any |
positional or keyword | Yes | Required value. |
lcd.LCD().close() -> bool
lcd.LCD().close() -> boolRelease this LCD device handle.
lcd.LCD().Example
lcd.LCD().Examplescreen = lcd.LCD(address=0x27, columns=16, rows=2) screen.print_at(0, 0, "Ready") second = lcd.LCD(address=0x3F, columns=20, rows=4) second.print_at(0, 0, "Second screen")
lcd.begin(address: int, columns: int = None, rows: int = None) -> None
lcd.begin(address: int, columns: int = None, rows: int = None) -> NoneLegacy: initialize the module-level default LCD.
Prefer ``screen = lcd.LCD(...)`` for new projects. The legacy wrapper keeps older singleton-style scripts working.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
address |
int |
positional or keyword | Yes | I2C address, usually 0x27 or 0x3f. |
columns |
int |
positional or keyword | No | Optional number of text columns. Defaults to 16. |
rows |
int |
positional or keyword | No | Optional number of text rows. Defaults to 2. |
None None.
lcd.clear() -> None
lcd.clear() -> NoneLegacy: clear the default display and move the cursor home.
None None.
lcd.clear_line(row: int) -> None
lcd.clear_line(row: int) -> NoneLegacy: clear one row on the default display.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
row |
int |
positional or keyword | Yes | Zero-based text row to clear. |
None None.
lcd.home() -> None
lcd.home() -> NoneLegacy: move the default cursor to column 0, row 0.
None None.
lcd.set_cursor(column: int, row: int) -> None
lcd.set_cursor(column: int, row: int) -> NoneLegacy: move the default text cursor.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
column |
int |
positional or keyword | Yes | Zero-based text column. |
row |
int |
positional or keyword | Yes | Zero-based text row. |
None None.
lcd.print(text: str) -> None
lcd.print(text: str) -> NoneLegacy: print text on the default display.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
text |
str |
positional or keyword | Yes | String to display. |
None None.
lcd.print_at(column: int, row: int, text: str) -> None
lcd.print_at(column: int, row: int, text: str) -> NoneLegacy: move the default cursor and print text in one call.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
column |
int |
positional or keyword | Yes | Zero-based text column. |
row |
int |
positional or keyword | Yes | Zero-based text row. |
text |
str |
positional or keyword | Yes | String to display. |
None None.
lcd.backlight(enabled: bool) -> None
lcd.backlight(enabled: bool) -> NoneLegacy: set the default LCD backlight state.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Boolean. True turns the backlight on; False turns it off. |
None None.
lcd.display(enabled: bool) -> None
lcd.display(enabled: bool) -> NoneLegacy: set whether default LCD text output is visible.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Boolean. True shows the display; False hides it. |
None None.
lcd.cursor(enabled: bool) -> None
lcd.cursor(enabled: bool) -> NoneLegacy: show or hide the default hardware text cursor.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Boolean. True shows the cursor; False hides it. |
None None.
lcd.blink(enabled: bool) -> None
lcd.blink(enabled: bool) -> NoneLegacy: enable or disable the default blinking cursor.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
enabled |
bool |
positional or keyword | Yes | Boolean. True enables blinking; False disables it. |
None None.
lcd.create_char(index: any, data: list) -> None
lcd.create_char(index: any, data: list) -> NoneLegacy: define one custom character on the default LCD.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
index |
any |
positional or keyword | Yes | Custom character slot from 0 to 7. |
data |
list |
positional or keyword | Yes | List, bytes, or string containing 8 row values. |
None None.
lcd.write_char(index: any) -> None
lcd.write_char(index: any) -> NoneLegacy: write a custom character on the default LCD.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
index |
any |
positional or keyword | Yes | Custom character slot from 0 to 7. |
None None.