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

4+6 digit dual LCD with maintenance/battery/signal (PCF8576). More...

#include <SegLCD_PCF8576_4Seg6SegMaintSegBatUnits.h>

Inheritance diagram for SegLCD_PCF8576_4Seg6SegMaintSegBatUnits:
SegDriver_PCF8576 SegDriver_PCF85176 SegDriver_PCx85 SegLCDLib

Public Types

enum  UnitFlags : uint16_t {
  UNIT_MPA = 0x01 , UNIT_KPA = 0x02 , UNIT_UEPS = 0x04 , UNIT_MM = 0x08 ,
  UNIT_MV = 0x10 , UNIT_NM = 0x20 , UNIT_KG = 0x40 , UNIT_G = 0x80 ,
  UNIT_DEGREE = 0x0100 , UNIT_ALL = 0x01FF
}
 
- Public Types inherited from SegDriver_PCx85
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

 SegLCD_PCF8576_4Seg6SegMaintSegBatUnits (SegTransportI2C &transport, uint8_t address=DEFAULT_PCX85_I2C_ADDRESS, uint8_t subaddress=DEFAULT_SUBADDRESS)
 
void init () override
 Logical display sections that can be targeted by higher-level rendering logic.
 
void clear () override
 Clear all visible segments on the display.
 
void setBatteryLevel (uint8_t value)
 
void setSignalLevel (uint8_t value)
 
void setUnits (uint16_t units)
 
void clearUnits (uint16_t units)
 
void setDegreeSymbol (bool state, uint8_t index=0)
 
void setMaintenanceSymbol (bool state, uint8_t index=0)
 
void setCursor (uint8_t row, uint8_t col) override
 Set cursor on exact digit.
 
size_t write (uint8_t ch) override
 
virtual size_t write (uint8_t)
 
size_t write (const char *str)
 Write a null-terminated string to the display.
 
size_t write (const char *buffer, size_t size)
 Write a buffer of characters to the display.
 
- Public Member Functions inherited from SegDriver_PCF8576
 SegDriver_PCF85176 (SegTransportI2C &transport, uint8_t address=DEFAULT_PCX85_I2C_ADDRESS, uint8_t subaddress=DEFAULT_SUBADDRESS)
 Constructor for PCF85176 segment driver.
 
- Public Member Functions inherited from SegDriver_PCF85176
 SegDriver_PCF85176 (SegTransportI2C &transport, uint8_t address=DEFAULT_PCX85_I2C_ADDRESS, uint8_t subaddress=DEFAULT_SUBADDRESS)
 Constructor for PCF85176 segment driver.
 
- Public Member Functions inherited from SegDriver_PCx85
 SegDriver_PCx85 (SegTransportI2C &transport, uint8_t address, uint8_t subaddress)
 Constructor for PCx85 segment driver.
 
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 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
 SegLCDLib ()=default
 Default constructor.
 
virtual ~SegLCDLib ()
 Virtual destructor to ensure proper cleanup in derived classes.
 
 SegLCDLib (const SegLCDLib &)=delete
 Disable copying to keep the RAM buffer uniquely owned.
 
SegLCDLiboperator= (const SegLCDLib &)=delete
 
void home ()
 Set cursor to 0, 0 without clear display.
 
size_t write (const char *str)
 Write a null-terminated string to the display.
 
size_t write (const char *buffer, size_t size)
 Write a buffer of characters to the display.
 
void initBacklight (SegBacklight *backlight, BacklightMode backlightMode=BACKLIGHT_DIGITAL)
 Initialize 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 _setColon (uint8_t row, uint8_t col, bool state) override
 Virtual method for setting colon.
 
void _setDecimal (uint8_t row, uint8_t col, bool state) override
 Virtual method for setting decimal point.
 
- Protected Member Functions inherited from SegDriver_PCF85176
void _sendCommand (uint8_t command, bool last=true) override
 
void _writeRam (uint8_t *data, size_t length, uint8_t address=0) override
 Low-level method to write a data buffer to display RAM.
 
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.
 
- Protected Member Functions inherited from SegDriver_PCx85
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)
 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.
 
- 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.
 
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.
 
void _writeRam (uint8_t data, uint8_t address=0)
 Low-level method to write a single byte 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.
 

Private Member Functions

uint8_t _mapSegmentsTop (uint8_t val)
 
uint8_t _mapSegments (uint8_t val)
 
uint8_t _convertUnitFlags (uint16_t units)
 
size_t _writeRow0 (uint8_t ch)
 
size_t _writeRow1 (uint8_t ch)
 

Private Attributes

uint8_t _buffer_default [6] = {0}
 

Static Private Attributes

