40 template <
typename GPIOtype>
41 void reserve(
const std::vector<GPIOtype> &collection)
43 for (
auto item : collection)
57 for (ButtonMatrix::const_iterator row = matrix.begin(); row != matrix.end(); row++)
61 for (std::map<InputGPIO, InputNumber>::const_iterator col = row->second.begin(); col != row->second.end(); col++)
82 template <
typename PinTags>
87 for (
auto chip : chips)
88 chip.reserve_and_book();
111 for (
auto chip : chain)
113 for (ShiftRegisterChip::const_iterator i = chip.begin(); i != chip.end(); i++)
126 template <
typename PinTags>
130 for (
auto i = chip.begin(); i != chip.end(); i++)
154 throw std::runtime_error(
"Useless rotary encoder: no input number for clockwise rotation");
156 throw std::runtime_error(
"Useless rotary encoder: no input number for counter-clockwise rotation");
158 throw std::runtime_error(
"Useless rotary encoder: same input numbers for clockwise and counter-clockwise");
183 uint8_t pinCount =
inputs.size();
184 if ((pinCount < 2) || (pinCount > 8))
185 throw std::runtime_error(
"Wrong count of input pins in a coded rotary switch");
187 uint8_t maxIndex = (1 << pinCount);
188 for (RotaryCodedSwitch::const_iterator i = spec.begin(); i != spec.end(); i++)
190 if (i->first >= maxIndex)
191 throw std::runtime_error(
192 "Invalid position ()" +
193 std::to_string(i->first) +
194 ") in a coded rotary switch. Valid range is [0," +
195 std::to_string(maxIndex) +
bool addIfNotExists(T item, std::vector< T > &vector)
Add an item to a collection without duplicates.
@ VALUE
Unspecified value.
std::vector< InputGPIO > InputGPIOCollection
Collection of input GPIOs.
std::vector< OutputGPIO > OutputGPIOCollection
Collection of output GPIOs.
void reserve() const
Reserve this GPIO for exclusive use.
Output-capable GPIO pin number.