MakeBlock Drive Updated Updated library for MakeBlock Ranger

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
MeColorSensor Class Reference

Driver for MeColorSensor module. More...

Inheritance diagram for MeColorSensor:
[legend]
Collaboration diagram for MeColorSensor:
[legend]

## Public Member Functions
| MeColorSensor (void)
| MeColorSensor (uint8_t port)
| MeColorSensor (uint8_t port, uint8_t address)
void | SensorInit (void)
uint8_t | ReportId (void)
void | ColorDataRead (void)
uint8_t | ColorDataReadOnebyOne (void)
long | ReturnColorCode (void)
uint8_t | ColorIdentify (void)
uint8_t | Returnresult (void)
uint8_t | ReturnGrayscale (void)
uint16_t | ReturnColorhue (void)
uint16_t | ReturnRedData (void)
uint16_t | ReturnGreenData (void)
uint16_t | ReturnBlueData (void)
uint16_t | ReturnColorData (void)
void | TurnOnLight (void)
void | TurnOffLight (void)
void | TurnOffmodule (void)
void | TurnOnmodule (void)
int8_t | writeReg (int16_t reg, uint8_t data)
int8_t | readData (uint8_t start, uint8_t *buffer, uint8_t size)
int8_t | writeData (uint8_t start, const uint8_t *pData, uint8_t size)
uint8_t | MAX (uint8_t r, uint8_t g, uint8_t b)
uint8_t | MIN (uint8_t r, uint8_t g, uint8_t b)
Public Member Functions inherited from MePort
| MePort (void)
| MePort (uint8_t port)
| MePort (uint8_t port, uint8_t slot)
uint8_t | getPort (void)
uint8_t | getSlot (void)
bool | dRead1 (uint8_t mode=INPUT)
bool | dRead2 (uint8_t mode=INPUT)
bool | dpRead1 (void)
bool | dpRead2 (void)
void | dWrite1 (bool value)
void | dWrite2 (bool value)
int16_t | aRead1 (void)
int16_t | aRead2 (void)
void | aWrite1 (int16_t value)
void | aWrite2 (int16_t value)
void | reset (uint8_t port)
void | reset (uint8_t port, uint8_t slot)
uint8_t | pin1 (void)
uint8_t | pin2 (void)
uint8_t | pin (void)
uint8_t | pin (uint8_t port, uint8_t slot)

## Public Attributes
uint8_t | Device_Address

## Additional Inherited Members
Protected Attributes inherited from MePort
uint8_t | s1
uint8_t | s2
uint8_t | _port
uint8_t | _slot

## Detailed Description

Driver for MeColorSensor module.

Copyright (C), 2012-2017, MakeBlock

## Constructor & Destructor Documentation

## ◆ MeColorSensor() [1/3]

MeColorSensor::MeColorSensor | ( | void |  | ) |

Alternate Constructor which can call your own function to map the MeColorSensor to arduino port, no pins are used or initialized here

## ◆ MeColorSensor() [2/3]

MeColorSensor::MeColorSensor | ( | uint8_t | port | ) |

Alternate Constructor which can call your own function to map the MeColorSensor to arduino port.

Parameters

  [in] | port | - RJ25 port number

Alternate Constructor which can call your own function to map the MeColorSensor to arduino port,

Parameters

  [in] | port | - RJ25 port number

## ◆ MeColorSensor() [3/3]

MeColorSensor::MeColorSensor | ( | uint8_t | port,
|  | uint8_t | address
| ) |  |

Alternate Constructor which can call your own function to map the MeColorSensor to arduino port and change the i2c device address

Parameters

  [in] | port | - RJ25 port number
  [in] | address | - the i2c address you want to set

## Member Function Documentation

## ◆ ColorDataRead()

void MeColorSensor::ColorDataRead | ( | void |  | ) |

Function
  ColorDataRead

Description
  read the MeColorSensor module color data.

Parameters

  [in] | None |

Output
  color RGB value

Returns
  None

Others
  None

