![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
Standard 16x2 character LCD screen (LCD1602) driven over I2C. More...
#include <LCD1602.h>
Public Member Functions | |
| LCD1602 (const LCD1602 &)=delete | |
| LCD1602 & | operator= (const LCD1602 &)=delete |
| LCD1602 (const int LCDAddr) | |
| Builds an LCD1602 at the given I2C address, opening the i2c device and enabling the backlight. More... | |
| LCD1602 (const int LCDAddr, const int fileDescriptor) | |
| Builds an LCD1602 at the given I2C address using an already-open file descriptor. More... | |
| LCD1602 (const int LCDAddr, const int fileDescriptor, const int blen) | |
| Builds an LCD1602 at the given I2C address using an already-open file descriptor and explicit backlight setting. More... | |
| virtual | ~LCD1602 () |
| Destroys the screen, turning it off first. More... | |
| virtual void | TurnOn () override |
| Initializes the LCD (8-bit then 4-bit mode, 2 lines, display on without cursor blink) and clears the screen. More... | |
| virtual void | TurnOff () override |
| Turns the display off. More... | |
| virtual void | ProcessRawValues () override |
| No-op: the LCD is an output device with no raw values to process. More... | |
| virtual std::string | ToString () const override |
| Serializes the LCD's I2C address, file descriptor, and backlight flag to a string. More... | |
| void | ClearScreen () |
| Clears the screen. More... | |
| void | WriteToScreen (int &x, int &y, const char data[]) |
| Writes a string starting at the given cursor position, clamping x to 0-15 and y to 0-1. More... | |
Public Member Functions inherited from RumPi::BaseComponent | |
| BaseComponent () | |
| Builds a base component with an unknown type and an empty name. More... | |
| virtual | ~BaseComponent () |
| Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More... | |
| virtual void | TurnOn ()=0 |
| Turns the component on (e.g. More... | |
| virtual void | TurnOff ()=0 |
| Turns the component off. More... | |
| virtual std::string | ToString () const =0 |
| Serializes the component's current readings to a string (usually JSON). More... | |
| virtual void | ProcessRawValues ()=0 |
| Reads and processes the component's latest raw values (called once per poll). More... | |
| virtual EComponentType | GetComponentType () const |
| Gets the component's type. More... | |
| const std::string & | GetName () const |
| Gets the component's unique per-instance name. More... | |
| void | SetName (const std::string &name) |
| Sets the component's unique per-instance name. More... | |
Private Member Functions | |
| void | WriteWord (const int word) |
| Writes a raw word to the LCD over I2C, setting or clearing the backlight bit according to the backlight flag. More... | |
| void | SendCommand (const int command) |
| Sends a command byte to the LCD in two 4-bit nibbles, toggling the enable line for each. More... | |
| void | SendData (const int data) |
| Sends a data byte to the LCD in two 4-bit nibbles, toggling the enable line for each. More... | |
Private Attributes | |
| int | myLCDAddress |
| The LCD's I2C address. More... | |
| int | myFileDescriptor |
| The open i2c device file descriptor. More... | |
| bool | myOwnsFileDescriptor |
| True if this component opened (and must close) the fd; false if borrowed. More... | |
| int | myBLEN |
| Backlight enable flag (1 = on). More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from RumPi::BaseComponent | |
| static std::string | ComponentTypeToString (const EComponentType theComponentTypeToConvert) |
| Maps an EComponentType to its string name. More... | |
| static EComponentType | StringToComponentType (const std::string &theComponentTypeName) |
| Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More... | |
Protected Attributes inherited from RumPi::BaseComponent | |
| EComponentType | myComponentType |
| The kind of component this is (set by each concrete subclass). More... | |
| std::string | myName |
| A unique per-instance name, assigned when the component is added to the manager. More... | |
Standard 16x2 character LCD screen (LCD1602) driven over I2C.
|
delete |
| RumPi::LCD1602::LCD1602 | ( | const int | LCDAddr | ) |
| RumPi::LCD1602::LCD1602 | ( | const int | LCDAddr, |
| const int | fileDescriptor | ||
| ) |
| RumPi::LCD1602::LCD1602 | ( | const int | LCDAddr, |
| const int | fileDescriptor, | ||
| const int | blen | ||
| ) |
Builds an LCD1602 at the given I2C address using an already-open file descriptor and explicit backlight setting.
| [in] | LCDAddr | The LCD's I2C address. |
| [in] | fileDescriptor | An already-open i2c device file descriptor. |
| [in] | blen | The backlight enable flag (1 = on). |
|
virtual |
| void RumPi::LCD1602::ClearScreen | ( | ) |
Clears the screen.
|
overridevirtual |
No-op: the LCD is an output device with no raw values to process.
Implements RumPi::BaseComponent.
|
private |
Sends a command byte to the LCD in two 4-bit nibbles, toggling the enable line for each.
| [in] | command | The command byte to send. |
|
private |
Sends a data byte to the LCD in two 4-bit nibbles, toggling the enable line for each.
| [in] | data | The data byte to send. |
|
overridevirtual |
Serializes the LCD's I2C address, file descriptor, and backlight flag to a string.
Implements RumPi::BaseComponent.
|
overridevirtual |
|
overridevirtual |
Initializes the LCD (8-bit then 4-bit mode, 2 lines, display on without cursor blink) and clears the screen.
Implements RumPi::BaseComponent.
| void RumPi::LCD1602::WriteToScreen | ( | int & | x, |
| int & | y, | ||
| const char | data[] | ||
| ) |
Writes a string starting at the given cursor position, clamping x to 0-15 and y to 0-1.
| [in,out] | x | The column (clamped to 0-15). |
| [in,out] | y | The row (clamped to 0-1). |
| [in] | data | The null-terminated string to write. |
|
private |
Writes a raw word to the LCD over I2C, setting or clearing the backlight bit according to the backlight flag.
| [in] | word | The word to write. |
|
private |
Backlight enable flag (1 = on).
|
private |
The open i2c device file descriptor.
|
private |
The LCD's I2C address.
|
private |
True if this component opened (and must close) the fd; false if borrowed.