Class Pixy2
- java.lang.Object
-
- io.github.pseudoresonance.pixy2api.Pixy2
-
public class Pixy2 extends java.lang.Object
Java Port of Pixy2 Arduino Library Interfaces with the Pixy2 over any provided, compatible link https://github.com/PseudoResonance/Pixy2JavaAPI
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Pixy2.Checksum
static class
Pixy2.LinkType
static class
Pixy2.Version
-
Field Summary
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
changeProg(char[] prog)
Sends change program packet to Pixy2void
close()
Closes Pixy2static Pixy2
createInstance(Link link)
Gets Pixy2 instance with supplied communication linkstatic Pixy2
createInstance(Pixy2.LinkType type)
Gets Pixy2 instance with supplied communication link typePixy2CCC
getCCC()
Get Pixy2 Color Connected Components trackerbyte
getFPS()
Gets Pixy2 camera framerate between 2-62fpsint
getFrameHeight()
Get height of the pixy's visual frame after initializationint
getFrameWidth()
Get width of the pixy's visual frame after initializationPixy2Line
getLine()
Get Pixy2 line trackerbyte
getResolution()
Gets camera resolution from Pixy2int
getVersion()
Gets version info from Pixy2Pixy2.Version
getVersionInfo()
Gets stored Pixy2Pixy2.Version
info or retrieves from Pixy2 if not presentPixy2Video
getVideo()
Get Pixy2 video trackerint
init()
Initializes Pixy2 and waits for startup to complete using default link argument valueint
init(int argument)
Initializes Pixy2 and waits for startup to completeprotected int
receivePacket()
Receives packet from Pixy2 and outputs to buffer for further processingprotected int
sendPacket()
Sends packet to Pixy2 from bufferbyte
setCameraBrightness(int brightness)
Sets Pixy2 camera brightness between 0-255byte
setLamp(byte upper, byte lower)
Turns Pixy2 light source on/off Use 1 to indicate on, 0 to indicate offbyte
setLED(int rgb)
Sets Pixy2 LED color to specified RGB valuebyte
setLED(int r, int g, int b)
Sets Pixy2 LED color to specified RGB values between 0-255byte
setLED(java.awt.Color color)
Sets Pixy2 LED color to specified Colorbyte
setServos(int pan, int tilt)
Sets Pixy2 servo positions between 0-1000
-
-
-
Field Detail
-
PIXY_BUFFERSIZE
public static final int PIXY_BUFFERSIZE
- See Also:
- Constant Field Values
-
PIXY_SEND_HEADER_SIZE
public static final int PIXY_SEND_HEADER_SIZE
- See Also:
- Constant Field Values
-
PIXY_MAX_PROGNAME
public static final int PIXY_MAX_PROGNAME
- See Also:
- Constant Field Values
-
PIXY_DEFAULT_ARGVAL
public static final int PIXY_DEFAULT_ARGVAL
- See Also:
- Constant Field Values
-
PIXY_CHECKSUM_SYNC
public static final int PIXY_CHECKSUM_SYNC
- See Also:
- Constant Field Values
-
PIXY_NO_CHECKSUM_SYNC
public static final int PIXY_NO_CHECKSUM_SYNC
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_CHANGE_PROG
public static final byte PIXY_TYPE_REQUEST_CHANGE_PROG
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_RESOLUTION
public static final byte PIXY_TYPE_REQUEST_RESOLUTION
- See Also:
- Constant Field Values
-
PIXY_TYPE_RESPONSE_RESOLUTION
public static final byte PIXY_TYPE_RESPONSE_RESOLUTION
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_VERSION
public static final byte PIXY_TYPE_REQUEST_VERSION
- See Also:
- Constant Field Values
-
PIXY_TYPE_RESPONSE_VERSION
public static final byte PIXY_TYPE_RESPONSE_VERSION
- See Also:
- Constant Field Values
-
PIXY_TYPE_RESPONSE_RESULT
public static final byte PIXY_TYPE_RESPONSE_RESULT
- See Also:
- Constant Field Values
-
PIXY_TYPE_RESPONSE_ERROR
public static final byte PIXY_TYPE_RESPONSE_ERROR
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_BRIGHTNESS
public static final byte PIXY_TYPE_REQUEST_BRIGHTNESS
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_SERVO
public static final byte PIXY_TYPE_REQUEST_SERVO
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_LED
public static final byte PIXY_TYPE_REQUEST_LED
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_LAMP
public static final byte PIXY_TYPE_REQUEST_LAMP
- See Also:
- Constant Field Values
-
PIXY_TYPE_REQUEST_FPS
public static final byte PIXY_TYPE_REQUEST_FPS
- See Also:
- Constant Field Values
-
PIXY_RESULT_OK
public static final byte PIXY_RESULT_OK
- See Also:
- Constant Field Values
-
PIXY_RESULT_ERROR
public static final byte PIXY_RESULT_ERROR
- See Also:
- Constant Field Values
-
PIXY_RESULT_BUSY
public static final byte PIXY_RESULT_BUSY
- See Also:
- Constant Field Values
-
PIXY_RESULT_CHECKSUM_ERROR
public static final byte PIXY_RESULT_CHECKSUM_ERROR
- See Also:
- Constant Field Values
-
PIXY_RESULT_TIMEOUT
public static final byte PIXY_RESULT_TIMEOUT
- See Also:
- Constant Field Values
-
PIXY_RESULT_BUTTON_OVERRIDE
public static final byte PIXY_RESULT_BUTTON_OVERRIDE
- See Also:
- Constant Field Values
-
PIXY_RESULT_PROG_CHANGING
public static final byte PIXY_RESULT_PROG_CHANGING
- See Also:
- Constant Field Values
-
PIXY_RCS_MIN_POS
public static final int PIXY_RCS_MIN_POS
- See Also:
- Constant Field Values
-
PIXY_RCS_MAX_POS
public static final int PIXY_RCS_MAX_POS
- See Also:
- Constant Field Values
-
PIXY_RCS_CENTER_POS
public static final int PIXY_RCS_CENTER_POS
- See Also:
- Constant Field Values
-
buffer
protected byte[] buffer
-
length
protected int length
-
type
protected int type
-
bufferPayload
protected byte[] bufferPayload
-
frameWidth
protected int frameWidth
-
frameHeight
protected int frameHeight
-
version
protected Pixy2.Version version
-
ccc
protected Pixy2CCC ccc
-
line
protected Pixy2Line line
-
video
protected Pixy2Video video
-
m_cs
protected boolean m_cs
-
-
Method Detail
-
init
public int init(int argument)
Initializes Pixy2 and waits for startup to complete- Parameters:
argument
- Argument to setupLink
- Returns:
- Pixy2 error code
-
init
public int init()
Initializes Pixy2 and waits for startup to complete using default link argument value- Returns:
- Pixy2 error code
-
createInstance
public static Pixy2 createInstance(Link link)
Gets Pixy2 instance with supplied communication link- Parameters:
link
- CommunicationLink
to Pixy2- Returns:
- Pixy2 instance
-
createInstance
public static Pixy2 createInstance(Pixy2.LinkType type)
Gets Pixy2 instance with supplied communication link type- Parameters:
type
- CommunicationPixy2.LinkType
to Pixy2- Returns:
- Pixy2 instance
-
close
public void close()
Closes Pixy2
-
getCCC
public Pixy2CCC getCCC()
Get Pixy2 Color Connected Components tracker- Returns:
- Pixy2 Color Connected Components tracker
-
getLine
public Pixy2Line getLine()
Get Pixy2 line tracker- Returns:
- Pixy2 line tracker
-
getVideo
public Pixy2Video getVideo()
Get Pixy2 video tracker- Returns:
- Pixy2 video tracker
-
getFrameWidth
public int getFrameWidth()
Get width of the pixy's visual frame after initialization- Returns:
- Pixy2 Frame Width
-
getFrameHeight
public int getFrameHeight()
Get height of the pixy's visual frame after initialization- Returns:
- Pixy2 Frame Height
-
getVersionInfo
public Pixy2.Version getVersionInfo()
Gets stored Pixy2Pixy2.Version
info or retrieves from Pixy2 if not present- Returns:
- Pixy2 Version Info
-
receivePacket
protected int receivePacket()
Receives packet from Pixy2 and outputs to buffer for further processing- Returns:
- Length of bytes received or Pixy2 error code
-
sendPacket
protected int sendPacket()
Sends packet to Pixy2 from buffer- Returns:
- Length of bytes sent or Pixy2 error code
-
changeProg
public byte changeProg(char[] prog)
Sends change program packet to Pixy2- Parameters:
prog
- Program name- Returns:
- Pixy2 error code
-
getVersion
public int getVersion()
Gets version info from Pixy2- Returns:
- Buffer length or Pixy2 error code
-
getResolution
public byte getResolution()
Gets camera resolution from Pixy2- Returns:
- Pixy2 error code
-
setCameraBrightness
public byte setCameraBrightness(int brightness)
Sets Pixy2 camera brightness between 0-255- Parameters:
brightness
- Byte representing camera brightness- Returns:
- Pixy2 error code
-
setServos
public byte setServos(int pan, int tilt)
Sets Pixy2 servo positions between 0-1000- Parameters:
pan
- Pan servo positiontilt
- Tilt servo position- Returns:
- Pixy2 error code
-
setLED
public byte setLED(java.awt.Color color)
Sets Pixy2 LED color to specified Color- Parameters:
color
- Color- Returns:
- Pixy2 error code
-
setLED
public byte setLED(int rgb)
Sets Pixy2 LED color to specified RGB value- Parameters:
rgb
- RGB value- Returns:
- Pixy2 error code
-
setLED
public byte setLED(int r, int g, int b)
Sets Pixy2 LED color to specified RGB values between 0-255- Parameters:
r
- R valueg
- G valueb
- B value- Returns:
- Pixy2 error code
-
setLamp
public byte setLamp(byte upper, byte lower)
Turns Pixy2 light source on/off Use 1 to indicate on, 0 to indicate off- Parameters:
upper
- Byte indicating status of white LEDslower
- Byte indicating status of RGB LED- Returns:
- Pixy2 error code
-
getFPS
public byte getFPS()
Gets Pixy2 camera framerate between 2-62fps- Returns:
- Framerate or Pixy2 error code
-
-