## ◆ ColorDataReadOnebyOne()

uint8_t MeColorSensor::ColorDataReadOnebyOne | ( | void |  | ) |

Function
  ColorDataReadOnebyOne

Description
  one by on to read the MeColorSensor module color data.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ColorDataReadOnebyOne

Description
  one by on to read the MeColorSensor module color data.

Parameters

  [in] | None |

Output
  None

Returns
  return 0 is detected ID,else return Black

Others
  None

## ◆ ColorIdentify()

uint8_t MeColorSensor::ColorIdentify | ( | void |  | ) |

Function
  ColorIdentify

Description
  Identify Color for the Module.when you want to use two modules, you can use this methods to get data.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ColorIdentify

Description
  Identify Color for the Module.when you want to use two modules, you can use this methods to get data.

Parameters

  [in] | None |

Output
  None

Returns
  return Color result

Others
  None

## ◆ MAX()

uint8_t MeColorSensor::MAX | ( | uint8_t | r,
|  | uint8_t | g,
|  | uint8_t | b
| ) |  |

Function
  MAX

Description
  find the max one from r g b.

Parameters

  [in] | r | g b

Output
  None

Returns
  Return the max one.

Others

## ◆ MIN()

uint8_t MeColorSensor::MIN | ( | uint8_t | r,
|  | uint8_t | g,
|  | uint8_t | b
| ) |  |

Function
  MIN

Description
  find the min one from r g b.

Parameters

  [in] | r | g b

Output
  None

Returns
  Return the min one.

Others

## ◆ readData()

int8_t MeColorSensor::readData | ( | uint8_t | start,
|  | uint8_t * | buffer,
|  | uint8_t | size
| ) |  |

Function
  readData

Description
  Write the data to i2c device.

Parameters

  [in] | start | - the address which will write the data to.
  [in] | pData | - the head address of data array.
  [in] | size | - set the number of data will be written to the devide.

Output
  None

Returns
  Return the error code. the definition of the value of variable return_value: 0:success 1:BUFFER_LENGTH is shorter than size 2:address send, nack received 3:data send, nack received 4:other twi error refer to the arduino official library twi.c

Others
  Calling the official i2c library to read data.

## ◆ ReportId()

uint8_t MeColorSensor::ReportId | ( | void |  | ) |

Function
  ReportId

Description
  Report the MeColorSensor Module ID.

Parameters

  [in] | None |

Output
  None

Returns
  default ID 0xE0

Others
  None

Function
  ReportId

Description
  Report the MeColorSensor Module ID.

Parameters

  [in] | None |

Output
  None

Returns
  return default ID 0xE0

Others
  None

## ◆ ReturnBlueData()

uint16_t MeColorSensor::ReturnBlueData | ( | void |  | ) |

Function
  ReturnBlueData

Description
  Return Color Blue value.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ReturnBlueData

Description
  Return Color Blue value.

Parameters

  [in] | None |

Output
  None

Returns
  return blue value

Others
  None

## ◆ ReturnColorCode()

long MeColorSensor::ReturnColorCode | ( | void |  | ) |

Function
  ReturnColorCode

Description
  Return the MeColorSensor Color Code.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ReturnColorCode

Description
  Return the MeColorSensor Color Code.

Parameters

  [in] | None |

Output
  None

Returns
  return color RGB code

Others
  None

## ◆ ReturnColorData()

uint16_t MeColorSensor::ReturnColorData | ( | void |  | ) |

Function
  ReturnColorData

Description
  Return Color data value.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ReturnColorData

Description
  Return Color data value.

Parameters

  [in] | None |

Output
  None

Returns
  return color data value

Others
  None

## ◆ ReturnColorhue()

uint16_t MeColorSensor::ReturnColorhue | ( | void |  | ) |

Function
  ReturnColorhue

Description
  Return Color hue.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ReturnColorhue

Description
  Return Color hue.

Parameters

  [in] | None |

Output
  None

Returns
  return color hue

Others
  None

## ◆ ReturnGrayscale()

