A class for serial-in/parallel-out shift registers, like the 74HC595.
More...
#include <ShiftRegisterOut.hpp>
|
| | ShiftRegisterOut (pin_t dataPin, pin_t clockPin, pin_t latchPin, BitOrder_t bitOrder=MSBFIRST) |
| | Create a new ShiftRegisterOut object with a shift register connected to the given pins, with a given bit order, and a given number of outputs. More...
|
| |
| void | begin () override |
| | Initialize the shift register. More...
|
| |
| void | update () override |
| | Write the state buffer to the physical outputs. More...
|
| |
| 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...
|
| |
| 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...
|
| |
template<uint8_t N>
class AH::ShiftRegisterOut< N >
A class for serial-in/parallel-out shift registers, like the 74HC595.
Definition at line 23 of file ShiftRegisterOut.hpp.
◆ BitOrder_t
◆ ShiftRegisterOut()
Create a new ShiftRegisterOut object with a shift register connected to the given pins, with a given bit order, and a given number of outputs.
Multiple shift registers can be cascaded by connecting the serial output of the first one to the input of the second one:
clockPin >───────────┬──────────────────────┬───────── ⋯
┏━━━━━━━┷━━━━━━━┓ ┏━━━━━━━┷━━━━━━━┓
┃ SH_CP ┃ ┃ SH_CP ┃
dataPin >───┨ DS Q7S ┠──────┨ DS Q7S ┠─ ⋯
┃ ST_CP ┃ ┃ ST_CP ┃
┗━━━━━━━┯━━━━━━━┛ ┗━━━━━━━┯━━━━━━━┛
latchPin >───────────┴──────────────────────┴───────── ⋯
- Parameters
-
| dataPin | The digital output pin connected to the serial data input (DS or SER) of the shift register. |
| clockPin | The digital output pin connected to the clock input (SH_CP or SRCLK) of the shift register. |
| 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 7 of file ShiftRegisterOut.ipp.
◆ begin()
◆ update()
◆ pinMode()
template<uint8_t N>
|
|
inlineoverridevirtualinherited |
◆ digitalWrite()
◆ digitalRead()
Get the current state of a given output pin.
- Parameters
-
| pin | The shift register pin to read from. |
- Return values
-
| 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.
◆ analogRead()
template<uint8_t N>
|
|
inlineoverridevirtualinherited |
The analogRead function is deprecated because a shift is always digital.
- Parameters
-
| pin | The shift register pin to read from. |
- Return values
-
| 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.
◆ analogWrite()
template<uint8_t N>
|
|
inlineoverridevirtualinherited |
The analogWrite function is not deprecated because a shift is always digital.
- Parameters
-
| 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.
◆ red()
Get the red output pin of the given LED.
- Parameters
-
| id | The zero-based LED number. |
Definition at line 36 of file ShiftRegisterOutBase.ipp.
◆ redPins()
◆ green()
Get the green output pin of the given LED.
- Parameters
-
| id | The zero-based LED number. |
Definition at line 25 of file ShiftRegisterOutBase.ipp.
◆ greenPins()
◆ blue()
Get the blue output pin of the given LED.
- Parameters
-
| id | The zero-based LED number. |
Definition at line 47 of file ShiftRegisterOutBase.ipp.
◆ bluePins()
◆ pins()
◆ length()
template<uint16_t N>
|
|
inlinestaticconstexprinherited |
◆ beginAll()
| void AH::ExtendedIOElement::beginAll |
( |
| ) |
|
|
staticinherited |
◆ pin()
| pin_t AH::ExtendedIOElement::pin |
( |
pin_t |
pin | ) |
const |
|
inherited |
Get the extended IO pin number of a given physical pin of this extended IO element.
- Parameters
-
| pin | The zero-based physical pin number of this IO element. |
- Returns
- The global, unique extended IO pin number for the given pin.
Definition at line 28 of file ExtendedIOElement.cpp.
◆ operator[]()
| pin_t AH::ExtendedIOElement::operator[] |
( |
pin_t |
pin | ) |
const |
|
inherited |
Get the extended IO pin number of a given physical pin of this extended IO element.
It is alias for ExtendedIOElement::pin.
- Parameters
-
| pin | The zero-based physical pin number of this IO element. |
- Returns
- The global, unique extended IO pin number for the given pin.
Definition at line 43 of file ExtendedIOElement.cpp.
◆ getLength()
| pin_t AH::ExtendedIOElement::getLength |
( |
| ) |
const |
|
inherited |
Get the number of pins this IO element has.
- Returns
- The number of pins this IO element has.
Definition at line 45 of file ExtendedIOElement.cpp.
◆ getEnd()
| pin_t AH::ExtendedIOElement::getEnd |
( |
| ) |
const |
|
inherited |
Get the largest global extended IO pin number that belongs to this extended IO element.
Definition at line 47 of file ExtendedIOElement.cpp.
◆ getStart()
| pin_t AH::ExtendedIOElement::getStart |
( |
| ) |
const |
|
inherited |
Get the smallest global extended IO pin number that belongs to this extended IO element.
Definition at line 49 of file ExtendedIOElement.cpp.
◆ getAll()
◆ dataPin
◆ clockPin
◆ latchPin
◆ bitOrder
◆ buffer
◆ dirty
◆ start
| const pin_t AH::ExtendedIOElement::start |
|
privateinherited |
◆ end
| const pin_t AH::ExtendedIOElement::end |
|
privateinherited |
◆ offset
| pin_t AH::ExtendedIOElement::offset = NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS |
|
staticprivateinherited |
◆ elements
◆ next
◆ previous
The documentation for this class was generated from the following files: