upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | Static Public Attributes | List of all members

API for the Grove Serial Camera. More...

Detailed Description

The driver was tested with the Grove Serial Camera. There is no protocol documentation currently available, so this module was developed based completely on the Seeed Studio* Arduino* sketch.

It is connected via a UART at 115,200 baud.

grovescam.jpg
// Instantiate a Grove Serial Camera on UART 0
// make sure port is initialized properly. 115200 baud is the default.
if (!camera.setupTty()) {
System.err.println("Failed to setup tty port parameters");
System.exit(-1);
}
if (camera.init())
System.out.println("Initialized...");
else
System.out.println("Initialization failed");
if (camera.preCapture())
System.out.println("preCapture succeeded...");
else
System.out.println("preCapture failed.");
if (camera.doCapture())
System.out.println("doCapture succeeded...");
else
System.out.println("doCapture failed.");
if (camera.getImageSize() > 0) {
System.out.println("Storing image.jpg...");
if (camera.storeImage("image.jpg"))
System.out.println("storeImage succeeded...");
else
System.out.println("storeImage failed.");
}

Classes

class  PIC_FORMATS_T
 

Public Member Functions

synchronized void delete ()
 
 GROVESCAM (int uart, short camAddr)
 
 GROVESCAM (int uart)
 
boolean dataAvailable (long millis)
 
int readData (byte[] buffer)
 
int writeData (byte[] buffer)
 
boolean setupTty (int baud)
 
boolean setupTty ()
 
void drainInput ()
 
boolean init ()
 
boolean preCapture (GROVESCAM.PIC_FORMATS_T fmt)
 
boolean preCapture ()
 
boolean doCapture ()
 
boolean storeImage (String fname)
 
int getImageSize ()
 

Static Public Attributes

static final long MAX_PKT_LEN = javaupm_grovescamJNI.GROVESCAM_MAX_PKT_LEN_get()
 

Constructor & Destructor Documentation

GROVESCAM ( int  uart,
short  camAddr 
)

Grove Serial Camera constructor

Parameters
uartDefault UART to use (0 or 1)
camAddr3-bit address identifier of the camera; default is 0

Member Function Documentation

boolean dataAvailable ( long  millis)

Checks to see if there is data available for reading

Parameters
millisNumber of milliseconds to wait; 0 means no waiting.
Returns
True if there is data available for reading
boolean doCapture ( )

Starts the capture

Returns
True if successful
void drainInput ( )

Reads serial input and discards until no more characters are available

int getImageSize ( )

Returns the picture length. Note: this is only valid after doCapture() has run successfully.

Returns
Image length
boolean init ( )

Initializes the camera

boolean preCapture ( GROVESCAM.PIC_FORMATS_T  fmt)

Tells the camera to prepare for a capture

Parameters
fmtOne of the PIC_FORMATS_T values
boolean setupTty ( int  baud)

Sets up proper tty I/O modes and the baud rate. For this device, the default baud rate is 9,600 (B9600).

Parameters
baudDesired baud rate
Returns
True if successful
boolean storeImage ( String  fname)

Stores the captured image in a file

Parameters
fnameName of the file to write
Returns
True if successful

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