USB Host Shield 2.0
|
#include <SwitchProParser.h>
Public Member Functions | |
SwitchProParser () | |
Switch Pro Controller functions | |
SwitchProOutput | switchProOutput |
bool | getButtonPress (ButtonEnum b) |
bool | getButtonClick (ButtonEnum b) |
int16_t | getAnalogHat (AnalogHatEnum a) |
void | enableImu (bool enable) |
float | getAngle (AngleEnum a) |
int16_t | getSensor (SensorEnum s) |
void | setAllOff () |
void | setRumbleOff () |
void | setRumbleToggle () |
void | setRumble (bool leftRumbleOn, bool rightRumbleOn) |
void | setRumbleLeft (bool on) |
void | setRumbleRight (bool on) |
void | setLedRaw (uint8_t mask) |
void | setLedOff () |
void | setLedOff (LEDEnum a) |
void | setLedOn (LEDEnum a) |
void | setLedToggle (LEDEnum a) |
void | setLedHomeOff () |
void | setLedHomeOn () |
void | setLedHomeToggle () |
uint16_t | getMessageCounter () |
uint8_t | getBatteryLevel () |
bool | isCharging () |
void | Parse (uint8_t len, uint8_t *buf) |
void | Reset () |
virtual void | sendOutputReport (uint8_t *data, uint8_t len)=0 |
virtual void | sendHandshake () |
virtual void | disableTimeout () |
This class parses all the data sent by the Switch Pro controller
Definition at line 141 of file SwitchProParser.h.
|
inline |
Constructor for the SwitchProParser class.
Definition at line 144 of file SwitchProParser.h.
bool SwitchProParser::getButtonPress | ( | ButtonEnum | b | ) |
getButtonPress(ButtonEnum b) will return true as long as the button is held down.
While getButtonClick(ButtonEnum b) will only return it once.
So you instance if you need to increase a variable once you would use getButtonClick(ButtonEnum b), but if you need to drive a robot forward you would use getButtonPress(ButtonEnum b).
b | ButtonEnum to read. |
Definition at line 29 of file SwitchProParser.cpp.
bool SwitchProParser::getButtonClick | ( | ButtonEnum | b | ) |
Allow derived classes to access the output variables.
Definition at line 34 of file SwitchProParser.cpp.
int16_t SwitchProParser::getAnalogHat | ( | AnalogHatEnum | a | ) |
Used to enable/disable the IMU. By default it is disabled.
enable | Enable/disable the IMU. |
Definition at line 174 of file SwitchProParser.h.
Get the angle of the controller calculated using the accelerometer.
Definition at line 184 of file SwitchProParser.h.
|
inline |
Used to get the raw values from the 3-axis gyroscope and 3-axis accelerometer inside the PS5 controller.
s | The sensor to read. |
Definition at line 196 of file SwitchProParser.h.
|
inline |
Turn both rumble and the LEDs off.
Definition at line 216 of file SwitchProParser.h.
|
inline |
Set rumble off.
Definition at line 223 of file SwitchProParser.h.
|
inline |
Toggle rumble.
Definition at line 228 of file SwitchProParser.h.
Turn on/off rumble.
leftRumbleOn | Turn on/off left rumble motor. |
rightRumbleOn | Turn on/off right rumble motor. |
Definition at line 237 of file SwitchProParser.h.
Turn on/off the left rumble.
on | Turn on/off left rumble motor. |
Definition at line 247 of file SwitchProParser.h.
Turn on/off the right rumble.
on | Turn on/off right rumble motor. |
Definition at line 256 of file SwitchProParser.h.
Set LED value without using the LEDEnum. This can also be used to flash the LEDs by setting the high 4-bits of the mask.
value | See: LEDEnum. |
Definition at line 266 of file SwitchProParser.h.
|
inline |
Turn all LEDs off.
Definition at line 272 of file SwitchProParser.h.
Turn the specific LEDEnum off.
a | The LEDEnum to turn off. |
Definition at line 280 of file SwitchProParser.h.
Turn the specific LEDEnum on.
a | The LEDEnum to turn on. |
Definition at line 289 of file SwitchProParser.h.
Toggle the specific LEDEnum.
a | The LEDEnum to toggle. |
Definition at line 298 of file SwitchProParser.h.
|
inline |
Turn home LED off.
Definition at line 304 of file SwitchProParser.h.
|
inline |
Turn home LED on.
Definition at line 310 of file SwitchProParser.h.
|
inline |
Toggle home LED.
Definition at line 316 of file SwitchProParser.h.
|
inline |
Get the incoming message count.
Definition at line 322 of file SwitchProParser.h.
|
inline |
Return the battery level of the Switch Pro Controller.
Definition at line 331 of file SwitchProParser.h.
|
inline |
Returns whenever the controller is plugged in and charging.
Definition at line 339 of file SwitchProParser.h.
Used to parse data sent from the Switch Pro controller.
len | Length of the data. |
buf | Pointer to the data buffer. |
Definition at line 55 of file SwitchProParser.cpp.
|
protected |
Used to reset the different buffers to their default values
Definition at line 231 of file SwitchProParser.cpp.
|
protectedpure virtual |
Send the output to the Switch Pro controller. This is implemented in SwitchProBT.h and SwitchProUSB.h.
data | Pointer to buffer to send by the derived class. |
len | Length of buffer. |
Implemented in SwitchProBT, and SwitchProUSB.
Used to send a handshake command via USB before disabling the timeout.
Reimplemented in SwitchProUSB.
Definition at line 362 of file SwitchProParser.h.
Needed to disable USB timeout for the controller, so it sends out data without the host having to send data continuously.
Reimplemented in SwitchProUSB.
Definition at line 368 of file SwitchProParser.h.
|
protected |
Allow derived classes to access the output variables.
Definition at line 371 of file SwitchProParser.h.