USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Protected Member Functions | List of all members
PSBuzz Class Reference

#include <PSBuzz.h>

Inheritance diagram for PSBuzz:
Inheritance graph
[legend]
Collaboration diagram for PSBuzz:
Collaboration graph
[legend]

Public Member Functions

 PSBuzz (USB *p)
 
bool connected ()
 
void attachOnInit (void(*funcOnInit)(void))
 
PS Buzzer Controller functions
bool getButtonPress (ButtonEnum b, uint8_t controller=0)
 
bool getButtonClick (ButtonEnum b, uint8_t controller=0)
 
void setLedRaw (bool value, uint8_t controller=0)
 
void setLedOffAll ()
 
void setLedOff (uint8_t controller=0)
 
void setLedOnAll ()
 
void setLedOn (uint8_t controller=0)
 
void setLedToggle (uint8_t controller=0)
 
- Public Member Functions inherited from HIDUniversal
 HIDUniversal (USB *p)
 
virtual bool SetReportParser (uint8_t id, HIDReportParser *prs)
 
virtual uint8_t Init (uint8_t parent, uint8_t port, bool lowspeed)
 
virtual uint8_t Release ()
 
virtual uint8_t Poll ()
 
virtual uint8_t GetAddress ()
 
virtual bool isReady ()
 
virtual void EndpointXtract (uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
 
- Public Member Functions inherited from HID
 HID (USB *pusb)
 
const USBGetUsb ()
 
uint8_t SetProtocol (uint8_t iface, uint8_t protocol)
 
uint8_t GetProtocol (uint8_t iface, uint8_t *dataptr)
 
uint8_t GetIdle (uint8_t iface, uint8_t reportID, uint8_t *dataptr)
 
uint8_t SetIdle (uint8_t iface, uint8_t reportID, uint8_t duration)
 
uint8_t GetReportDescr (uint16_t wIndex, USBReadParser *parser=NULL)
 
uint8_t GetHidDescr (uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
 
uint8_t GetReport (uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t *dataptr)
 
uint8_t SetReport (uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t *dataptr)
 
- Public Member Functions inherited from USBDeviceConfig
virtual uint8_t ConfigureDevice (uint8_t parent, uint8_t port, bool lowspeed)
 
virtual void ResetHubPort (uint8_t port)
 
virtual boolean DEVCLASSOK (uint8_t klass)
 

Protected Member Functions

void Reset ()
 
HIDUniversal implementation
virtual void ParseHIDData (HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
 
virtual uint8_t OnInitSuccessful ()
 
USBDeviceConfig implementation
virtual boolean VIDPIDOK (uint16_t vid, uint16_t pid)
 
- Protected Member Functions inherited from HIDUniversal
virtual HIDReportParserGetReportParser (uint8_t id)
 
- Protected Member Functions inherited from HID
void PrintEndpointDescriptor (const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
 
void PrintHidDescriptor (const USB_HID_DESCRIPTOR *pDesc)
 

Additional Inherited Members

- Protected Attributes inherited from HIDUniversal
EpInfo epInfo [totalEndpoints]
 
HIDInterface hidInterfaces [maxHidInterfaces]
 
bool bHasReportId
 
uint16_t PID
 
uint16_t VID
 
- Protected Attributes inherited from HID
USBpUsb
 
uint8_t bAddress
 
- Static Protected Attributes inherited from HID
static const uint8_t epInterruptInIndex = 1
 
static const uint8_t epInterruptOutIndex = 2
 
static const uint8_t maxHidInterfaces = 3
 
static const uint8_t maxEpPerInterface = 2
 
static const uint8_t totalEndpoints = (maxHidInterfaces * maxEpPerInterface + 1)
 

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::PSBuzz ( USB p)
inline

Constructor for the PSBuzz class.

Parameters
pPointer to the USB class instance.

Definition at line 49 of file PSBuzz.h.

Member Function Documentation

bool PSBuzz::connected ( )
inline

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.

void PSBuzz::attachOnInit ( void(*)(void)  funcOnInit)
inline

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 PSBuzz::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.

bool PSBuzz::getButtonClick ( 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 56 of file PSBuzz.cpp.

void PSBuzz::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 PSBuzz::setLedOffAll ( )
inline

Turn all LEDs off.

Definition at line 98 of file PSBuzz.h.

void PSBuzz::setLedOff ( uint8_t  controller = 0)
inline

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 PSBuzz::setLedOnAll ( )
inline

Turn all LEDs on.

Definition at line 114 of file PSBuzz.h.

void PSBuzz::setLedOn ( uint8_t  controller = 0)
inline

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 PSBuzz::setLedToggle ( uint8_t  controller = 0)
inline

Toggle the LED on a specific controller.

Parameters
controllerThe controller to turn off. Defaults to 0.

Definition at line 132 of file PSBuzz.h.

void PSBuzz::ParseHIDData ( HID hid,
bool  is_rpt_id,
uint8_t  len,
uint8_t *  buf 
)
protectedvirtual

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.

Reimplemented from HIDUniversal.

Definition at line 23 of file PSBuzz.cpp.

uint8_t PSBuzz::OnInitSuccessful ( )
protectedvirtual

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.

Reimplemented from HIDUniversal.

Definition at line 41 of file PSBuzz.cpp.

void PSBuzz::Reset ( )
inlineprotected

Used to reset the different buffers to their default values

Definition at line 157 of file PSBuzz.h.

virtual boolean PSBuzz::VIDPIDOK ( uint16_t  vid,
uint16_t  pid 
)
inlineprotectedvirtual

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.

Reimplemented from USBDeviceConfig.

Definition at line 172 of file PSBuzz.h.


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