LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::Controller Class Reference

#include <controller.hpp>

Public Member Functions

 Controller (ControllerId iid=ControllerId::master)
 
virtual ~Controller ()
 
virtual bool isConnected ()
 Returns whether the controller is connected.
 
virtual float getAnalog (ControllerAnalog ichannel)
 Returns the current analog reading for the channel in the range [-1, 1].
 
virtual bool getDigital (ControllerDigital ibutton)
 Returns whether the digital button is currently pressed.
 
virtual ControllerButtonoperator[] (ControllerDigital ibtn)
 Returns a ControllerButton for the given button on this controller.
 
virtual std::int32_t setText (std::uint8_t iline, std::uint8_t icol, std::string itext)
 Sets text to the controller LCD screen.
 
virtual std::int32_t clear ()
 Clears all of the lines of the controller screen.
 
virtual std::int32_t clearLine (std::uint8_t iline)
 Clears an individual line of the controller screen.
 
virtual std::int32_t rumble (std::string irumblePattern)
 Rumble the controller.
 
virtual std::int32_t getBatteryCapacity ()
 Gets the battery capacity of the given controller.
 
virtual std::int32_t getBatteryLevel ()
 Gets the battery level of the given controller.
 

Protected Attributes

ControllerId okapiId
 
pros::controller_id_e_t prosId
 
std::array< ControllerButton *, 12 > buttonArray {}
 

Detailed Description

Definition at line 14 of file controller.hpp.

Constructor & Destructor Documentation

◆ Controller()

okapi::Controller::Controller ( ControllerId  iid = ControllerId::master)

◆ ~Controller()

virtual okapi::Controller::~Controller ( )
virtual

Member Function Documentation

◆ clear()

virtual std::int32_t okapi::Controller::clear ( )
virtual

Clears all of the lines of the controller screen.

On vexOS version 1.0.0 this function will block for 110ms.

Returns
1 if the operation was successful, PROS_ERR otherwise

◆ clearLine()

virtual std::int32_t okapi::Controller::clearLine ( std::uint8_t  iline)
virtual

Clears an individual line of the controller screen.

Parameters
ilinethe line number to clear in the range [0, 2].
Returns
1 if the operation was successful, PROS_ERR otherwise

◆ getAnalog()

virtual float okapi::Controller::getAnalog ( ControllerAnalog  ichannel)
virtual

Returns the current analog reading for the channel in the range [-1, 1].

Returns 0 if the controller is not connected.

Parameters
ichannelthe channel to read
Returns
the value of that channel in the range [-1, 1]

◆ getBatteryCapacity()

virtual std::int32_t okapi::Controller::getBatteryCapacity ( )
virtual

Gets the battery capacity of the given controller.

This function uses the following values of errno when an error state is reached: EACCES - Another resource is currently trying to access the controller port.

Returns
the controller's battery capacity

◆ getBatteryLevel()

virtual std::int32_t okapi::Controller::getBatteryLevel ( )
virtual

Gets the battery level of the given controller.

This function uses the following values of errno when an error state is reached: EACCES - Another resource is currently trying to access the controller port.

Returns
the controller's battery level

◆ getDigital()

virtual bool okapi::Controller::getDigital ( ControllerDigital  ibutton)
virtual

Returns whether the digital button is currently pressed.

Returns false if the controller is not connected.

Parameters
ibuttonthe button to check
Returns
true if the button is pressed, false if the controller is not connected

◆ isConnected()

virtual bool okapi::Controller::isConnected ( )
virtual

Returns whether the controller is connected.

Returns
true if the controller is connected

◆ operator[]()

virtual ControllerButton & okapi::Controller::operator[] ( ControllerDigital  ibtn)
virtual

Returns a ControllerButton for the given button on this controller.

Parameters
ibtnthe button
Returns
a ControllerButton on this controller

◆ rumble()

virtual std::int32_t okapi::Controller::rumble ( std::string  irumblePattern)
virtual

Rumble the controller.

Controller rumble activation is currently in beta, so continuous, fast updates will not work well.

Parameters
irumblePatternA string consisting of the characters '.', '-', and ' ', where dots are short rumbles, dashes are long rumbles, and spaces are pauses. Maximum supported length is 8 characters.
Returns
1 if the operation was successful or PROS_ERR if the operation failed, setting errno.

◆ setText()

virtual std::int32_t okapi::Controller::setText ( std::uint8_t  iline,
std::uint8_t  icol,
std::string  itext 
)
virtual

Sets text to the controller LCD screen.

Parameters
ilinethe line number in the range [0-2] at which the text will be displayed
icolthe column number in the range [0-14] at which the text will be displayed
itextthe string to display
Returns
1 if the operation was successful, PROS_ERR otherwise

Member Data Documentation

◆ buttonArray

std::array<ControllerButton *, 12> okapi::Controller::buttonArray {}
protected

Definition at line 116 of file controller.hpp.

◆ okapiId

ControllerId okapi::Controller::okapiId
protected

Definition at line 114 of file controller.hpp.

◆ prosId

pros::controller_id_e_t okapi::Controller::prosId
protected

Definition at line 115 of file controller.hpp.


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