WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::ExpansionHub Class Reference

This class controls a REV ExpansionHub plugged in over USB to Systemcore. More...

#include <wpi/hardware/expansionhub/ExpansionHub.hpp>

Public Member Functions

 ExpansionHub (int usbId)
 Constructs a new ExpansionHub for a given USB ID.
 ~ExpansionHub () noexcept=default
ExpansionHubServo MakeServo (int channel)
 Constructs a servo at the requested channel on this hub.
ExpansionHubMotor MakeMotor (int channel)
 Constructs a motor at the requested channel on this hub.
bool IsHubConnected () const
 Gets if the hub is currently connected over USB.
int GetUsbId () const
 Gets the USB ID of this hub.

Static Public Attributes

static constexpr int NumUsbPorts = 4
static constexpr int NumServoPorts = 6
static constexpr int NumMotorPorts = 4

Friends

class ExpansionHubServo
class ExpansionHubMotor
class DataStore

Detailed Description

This class controls a REV ExpansionHub plugged in over USB to Systemcore.

Constructor & Destructor Documentation

◆ ExpansionHub()

wpi::ExpansionHub::ExpansionHub ( int usbId)
explicit

Constructs a new ExpansionHub for a given USB ID.

Multiple instances can be constructed, but will point to the same backing object with a ref count.

Parameters
usbIdThe USB Port ID the hub is plugged into.

◆ ~ExpansionHub()

wpi::ExpansionHub::~ExpansionHub ( )
defaultnoexcept

Member Function Documentation

◆ GetUsbId()

int wpi::ExpansionHub::GetUsbId ( ) const
inline

Gets the USB ID of this hub.

Returns
The USB ID

◆ IsHubConnected()

bool wpi::ExpansionHub::IsHubConnected ( ) const

Gets if the hub is currently connected over USB.

Returns
True if hub connection, otherwise false

◆ MakeMotor()

ExpansionHubMotor wpi::ExpansionHub::MakeMotor ( int channel)

Constructs a motor at the requested channel on this hub.

Only a single instance of each motor per hub can be constructed at a time.

Parameters
channelThe motor channel
Returns
Motor object

◆ MakeServo()

ExpansionHubServo wpi::ExpansionHub::MakeServo ( int channel)

Constructs a servo at the requested channel on this hub.

Only a single instance of each servo per hub can be constructed at a time.

Parameters
channelThe servo channel
Returns
Servo object

◆ DataStore

friend class DataStore
friend

◆ ExpansionHubMotor

friend class ExpansionHubMotor
friend

◆ ExpansionHubServo

friend class ExpansionHubServo
friend

Member Data Documentation

◆ NumMotorPorts

int wpi::ExpansionHub::NumMotorPorts = 4
staticconstexpr

◆ NumServoPorts

int wpi::ExpansionHub::NumServoPorts = 6
staticconstexpr

◆ NumUsbPorts

int wpi::ExpansionHub::NumUsbPorts = 4
staticconstexpr

The documentation for this class was generated from the following file: