A class for serial-in/parallel-out shift registers, like the 74HC595. More...
#include <ShiftRegisterOutBase.hpp>
Public Types | |
using | BitOrder_t = uint8_t |
Public Member Functions | |
void | pinMode (pin_t pin, uint8_t mode) override __attribute__((deprecated)) |
The pinMode function is not implemented because the mode is OUTPUT by definition. More... | |
void | digitalWrite (pin_t pin, uint8_t val) override |
Set the state of a given output pin. More... | |
int | digitalRead (pin_t pin) override |
Get the current state of a given output pin. More... | |
analog_t | analogRead (pin_t pin) override __attribute__((deprecated)) |
The analogRead function is deprecated because a shift is always digital. More... | |
void | analogWrite (pin_t pin, analog_t val) override __attribute__((deprecated)) |
The analogWrite function is not deprecated because a shift is always digital. More... | |
pin_t | red (pin_t id) |
Get the red output pin of the given LED. More... | |
Array< pin_t, N/3 > | redPins () |
Get an array containing all pins with red LEDs. More... | |
pin_t | green (pin_t id) |
Get the green output pin of the given LED. More... | |
Array< pin_t, N/3 > | greenPins () |
Get an array containing all pins with green LEDs. More... | |
pin_t | blue (pin_t id) |
Get the blue output pin of the given LED. More... | |
Array< pin_t, N/3 > | bluePins () |
Get an array containing all pins with blue LEDs. More... | |
Array< pin_t, N > | pins () const |
Get an array containing all pins of the element. More... | |
virtual void | begin ()=0 |
Initialize the extended IO element. More... | |
virtual void | update ()=0 |
Update the extended IO element: write the internal state to the physical outputs, or read the physical state into the input buffers. More... | |
pin_t | pin (pin_t pin) const |
Get the extended IO pin number of a given physical pin of this extended IO element. More... | |
pin_t | operator[] (pin_t pin) const |
Get the extended IO pin number of a given physical pin of this extended IO element. More... | |
pin_t | getLength () const |
Get the number of pins this IO element has. More... | |
pin_t | getEnd () const |
Get the largest global extended IO pin number that belongs to this extended IO element. More... | |
pin_t | getStart () const |
Get the smallest global extended IO pin number that belongs to this extended IO element. More... | |
Static Public Member Functions | |
static constexpr uint16_t | length () |
static void | beginAll () |
Initialize all extended IO elements. More... | |
static DoublyLinkedList< ExtendedIOElement > & | getAll () |
Get the list of all Extended IO elements. More... | |
Protected Member Functions | |
ShiftRegisterOutBase (pin_t latchPin, BitOrder_t bitOrder) | |
Create a new ShiftRegisterOutBase object with a given bit order, and a given number of outputs. More... | |
Protected Attributes | |
const pin_t | latchPin |
const BitOrder_t | bitOrder |
BitArray< N > | buffer |
bool | dirty = true |
ExtendedIOElement * | next |
ExtendedIOElement * | previous |
Private Attributes | |
const pin_t | start |
const pin_t | end |
Static Private Attributes | |
static pin_t | offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS |
static DoublyLinkedList< ExtendedIOElement > | elements |
A class for serial-in/parallel-out shift registers, like the 74HC595.
N | The number of bits in total. Usually, shift registers (e.g. the 74HC595) have eight bits per chip, so length = 8 * k where k is the number of cascaded chips. |
Definition at line 25 of file ShiftRegisterOutBase.hpp.
using AH::ShiftRegisterOutBase< N >::BitOrder_t = uint8_t |
Definition at line 30 of file ShiftRegisterOutBase.hpp.
|
protected |
Create a new ShiftRegisterOutBase object with a given bit order, and a given number of outputs.
latchPin | The digital output pin connected to the latch pin (ST_CP or RCLK) of the shift register. |
bitOrder | Either MSBFIRST (most significant bit first) or LSBFIRST (least significant bit first). |
Definition at line 8 of file ShiftRegisterOutBase.ipp.
|
inlineoverridevirtual |
The pinMode function is not implemented because the mode is OUTPUT
by definition.
Implements AH::ExtendedIOElement.
Definition at line 52 of file ShiftRegisterOutBase.hpp.
|
overridevirtual |
Set the state of a given output pin.
pin | The shift register pin to set. |
val | The value to set the pin to. (Either HIGH (1) or LOW (0)) |
Implements AH::ExtendedIOElement.
Definition at line 13 of file ShiftRegisterOutBase.ipp.
|
overridevirtual |
Get the current state of a given output pin.
pin | The shift register pin to read from. |
0 | The state of the pin is LOW . |
1 | The state of the pin is HIGH . |
Implements AH::ExtendedIOElement.
Definition at line 20 of file ShiftRegisterOutBase.ipp.
|
inlineoverridevirtual |
The analogRead function is deprecated because a shift is always digital.
pin | The shift register pin to read from. |
0 | The state of the pin is LOW . |
1023 | The state of the pin is HIGH . |
Implements AH::ExtendedIOElement.
Definition at line 90 of file ShiftRegisterOutBase.hpp.
|
inlineoverridevirtual |
The analogWrite function is not deprecated because a shift is always digital.
pin | The shift register pin to set. |
val | The value to set the pin to. A value greater or equal to 0x80 will set the pin to a HIGH state, a value less than 0x80 will set the pin to a LOW state. |
Implements AH::ExtendedIOElement.
Definition at line 104 of file ShiftRegisterOutBase.hpp.
pin_t AH::ShiftRegisterOutBase< N >::red | ( | pin_t | id | ) |
Get the red output pin of the given LED.
id | The zero-based LED number. |
Definition at line 36 of file ShiftRegisterOutBase.ipp.
Array< pin_t, N/3 > AH::ShiftRegisterOutBase< N >::redPins | ( | ) |
Get an array containing all pins with red LEDs.
Definition at line 41 of file ShiftRegisterOutBase.ipp.
pin_t AH::ShiftRegisterOutBase< N >::green | ( | pin_t | id | ) |
Get the green output pin of the given LED.
id | The zero-based LED number. |
Definition at line 25 of file ShiftRegisterOutBase.ipp.
Array< pin_t, N/3 > AH::ShiftRegisterOutBase< N >::greenPins | ( | ) |
Get an array containing all pins with green LEDs.
Definition at line 30 of file ShiftRegisterOutBase.ipp.
pin_t AH::ShiftRegisterOutBase< N >::blue | ( | pin_t | id | ) |
Get the blue output pin of the given LED.
id | The zero-based LED number. |
Definition at line 47 of file ShiftRegisterOutBase.ipp.
Array< pin_t, N/3 > AH::ShiftRegisterOutBase< N >::bluePins | ( | ) |
Get an array containing all pins with blue LEDs.
Definition at line 52 of file ShiftRegisterOutBase.ipp.
|
inlineinherited |
Get an array containing all pins of the element.
Definition at line 27 of file StaticSizeExtendedIOElement.hpp.
|
inlinestaticconstexprinherited |
Definition at line 31 of file StaticSizeExtendedIOElement.hpp.
|
pure virtualinherited |
Initialize the extended IO element.
Implemented in AH::AnalogMultiplex< N >, AH::ShiftRegisterOut< N >, AH::SPIShiftRegisterOut< N >, and AH::MAX7219.
|
staticinherited |
Initialize all extended IO elements.
Definition at line 23 of file ExtendedIOElement.cpp.
|
pure virtualinherited |
Update the extended IO element: write the internal state to the physical outputs, or read the physical state into the input buffers.
Implemented in AH::MAX7219, AH::AnalogMultiplex< N >, AH::ShiftRegisterOut< N >, and AH::SPIShiftRegisterOut< N >.
Get the extended IO pin number of a given physical pin of this extended IO element.
pin | The zero-based physical pin number of this IO element. |
Definition at line 28 of file ExtendedIOElement.cpp.
Get the extended IO pin number of a given physical pin of this extended IO element.
It is alias for ExtendedIOElement::pin
.
pin | The zero-based physical pin number of this IO element. |
Definition at line 43 of file ExtendedIOElement.cpp.
|
inherited |
Get the number of pins this IO element has.
Definition at line 45 of file ExtendedIOElement.cpp.
|
inherited |
Get the largest global extended IO pin number that belongs to this extended IO element.
Definition at line 47 of file ExtendedIOElement.cpp.
|
inherited |
Get the smallest global extended IO pin number that belongs to this extended IO element.
Definition at line 49 of file ExtendedIOElement.cpp.
|
staticinherited |
Get the list of all Extended IO elements.
Definition at line 51 of file ExtendedIOElement.cpp.
|
protected |
Definition at line 149 of file ShiftRegisterOutBase.hpp.
|
protected |
Definition at line 150 of file ShiftRegisterOutBase.hpp.
|
protected |
Definition at line 152 of file ShiftRegisterOutBase.hpp.
|
protected |
Definition at line 153 of file ShiftRegisterOutBase.hpp.
|
privateinherited |
Definition at line 193 of file ExtendedIOElement.hpp.
|
privateinherited |
Definition at line 194 of file ExtendedIOElement.hpp.
|
staticprivateinherited |
Definition at line 195 of file ExtendedIOElement.hpp.
|
staticprivateinherited |
Definition at line 197 of file ExtendedIOElement.hpp.
|
protectedinherited |
Definition at line 305 of file LinkedList.hpp.
|
protectedinherited |
Definition at line 306 of file LinkedList.hpp.