static constexpr uint8_t ADDR_SIGNAL = 0x0A
 
static constexpr uint8_t ADDR_BATT = 0x08
 
static constexpr uint8_t ADDR_SMALL_SEGS = 0x00
 
static constexpr uint8_t ADDR_LABELS = 0x11
 
static constexpr uint8_t ADDR_BIG_SEGS = 0x0B
 
static constexpr uint8_t RAM_ADDR_LAST = 0x18
 
static constexpr uint8_t RAM_BYTE_COUNT = (RAM_ADDR_LAST + 2) / 2
 
static constexpr uint8_t FLAG_COLON_TOP = 0x01
 
static constexpr uint8_t FLAG_COLON_DEFAULT_LEFT = 0x02
 
static constexpr uint8_t FLAG_COLON_DEFAULT_RIGHT = 0x04
 
static constexpr int8_t DECIMAL_COL_OFFSET = -1
 
static constexpr uint8_t DECIMAL_TOP_MIN_COL = 0
 
static constexpr uint8_t DECIMAL_TOP_MAX_COL = 2
 
static constexpr uint8_t DECIMAL_BOTTOM_MIN_COL = 0
 
static constexpr uint8_t DECIMAL_BOTTOM_MAX_COL = 4
 
static constexpr uint8_t COLON_TOP_COL = 2
 
static constexpr uint8_t COLON_BOTTOM_LEFT_COL = 2
 
static constexpr uint8_t COLON_BOTTOM_RIGHT_COL = 4
 

Additional Inherited Members

- Protected Attributes inherited from SegDriver_PCx85
SegTransportI2C_transport
 
uint8_t _address
 
uint8_t _subaddress
 
ModeDrive _drive
 
ModeBias _bias
 
- Protected Attributes inherited from SegLCDLib
bool _autoFlush = true
 Autoflush mode enabled flag (default: true for LCD API 1.0 compatibility).
 
SegBacklight_backlight = nullptr
 Backlight implementation (nullptr if disabled)
 
BacklightMode _backlightMode = BACKLIGHT_DIGITAL
 Backlight mode (DIGITAL or PWM)
 
uint8_t _backlightBrightness = 0
 Cached backlight brightness.
 
uint8_t _displayFlags = 0
 Generic flag storage for display-specific state tracking.
 
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 inherited from SegDriver_PCF85176
static constexpr uint8_t MAX_ADDRESS = 39
 
static constexpr uint8_t CMD_LAST_COMMAND = 0x80
 
- Static Protected Attributes inherited from SegDriver_PCx85
static constexpr uint8_t CMD_MODE = 0x40
 
static constexpr uint8_t CMD_DEVICE_SELECT = 0x60
 
static constexpr uint8_t CMD_BLINK = 0x70
 
static constexpr uint8_t CMD_BANK_SELECT = 0x78
 
static constexpr uint8_t DEFAULT_PCX85_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.
 

Detailed Description

4+6 digit dual LCD with maintenance/battery/signal (PCF8576).

Features: maintenance indicator, battery level, signal strength, unit labels. I2C interface (SA0 pin sets address, A0-A2 are subaddresses).

See also
examples/PCF8576/4Seg6SegMaintSegBatUnits/4Seg6SegMaintSegBatUnits.ino

Member Enumeration Documentation

◆ UnitFlags

Enumerator
UNIT_MPA 
UNIT_KPA 
UNIT_UEPS 
UNIT_MM 
UNIT_MV 
UNIT_NM 
UNIT_KG 
UNIT_G 
UNIT_DEGREE 
UNIT_ALL 

Constructor & Destructor Documentation

◆ SegLCD_PCF8576_4Seg6SegMaintSegBatUnits()

SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::SegLCD_PCF8576_4Seg6SegMaintSegBatUnits ( SegTransportI2C transport,
uint8_t  address = DEFAULT_PCX85_I2C_ADDRESS,
uint8_t  subaddress = DEFAULT_SUBADDRESS 
)

Member Function Documentation

◆ _convertUnitFlags()

uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_convertUnitFlags ( uint16_t  units)
private

◆ _mapSegments()

uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_mapSegments ( uint8_t  val)
private

◆ _mapSegmentsTop()

uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_mapSegmentsTop ( uint8_t  val)
private

◆ _setColon()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_setColon ( uint8_t  ,
uint8_t  ,
bool   
)
overrideprotectedvirtual

Virtual method for setting colon.

Default implementation is empty (no-op).

Reimplemented from SegLCDLib.

◆ _setDecimal()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_setDecimal ( uint8_t  ,
uint8_t  ,
bool   
)
overrideprotectedvirtual

Virtual method for setting decimal point.

Each LCD has its own implementation with HW specifics. Default implementation is empty (no-op).

