SegLCDLib
Loading...
Searching...
No Matches
SegDriver_PCx85 Class Reference

Base class for PCx85 LCD segment display drivers. More...

#include <SegDriver_PCx85.h>

Inheritance diagram for SegDriver_PCx85:
SegLCDLib SegDriver_PCF85176 SegLCD_PCx85_Raw SegDriver_PCF8576 SegLCD_PCF85176_2Row4DigSigBatPwr SegLCD_PCF85176_4DR821B SegLCD_PCF85176_6DigitSignalBatteryProgress SegLCD_PCF85176_OneDigit SegLCD_PCF85176_T1T2Lcd SegLCD_PCF85176_TempHumidity SegLCD_PCF8576_4Seg6SegMaintSegBatUnits

Public Types

enum  ModeStatus { MODE_STATUS_BLANK = 0 , MODE_STATUS_ENABLED = 1 }
 Enable/disable display. More...
 
enum  BlinkFrequency { BLINK_FREQUENCY_OFF = 0 , BLINK_FREQUENCY_1 = 1 , BLINK_FREQUENCY_2 = 2 , BLINK_FREQUENCY_3 = 3 }
 Set blink frequency. More...
 
enum  BlinkMode { BLINK_MODE_NORMAL = 0 , BLINK_MODE_ALTRAM = 1 }
 Set blink mode. More...
 
- Public Types inherited from SegLCDLib
enum  BacklightMode { BACKLIGHT_DIGITAL , BACKLIGHT_PWM }
 Backlight mode for GPIO control. More...
 

Public Member Functions

 SegDriver_PCx85 (TwoWire &i2c, uint8_t address, uint8_t subaddress)
 Constructor for PCx85 segment driver.
 
virtual void init () override
 Logical display sections that can be targeted by higher-level rendering logic.
 
void bankSelect (uint8_t input, uint8_t output)
 Select bank for input and output.
 
void blink (BlinkFrequency blink=BLINK_FREQUENCY_OFF, BlinkMode mode=BLINK_MODE_NORMAL)
 Set blink frequency and mode.
 
void clear () override
 Clear all visible segments on the display.
 
void on () override
 Turn the display on.
 
void off () override
 Turn the display off.
 
void command (uint8_t command) override
 Send RAW command to controller.
 
void flush (uint8_t startAddr, uint8_t length) override
 Flush specific range of buffered changes to the display.
 
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.
 
- Public Member Functions inherited from SegLCDLib
virtual ~SegLCDLib ()
 Virtual destructor to ensure proper cleanup in derived classes.
 
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)
 
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.
 
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 _setMode (ModeStatus status, ModeDrive drive=MODE_DRIVE_14, ModeBias bias=MODE_BIAS_13)
 Set the mode of the display.
 
void _writeRam (uint8_t data, uint8_t address=0) override
 Low-level method to write a single byte to display RAM.
 
void _writeRam (uint8_t *data, size_t length, uint8_t address=0) override
 Low-level method to write a data buffer to display RAM.
 
- Protected Member Functions inherited from SegLCDLib
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.
 
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.
 

Static Protected Attributes

static constexpr uint8_t DEFAULT_PCF85176_I2C_ADDRESS = 0x38
 
static constexpr uint8_t DEFAULT_SUBADDRESS = 0x00
 
- Static Protected Attributes inherited from SegLCDLib
static constexpr uint8_t FLAG_PENDING_DOT = 0x80
 Common flag for decimal handling when RAM offset is 0.
 

Private Member Functions

void _deviceSelect ()
 Select the device for communication.
 

Private Attributes

TwoWire & _i2c
 
uint8_t _address
 
uint8_t _subaddress
 
ModeDrive _drive
 
ModeBias _bias
 

Additional Inherited Members

- Protected Attributes inherited from SegLCDLib
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.
 

Detailed Description

Base class for PCx85 LCD segment display drivers.

Implementation of the PCF85176 and similar I2C controllers.

Member Enumeration Documentation

◆ BlinkFrequency

Set blink frequency.

Enumerator
BLINK_FREQUENCY_OFF 

No blinking.

BLINK_FREQUENCY_1 

Blink at ~2Hz.

BLINK_FREQUENCY_2 

Blink at ~1Hz.

BLINK_FREQUENCY_3 

Blink at ~0.5Hz.

◆ BlinkMode

Set blink mode.

Note: that alternate RAM blink mode is not supported if 1/3 or 1/4 drive mode is used.

Enumerator
BLINK_MODE_NORMAL 

Normal blink mode.

BLINK_MODE_ALTRAM 

Alternate RAM blink mode.

◆ ModeStatus

Enable/disable display.

Enumerator
MODE_STATUS_BLANK 

Display is blanked.

MODE_STATUS_ENABLED 

Display is enabled.

Constructor & Destructor Documentation

◆ SegDriver_PCx85()

SegDriver_PCx85::SegDriver_PCx85 ( TwoWire &  i2c,
uint8_t  address,
uint8_t  subaddress 
)

Constructor for PCx85 segment driver.

Address is selected by SA0 pins on the device. Subaddress is selected by A0 to A2 pins on the device

Parameters
i2cReference to the TwoWire object for I2C communication
addressI2C address of the PCx85 device
subaddressSubaddress for the device

Member Function Documentation

◆ _deviceSelect()

