MatrixMiniR4 1.1.4
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MiniR4ColorSensorExt.h
Go to the documentation of this file.
1
7#ifndef _MiniR4ColorSensorExt_H_
8#define _MiniR4ColorSensorExt_H_
9
10#include <Arduino.h>
11#include <Wire.h>
12
13#ifndef ADDR_PCA954X
14# define ADDR_PCA954X 0x70
15#endif
16
17#define MatrixColor_ADDR 0x22
18
19typedef enum __ColorType
20{
21 R = 4,
27 K
29
37{
38private:
39 typedef enum __ColorRegType
40 {
41 Device_ID = 1,
42 Device_CONFIG,
43 Device_LIGHT,
44 Device_RED,
45 Device_GREEN,
46 Device_BLUE,
47 Device_CYAN,
48 Device_MAGENTA,
49 Device_YELLOW,
50 Device_BLACK,
51 Device_GRAY,
52 Device_NUM_COLOR
53 } ColorRegType;
54
55 uint8_t setting = 0x0F;
56 uint8_t i2cReadData(ColorRegType reg);
57 void i2cMUXSelect();
58 void i2cWriteData(ColorRegType reg, uint8_t data);
59
60public:
61 uint8_t _ch = 0;
62 TwoWire* _pWire;
63
69 bool begin();
70
76 void setGamma(bool state);
77
85 void setLight(bool state, bool mode, uint8_t pwm);
86
93 uint8_t getColor(ColorType color);
94
100 uint8_t getGrayscale();
101
109 uint8_t getColorNumber();
110};
111
112#endif
enum __ColorType ColorType
Class for interacting with a color sensor.
uint8_t getColorNumber()
Gets the number of colors supported by the sensor. Number of color as follow as below: 0:Black,...
bool begin()
Initializes the color sensor.
uint8_t getGrayscale()
Gets the grayscale value from the sensor.
uint8_t getColor(ColorType color)
Gets the value of a specific color from the sensor.
void setLight(bool state, bool mode, uint8_t pwm)
Sets the light state and mode for the sensor.
void setGamma(bool state)
Sets the gamma correction state for the sensor.