ReduxLib C++ 2026.1.2
Loading...
Searching...
No Matches
DigoutChain.h
1// Copyright (c) Bagholders of Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the Mozilla Public License v2.0.
3
4#pragma once
5#include <cstddef>
6#include <array>
7#include "DigoutSlot.h"
8
10
11/**
12 * Fixed-size container for a digital output logic chain.
13 *
14 * Chains are limited to 16 slots.
15 */
17 public:
18
19 /**
20 * Creates a new empty chain.
21 */
22 constexpr DigoutChain();
23
24 /**
25 * Adds a slot to the chain (up to 16).
26 * @param slot slot to add
27 * @return reference to this chain
28 */
29 DigoutChain& Add(const DigoutSlot& slot);
30
31 /**
32 * Gets a slot by index.
33 * @param index slot index
34 * @return the slot at index, or DigoutSlot::Disabled() if out of range
35 */
36 DigoutSlot GetSlot(size_t index);
37
38 /**
39 * Gets the number of slots currently stored in the chain.
40 * @return chain length
41 */
42 size_t GetLength();
43
44 private:
45 std::array<DigoutSlot, 16> slots{ DigoutSlot{} };
46 size_t length = 0;
47};
48
49} // namespace redux::sensors::canandcolor
Definition DigoutChain.h:16
DigoutChain & Add(const DigoutSlot &slot)
Definition DigoutSlot.h:19
Definition Canandcolor.h:19