NXShield  v1.07
NXShield Library Reference by OpenElectrons.com
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
NXTCam Class Reference

This class interfaces with NXTCam attached to NXShield. More...

#include <NXTCam.h>

Inheritance diagram for NXTCam:
NXShieldI2C BaseI2CDevice SoftI2cMaster

Public Member Functions

 NXTCam (uint8_t i2c_address=0x02)
 
uint8_t issueCommand (char command)
 
bool sortSize ()
 
bool selectObjectMode ()
 
bool writeImageRegisters ()
 
bool disableTracking ()
 
bool enableTracking ()
 
bool getColorMap ()
 
bool illuminationOn ()
 
bool readImageRegisters ()
 
bool selectLineMode ()
 
bool pingCam ()
 
bool resetCam ()
 
bool sendColorMap ()
 
bool illuminationOff ()
 
bool sortColor ()
 
bool sortNone ()
 
bool camFirmware ()
 
int getNumberObjects ()
 
void getBlobs (int *nblobs, uint8_t *color, uint8_t *left, uint8_t *top, uint8_t *right, uint8_t *bottom)
 
- Public Member Functions inherited from NXShieldI2C
 NXShieldI2C (uint8_t i2c_address)
 
void init (void *shield, SH_BankPort bp)
 
uint8_t readByte (uint8_t location)
 
uint16_t readInteger (uint8_t location)
 
uint32_t readLong (uint8_t location)
 
uint8_t * readRegisters (uint8_t start_register, uint8_t bytes, uint8_t *buf)
 
