|
SegLCDLib
|
Abstract base class for LCD segment display drivers. More...
#include <SegLCDLib.h>
Public Types | |
| enum | BacklightMode { BACKLIGHT_DIGITAL , BACKLIGHT_PWM } |
| Backlight mode for GPIO control. More... | |
Public Member Functions | |
| virtual | ~SegLCDLib () |
| Virtual destructor to ensure proper cleanup in derived classes. | |
| virtual void | init ()=0 |
| Logical display sections that can be targeted by higher-level rendering logic. | |
| virtual void | clear () |
| Clear all visible segments on the display. | |
| void | home () |
| Set cursor to 0, 0 without clear display. | |
| virtual void | setCursor (uint8_t row, uint8_t col) |
| Set cursor on exact digit. | |
| virtual size_t | write (uint8_t ch) |
| virtual void | command (uint8_t command)=0 |
| Send RAW command to controller. | |
| virtual void | on ()=0 |
| Turn the display on. | |
| virtual void | off ()=0 |
| Turn the display off. | |
| void | initBacklight (int8_t backlightPin, BacklightMode backlightMode=BACKLIGHT_DIGITAL, bool backlightActiveHigh=true) |
| Initialize GPIO backlight control. | |
| virtual void | setBacklight (bool state) |
| Set backlight state (on/off). | |
| virtual void | setBacklight (int brightness) |
| Set backlight brightness (0-255). | |
| void | setAutoFlush (bool enable) |
| Enable or disable autoflush mode. | |
| bool | getAutoFlush () const |
| Get current autoflush state. | |
| virtual void | flush () |
| Flush all buffered changes to the display. | |
| virtual void | flush (uint8_t startAddr, uint8_t length) |
| Flush specific range of buffered changes to the display. | |
| const uint8_t * | getRamBuffer () const |
| Get pointer to internal RAM buffer (read-only). | |
| size_t | getRamBufferSize () const |
| Get size of internal RAM buffer in bytes. | |
Protected Member Functions | |
| void | _setFlag (uint8_t mask) |
| Set a specific flag bit. | |
| void | _clearFlag (uint8_t mask) |
| Clear a specific flag bit. | |
| bool | _isFlagSet (uint8_t mask) const |
| Check if a specific flag bit is set. | |
| void | _clearAllFlags () |
| Clear all flags. | |
| bool | _dotWrite (uint8_t ch, int8_t minCol, int8_t maxCol, int8_t ramOffset) |
| Write decimal point. | |
| void | _dotClearCur (int8_t minCol, int8_t maxCol) |
| Clear current decimal (overwrite). | |
| void | _colonClearIfNotFlagged (uint8_t ch, uint8_t colonCol, uint8_t colonFlag) |
| Clear colon if its flag is not set. | |
| virtual void | _setDecimal (uint8_t row, uint8_t col, bool state) |
| Virtual method for setting decimal point. | |
| virtual void | _setColon (uint8_t row, uint8_t col, bool state) |
| Virtual method for setting colon. | |
| void | _allocateBuffer (size_t size) |
| Allocate RAM buffer for display data. | |
| void | _writeRamMasked (uint8_t data, uint8_t address, uint8_t mask=0xFF) |
| Write to display RAM with nibble-aware masking support. | |
| virtual void | _writeRam (uint8_t data, uint8_t address)=0 |
| Low-level method to write a single byte to display RAM. | |
| virtual void | _writeRam (uint8_t *data, size_t length, uint8_t address)=0 |
| Low-level method to write a data buffer to display RAM. | |
| uint8_t | _get_char_value (char ch) |
| Helper method to convert a character to its segment representation. | |
| uint16_t | _get_16char_value (char ch) |
| Helper method to convert a character to its 16-segment representation. | |
Protected Attributes | |
| bool | _autoFlush = true |
| Autoflush mode enabled flag (default: true for LCD API 1.0 compatibility). | |
| int8_t | _backlightPin = -1 |
| Backlight GPIO pin (-1 if disabled) | |
| BacklightMode | _backlightMode = BACKLIGHT_DIGITAL |
| Backlight mode (DIGITAL or PWM) | |
| bool | _backlightActiveHigh = true |
| Backlight active high flag. | |
| uint8_t | _backlightBrightness = 0 |
| Cached backlight brightness. | |
| uint8_t | _displayFlags = 0 |
| LEDC channel for old ESP32 Arduino Core (2.0.x) | |
| uint8_t * | _ramBuffer = nullptr |
| Dynamic RAM buffer for display data (allocated by derived classes). | |
| size_t | _ramBufferSize = 0 |
| Size of allocated RAM buffer in bytes. | |
| uint8_t | _cursorRow = 0 |
| Current Row. | |
| uint8_t | _cursorCol = 0 |
| Current Column. | |
Static Protected Attributes | |
| static constexpr uint8_t | FLAG_PENDING_DOT = 0x80 |
| Common flag for decimal handling when RAM offset is 0. | |
Abstract base class for LCD segment display drivers.
This class defines the generic interface required by all LCD segment drivers, including display control, character output, and data writing methods.
|
virtual |
Virtual destructor to ensure proper cleanup in derived classes.
|
protected |
Allocate RAM buffer for display data.
| size | Buffer size in bytes |
|
protected |
Clear all flags.
|
protected |
Clear a specific flag bit.
| mask | Bitmask with bit(s) to clear |
|
protected |
Clear colon if its flag is not set.
Internal helper for display-specific write() implementations.
| ch | Character being processed |
| colonCol | Colon position |
| colonFlag | Flag bit for this colon |
|
protected |
Clear current decimal (overwrite).
Internal helper for display-specific write() implementations.
| minCol | Minimum valid column |
| maxCol | Maximum valid column |
|
protected |
Write decimal point.
Internal helper for display-specific write() implementations.
| ch | Character to process |
| minCol | Minimum valid column for decimal |
| maxCol | Maximum valid column for decimal |
| ramOffset | RAM offset for decimal (-1, 0, or +1) |
|
protected |
Helper method to convert a character to its 16-segment representation.
|
protected |
Helper method to convert a character to its segment representation.
|
protected |
Check if a specific flag bit is set.
| mask | Bitmask with bit(s) to check |
|
inlineprotectedvirtual |
Virtual method for setting colon.
Default implementation is empty (no-op).
Reimplemented in SegLCD_HT1621_4SegDegree, SegLCD_HT1621_LCM59011, SegLCD_PCF85176_4DR821B, SegLCD_PCF85176_6DigitSignalBatteryProgress, SegLCD_PCF85176_T1T2Lcd, and SegLCD_PCF8576_4Seg6SegMaintSegBatUnits.
|
inlineprotectedvirtual |
Virtual method for setting decimal point.
Each LCD has its own implementation with HW specifics. Default implementation is empty (no-op).
Reimplemented in SegLCD_HT1621_4SegDegree, SegLCD_HT1621_6SegBat, SegLCD_HT1621_LCM0844, SegLCD_HT1621_LCM88128, SegLCD_HT1622_10Dig16Seg, SegLCD_PCF85176_2Row4DigSigBatPwr, SegLCD_PCF85176_4DR821B, SegLCD_PCF85176_6DigitSignalBatteryProgress, SegLCD_PCF85176_OneDigit, SegLCD_PCF85176_T1T2Lcd, SegLCD_PCF85176_TempHumidity, SegLCD_PCF8576_4Seg6SegMaintSegBatUnits, and SegLCD_VK0192_5DigSigBattProgress.
|
protected |
Set a specific flag bit.
| mask | Bitmask with bit(s) to set |
|
protectedpure virtual |
Low-level method to write a data buffer to display RAM.
| data | Pointer to data buffer |
| length | Length of data buffer |
| address | Start RAM address |
Implemented in SegDriver_3Wire, SegDriver_HT1622, SegDriver_PCx85, and SegDriver_VK0192.
|
protectedpure virtual |
Low-level method to write a single byte to display RAM.
| data | Data byte |
| address | RAM address |
Implemented in SegDriver_3Wire, SegDriver_HT1622, SegDriver_VK0192, and SegDriver_PCx85.
|
protected |
Write to display RAM with nibble-aware masking support.
Handles both byte-aligned and nibble-aligned addresses with read-modify-write when mask is not 0xFF. Updates internal buffer and writes to hardware.
| data | Value to write |
| address | RAM address (nibble-level addressing) |
| mask | Bitmask for selective bit updates (0xFF = write all bits) |
|
virtual |
Clear all visible segments on the display.
Reimplemented in SegDriver_HT1621, SegDriver_HT1622, SegDriver_PCx85, SegDriver_VK0192, SegLCD_HT1621_4SegDegree, SegLCD_PCF85176_TempHumidity, and SegLCD_PCF8576_4Seg6SegMaintSegBatUnits.
|
pure virtual |
Send RAW command to controller.
| command | Raw command byte |
Implemented in SegDriver_3Wire, and SegDriver_PCx85.
|
virtual |
Flush all buffered changes to the display.
Writes the entire display buffer to the hardware. This is useful when autoflush is disabled to batch multiple write() calls into a single hardware update cycle.
Safe to call even when autoflush is enabled (no effect).
Reimplemented in SegDriver_HT1621, SegDriver_HT1622, SegDriver_PCx85, and SegDriver_VK0192.
|
virtual |
Flush specific range of buffered changes to the display.
Writes a specific address range from the display buffer to hardware. This is an advanced API for optimizing updates when only part of the display needs to be refreshed.
For example, to update only the first row of a multi-row display:
Safe to call even when autoflush is enabled (no effect).
| startAddr | Starting buffer address in bytes (RAM buffer index) |
| length | Number of bytes to flush |
Reimplemented in SegDriver_HT1621, SegDriver_HT1622, SegDriver_PCx85, SegDriver_VK0192, SegDriver_HT1621, SegDriver_HT1622, SegDriver_PCx85, and SegDriver_VK0192.
| bool SegLCDLib::getAutoFlush | ( | ) | const |
Get current autoflush state.
| const uint8_t * SegLCDLib::getRamBuffer | ( | ) | const |
Get pointer to internal RAM buffer (read-only).
| size_t SegLCDLib::getRamBufferSize | ( | ) | const |
Get size of internal RAM buffer in bytes.
| void SegLCDLib::home | ( | ) |
Set cursor to 0, 0 without clear display.
|
pure virtual |
Logical display sections that can be targeted by higher-level rendering logic.
Initialize the display driver, clear display and set position to 0,0.
Implemented in SegDriver_3Wire, SegDriver_PCx85, SegLCD_HT1621_4SegDegree, SegLCD_HT1621_6SegBat, SegLCD_HT1621_LCM0844, SegLCD_HT1621_LCM59011, SegLCD_HT1621_LCM88128, SegLCD_HT1622_10Dig16Seg, SegLCD_PCF85176_2Row4DigSigBatPwr, SegLCD_PCF85176_4DR821B, SegLCD_PCF85176_6DigitSignalBatteryProgress, SegLCD_PCF85176_OneDigit, SegLCD_PCF85176_T1T2Lcd, SegLCD_PCF85176_TempHumidity, SegLCD_PCF8576_4Seg6SegMaintSegBatUnits, and SegLCD_VK0192_5DigSigBattProgress.
| void SegLCDLib::initBacklight | ( | int8_t | backlightPin, |
| BacklightMode | backlightMode = BACKLIGHT_DIGITAL, |
||
| bool | backlightActiveHigh = true |
||
| ) |
Initialize GPIO backlight control.
Must be called from init() of concrete implementations to setup the backlight GPIO.
| backlightPin | GPIO pin for backlight control (-1 to disable) |
| backlightMode | Backlight mode (DIGITAL or PWM) |
| backlightActiveHigh | true if backlight is active high (default), false for active low |
|
pure virtual |
Turn the display off.
Implemented in SegDriver_3Wire, and SegDriver_PCx85.
|
pure virtual |
Turn the display on.
Implemented in SegDriver_3Wire, and SegDriver_PCx85.
| void SegLCDLib::setAutoFlush | ( | bool | enable | ) |
Enable or disable autoflush mode.
In autoflush mode (default), each write() call immediately updates the display. This maintains LCD API 1.0 compatibility but can cause flicker when multiple segments are updated rapidly (e.g., writing "123.4" causes decimal point to flicker).
In manual flush mode, write() only updates the internal buffer. Call flush() to write all buffered changes to the display at once, eliminating flicker.
Example usage:
| enable | true to enable autoflush (default), false for manual flush mode |
|
virtual |
Set backlight state (on/off).
| state | true to turn backlight on, false to turn off |
|
virtual |
Set backlight brightness (0-255).
| brightness | Brightness level 0-255, where 0 is off and 255 is full brightness |
|
virtual |
Set cursor on exact digit.
Because LCD API is mainly used for character displays in this segment displays this function will be littlebit confusing. Because most of Segment LCD has only one row, thus this will be like row 0 and column will represent actual digit.
But if there is LCD like T1T2 LCD. Row 0 will be clock part, Row 1 will be T1: part and Row 2 will be T2: part of LCD
| row | Row, where 0-MAXROWS |
| col | Column 0-MAXDIGITS in current row |
Reimplemented in SegLCD_HT1621_4SegDegree, SegLCD_PCF85176_4DR821B, SegLCD_PCF85176_6DigitSignalBatteryProgress, SegLCD_PCF85176_T1T2Lcd, SegLCD_PCF85176_TempHumidity, SegLCD_PCF8576_4Seg6SegMaintSegBatUnits, and SegLCD_VK0192_5DigSigBattProgress.
|
inlinevirtual |
Reimplemented in SegLCD_HT1621_4SegDegree, SegLCD_HT1621_6SegBat, SegLCD_HT1621_LCM0844, SegLCD_HT1621_LCM59011, SegLCD_HT1621_LCM88128, SegLCD_HT1622_10Dig16Seg, SegLCD_PCF85176_2Row4DigSigBatPwr, SegLCD_PCF85176_4DR821B, SegLCD_PCF85176_6DigitSignalBatteryProgress, SegLCD_PCF85176_OneDigit, SegLCD_PCF85176_T1T2Lcd, SegLCD_PCF85176_TempHumidity, SegLCD_PCF8576_4Seg6SegMaintSegBatUnits, SegLCD_PCx85_Raw, and SegLCD_VK0192_5DigSigBattProgress.
|
protected |
Autoflush mode enabled flag (default: true for LCD API 1.0 compatibility).
|
protected |
Backlight active high flag.
|
protected |
Cached backlight brightness.
|
protected |
Backlight mode (DIGITAL or PWM)
|
protected |
Backlight GPIO pin (-1 if disabled)
|
protected |
Current Column.
|
protected |
Current Row.
|
protected |
LEDC channel for old ESP32 Arduino Core (2.0.x)
Generic flag storage for display-specific state tracking.
Individual LCD implementations can use these bits to track state like:
Usage: Define bit constants in derived class, use helper methods to set/clear/check.
|
protected |
Dynamic RAM buffer for display data (allocated by derived classes).
|
protected |
Size of allocated RAM buffer in bytes.
|
staticconstexprprotected |
Common flag for decimal handling when RAM offset is 0.
Used when decimal point shares the same RAM byte as the digit. Set when '.' is written, cleared after next character preserves it.