| EVShield v1.3 EVShield Library Reference by mindsensors.com

Public Member Functions | List of all members
EVs_LineLeader Class Reference

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

`#include <EVs_LineLeader.h>`

Inheritance diagram for EVs_LineLeader:

## Public Member Functions
| EVs_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 EVShieldI2C
| EVShieldI2C (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=(uint8_t) NULL, uint8_t sdaPin=(uint8_t) 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 EVShieldI2C
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 EVShield.

## Constructor & Destructor Documentation

## § EVs_LineLeader()

EVs_LineLeader::EVs_LineLeader | ( | uint8_t | i2c_address = `0x02` | ) |

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

## Member Function Documentation

## § calibrateBlack()

bool EVs_LineLeader::calibrateBlack | ( |  | ) |

calibrate the current input to the device as black

## § calibrateWhite()

bool EVs_LineLeader::calibrateWhite | ( |  | ) |

calibrate the current input to the device as white

## § configureEurope()

bool EVs_LineLeader::configureEurope | ( |  | ) |

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

## § configureUniversal()

bool EVs_LineLeader::configureUniversal | ( |  | ) |

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

## § configureUS()

bool EVs_LineLeader::configureUS | ( |  | ) |

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

## § getAverage()

unsigned char EVs_LineLeader::getAverage | ( |  | ) |

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

## § getBlackCalibration()

uint8_t * EVs_LineLeader::getBlackCalibration | ( |  | ) |

returns the current calibration of black

## § getBlackLimit()

uint8_t * EVs_LineLeader::getBlackLimit | ( |  | ) |

get the limit at which black changes to white

## § getKd()

uint8_t EVs_LineLeader::getKd | ( | uint8_t | kd | ) |

get the current derivative factor for PID control

## § getKdFactor()

uint8_t EVs_LineLeader::getKdFactor | ( | uint8_t | kdfact | ) |

Get the Kd factor

Returns
  kd factor

## § getKi()

uint8_t EVs_LineLeader::getKi | ( | uint8_t | ki | ) |

get the current integral factor for PID control

## § getKiFactor()

uint8_t EVs_LineLeader::getKiFactor | ( | uint8_t | kifact | ) |

Get the Ki factor

Returns
  ki factor

## § getKp()

uint8_t EVs_LineLeader::getKp | ( | uint8_t | kp | ) |

get the current proportion factor for PID control

## § getKpFactor()

uint8_t EVs_LineLeader::getKpFactor | ( | uint8_t | kpfact | ) |

Get the Kp factor

Returns
  kp factor

## § getRawCalibrated()

uint8_t * EVs_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.

## § getRawUncalibrated()

uint8_t * EVs_LineLeader::getRawUncalibrated | ( |  | ) |

get the raw uncalibrated sensor values straight from the sensor

Returns
  array of 8 bytes of the sensors' uncalibrated values.

## § getResult()

unsigned char EVs_LineLeader::getResult | ( |  | ) |

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

## § getSetPoint()

uint8_t EVs_LineLeader::getSetPoint | ( |  | ) |

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

## § getSteering()

int EVs_LineLeader::getSteering | ( |  | ) |

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

## § getWhiteCalibration()

uint8_t * EVs_LineLeader::getWhiteCalibration | ( |  | ) |

returns the current calibration of white

## § getWhiteLimit()

uint8_t * EVs_LineLeader::getWhiteLimit | ( |  | ) |

get the limit at which white changes to black

## § invertLineColorToWhite()

bool EVs_LineLeader::invertLineColorToWhite | ( |  | ) |

Color inversion (White line on a black background)

## § issueCommand()

uint8_t EVs_LineLeader::issueCommand | ( | char | command | ) |

write a command byte to the command register of the device

## § resetColorInversion()

bool EVs_LineLeader::resetColorInversion | ( |  | ) |

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

## § setKd()

bool EVs_LineLeader::setKd | ( | uint8_t | kd | ) |

set the derivative factor for PID control

## § setKdFactor()

bool EVs_LineLeader::setKdFactor | ( | uint8_t | kdfact | ) |

Set the Kd factor

## § setKi()

bool EVs_LineLeader::setKi | ( | uint8_t | ki | ) |

set the integral factor for PID control

## § setKiFactor()

bool EVs_LineLeader::setKiFactor | ( | uint8_t | kifact | ) |

Set the Ki factor

## § setKp()

bool EVs_LineLeader::setKp | ( | uint8_t | kp | ) |

set the proportion factor for PID control

## § setKpFactor()

bool EVs_LineLeader::setKpFactor | ( | uint8_t | kpfact | ) |

Set the Kp factor

## § setSetPoint()

bool EVs_LineLeader::setSetPoint | ( | uint8_t | spoint | ) |

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

## § sleep()

bool EVs_LineLeader::sleep | ( |  | ) |

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

## § takeSnapshot()

bool EVs_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).

## § wakeUp()

bool EVs_LineLeader::wakeUp | ( |  | ) |

turn on the LEDs and wake up the device

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

- C:/Program Files (x86)/Arduino-1.6.12/libraries/EVShield/EVs_LineLeader.h
- C:/Program Files (x86)/Arduino-1.6.12/libraries/EVShield/EVs_LineLeader.cpp