Reimplemented from SegLCDLib.

◆ _writeRow0()

size_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_writeRow0 ( uint8_t  ch)
private

◆ _writeRow1()

size_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_writeRow1 ( uint8_t  ch)
private

◆ clear()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::clear ( )
overridevirtual

Clear all visible segments on the display.

Reimplemented from SegLCDLib.

◆ clearUnits()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::clearUnits ( uint16_t  units)

◆ init()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::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.

Reimplemented from SegDriver_PCx85.

◆ setBatteryLevel()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::setBatteryLevel ( uint8_t  value)

◆ setCursor()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::setCursor ( uint8_t  row,
uint8_t  col 
)
overridevirtual

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

Parameters
rowRow, where 0-MAXROWS
colColumn 0-MAXDIGITS in current row

Reimplemented from SegLCDLib.

◆ setDegreeSymbol()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::setDegreeSymbol ( bool  state,
uint8_t  index = 0 
)

◆ setMaintenanceSymbol()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::setMaintenanceSymbol ( bool  state,
uint8_t  index = 0 
)

◆ setSignalLevel()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::setSignalLevel ( uint8_t  value)

◆ setUnits()

void SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::setUnits ( uint16_t  units)

◆ write() [1/4]

size_t SegLCDLib::write ( const char *  buffer,
size_t  size 
)

Write a buffer of characters to the display.

Parameters
bufferCharacter buffer (not required to be null-terminated)
sizeNumber of characters to write
Returns
Number of characters written

◆ write() [2/4]

size_t SegLCDLib::write ( const char *  str)

Write a null-terminated string to the display.

Available identically under Arduino and non-Arduino frameworks (ESP-IDF, RP2040 SDK, STM32...). Internally forwards each character to write(uint8_t).

Parameters
strNull-terminated C-string
Returns
Number of characters written

◆ write() [3/4]

size_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::write ( uint8_t  ch)
overridevirtual

Reimplemented from SegLCDLib.

◆ write() [4/4]

virtual size_t SegLCDLib::write ( uint8_t  )
inlinevirtual

Reimplemented from SegLCDLib.

Field Documentation

◆ _buffer_default

uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::_buffer_default[6] = {0}
private

◆ ADDR_BATT

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::ADDR_BATT = 0x08
staticconstexprprivate

◆ ADDR_BIG_SEGS

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::ADDR_BIG_SEGS = 0x0B
staticconstexprprivate

◆ ADDR_LABELS

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::ADDR_LABELS = 0x11
staticconstexprprivate

◆ ADDR_SIGNAL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::ADDR_SIGNAL = 0x0A
staticconstexprprivate

◆ ADDR_SMALL_SEGS

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::ADDR_SMALL_SEGS = 0x00
staticconstexprprivate

◆ COLON_BOTTOM_LEFT_COL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::COLON_BOTTOM_LEFT_COL = 2
staticconstexprprivate

◆ COLON_BOTTOM_RIGHT_COL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::COLON_BOTTOM_RIGHT_COL = 4
staticconstexprprivate

◆ COLON_TOP_COL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::COLON_TOP_COL = 2
staticconstexprprivate

◆ DECIMAL_BOTTOM_MAX_COL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::DECIMAL_BOTTOM_MAX_COL = 4
staticconstexprprivate

◆ DECIMAL_BOTTOM_MIN_COL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::DECIMAL_BOTTOM_MIN_COL = 0
staticconstexprprivate

◆ DECIMAL_COL_OFFSET

constexpr int8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::DECIMAL_COL_OFFSET = -1
staticconstexprprivate

◆ DECIMAL_TOP_MAX_COL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::DECIMAL_TOP_MAX_COL = 2
staticconstexprprivate

◆ DECIMAL_TOP_MIN_COL

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::DECIMAL_TOP_MIN_COL = 0
staticconstexprprivate

◆ FLAG_COLON_DEFAULT_LEFT

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::FLAG_COLON_DEFAULT_LEFT = 0x02
staticconstexprprivate

◆ FLAG_COLON_DEFAULT_RIGHT

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::FLAG_COLON_DEFAULT_RIGHT = 0x04
staticconstexprprivate

◆ FLAG_COLON_TOP

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::FLAG_COLON_TOP = 0x01
staticconstexprprivate

◆ RAM_ADDR_LAST

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::RAM_ADDR_LAST = 0x18
staticconstexprprivate

◆ RAM_BYTE_COUNT

constexpr uint8_t SegLCD_PCF8576_4Seg6SegMaintSegBatUnits::RAM_BYTE_COUNT = (RAM_ADDR_LAST + 2) / 2
staticconstexprprivate

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