uint8_t MeColorSensor::ReturnGrayscale | ( | void |  | ) |

Function
  ReturnGrayscale

Description
  Return Color Grayscale.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  Gray = R*0.299 + G*0.587 + B*0.114 Gray = (r*38 + g*75 + b*15)>>7;

Function
  ReturnGrayscale

Description
  Return Color Grayscale.

Parameters

  [in] | None |

Output
  None

Returns
  return Color Grayscale value

Others
  Gray = R*0.299 + G*0.587 + B*0.114 Gray = (r*38 + g*75 + b*15)>>7;

## ◆ ReturnGreenData()

uint16_t MeColorSensor::ReturnGreenData | ( | void |  | ) |

Function
  ReturnGreenData

Description
  Return Color Green value.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ReturnGreenData

Description
  Return Color Green value.

Parameters

  [in] | None |

Output
  None

Returns
  return green value

Others
  None

## ◆ ReturnRedData()

uint16_t MeColorSensor::ReturnRedData | ( | void |  | ) |

Function
  ReturnRedData

Description
  Return Color Red value.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  ReturnRedData

Description
  Return Color Red value.

Parameters

  [in] | None |

Output
  None

Returns
  return red value

Others
  None

## ◆ Returnresult()

uint8_t MeColorSensor::Returnresult | ( | void |  | ) |

Function
  Returnresult

Description
  Identify Color for the Module.when you use just one module, you can use this methods to get data.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

Function
  Returnresult

Description
  Identify Color for the Module.when you use just one module, you can use this methods to get data.

Parameters

  [in] | None |

Output
  None

Returns
  return color result

Others
  None

## ◆ SensorInit()

void MeColorSensor::SensorInit | ( | void |  | ) |

Function
  SensorInit

Description
  Initialize the MeColorSensor.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  You can check the bh1745 datasheet for the registor address.

## ◆ TurnOffLight()

void MeColorSensor::TurnOffLight | ( | void |  | ) |

Function
  TurnOffLight

Description
  Turn Off the MeColorSensor module Light.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

## ◆ TurnOffmodule()

void MeColorSensor::TurnOffmodule | ( | void |  | ) |

Function
  TurnOffmodule

Description
  Turn Off the MeColorSensor module.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

## ◆ TurnOnLight()

void MeColorSensor::TurnOnLight | ( | void |  | ) |

Function
  TurnOnLight

Description
  Turn On the MeColorSensor module Light.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

## ◆ TurnOnmodule()

void MeColorSensor::TurnOnmodule | ( | void |  | ) |

Function
  TurnOnmodule

Description
  Turn On the MeColorSensor module.

Parameters

  [in] | None |

Output
  None

Returns
  None

Others
  None

## ◆ writeData()

int8_t MeColorSensor::writeData | ( | uint8_t | start,
|  | const uint8_t * | pData,
|  | uint8_t | size
| ) |  |

Function
  writeData

Description
  Write the data to i2c device.

Parameters

  [in] | start | - the address which will write the data to.
  [in] | pData | - the head address of data array.
  [in] | size | - set the number of data will be written to the devide.

Output
  None

Returns
  Return the error code. the definition of the value of variable return_value: 0:success 1:BUFFER_LENGTH is shorter than size 2:address send, nack received 3:data send, nack received 4:other twi error refer to the arduino official library twi.c

Others
  Calling the official i2c library to write data.

## ◆ writeReg()

int8_t MeColorSensor::writeReg | ( | int16_t | reg,
|  | uint8_t | data
| ) |  |

Function
  writeReg

Description
  write the MeColorSensor module register.

Parameters

  [in] | None |

Output
  None

Returns
  Return the error code. the definition of the value of variable return_value: 0:success 1:BUFFER_LENGTH is shorter than size 2:address send, nack received 3:data send, nack received 4:other twi error refer to the arduino official library twi.c

Others
  To set the register for initializing.

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

- src/MeColorSensor.h
- src/MeColorSensor.cpp