Package trclib.archive
Class TrcPixyCam1
java.lang.Object
trclib.archive.TrcPixyCam1
- Direct Known Subclasses:
FrcPixyCam1
This class implements a platform independent pixy camera 1. This class is intended to be extended by a platform
dependent pixy class which provides the abstract methods required by this class. This class provides the parser
to read and parse the object block from the pixy camera 1. It also provides access to the last detected objects
reported by the pixy camera asynchronously.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class implements the pixy camera object block communication protocol.static enumThis is used identify the request type. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrcPixyCam1(String instanceName, boolean msbFirst) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidasyncReadData(TrcPixyCam1.RequestId requestId, int length) This method issues an asynchronous read of the specified number of bytes from the device.voidasyncWriteBytes(byte[] data) This method writes the data to the device one byte at a time.abstract voidasyncWriteData(TrcPixyCam1.RequestId requestId, byte[] data) This method writes the data buffer to the device asynchronously.voidend()This method sets the pixy camera to end state so it will start properly next time.This method returns an array of detected object blocks.protected voidrequestHandler(Object context) This method is called when the read request is completed.voidsetBrightness(byte brightness) This method sets the camera brightness.voidsetLED(byte red, byte green, byte blue) This method sets the LED to the specified color.voidsetPanTilt(int pan, int tilt) This method sets the pan and tilt servo positions.voidstart()This method starts the pixy camera by queuing the initial read request if not already.toString()This method returns the instance name.
-
Field Details
-
instanceName
-
-
Constructor Details
-
TrcPixyCam1
Constructor: Create an instance of the object.- Parameters:
instanceName- specifies the instance name.msbFirst- specifies true if a word has MSB first.
-
-
Method Details
-
asyncReadData
This method issues an asynchronous read of the specified number of bytes from the device.- Parameters:
requestId- specifies the ID to identify the request for the request handler. Can be null if none was provided.length- specifies the number of bytes to read.
-
asyncWriteData
This method writes the data buffer to the device asynchronously.- Parameters:
requestId- specifies the ID to identify the request for the request handler. Can be null if none was provided.data- specifies the data buffer.
-
toString
This method returns the instance name. -
start
public void start()This method starts the pixy camera by queuing the initial read request if not already. -
end
public void end()This method sets the pixy camera to end state so it will start properly next time. -
asyncWriteBytes
public void asyncWriteBytes(byte[] data) This method writes the data to the device one byte at a time.- Parameters:
data- specifies the buffer containing the data to be written to the device.
-
setLED
public void setLED(byte red, byte green, byte blue) This method sets the LED to the specified color.- Parameters:
red- specifies the red value.green- specifies the green value.blue- specifies the blue value.
-
setBrightness
public void setBrightness(byte brightness) This method sets the camera brightness.- Parameters:
brightness- specifies the brightness value.
-
setPanTilt
public void setPanTilt(int pan, int tilt) This method sets the pan and tilt servo positions.- Parameters:
pan- specifies the pan position between 0 and 1000.tilt- specifies the tilt position between 0 and 1000.
-
getDetectedObjects
This method returns an array of detected object blocks.- Returns:
- array of detected object blocks, can be null if no object detected or result of the next frame not yet available.
-
requestHandler
This method is called when the read request is completed.- Parameters:
context- specifies the read request.
-