void SegDriver_PCx85::_deviceSelect ( )
private

Select the device for communication.

This method is used to set the device by subaddress. If address during writing overflow one device's address next device is selected. So this is used to select back to this device.

◆ _setMode()

void SegDriver_PCx85::_setMode ( ModeStatus  status,
ModeDrive  drive = MODE_DRIVE_14,
ModeBias  bias = MODE_BIAS_13 
)
protected

Set the mode of the display.

This method sets the drive and bias modes for the display. It also enables or disables the display based on the status.

Parameters
statusDisplay status (enabled or blanked)
driveDrive mode (default is MODE_DRIVE_14)
biasBias mode (default is MODE_BIAS_13)

◆ _writeRam() [1/2]

void SegDriver_PCx85::_writeRam ( uint8_t *  data,
size_t  length,
uint8_t  address = 0 
)
overrideprotectedvirtual

Low-level method to write a data buffer to display RAM.

Parameters
dataPointer to data buffer
lengthLength of data buffer
addressStart RAM address

Implements SegLCDLib.

◆ _writeRam() [2/2]

void SegDriver_PCx85::_writeRam ( uint8_t  data,
uint8_t  address = 0 
)
overrideprotectedvirtual

Low-level method to write a single byte to display RAM.

Parameters
dataData byte
addressRAM address

Implements SegLCDLib.

◆ bankSelect()

void SegDriver_PCx85::bankSelect ( uint8_t  input,
uint8_t  output 
)

Select bank for input and output.

The bank-select command controls where data is written to RAM and where it is displayed from. Valid values for input and output are 0 or 1.

Parameters
inputinput bank selection; storage of arriving display data
outputoutput bank selection; retrieval of LCD display data

◆ blink()

void SegDriver_PCx85::blink ( BlinkFrequency  blink = BLINK_FREQUENCY_OFF,
BlinkMode  mode = BLINK_MODE_NORMAL 
)

Set blink frequency and mode.

Parameters
blinkBlink frequency to set (default is BLINK_FREQUENCY_OFF)
modeBlink mode to set (default is BLINK_MODE_NORMAL)

◆ clear()

void SegDriver_PCx85::clear ( )
overridevirtual

Clear all visible segments on the display.

Reimplemented from SegLCDLib.

Reimplemented in SegLCD_PCF85176_TempHumidity, and SegLCD_PCF8576_4Seg6SegMaintSegBatUnits.

◆ command()

void SegDriver_PCx85::command ( uint8_t  command)
inlineoverridevirtual

Send RAW command to controller.

Parameters
commandRaw command byte

Implements SegLCDLib.

◆ flush() [1/3]

void SegLCDLib::flush ( )
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).

See also
setAutoFlush()

Reimplemented from SegLCDLib.

◆ flush() [2/3]

void SegLCDLib::flush ( uint8_t  startAddr,
uint8_t  length 
)
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:

lcd.flush(0, 6); // Update first 6 bytes (row 0)

Safe to call even when autoflush is enabled (no effect).

Parameters
startAddrStarting buffer address in bytes (RAM buffer index)
lengthNumber of bytes to flush
See also
setAutoFlush()

Reimplemented from SegLCDLib.

◆ flush() [3/3]

void SegDriver_PCx85::flush ( uint8_t  startAddr,
uint8_t  length 
)
overridevirtual

Flush specific range of buffered changes to the display.

Optimized implementation for PCx85 that uses efficient I2C bulk write.

Parameters
startAddrStarting buffer address in bytes (RAM buffer index)
lengthNumber of bytes to flush

Reimplemented from SegLCDLib.

◆ init()

void SegDriver_PCx85::init ( )
overridevirtual

Logical display sections that can be targeted by higher-level rendering logic.

Initialize the display driver, clear display and set position to 0,0.

Implements SegLCDLib.

Reimplemented in SegLCD_PCF85176_2Row4DigSigBatPwr, SegLCD_PCF85176_4DR821B, SegLCD_PCF85176_6DigitSignalBatteryProgress, SegLCD_PCF85176_OneDigit, SegLCD_PCF85176_T1T2Lcd, SegLCD_PCF85176_TempHumidity, and SegLCD_PCF8576_4Seg6SegMaintSegBatUnits.

◆ off()

void SegDriver_PCx85::off ( )
overridevirtual

Turn the display off.

Implements SegLCDLib.

◆ on()

void SegDriver_PCx85::on ( )
overridevirtual

Turn the display on.

Implements SegLCDLib.

Field Documentation

◆ _address

uint8_t SegDriver_PCx85::_address
private

◆ _bias

ModeBias SegDriver_PCx85::_bias
private

◆ _drive

ModeDrive SegDriver_PCx85::_drive
private

◆ _i2c

TwoWire& SegDriver_PCx85::_i2c
private

◆ _subaddress

uint8_t SegDriver_PCx85::_subaddress
private

◆ DEFAULT_PCF85176_I2C_ADDRESS

constexpr uint8_t SegDriver_PCx85::DEFAULT_PCF85176_I2C_ADDRESS = 0x38
staticconstexprprotected

◆ DEFAULT_SUBADDRESS

constexpr uint8_t SegDriver_PCx85::DEFAULT_SUBADDRESS = 0x00
staticconstexprprotected

The documentation for this class was generated from the following files: