Zoltan Hudak / UsbHostMAX3421E

Dependents:   UsbHostMAX3421E_Hello

Embed: (wiki syntax)

« Back to documentation index

PSBuzz Class Reference

This class implements support for the PS Buzz controllers via USB. More...

#include <PSBuzz.h>

Inherits HIDUniversal.

Public Member Functions

 PSBuzz (Usb *p)
 Constructor for the PSBuzz class.
bool connected ()
 Used to check if a PS Buzz controller is connected.
void attachOnInit (void(*funcOnInit)(void))
 Used to call your own function when the device is successfully initialized.
PS Buzzer Controller functions
bool getButtonPress (ButtonEnum b, uint8_t controller=0)
 getButtonPress(ButtonEnum b) will return true as long as the button is held down.
bool getButtonClick (ButtonEnum b, uint8_t controller=0)
void setLedRaw (bool value, uint8_t controller=0)
 Set LED value without using LEDEnum.
void setLedOffAll ()
 Turn all LEDs off.
void setLedOff (uint8_t controller=0)
 Turn the LED off on a specific controller.
void setLedOnAll ()
 Turn all LEDs on.
void setLedOn (uint8_t controller=0)
 Turn the LED on on a specific controller.
void setLedToggle (uint8_t controller=0)
 Toggle the LED on a specific controller.

Protected Member Functions

void Reset ()
 Used to reset the different buffers to their default values.
HIDUniversal implementation
void ParseHIDData (USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
 Used to parse USB HID data.
uint8_t OnInitSuccessful ()
 Called when a device is successfully initialized.
USBDeviceConfig implementation
virtual bool VIDPIDOK (uint16_t vid, uint16_t pid)
 Used by the USB core to check what this driver support.

Detailed Description

This class implements support for the PS Buzz controllers via USB.

It uses the HIDUniversal class for all the USB communication.

Definition at line 43 of file PSBuzz.h.


Constructor & Destructor Documentation

PSBuzz ( Usb *  p )

Constructor for the PSBuzz class.

Parameters:
pPointer to the USB class instance.

Definition at line 49 of file PSBuzz.h.


Member Function Documentation

void attachOnInit ( void(*)(void)  funcOnInit )

Used to call your own function when the device is successfully initialized.

Parameters:
funcOnInitFunction to call.

Definition at line 66 of file PSBuzz.h.

bool connected (  )

Used to check if a PS Buzz controller is connected.

Returns:
Returns true if it is connected.

Definition at line 58 of file PSBuzz.h.

bool getButtonPress ( ButtonEnum  b,
uint8_t  controller = 0 
)

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).

Parameters:
bButtonEnum to read.
controllerThe controller to read from. Default to 0.
Returns:
getButtonPress(ButtonEnum b) will return a true as long as a button is held down, while getButtonClick(ButtonEnum b) will return true once for each button press.

Definition at line 52 of file PSBuzz.cpp.

uint8_t OnInitSuccessful (  ) [protected]

Called when a device is successfully initialized.

Use attachOnInit(void (*funcOnInit)(void)) to call your own function. This is useful for instance if you want to set the LEDs in a specific way.

Definition at line 41 of file PSBuzz.cpp.

void ParseHIDData ( USBHID *  hid,
bool  is_rpt_id,
uint8_t  len,
uint8_t *  buf 
) [protected]

Used to parse USB HID data.

Parameters:
hidPointer to the HID class.
is_rpt_idOnly used for Hubs.
lenThe length of the incoming data.
bufPointer to the data buffer.
void Reset (  ) [protected]

Used to reset the different buffers to their default values.

Definition at line 157 of file PSBuzz.h.

void setLedOff ( uint8_t  controller = 0 )

Turn the LED off on a specific controller.

Parameters:
controllerThe controller to turn off. Defaults to 0.

Definition at line 108 of file PSBuzz.h.

void setLedOffAll (  )

Turn all LEDs off.

Definition at line 98 of file PSBuzz.h.

void setLedOn ( uint8_t  controller = 0 )

Turn the LED on on a specific controller.

Parameters:
controllerThe controller to turn off. Defaults to 0.

Definition at line 124 of file PSBuzz.h.

void setLedOnAll (  )

Turn all LEDs on.

Definition at line 114 of file PSBuzz.h.

void setLedRaw ( bool  value,
uint8_t  controller = 0 
)

Set LED value without using LEDEnum.

Parameters:
valueSee: LEDEnum. Set LED values directly.
valueUsed to set whenever the LED should be on or off
controllerThe controller to control. Defaults to 0.

Definition at line 64 of file PSBuzz.cpp.

void setLedToggle ( uint8_t  controller = 0 )

Toggle the LED on a specific controller.

Parameters:
controllerThe controller to turn off. Defaults to 0.

Definition at line 132 of file PSBuzz.h.

virtual bool VIDPIDOK ( uint16_t  vid,
uint16_t  pid 
) [protected, virtual]

Used by the USB core to check what this driver support.

Parameters:
vidThe device's VID.
pidThe device's PID.
Returns:
Returns true if the device's VID and PID matches this driver.

Definition at line 172 of file PSBuzz.h.