Skip to main content

LCD

I2C
output
Medium RAM
0.1.0

#Description

An LCD is a simple display that can display up to 32 characters and change its background colour. Perfect for showing simple states or messages.

#Aliases

  • LCD Display

#Functions



#JavaScript / Node.js

ClassLCDextends I2cComponentBase

LCD component for controlling a 16x2 I2C character display with RGB backlight (Grove LCD RGB Backlight). Extends ComponentBase as a complex output component with custom serial commands.

#Value type

TypeScript
interface LCDValue {
  string: string;
  backgroundColor: string;
}

#Constructor options

OptionTypeRequiredDescriptionInherited from
pinI2CPinIDrequiredI2cComponentBase

#Events

EventParametersDescription
changevalue: LCDValue

#Methods

drawString(text: string)

Draw text on the display using the shadow-diff streaming protocol. Only changed character cells are rewritten, avoiding flicker. Long text is automatically chunked by the serial protocol layer.

print(text: string)

@deprecated Use drawString() instead. Kept for backwards compatibility.

clear()

Clear the display.

setCursor(col: number, row: number)

Set the cursor position.

setRGB(r: number, g: number, b: number)

Set backlight color using RGB values.

bgColor(hex: string)

Set backlight color using a hex string.

backlightOff()

Turn off the backlight.

get i2cIdI2CPinIDfrom I2cComponentBase

The resolved I2C pin ID (e.g. "i2c-0"). Useful for logging or passing back to the Arduino sketch.

#Example

JavaScript
import { Board, LCD } from "@blokdots/components";

const board = new Board("/dev/ttyACM0");
await board.open();

const lCD = new LCD({ board, pin: "example" });


#C++ (Arduino)

ClassLCDDisplayextends ComponentBase

16x2 I2C LCD with RGB backlight using Seeed's Grove_LCD_RGB_Backlight library. - Uses ComponentBase begin()/tick() registration. - Optional EventBus "changed" event emission (rate-limited).

#Required libraries

#Setup

C++
#include "blokdots.h"

LCDDisplay myComponent();

#Constructor

LCDDisplay(cols, rows, charSize, wire, startR, startG, startB, startBacklightOn)
ParameterTypeDefault
colsuint8_t16
rowsuint8_t2
charSizeuint8_tLCD_5x8DOTS
wireTwoWireWire
startRuint8_t255
startGuint8_t255
startBuint8_t255
startBacklightOnbooltrue
LCDDisplay(bus, evtChanged, cols, rows, charSize, wire, startR, startG, startB, startBacklightOn, minEmitIntervalMs)
ParameterTypeDefault
busEventBusrequired
evtChangeduint8_trequired
colsuint8_t16
rowsuint8_t2
charSizeuint8_tLCD_5x8DOTS
wireTwoWireWire
startRuint8_t255
startGuint8_t255
startBuint8_t255
startBacklightOnbooltrue
minEmitIntervalMsuint16_t0

#Methods

clear()
home()
setCursor(col, row)
ParameterTypeDefault
coluint8_trequired
rowuint8_trequired
print(s)

Print helpers — all route through drawString() for shadow-diff / no-flicker.

ParameterTypeDefault
sconst charrequired
print(v)
ParameterTypeDefault
vintrequired
print(v)
ParameterTypeDefault
vunsigned intrequired
print(v)
ParameterTypeDefault
vlongrequired
print(v)
ParameterTypeDefault
vunsigned longrequired
print(v, digits)
ParameterTypeDefault
vfloatrequired
digitsuint8_t2
setRGB(r, g, b)
ParameterTypeDefault
ruint8_trequired
guint8_trequired
buint8_trequired
setRGB(c)

NEW: blokdots::Color overload

ParameterTypeDefault
cblokdots::Colorrequired
bgColor(r, g, b)

alias (kept for compatibility)

ParameterTypeDefault
ruint8_trequired
guint8_trequired
buint8_trequired
bgColor(c)

NEW: blokdots::Color alias

ParameterTypeDefault
cblokdots::Colorrequired
bgColor(hex)

Optional: hex input, uses your color utils

ParameterTypeDefault
hexconst charrequired
backlightOff()
isBacklightOn()bool
setLine(row, text)
ParameterTypeDefault
rowuint8_trequired
textconst charrequired
setText2(line0, line1)
ParameterTypeDefault
line0const charrequired
line1const charrequired
drawString(text)

Uses the same shadow-diff logic: only changed cells are written.

ParameterTypeDefault
textconst charrequired
beginDrawString()
drawStringChunk(text)
ParameterTypeDefault
textconst charrequired
endDrawString()
displayOn()
displayOff()
cursorOn()
cursorOff()
blinkOn()
blinkOff()
blinkLEDOn()
blinkLEDOff()
autoscrollOn()
autoscrollOff()
leftToRight()
rightToLeft()
scrollDisplayLeft()
scrollDisplayRight()
createChar(location, charmap[])
ParameterTypeDefault
locationuint8_trequired
charmap[]uint8_trequired
columns()uint8_t
rowsCount()uint8_t