#pragma once #include #include // Wrapper class to prevent duplicate motor port assignments // This board can drive up to 16 motors class AdafruitPWMBoard { public: AdafruitPWMBoard(const uint8_t addr, const uint8_t pwmFreq); AdafruitPWMBoard(const AdafruitPWMBoard& other) = delete; AdafruitPWMBoard(AdafruitPWMBoard&&) noexcept = default; Adafruit_PWMServoDriver& get() noexcept { return hwif; }; const Adafruit_PWMServoDriver& get() const noexcept { return hwif; }; bool isGood() const noexcept { return good; } bool isMotorSlotOccupied(const uint8_t motorIndex) const noexcept; // Returns false if the slot is already occupied or index is out of range bool occupyMotorSlot(const uint8_t motorIndex) noexcept; // Returns false if the slot is already free or index is out of range bool releaseMotorSlot(const uint8_t motorIndex) noexcept; private: // No release needed, hardware interface does not expose any method for release Adafruit_PWMServoDriver hwif; bool good; uint16_t occupiedMotorSlots = 0; };