This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
ShiftRegisterOutBase.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
6 #include <Helpers/BitArray.hpp>
7 
9 
21 template <uint8_t N>
23  protected:
36 
37  public:
42  void pinMode(UNUSED_PARAM pin_t pin, UNUSED_PARAM uint8_t mode) override
43  __attribute__((deprecated)) {}
44 
54  void digitalWrite(pin_t pin, uint8_t val) override;
55 
66  int digitalRead(pin_t pin) override;
67 
78  analog_t analogRead(pin_t pin) override __attribute__((deprecated)) {
79  return 1023 * digitalRead(pin);
80  }
81 
92  void analogWrite(pin_t pin, analog_t val) override
93  __attribute__((deprecated)) {
94  digitalWrite(pin, val >= 0x80);
95  }
96 
103  pin_t red(pin_t id);
104 
108  Array<pin_t, N / 3> redPins();
109 
116  pin_t green(pin_t id);
117 
121  Array<pin_t, N / 3> greenPins();
122 
129  pin_t blue(pin_t id);
130 
134  Array<pin_t, N / 3> bluePins();
135 
136  protected:
138  const uint8_t bitOrder;
139 
141  bool dirty = true;
142 };
143 
145 
146 #include "ShiftRegisterOutBase.ipp"
ShiftRegisterOutBase::bitOrder
const uint8_t bitOrder
Definition: ShiftRegisterOutBase.hpp:138
pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition: Def.hpp:17
StaticSizeExtendedIOElement
A class for ExtendedIOElements with a fixed size.
Definition: StaticSizeExtendedIOElement.hpp:16
BitArray.hpp
Array
An array wrapper for easy copying, comparing, and iterating.
Definition: Array.hpp:20
ShiftRegisterOutBase::pinMode
void pinMode(UNUSED_PARAM pin_t pin, UNUSED_PARAM uint8_t mode) override __attribute__((deprecated))
The pinMode function is not implemented because the mode is OUTPUT by definition.
Definition: ShiftRegisterOutBase.hpp:42
ShiftRegisterOutBase::bluePins
Array< pin_t, N/3 > bluePins()
Get an array containing all pins with blue LEDs.
Definition: ShiftRegisterOutBase.ipp:51
UNUSED_PARAM
#define UNUSED_PARAM
Definition: Def.hpp:79
ShiftRegisterOutBase
A class for serial-in/parallel-out shift registers, like the 74HC595.
Definition: ShiftRegisterOutBase.hpp:22
ShiftRegisterOutBase::latchPin
const pin_t latchPin
Definition: ShiftRegisterOutBase.hpp:137
ShiftRegisterOutBase::blue
pin_t blue(pin_t id)
Get the blue output pin of the given LED.
Definition: ShiftRegisterOutBase.ipp:46
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
ShiftRegisterOutBase::dirty
bool dirty
Definition: ShiftRegisterOutBase.hpp:141
analog_t
uint16_t analog_t
The type returned from analogRead and similar functions.
Definition: Def.hpp:15
ShiftRegisterOutBase.ipp
ShiftRegisterOutBase::greenPins
Array< pin_t, N/3 > greenPins()
Get an array containing all pins with green LEDs.
Definition: ShiftRegisterOutBase.ipp:29
ExtendedIOElement::pin
pin_t pin(pin_t pin) const
Get the extended IO pin number of a given physical pin of this extended IO element.
Definition: ExtendedIOElement.cpp:26
ShiftRegisterOutBase::buffer
BitArray< N > buffer
Definition: ShiftRegisterOutBase.hpp:140
StaticSizeExtendedIOElement.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
ShiftRegisterOutBase::digitalRead
int digitalRead(pin_t pin) override
Get the current state of a given output pin.
Definition: ShiftRegisterOutBase.ipp:19
ShiftRegisterOutBase::analogRead
analog_t analogRead(pin_t pin) override __attribute__((deprecated))
The analogRead function is deprecated because a shift is always digital.
Definition: ShiftRegisterOutBase.hpp:78
ShiftRegisterOutBase::analogWrite
void analogWrite(pin_t pin, analog_t val) override __attribute__((deprecated))
The analogWrite function is not deprecated because a shift is always digital.
Definition: ShiftRegisterOutBase.hpp:92
ShiftRegisterOutBase::green
pin_t green(pin_t id)
Get the green output pin of the given LED.
Definition: ShiftRegisterOutBase.ipp:24
ShiftRegisterOutBase::digitalWrite
void digitalWrite(pin_t pin, uint8_t val) override
Set the state of a given output pin.
Definition: ShiftRegisterOutBase.ipp:12
ShiftRegisterOutBase::redPins
Array< pin_t, N/3 > redPins()
Get an array containing all pins with red LEDs.
Definition: ShiftRegisterOutBase.ipp:40
ShiftRegisterOutBase::red
pin_t red(pin_t id)
Get the red output pin of the given LED.
Definition: ShiftRegisterOutBase.ipp:35
BitArray
A class for arrays of bits.
Definition: BitArray.hpp:18
ShiftRegisterOutBase::ShiftRegisterOutBase
ShiftRegisterOutBase(pin_t latchPin, uint8_t bitOrder)
Create a new ShiftRegisterOutBase object with a given bit order, and a given number of outputs.
Definition: ShiftRegisterOutBase.ipp:8