MatrixMiniR4 1.1.9
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MatrixColor Class Reference

Class for interacting with a color sensor. More...

#include <MiniR4ColorSensorExt.h>

Public Member Functions

bool begin ()
 Initializes the color sensor.
 
void setGamma (bool state)
 Sets the gamma correction state for the sensor.
 
void setLight (bool state, bool mode, uint8_t pwm)
 Sets the light state and mode for the sensor.
 
uint8_t getColor (ColorType color)
 Gets the value of a specific color from the sensor.
 
uint8_t getGrayscale ()
 Gets the grayscale value from the sensor.
 
uint8_t getColorNumber_Deprecated ()
 (Deprecated) Gets the number of colors supported by the sensor. Number of color as follow as below: 0:Black, 1:White, 2:Cyan, 3:Ocean, 4:Blue, 5:Violet, 6:Magenta 7:Raspberry, 8:Red, 9:Orange, 10:Yellow, 11:Spring, 12:Green, 13:Turquoise
 
float getH ()
 Getting Hue value (色相) from color sensor.
 
float getS ()
 Getting Saturation value (飽和度) from color sensor.
 
float getV ()
 Getting Value/Brightness (明度) from color sensor.
 
int8_t getColorID ()
 Get Color ID for easy color recognition.
 
void RGB2HSV (uint8_t r, uint8_t g, uint8_t b, float &h, float &s, float &v)
 A method to convert RGB to HSV.
 

Public Attributes

uint8_t _ch = 0
 
TwoWire * _pWire
 

Detailed Description

Class for interacting with a color sensor.

This class provides methods to initialize the sensor, configure settings, and retrieve color values from the sensor.

Definition at line 47 of file MiniR4ColorSensorExt.h.

Member Function Documentation

◆ begin()

bool MatrixColor::begin ( )

Initializes the color sensor.

Returns
true if initialization was successful, false otherwise.

Definition at line 8 of file MiniR4ColorSensorExt.cpp.

◆ getColor()

uint8_t MatrixColor::getColor ( ColorType color)

Gets the value of a specific color from the sensor.

Parameters
colorThe color type to retrieve.
Returns
The value of the specified color.

Definition at line 53 of file MiniR4ColorSensorExt.cpp.

◆ getColorID()

int8_t MatrixColor::getColorID ( )

Get Color ID for easy color recognition.

Returns
Color ID: -1 = No color (too dark or sensor error), 0 = Black (Not easy to detect), 1 = Violet, 3 = Blue, 4 = Light Blue (Cyan), 6 = Green, 7 = Yellow, 9 = Red, 10 = White,

Definition at line 131 of file MiniR4ColorSensorExt.cpp.

◆ getColorNumber_Deprecated()

uint8_t MatrixColor::getColorNumber_Deprecated ( )

(Deprecated) Gets the number of colors supported by the sensor. Number of color as follow as below: 0:Black, 1:White, 2:Cyan, 3:Ocean, 4:Blue, 5:Violet, 6:Magenta 7:Raspberry, 8:Red, 9:Orange, 10:Yellow, 11:Spring, 12:Green, 13:Turquoise

Returns
The number of color values.

Definition at line 65 of file MiniR4ColorSensorExt.cpp.

◆ getGrayscale()

uint8_t MatrixColor::getGrayscale ( )

Gets the grayscale value from the sensor.

Returns
The grayscale value.

Definition at line 60 of file MiniR4ColorSensorExt.cpp.

◆ getH()

float MatrixColor::getH ( )

Getting Hue value (色相) from color sensor.

Returns
Hue value (0-360 degrees).

Definition at line 116 of file MiniR4ColorSensorExt.cpp.

◆ getS()

float MatrixColor::getS ( )

Getting Saturation value (飽和度) from color sensor.

Returns
Saturation percentage (0-100%).

Definition at line 121 of file MiniR4ColorSensorExt.cpp.

◆ getV()

float MatrixColor::getV ( )

Getting Value/Brightness (明度) from color sensor.

Returns
Value percentage (0-100%).

Definition at line 126 of file MiniR4ColorSensorExt.cpp.

◆ RGB2HSV()

void MatrixColor::RGB2HSV ( uint8_t r,
uint8_t g,
uint8_t b,
float & h,
float & s,
float & v )

A method to convert RGB to HSV.

Parameters
rRed value (0-255)
gGreen value (0-255)
bBlue value (0-255)
hHue output (0-360 degrees)
sSaturation output (0-100%)
vValue output (0-100%)

Definition at line 71 of file MiniR4ColorSensorExt.cpp.

◆ setGamma()

void MatrixColor::setGamma ( bool state)

Sets the gamma correction state for the sensor.

Parameters
statetrue to enable gamma correction, false to disable it.

Definition at line 23 of file MiniR4ColorSensorExt.cpp.

◆ setLight()

void MatrixColor::setLight ( bool state,
bool mode,
uint8_t pwm )

Sets the light state and mode for the sensor.

Parameters
statetrue to turn on the light, false to turn it off.
modeThe mode of the light (e.g., PWM).
pwmThe PWM value to set the light brightness.

Definition at line 34 of file MiniR4ColorSensorExt.cpp.

Member Data Documentation

◆ _ch

uint8_t MatrixColor::_ch = 0

Definition at line 80 of file MiniR4ColorSensorExt.h.

◆ _pWire

TwoWire* MatrixColor::_pWire

Definition at line 81 of file MiniR4ColorSensorExt.h.


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