1 #ifndef _ADAFRUIT_IS31FL3741_H_ 2 #define _ADAFRUIT_IS31FL3741_H_ 4 #include <Adafruit_BusIO_Register.h> 5 #include <Adafruit_GFX.h> 6 #include <Adafruit_I2CDevice.h> 9 #define IS3741_ADDR_DEFAULT 0x30 11 #define IS3741_COMMANDREGISTER 0xFD 12 #define IS3741_COMMANDREGISTERLOCK 0xFE 13 #define IS3741_INTMASKREGISTER 0xF0 14 #define IS3741_INTSTATUSREGISTER 0xF1 15 #define IS3741_IDREGISTER 0xFC 17 #define IS3741_FUNCREG_CONFIG 0x00 18 #define IS3741_FUNCREG_GCURRENT 0x01 19 #define IS3741_FUNCREG_RESET 0x3F 24 IS3741_RGB = ((0 << 4) | (1 << 2) | (2)),
25 IS3741_RBG = ((0 << 4) | (2 << 2) | (1)),
26 IS3741_GRB = ((1 << 4) | (0 << 2) | (2)),
27 IS3741_GBR = ((2 << 4) | (0 << 2) | (1)),
28 IS3741_BRG = ((1 << 4) | (2 << 2) | (0)),
29 IS3741_BGR = ((2 << 4) | (1 << 2) | (0)),
33 static const uint8_t PROGMEM _IS31GammaTable[256] = {
34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
36 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3,
37 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6,
38 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
39 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17,
40 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
41 25, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35,
42 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 48,
43 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
44 64, 65, 66, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81,
45 82, 84, 85, 86, 88, 89, 90, 92, 93, 94, 96, 97, 99, 100, 102,
46 103, 105, 106, 108, 109, 111, 112, 114, 115, 117, 119, 120, 122, 124, 125,
47 127, 129, 130, 132, 134, 136, 137, 139, 141, 143, 145, 146, 148, 150, 152,
48 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182,
49 184, 186, 188, 191, 193, 195, 197, 199, 202, 204, 206, 209, 211, 213, 215,
50 218, 220, 223, 225, 227, 230, 232, 235, 237, 240, 242, 245, 247, 250, 252,
70 bool begin(uint8_t addr = IS3741_ADDR_DEFAULT, TwoWire *theWire = &Wire);
82 bool setLEDPWM(uint16_t lednum, uint8_t pwm);
83 bool fill(uint8_t fillpwm = 0);
114 static uint16_t
color565(uint8_t red, uint8_t green, uint8_t blue) {
115 return ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | (blue >> 3);
125 return ((color >> 8) & 0xF800) | ((color >> 5) & 0x07E0) |
126 ((color >> 3) & 0x001F);
140 static uint32_t
Color(uint8_t r, uint8_t g, uint8_t b) {
141 return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
157 return pgm_read_byte(&_IS31GammaTable[x]);
161 static uint32_t
gamma32(uint32_t x);
162 static uint32_t
ColorHSV(uint16_t hue, uint8_t sat = 255, uint8_t val = 255);
166 bool setLEDvalue(uint8_t first_page, uint16_t lednum, uint8_t value);
186 bool begin(uint8_t addr = IS3741_ADDR_DEFAULT, TwoWire *theWire = &Wire);
215 : rOffset((order >> 4) & 3), gOffset((order >> 2) & 3),
216 bOffset(order & 3) {}
234 public Adafruit_GFX {
246 void fill(uint16_t color = 0);
261 public Adafruit_GFX {
273 void fill(uint16_t color = 0);
308 void drawPixel(int16_t x, int16_t y, uint16_t color);
327 void drawPixel(int16_t x, int16_t y, uint16_t color);
346 void drawPixel(int16_t x, int16_t y, uint16_t color);
364 void drawPixel(int16_t x, int16_t y, uint16_t color);
400 uint16_t _brightness = 256;
420 void setPixelColor(int16_t n, uint32_t color);
421 void setPixelColor(int16_t n, uint8_t t, uint8_t g, uint8_t b);
422 void fill(uint32_t color);
423 void fill(uint8_t r, uint8_t g, uint8_t b);
441 void setPixelColor(int16_t n, uint32_t color);
442 void setPixelColor(int16_t n, uint8_t r, uint8_t g, uint8_t b);
443 void fill(uint32_t color);
444 void fill(uint8_t r, uint8_t g, uint8_t b);
464 canvas =
new GFXcanvas16(18 * 3, 5 * 3);
473 GFXcanvas16 *canvas = NULL;
496 right_ring(this, true) {}
497 void drawPixel(int16_t x, int16_t y, uint16_t color);
522 IS3741_order order = IS3741_BGR)
525 left_ring(this, false), right_ring(this, true) {}
526 void drawPixel(int16_t x, int16_t y, uint16_t color);
552 : Adafruit_GFX(18, 5), _is31(controller) {}
553 void drawPixel(int16_t x, int16_t y, uint16_t color);
572 void setPixelColor(int16_t n, uint32_t color);
573 void fill(uint32_t color);
590 uint16_t _brightness = 256;
643 void drawPixel(int16_t x, int16_t y, uint16_t color);
653 GFXcanvas16 *canvas = NULL;
670 void setPixelColor(int16_t n, uint32_t color);
671 void fill(uint32_t color);
688 uint16_t _brightness = 256;
734 #endif // _ADAFRUIT_IS31FL3741_H_ Adafruit_IS31FL3741()
Constructor for IS31FL3741 LED driver.
Definition: Adafruit_IS31FL3741.h:69
uint8_t numPixels(void) const
Return number of LEDs in ring (a la NeoPixel)
Definition: Adafruit_IS31FL3741.h:389
Adafruit_IS31FL3741_EVB_buffered(IS3741_order order=IS3741_BGR)
Constructor for Lumissil IS31FL3741 OEM evaluation board, 13x9 pixels, buffered.
Definition: Adafruit_IS31FL3741.h:325
bool unlock(void)
Allows changing of command register by writing 0xC5 to 0xFE.
Definition: Adafruit_IS31FL3741.cpp:152
void setBrightness(uint8_t b)
Set brightness of LED ring. This is a mathematical brightness scale applied to setPixel() colors when...
Definition: Adafruit_IS31FL3741.h:397
bool selectPage(uint8_t page)
Select a given bank/page in the chip memory for subsequent reads/writes.
Definition: Adafruit_IS31FL3741.cpp:167
Base class for EyeLights LED glasses. Holds a few items that are common to direct or buffered instanc...
Definition: Adafruit_IS31FL3741.h:453
const uint16_t * ring_map
Pointer to LED index lookup table.
Definition: Adafruit_IS31FL3741.h:402
Class for Lumissil IS31FL3741 LED driver. This is the base class upon which the rest of this code bui...
Definition: Adafruit_IS31FL3741.h:64
Class for Adafruit LED Glasses (matrix portion) with LED data being buffered on the microcontroller a...
Definition: Adafruit_IS31FL3741.h:639
uint8_t getGlobalCurrent(void)
Get the global current-mirror register setting.
Definition: Adafruit_IS31FL3741.cpp:139
Adafruit_IS31FL3741_ColorOrder(IS3741_order order)
Constructor for Adafruit_IS31FL3741_ColorOrder.
Definition: Adafruit_IS31FL3741.h:214
Adafruit_EyeLights(bool withCanvas=false, IS3741_order order=IS3741_BGR)
Constructor for Adafruit_EyeLights object.
Definition: Adafruit_IS31FL3741.h:493
Adafruit_IS31FL3741_EVB(IS3741_order order=IS3741_BGR)
Constructor for Lumissil IS31FL3741 OEM evaluation board, 13x9 pixels, direct (unbuffered).
Definition: Adafruit_IS31FL3741.h:306
Class for buffered EyeLights LED ring, left or right.
Definition: Adafruit_IS31FL3741.h:431
const uint16_t * ring_map
Pointer to lookup table.
Definition: Adafruit_IS31FL3741.h:689
static uint32_t ColorHSV(uint16_t hue, uint8_t sat=255, uint8_t val=255)
Convert hue, saturation and value into a packed 32-bit RGB color that can be passed to setPixelColor(...
Definition: Adafruit_IS31FL3741.cpp:333
Class for a "buffered" Lumissil IS31FL3741 LED driver – LED PWM state is staged in RAM (requiring 35...
Definition: Adafruit_IS31FL3741.h:183
Adafruit_EyeLights_Ring right_ring
Right LED ring object.
Definition: Adafruit_IS31FL3741.h:500
bool reset(void)
Perform software reset, update all registers to POR values.
Definition: Adafruit_IS31FL3741.cpp:96
Class for Lumissil IS31FL3741 Glasses (left ring) with LED data being buffered on the microcontroller...
Definition: Adafruit_IS31FL3741.h:701
void setBrightness(uint8_t b)
Set brightness of LED ring. This is a mathematical brightness scale applied to setPixel() colors when...
Definition: Adafruit_IS31FL3741.h:586
bool begin(uint8_t addr=IS3741_ADDR_DEFAULT, TwoWire *theWire=&Wire)
Initialize I2C and IS31FL3741 hardware.
Definition: Adafruit_IS31FL3741.cpp:71
Class for Adafruit LED Glasses (ring portion). Not used by user code directly, the left and right cla...
Definition: Adafruit_IS31FL3741.h:568
uint8_t rOffset
Index of red element within RGB triplet.
Definition: Adafruit_IS31FL3741.h:217
Adafruit_EyeLights_Ring left_ring
Left LED ring object.
Definition: Adafruit_IS31FL3741.h:499
Class for Adafruit EyeLights, buffered.
Definition: Adafruit_IS31FL3741.h:508
Class for Adafruit EyeLights, direct (unbuffered).
Definition: Adafruit_IS31FL3741.h:481
Adafruit_IS31FL3741_GlassesRightRing(Adafruit_IS31FL3741 *controller)
Constructor for glasses right LED ring.
Definition: Adafruit_IS31FL3741.h:626
Adafruit_IS31FL3741_buffered * _is31
Pointer to core object.
Definition: Adafruit_IS31FL3741.h:652
Adafruit_IS31FL3741_GlassesLeftRing(Adafruit_IS31FL3741 *controller)
Constructor for glasses left LED ring.
Definition: Adafruit_IS31FL3741.h:608
Adafruit_EyeLights_Ring_buffered right_ring
Right LED ring object.
Definition: Adafruit_IS31FL3741.h:529
Class for IS31FL3741 Adafruit STEMMA QT board, direct (unbuffered).
Definition: Adafruit_IS31FL3741.h:336
GFXcanvas16 * getCanvas(void) const
Get pointer to GFX canvas for smooth drawing.
Definition: Adafruit_IS31FL3741.h:649
Class for Adafruit LED Glasses (left ring).
Definition: Adafruit_IS31FL3741.h:601
bool setLEDscaling(uint16_t lednum, uint8_t scale)
Set the scaling level for a single LED.
Definition: Adafruit_IS31FL3741.cpp:266
bool fillTwoPages(uint8_t first_page, uint8_t value)
Fill two pages of IS31FL3741 registers related to PWM levels or scaling; used by the fill() and setLE...
Definition: Adafruit_IS31FL3741.cpp:225
bool setLEDPWM(uint16_t lednum, uint8_t pwm)
Set the PWM level for a single LED.
Definition: Adafruit_IS31FL3741.cpp:294
uint8_t bOffset
Index of blue element within RGB triplet.
Definition: Adafruit_IS31FL3741.h:219
Class for IS31FL3741 Adafruit STEMMA QT board, buffered.
Definition: Adafruit_IS31FL3741.h:354
Adafruit_IS31FL3741_QT_buffered(IS3741_order order=IS3741_BGR)
Constructor for STEMMA QT version (13 x 9 LEDs), buffered.
Definition: Adafruit_IS31FL3741.h:362
const uint16_t * ring_map
Pointer to lookup table.
Definition: Adafruit_IS31FL3741.h:591
void setBrightness(uint8_t b)
Set brightness of LED ring. This is a mathematical brightness scale applied to setPixel() colors when...
Definition: Adafruit_IS31FL3741.h:684
uint8_t numPixels(void) const
Return number of LEDs in ring (a la NeoPixel)
Definition: Adafruit_IS31FL3741.h:578
GFXcanvas16 * getCanvas(void) const
Get pointer to GFX canvas for smooth drawing.
Definition: Adafruit_IS31FL3741.h:470
Adafruit_EyeLights_buffered(bool withCanvas=false, IS3741_order order=IS3741_BGR)
Constructor for Adafruit_EyeLights_buffered object.
Definition: Adafruit_IS31FL3741.h:521
Adafruit_IS31FL3741_QT(IS3741_order order=IS3741_BGR)
Constructor for STEMMA QT version (13 x 9 LEDs), direct (unbuffered).
Definition: Adafruit_IS31FL3741.h:344
Class for Adafruit LED Glasses (right ring) with LED data being buffered on the microcontroller and s...
Definition: Adafruit_IS31FL3741.h:722
Adafruit_I2CDevice * _i2c_dev
Pointer to I2C device.
Definition: Adafruit_IS31FL3741.h:170
void * parent
Pointer back to EyeLights object.
Definition: Adafruit_IS31FL3741.h:401
uint8_t numPixels(void) const
Return number of LEDs in ring (a la NeoPixel)
Definition: Adafruit_IS31FL3741.h:676
Class for specifying RGB byte sequence order when above classes are used with RGB LEDs...
Definition: Adafruit_IS31FL3741.h:208
Adafruit_EyeLights_Ring(void *parent, bool isRight)
Constructor for one of the EyeLights ring objects (direct, unbuffered). Used internally by the librar...
Definition: Adafruit_IS31FL3741.h:418
Base class for EyeLights LED ring. Holds a few items that are common to direct or buffered instances...
Definition: Adafruit_IS31FL3741.h:382
static uint16_t color565(uint32_t color)
Converter for RGB888-format color (packed) to RGB565-format.
Definition: Adafruit_IS31FL3741.h:124
Class for Lumissil IS31FL3741 OEM evaluation board, direct (unbuffered).
Definition: Adafruit_IS31FL3741.h:298
Class for Adafruit LED Glasses (matrix portion).
Definition: Adafruit_IS31FL3741.h:545
static uint32_t gamma32(uint32_t x)
A gamma-correction function for 32-bit packed RGB colors. Makes color transitions appear more percept...
Definition: Adafruit_IS31FL3741.cpp:422
static uint32_t Color(uint8_t r, uint8_t g, uint8_t b)
Convert separate red, green and blue values into a single "packed" 24-bit RGB color.
Definition: Adafruit_IS31FL3741.h:140
Adafruit_EyeLights_Base(bool withCanvas)
Constructor for Adafruit_EyeLights_Base object. This is used internally by the library, not user code.
Definition: Adafruit_IS31FL3741.h:462
Class for direct (unbuffered) EyeLights LED ring, left or right.
Definition: Adafruit_IS31FL3741.h:410
Adafruit_EyeLights_Ring_buffered left_ring
Left LED ring object.
Definition: Adafruit_IS31FL3741.h:528
static uint8_t gamma8(uint8_t x)
An 8-bit gamma-correction function for basic pixel brightness adjustment. Makes color transitions app...
Definition: Adafruit_IS31FL3741.h:156
Class encapsulating a buffered IS31FL3741, ColorOrder and GFX all in one – mostly so a common fill()...
Definition: Adafruit_IS31FL3741.h:258
Adafruit_IS31FL3741_GlassesRightRing_buffered(Adafruit_IS31FL3741_buffered *controller)
Constructor for buffered glasses right LED ring.
Definition: Adafruit_IS31FL3741.h:729
bool fill(uint8_t fillpwm=0)
Set the PWM value for all LEDs - great for clearing the whole display at once. Optimized for fewer I2...
Definition: Adafruit_IS31FL3741.cpp:307
Class for Adafruit LED Glasses (right ring).
Definition: Adafruit_IS31FL3741.h:619
Class for Lumissil IS31FL3741 OEM evaluation board, buffered.
Definition: Adafruit_IS31FL3741.h:316
Adafruit_IS31FL3741_GlassesLeftRing_buffered(Adafruit_IS31FL3741_buffered *controller)
Constructor for buffered glasses left LED ring.
Definition: Adafruit_IS31FL3741.h:708
Adafruit_EyeLights_Ring_buffered(void *parent, bool isRight)
Constructor for one of the EyeLights ring objects (buffered). Used internally by the library...
Definition: Adafruit_IS31FL3741.h:439
Class encapsulating a direct (unbuffered) IS31FL3741, ColorOrder and GFX all in one – mostly so a co...
Definition: Adafruit_IS31FL3741.h:232
bool enable(bool en)
Enable/disable output via the shutdown register bit.
Definition: Adafruit_IS31FL3741.cpp:110
Class for Adafruit LED Glasses (ring portion) with LED data being buffered on the microcontroller and...
Definition: Adafruit_IS31FL3741.h:666
uint8_t * getBuffer(void)
Return address of LED buffer.
Definition: Adafruit_IS31FL3741.h:192
bool setLEDvalue(uint8_t first_page, uint16_t lednum, uint8_t value)
Set either the PWM or scaling level for a single LED; used by the setLEDPWM() and setLEDscaling() fun...
Definition: Adafruit_IS31FL3741.cpp:197
uint8_t gOffset
Index of green element within RGB triplet.
Definition: Adafruit_IS31FL3741.h:218
void show(void)
Empty function makes direct & buffered code more interchangeable. Direct classes have an immediate effect...
Definition: Adafruit_IS31FL3741.h:93
int8_t _page
Cached value of the page we're currently addressing.
Definition: Adafruit_IS31FL3741.h:169
Adafruit_IS31FL3741_GlassesMatrix(Adafruit_IS31FL3741 *controller)
Constructor for LED glasses (matrix portion, 18x5 LEDs)
Definition: Adafruit_IS31FL3741.h:551
bool setGlobalCurrent(uint8_t current)
Set global current-mirror from 0 (off) to 255 (brightest).
Definition: Adafruit_IS31FL3741.cpp:126
static uint16_t color565(uint8_t red, uint8_t green, uint8_t blue)
Converter for RGB888-format color (separate) to RGB565-format.
Definition: Adafruit_IS31FL3741.h:114