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

This class interfaces with NXTLineLeader sensor attached to NXShield. More...

#include <LineLeader.h>

Inheritance diagram for LineLeader:
NXShieldI2C BaseI2CDevice SoftI2cMaster

Public Member Functions

 LineLeader (uint8_t i2c_address=0x02)
 
uint8_t issueCommand (char command)
 
bool calibrateWhite ()
 
bool calibrateBlack ()
 
bool sleep ()
 
bool wakeUp ()
 
bool invertLineColorToWhite ()
 
bool resetColorInversion ()
 
bool takeSnapshot ()
 
bool configureUS ()
 
bool configureEurope ()
 
bool configureUniversal ()
 
uint8_t getSetPoint ()
 
bool setSetPoint (uint8_t spoint)
 
uint8_t getKp (uint8_t kp)
 
bool setKp (uint8_t kp)
 
uint8_t getKi (uint8_t ki)
 
bool setKi (uint8_t ki)
 
uint8_t getKd (uint8_t kd)
 
bool setKd (uint8_t kd)
 
uint8_t getKpFactor (uint8_t kpfact)
 
bool setKpFactor (uint8_t kpfact)
 
uint8_t getKiFactor (uint8_t kifact)
 
bool setKiFactor (uint8_t kifact)
 
uint8_t getKdFactor (uint8_t kdfact)
 
bool setKdFactor (uint8_t kdfact)
 
int getSteering ()
 
unsigned char getAverage ()
 
unsigned char getResult ()
 
uint8_t * getRawCalibrated ()
 
uint8_t * getRawUncalibrated ()
 
uint8_t * getWhiteLimit ()
 
uint8_t * getBlackLimit ()
 
uint8_t * getWhiteCalibration ()
 
uint8_t * getBlackCalibration ()
 
- 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 NXTLineLeader sensor attached to NXShield.

Constructor & Destructor Documentation

LineLeader::LineLeader ( uint8_t  i2c_address = 0x02)

class constructor for LineLeader; custom i2c address is an optional parameter

Member Function Documentation

bool LineLeader::calibrateBlack ( )

calibrate the current input to the device as black

bool LineLeader::calibrateWhite ( )

calibrate the current input to the device as white

bool LineLeader::configureEurope ( )

Configure sensor for European region (and regions with 50 Hz electrical frequency)

bool LineLeader::configureUniversal ( )

Configure sensor for universal frequency (in this mode the sensor adjusts for any frequency, this is also the default mode).

bool LineLeader::configureUS ( )

Configure Sensor for US region (and regions with 60 Hz electrical frequency).

unsigned char LineLeader::getAverage ( )

returns a weighted average of the current position of the line in relation to the sensor

uint8_t * LineLeader::getBlackCalibration ( )

returns the current calibration of black

uint8_t * LineLeader::getBlackLimit ( )

get the limit at which black changes to white

uint8_t LineLeader::getKd ( uint8_t  kd)

get the current derivative factor for PID control

uint8_t LineLeader::getKdFactor ( uint8_t  kdfact)

Get the Kd factor

Returns
kd factor
uint8_t LineLeader::getKi ( uint8_t  ki)

get the current integral factor for PID control

uint8_t LineLeader::getKiFactor ( uint8_t  kifact)

Get the Ki factor

Returns
ki factor
uint8_t LineLeader::getKp ( uint8_t  kp)

get the current proportion factor for PID control

uint8_t LineLeader::getKpFactor ( uint8_t  kpfact)

Get the Kp factor

Returns
kp factor
uint8_t * LineLeader::getRawCalibrated ( )

get the raw readings from the sensor that is calibrated based on black and white calibration values

Returns
array of 8 bytes of the sensors' calibrated values.
uint8_t * LineLeader::getRawUncalibrated ( )

get the raw uncalibrated sensor values straight from the sensor

Returns
array of 8 bytes of the sensors' uncalibrated values.
unsigned char LineLeader::getResult ( )

returns a byte of the current result; each bit corresponds to one light sensor

uint8_t LineLeader::getSetPoint ( )

returns the current setpoint used by the PID control on the device

int LineLeader::getSteering ( )

current steering value, add or subtract from the speed of motors on each side

uint8_t * LineLeader::getWhiteCalibration ( )

returns the current calibration of white

uint8_t * LineLeader::getWhiteLimit ( )

get the limit at which white changes to black

bool LineLeader::invertLineColorToWhite ( )

Color inversion (White line on a black background)

uint8_t LineLeader::issueCommand ( char  command)

write a command byte to the command register of the device

bool LineLeader::resetColorInversion ( )

Reset Color inversion (black line on a white background, this is also the default).

bool LineLeader::setKd ( uint8_t  kd)

set the derivative factor for PID control

bool LineLeader::setKdFactor ( uint8_t  kdfact)

Set the Kd factor

bool LineLeader::setKi ( uint8_t  ki)

set the integral factor for PID control

bool LineLeader::setKiFactor ( uint8_t  kifact)

Set the Ki factor

bool LineLeader::setKp ( uint8_t  kp)

set the proportion factor for PID control

bool LineLeader::setKpFactor ( uint8_t  kpfact)

Set the Kp factor

bool LineLeader::setSetPoint ( uint8_t  spoint)

set the desired point relative to the 8 sensors for PID control

bool LineLeader::sleep ( )

turn off the LEDs on the device and put it in the sleep state

bool LineLeader::takeSnapshot ( )

Take a snapshot, this command looks at the line under the sensor and stores the width and position of the line in sensor’s memory. Subsequently, sensor will use these characteristics of line to track it. This command inverts the colors if it sees a white line on black background. (PID parameters are not affected).

bool LineLeader::wakeUp ( )

turn on the LEDs and wake up the device


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