avr-classes
Public Member Functions | Protected Attributes | List of all members
OutputShiftRegisterPort Class Reference

#include <outputshiftregisterport.h>

Inheritance diagram for OutputShiftRegisterPort:
OutputPort OutputShiftRegisterPortWithLatch

Public Member Functions

 OutputShiftRegisterPort (OutputShiftRegister *shiftRegister, bool autoFlush=true)
 
bool getAutoFlush (void) const
 
void setAutoFlush (bool state)
 
virtual void setValue (uint8_t value, uint8_t mask=0xff) override
 
void flush (void)
 

Protected Attributes

OutputShiftRegister *const m_shiftRegister
 

Detailed Description

Class that implements an OutputPort using a shift register. It uses the OutputShiftRegister interface that defines only a data and clock line, thus there will be always 8 bits transported (instead of clearing the register and making use of leading zeros). You can define OutputPortPin instances on top of the OutputPort which will work just like regular OutputPins, just a bit slower. When having the property autoFlush set, each write access to the OutputShiftRegisterPort will directly be transferred to the associated device. If autoFlush is not set, multiple write actions can be accumulated before transferring them to the device explicitly using the flush() method.

Constructor & Destructor Documentation

◆ OutputShiftRegisterPort()

OutputShiftRegisterPort::OutputShiftRegisterPort ( OutputShiftRegister shiftRegister,
bool  autoFlush = true 
)
inline

Constructor.

Parameters
shiftRegisterPointer to OutputShiftRegister instance to be used as output device.
autoFlushValue of autoFlush property, defaulting to true.

Member Function Documentation

◆ flush()

void OutputShiftRegisterPort::flush ( void  )
inline

Excplicitly transferrs internal value to the associated device.

◆ getAutoFlush()

bool OutputShiftRegisterPort::getAutoFlush ( void  ) const
inline

Getter for current value of autoFlush property.

Returns
Current value of autoFlush property.

◆ setAutoFlush()

void OutputShiftRegisterPort::setAutoFlush ( bool  state)
inline

Setter for value of autoFlush property.

Parameters
stateNew value for autoFlush property, true means that autoFlush is active.

◆ setValue()

virtual void OutputShiftRegisterPort::setValue ( uint8_t  value,
uint8_t  mask = 0xff 
)
inlineoverridevirtual

Setter for 8 bit OutputPort value. Depending on the state of the autoFlush property this directly triggers a writing operation to the associated device (autoFlush = true), or updates the internal value only (autoFlush = false). When autoFlush is inactive, the value must be transferred explicitly using flush().

Parameters
valueValue to be set.
maskMask with pins to manipulate according to value.

Implements OutputPort.

Member Data Documentation

◆ m_shiftRegister

OutputShiftRegister* const OutputShiftRegisterPort::m_shiftRegister
protected

Pointer to OutputShiftRegister instance to be used as output device.