implement AFServoMotor
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_PWMServoDriver.h>
|
||||
|
||||
// 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);
|
||||
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user