char * readString (uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
 
bool writeRegisters (uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
 
bool writeByte (uint8_t location, uint8_t data)
 
bool writeInteger (uint8_t location, uint16_t data)
 
bool writeLong (uint8_t location, uint32_t data)
 
char * getFirmwareVersion ()
 
char * getVendorID ()
 
char * getDeviceID ()
 
char * getFeatureSet ()
 
uint8_t getErrorCode ()
 
bool checkAddress ()
 
bool setAddress (uint8_t address)
 
- Public Member Functions inherited from BaseI2CDevice
 BaseI2CDevice (uint8_t i2c_address)
 
void initProtocol ()
 
uint8_t * readRegisters (uint8_t start_register, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0, bool clear_buffer=false)
 
uint8_t readByte (uint8_t location)
 
int16_t readInteger (uint8_t location)
 
uint32_t readLong (uint8_t location)
 
char * readString (uint8_t location, uint8_t bytes_to_read, uint8_t *buffer=0, uint8_t buffer_length=0)
 
bool writeRegisters (uint8_t start_register, uint8_t bytes_to_write, uint8_t *buffer=0)
 
bool writeByte (uint8_t location, uint8_t data)
 
bool writeInteger (uint8_t location, uint16_t data)
 
bool writeLong (uint8_t location, uint32_t data)
 
bool checkAddress ()
 
bool setAddress (uint8_t i2c_address)
 
uint8_t getAddress ()
 
uint8_t getWriteErrorCode ()
 
char * getFirmwareVersion ()
 
char * getVendorID ()
 
char * getDeviceID ()
 
char * getFeatureSet ()
 
- Public Member Functions inherited from SoftI2cMaster
uint8_t start (uint8_t addressRW)
 
void stop (void)
 
uint8_t restart (uint8_t addressRW)
 
uint8_t write (uint8_t b)
 
uint8_t read (uint8_t last)
 
 SoftI2cMaster (uint8_t devAddr)
 
void initProtocol (uint8_t sclPin=NULL, uint8_t sdaPin=NULL)
 
uint8_t * readRegisters (uint8_t startRegister, uint8_t bytes, uint8_t *buf=NULL)
 
bool writeRegistersWithLocation (int bytes, uint8_t *buf)
 
bool writeRegisters (uint8_t location, uint8_t bytes_to_write, uint8_t *buffer=0)
 
bool writeByte (uint8_t location, uint8_t data)
 
bool writeInteger (uint8_t location, uint16_t data)
 
bool writeLong (uint8_t location, uint32_t data)
 
char * readString (uint8_t startRegister, uint8_t bytes, uint8_t *buf=NULL, uint8_t len=0)
 
uint8_t readByte (uint8_t location)
 
int16_t readInteger (uint8_t location)
 
uint32_t readLong (uint8_t location)
 
char * getFirmwareVersion ()
 
char * getVendorID ()
 
char * getDeviceID ()
 
uint8_t getWriteErrorCode ()
 
bool checkAddress ()
 
bool setAddress (uint8_t address)
 

Additional Inherited Members

- Public Attributes inherited from NXShieldI2C
void * mp_shield
 
uint8_t * _i2c_buffer
 
uint8_t m_protocol
 
- Public Attributes inherited from SoftI2cMaster
uint8_t * _so_buffer
 
- Static Public Attributes inherited from BaseI2CDevice
static uint8_t * _buffer = 0
 
static bool b_initialized = false
 
- Protected Member Functions inherited from BaseI2CDevice
void setWriteErrorCode (uint8_t code)
 

Detailed Description

This class interfaces with NXTCam attached to NXShield.

Constructor & Destructor Documentation

NXTCam::NXTCam ( uint8_t  i2c_address = 0x02)

class constructor for NXTCam with optional custom i2c address parameter

Member Function Documentation

bool NXTCam::camFirmware ( )

get the firmware of the NXTCam

bool NXTCam::disableTracking ( )

disable tracking for the NXTCam

bool NXTCam::enableTracking ( )

enable tracking for the NXTCam

void NXTCam::getBlobs ( int *  nblobs,
uint8_t *  color,
uint8_t *  left,
uint8_t *  top,
uint8_t *  right,
uint8_t *  bottom 
)

This function gets the blob information of all the blobs that NXTCam is tracking. There could be upto 8 blobs being tracked by NXTCam. All the parameters of this function are return values. This function will return color and coordinate information for all the blobs.

Parameters
nblobsIn this variable, number of blobs NXTCam sees are returned. The blobs NXTCam sees could be of different color or same color. For e.g. if you have 3 colors defined, say red (color 1), blue (color 2) and green (color3), and you have 3 red objects and 2 blue objects and 1 green object in front of NXTCam, nblobs will be 6. color[]: a array of colors for the blobs in above example, Color array will have 6 valid elements - three bytes will say 1 (for color1), and 2 bytes will say (for color 2), and 1 byte will say 3 (for color 3). Based on sorting chosen, they will be sorted by size or color (if the sorting was color, first 3 bytes will be 1, next two will be 2 and next one will be 3).
colora array of colors for the blobs (array has 8 elements)
leftthe coordinate values of the blobs (array of 8 elements)
topthe coordinate values of the blobs (array of 8 elements)
rightthe coordinate values of the blobs (array of 8 elements)
bottomthe coordinate values of the blobs (array of 8 elements)
Returns
look at the nblobs first to see how many blobs are being tracked, and then read the respective color and coordinate infromation.
bool NXTCam::getColorMap ( )

get the current colormap of the NXTCam

int NXTCam::getNumberObjects ( )

get the total number of objected tracked by the NXTCam

bool NXTCam::illuminationOff ( )

not impmemented yet

bool NXTCam::illuminationOn ( )

not impmemented yet

uint8_t NXTCam::issueCommand ( char  command)

issue character command byte to the command register of the NXTCam (command such as enable tracking, stop tracking, etc). Refer to User Guide for available commands.

bool NXTCam::pingCam ( )

ping the NXTCam to test connection

bool NXTCam::readImageRegisters ( )

read the image registers of the CCD

bool NXTCam::resetCam ( )

reset the NXTCam

bool NXTCam::selectLineMode ( )

put the NXTCam in line tracking mode

bool NXTCam::selectObjectMode ( )

configure the tracking mode of the device to object tracking

bool NXTCam::sendColorMap ( )

send ColorMap to the NXTCam

bool NXTCam::sortColor ( )

sort the blobs by color

bool NXTCam::sortNone ( )

clear any selected sort configuration

bool NXTCam::sortSize ( )

sort the blobs from the NXTCam byt blobs

bool NXTCam::writeImageRegisters ( )

write to the image registers of the CCD


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