-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the library of the new LED Ring
- Loading branch information
1 parent
db9598d
commit 310f7d6
Showing
7 changed files
with
622 additions
and
83 deletions.
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
examples/RGB LED Ring Small/LEDRingSmall_Demo/LEDRingSmall_Demo.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
#include <Wire.h> | ||
#include "LEDRingSmall.h" | ||
|
||
/* | ||
Connections with Arduino UNO: | ||
- -> GND | ||
+ -> 5V | ||
SDA -> A4 | ||
SCL -> A5 | ||
INT -> A3 | ||
*/ | ||
const uint32_t fade1_table[24] = {0x8011EE, 0xA004DA, 0xBF00BF, 0xDA04A0, 0xEE1180, 0xFB255F, 0xFF4040, 0xFB5F25, 0xEE8011, 0xDAA004, 0xBFBF00, 0xA0DA04, 0x80EE11, 0x5FFB25, 0x40FF40, 0x25FB5F, 0x11EE80, 0x04DAA0, 0x00BFBF, 0x04A0DA, 0x1180EE, 0x255FFB, 0x4040FF, 0x5F25FB}; | ||
const uint32_t fade2_table[24] = {0xFF0000, 0xFF0004, 0xFF0020, 0xFF006B, 0xFF00FF, 0x6B00FF, 0x2000FF, 0x0400FF, 0x0000FF, 0x0004FF, 0x0020FF, 0x006BFF, 0x00FFFF, 0x00FF6B, 0x00FF20, 0x00FF04, 0x00FF00, 0x04FF00, 0x20FF00, 0x6BFF00, 0xFFFF00, 0xFF6B00, 0xFF2000, 0xFF0400}; | ||
static uint8_t j = 0; | ||
static uint8_t i = 0; | ||
static uint16_t tim = 0; | ||
static uint8_t r = 5, g = 8, b = 20, rg = 40, br = 35, bg = 17; | ||
|
||
LEDRingSmall LEDRingSmall(0x60); | ||
|
||
void setup(void) { | ||
|
||
Wire.begin(); | ||
Wire.setClock(400000); | ||
|
||
LEDRingSmall.LEDRingSmall_Reset(); | ||
delay(20); | ||
|
||
LEDRingSmall.LEDRingSmall_Configuration(0x01); //Normal operation | ||
LEDRingSmall.LEDRingSmall_PWMFrequencyEnable(1); | ||
LEDRingSmall.LEDRingSmall_SpreadSpectrum(0b0010110); | ||
LEDRingSmall.LEDRingSmall_GlobalCurrent(0x10); | ||
LEDRingSmall.LEDRingSmall_SetScaling(0xFF); | ||
LEDRingSmall.LEDRingSmall_PWM_MODE(); | ||
|
||
|
||
|
||
} | ||
|
||
void loop() { | ||
LEDRingSmall.LEDRingSmall_GlobalCurrent(0x10); | ||
LEDRingSmall.LEDRingSmall_PWM_MODE(); | ||
|
||
for (i = 0; i < 24; i++) { | ||
LEDRingSmall.LEDRingSmall_Set_RED(i, 0xff); | ||
delay(30); | ||
} | ||
|
||
for (i = 0; i < 24; i++) { | ||
LEDRingSmall.LEDRingSmall_Set_RED(i, 0); | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(i, 0xff); | ||
delay(30); | ||
} | ||
|
||
for (i = 0; i < 24; i++) { | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(i, 0); | ||
LEDRingSmall.LEDRingSmall_Set_BLUE(i, 0xff); | ||
delay(30); | ||
} | ||
|
||
for (i = 0; i < 24; i++) { | ||
|
||
LEDRingSmall.LEDRingSmall_Set_RGB(i, 0xfc6b03); | ||
delay(30); | ||
} | ||
|
||
for (i = 0; i < 24; i++) { | ||
|
||
LEDRingSmall.LEDRingSmall_Set_RGB(i, 0xfc03c6); | ||
delay(30); | ||
} | ||
// delay(2000); | ||
//LEDRingSmall.LEDRingSmall_ClearAll(); | ||
|
||
|
||
|
||
|
||
for (tim = 0; tim < 2000; tim++) { | ||
|
||
|
||
|
||
if ((tim % 5) == 0) { | ||
LEDRingSmall.LEDRingSmall_Set_RED(r, 0); | ||
r = r + 1; | ||
if (r >= 24) | ||
r = 0; | ||
LEDRingSmall.LEDRingSmall_Set_RED(r, 0xFF); | ||
} | ||
|
||
if ((tim % 6) == 0) { | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(g, 0); | ||
g = g + 1; | ||
if (g >= 24) | ||
g = 0; | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(g, 0xFF); | ||
} | ||
|
||
if ((tim % 8) == 0) { | ||
LEDRingSmall.LEDRingSmall_Set_BLUE(b, 0); | ||
b = b + 1; | ||
if (b >= 24) | ||
b = 0; | ||
LEDRingSmall.LEDRingSmall_Set_BLUE(b, 0xFF); | ||
} | ||
|
||
|
||
if ((tim % 7) == 0) { | ||
LEDRingSmall.LEDRingSmall_Set_BLUE(br, 0); | ||
LEDRingSmall.LEDRingSmall_Set_RED(br, 0); | ||
br = br + 1; | ||
if (br >= 24) | ||
br = 0; | ||
LEDRingSmall.LEDRingSmall_Set_BLUE(br, 0xFF); | ||
LEDRingSmall.LEDRingSmall_Set_RED(br, 0xFF); | ||
} | ||
|
||
|
||
if ((tim % 10) == 0) { | ||
LEDRingSmall.LEDRingSmall_Set_BLUE(bg, 0); | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(bg, 0); | ||
bg = bg + 1; | ||
if (bg >= 24) | ||
bg = 0; | ||
LEDRingSmall.LEDRingSmall_Set_BLUE(bg, 0xFF); | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(bg, 0xFF); | ||
} | ||
|
||
if ((tim % 11) == 0) { | ||
LEDRingSmall.LEDRingSmall_Set_RED(rg, 0); | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(rg, 0); | ||
rg = rg + 1; | ||
if (rg >= 24) | ||
rg = 0; | ||
LEDRingSmall.LEDRingSmall_Set_RED(rg, 0xFF); | ||
LEDRingSmall.LEDRingSmall_Set_GREEN(rg, 0xFF); | ||
} | ||
|
||
delay(10); | ||
} | ||
|
||
|
||
for (tim = 0; tim < 100; tim++) { | ||
j = tim % 24; | ||
|
||
for (i = 0; i < 24; i++) { | ||
LEDRingSmall.LEDRingSmall_Set_RGB(i, fade1_table[j]); | ||
j++; | ||
if (j >= 24) | ||
j = 0; | ||
} | ||
delay(40); | ||
} | ||
|
||
for (tim = 0; tim < 100; tim++) { | ||
j = tim % 24; | ||
for (i = 0; i < 24; i++) { | ||
LEDRingSmall.LEDRingSmall_Set_RGB(i, fade2_table[j]); | ||
j++; | ||
if (j >= 24) | ||
j = 0; | ||
} | ||
delay(40); | ||
} | ||
|
||
for (i = 0xff; i > 0; i--) { | ||
|
||
LEDRingSmall.LEDRingSmall_GlobalCurrent(i); | ||
delay(20); | ||
} | ||
LEDRingSmall.LEDRingSmall_ClearAll(); | ||
LEDRingSmall.LEDRingSmall_GlobalCurrent(0xff); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# RGB LED Ring Arduino Library | ||
|
||
-------------------------------------------------------------------------------- | ||
|
||
## Introduction | ||
|
||
Here you can find the library description of the [RGB LED Ring](https://github.com/Fattoresaimon/RGB_LED_Ring) for the Arduino IDE. | ||
The RGB LED Ring is based on the driver ISSI [IS31FL3737 ](http://www.issi.com/WW/pdf/31FL3737.pdf), for more functionality please check the datasheet of the driver. | ||
At the moment the breathing effect are not implemented. | ||
|
||
The RGB LED Ring is available on [Tindie!]( https://www.tindie.com/products/20279/) | ||
|
||
## Initialization of the class | ||
|
||
The library makes available the class **LEDRing** | ||
To initialize the library, you have to declare an instance of the class **LEDRing** for each LED Ring. | ||
For example: | ||
|
||
``` C++ | ||
LEDRing LEDRing(0x5A); | ||
``` | ||
Declaration of the RGB LED Ring with the jumper 0x5A soldered | ||
## Configuration | ||
### void LEDRing_Reset(void) | ||
Reset all the IS31FL3737 to the default state | ||
### void LEDRing_Configuration(uint8_t conf) | ||
This method write the register ad the address 00h of the IS31FL3737. Please refer the datasheet for further information. | ||
### void LEDRing_GlobalCurrent(uint8_t conf) | ||
This method write the register 01h and it set the LEDs current. | ||
It's possible to set up to 256 step from 0 to 0xFF. | ||
Higher value make the LEDs brighter. | ||
### void LEDRing_PULLUP(uint8_t pull) | ||
### void LEDRing_PULLDOWN(uint8_t pull) | ||
Configure the PULLUP or PULLDOWN resistor. | ||
This resistor are used for avoid the "ghost" effect in a matrix LED architecture. | ||
The possible value are the following: | ||
| PUR / PDR | Value | | ||
| :--: | ---- | | ||
| 000 | No pull-up resistor | | ||
| 001 | 0.5kΩ | | ||
| 010 | 1.0kΩ | | ||
| 011 | 2.0kΩ | | ||
| 100 | 4.0kΩ | | ||
| 101 | 8.0kΩ | | ||
| 110 | 16kΩ | | ||
| 111 | 32kΩ | | ||
### void LEDRing_EnableAllOutput(void) | ||
This method enable all the LEDs, by default the LEDs are disabled. | ||
### void LEDRing_DisableAllOutput(void) | ||
This method disable all the LEDs. | ||
### void LEDRing_PWM_MODE(void) | ||
This method set all the LEDs in PWM mode. | ||
### void LEDRing_ClearAll(void) | ||
This method set the PWM value to 0 for each LED. | ||
### void LEDRing_Set_RGB(uint8_t led_n, uint32_t color) | ||
Set the RGB color for a specific LED. | ||
**n** is the LED number ( 0 to 47 ), while the **color** is the RGB color in 24bit format. | ||
#### Examples: | ||
```C++ | ||
LEDRing.LEDRing_Set_RGB(10, 0xFF9933); | ||
``` | ||
|
||
### void LEDRing_Set_RED(uint8_t led_n, uint8_t color) | ||
### void LEDRing_Set_GREEN(uint8_t led_n, uint8_t color) | ||
### void LEDRing_Set_BLUE(uint8_t led_n, uint8_t color) | ||
|
||
Set a specific color to a specific LED | ||
**n** is the LED number ( 0 to 47 ), while the **color** is the color in 8bit format. | ||
|
||
#### Examples: | ||
|
||
```C++ | ||
LEDRing.LEDRing_Set_RED(4, 128); | ||
LEDRing.LEDRing_Set_GREEN(5, 200); | ||
LEDRing.LEDRing_Set_BLUE(6, 80); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.