MakeBlock Drive Updated Updated library for MakeBlock Ranger

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

Driver for W2812 full-color LED. More...

`#include <src/MeRGBLed.h>`

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

## Public Member Functions
| MeRGBLed (void)
| MeRGBLed (uint8_t port)
| MeRGBLed (uint8_t port, uint8_t led_num)
| MeRGBLed (uint8_t port, uint8_t slot, uint8_t led_num)
| ~MeRGBLed (void)
void | reset (uint8_t port)
void | reset (uint8_t port, uint8_t slot)
void | setpin (uint8_t port)
uint8_t | getNumber (void)
cRGB | getColorAt (uint8_t index)
void | fillPixelsBak (uint8_t red, uint8_t green, uint8_t blue)
bool | setColorAt (uint8_t index, uint8_t red, uint8_t green, uint8_t blue)
bool | setColor (uint8_t index, uint8_t red, uint8_t green, uint8_t blue)
bool | setColor (uint8_t red, uint8_t green, uint8_t blue)
bool | setColor (uint8_t index, long value)
void | setNumber (uint8_t num_led)
void | show (void)
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)

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

## Detailed Description

Driver for W2812 full-color LED.

Driver for W2812 full-color LED lights.

Class: MeRGBLed

Description
  Declaration of Class MeRGBLed

Copyright (C), 2014-2018, MakeBlock

## Constructor & Destructor Documentation

## ◆ MeRGBLed() [1/4]

MeRGBLed::MeRGBLed | ( | void |  | ) |

Alternate Constructor which can call your own function to map the MeRGBLed to arduino port, no pins are used or initialized here, it only assigned the LED display buffer. The default number of light strips is 32.

Parameters

  [in] | None |

## ◆ MeRGBLed() [2/4]

MeRGBLed::MeRGBLed | ( | uint8_t | port | ) |

Alternate Constructor which can call your own function to map the MeRGBLed to arduino port, it will assigned the LED display buffer and initialization the GPIO of LED lights. The slot2 will be used here, and the default number of light strips is 32.

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2

## ◆ MeRGBLed() [3/4]

MeRGBLed::MeRGBLed | ( | uint8_t | port,
|  | uint8_t | led_num
| ) |  |

Alternate Constructor which can call your own function to map the MeRGBLed to arduino port, it will assigned the LED display buffer and initialization the GPIO of LED lights. The slot2 will be used here, you can reset the LED number by this constructor.

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2
  [in] | led_num | - The LED number

## ◆ MeRGBLed() [4/4]

MeRGBLed::MeRGBLed | ( | uint8_t | port,
|  | uint8_t | slot,
|  | uint8_t | led_num
| ) |  |

Alternate Constructor which can call your own function to map the MeRGBLed to arduino port, it will assigned the LED display buffer and initialization the GPIO of LED lights. You can set any slot for the LED data PIN, and reset the LED number by this constructor.

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2
  [in] | slot | - SLOT1 or SLOT2
  [in] | led_num | - The LED number

## ◆ ~MeRGBLed()

MeRGBLed::~MeRGBLed | ( | void |  | ) |

Destructor which can call your own function, it will release the LED buffer

## Member Function Documentation

## ◆ fillPixelsBak()

void MeRGBLed::fillPixelsBak | ( | uint8_t | red,
|  | uint8_t | green,
|  | uint8_t | blue
| ) |  |

Function
  fillPixelsBak

Description
  fill the LED color data to pixels_bak.

Parameters

  [in] | red | - Red values
  [in] | green | - green values
  [in] | blue | - blue values

Output
  None

Returns
  None

Others
  None

## ◆ getColorAt()

cRGB MeRGBLed::getColorAt | ( | uint8_t | index | ) |

Function
  getColorAt

Description
  Get the LED color value from its index

Parameters

  [in] | index | - The LED index number you want to read its value

Output
  None

Returns
  The LED color value, include the R,G,B

Others
  The index value from 1 to the max

## ◆ getNumber()

uint8_t MeRGBLed::getNumber | ( | void |  | ) |

Function
  getNumber

Description
  Get the LED number you can light it.

Output
  None

Returns
  The total number of LED's

Others
  The index value from 1 to the max

## ◆ reset() [1/2]

void MeRGBLed::reset | ( | uint8_t | port | ) |

Function
  reset

Description
  Reset the LED available data PIN by its RJ25 port, and slot2 will be used as default.

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2

Output
  None

Returns
  None

Others
  None

## ◆ reset() [2/2]

void MeRGBLed::reset | ( | uint8_t | port,
|  | uint8_t | slot
| ) |  |

Function
  reset

Description
  Reset the LED available data PIN by its RJ25 port and slot.

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2
  [in] | slot | - SLOT1 or SLOT2

Output
  None

Returns
  None

Others
  None

## ◆ setColor() [1/3]

bool MeRGBLed::setColor | ( | uint8_t | index,
|  | long | value
| ) |  |

Function
  setColor

Description
  Set the LED color for any LED.

Parameters

  [in] | value | - the LED color defined as long type, for example (white) = 0xFFFFFF

Output
  None

Returns
  TRUE: Successful implementation FALSE: Wrong execution

Others
  The index value from 1 to the max, if you set the index 0, all the LED will be lit

## ◆ setColor() [2/3]

bool MeRGBLed::setColor | ( | uint8_t | index,
|  | uint8_t | red,
|  | uint8_t | green,
|  | uint8_t | blue
| ) |  |

Function
  setColor

Description
  Set the LED color for any LED.

Parameters

  [in] | index | - The LED index number you want to set its color
  [in] | red | - Red values
  [in] | green | - green values
  [in] | blue | - blue values

Output
  None

Returns
  TRUE: Successful implementation FALSE: Wrong execution

Others
  The index value from 1 to the max, if you set the index 0, all the LED will be lit

## ◆ setColor() [3/3]

bool MeRGBLed::setColor | ( | uint8_t | red,
|  | uint8_t | green,
|  | uint8_t | blue
| ) |  |

Function
  setColor

Description
  Set the LED color for all LED.

Parameters

  [in] | red | - Red values
  [in] | green | - green values
  [in] | blue | - blue values

Output
  None

Returns
  TRUE: Successful implementation FALSE: Wrong execution

Others
  All the LED will be lit.

## ◆ setColorAt()

bool MeRGBLed::setColorAt | ( | uint8_t | index,
|  | uint8_t | red,
|  | uint8_t | green,
|  | uint8_t | blue
| ) |  |

Function
  setColorAt

Description
  Set the LED color for any LED.

Parameters

  [in] | index | - The LED index number you want to set its color
  [in] | red | - Red values
  [in] | green | - green values
  [in] | blue | - blue values

Output
  None

Returns
  TRUE: Successful implementation FALSE: Wrong execution

Others
  The index value from 0 to the max.

## ◆ setNumber()

void MeRGBLed::setNumber | ( | uint8_t | num_leds | ) |

Function
  setNumber

Description
  Assigned the LED display buffer by the LED number

Parameters

  [in] | num_leds | - The LED number you used

Output
  None

Returns
  None

Others
  None

## ◆ setpin()

void MeRGBLed::setpin | ( | uint8_t | port | ) |

Function
  setpin

Description
  Reset the LED available data PIN by its arduino port.

Parameters

  [in] | port | - arduino port(should digital pin)

Output
  None

Returns
  None

Others
  None

## ◆ show()

void MeRGBLed::show | ( | void |  | ) |

Function
  show

Description
  Transmission the data to WS2812

Output
  None

Returns
  None

Others
  None

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

- src/MeRGBLed.h
- src/MeRGBLed.cpp