Skip to content

Commit

Permalink
Added the library of the new LED Ring
Browse files Browse the repository at this point in the history
  • Loading branch information
Fattoresaimon committed Jan 14, 2022
1 parent db9598d commit 310f7d6
Show file tree
Hide file tree
Showing 7 changed files with 622 additions and 83 deletions.
175 changes: 175 additions & 0 deletions examples/RGB LED Ring Small/LEDRingSmall_Demo/LEDRingSmall_Demo.ino
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);


}
90 changes: 90 additions & 0 deletions examples/RGB LED Ring Small/README.md
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);
```
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
#include <Wire.h>
#include <LEDRing.h>
#include "LEDRing.h"


/*
Connections with Arduino UNO:
VCC -> 5V
GND -> GND
VIO -> 5V
- -> GND
+ -> 5V
SDA -> A4
SCL -> A5
INT -> //Not used now
INT -> A3
*/

const uint32_t fade1_table[48] = {0x8011EE, 0x900AE5, 0xA004DA, 0xB001CD, 0xBF00BF, 0xCD01B0, 0xDA04A0, 0xE50A90, 0xEE1180, 0xF51A6F, 0xFB255F, 0xFE324F, 0xFF4040, 0xFE4F32, 0xFB5F25, 0xF56F1A, 0xEE8011, 0xE5900A, 0xDAA004, 0xCDB001, 0xBFBF00, 0xB0CD01, 0xA0DA04, 0x90E50A, 0x80EE11, 0x6FF51A, 0x5FFB25, 0x4FFE32, 0x40FF40, 0x32FE4F, 0x25FB5F, 0x1AF56F, 0x11EE80, 0x0AE590, 0x04DAA0, 0x01CDB0, 0x00BFBF, 0x01B0CD, 0x04A0DA, 0x0A90E5, 0x1180EE, 0x1A6FF5, 0x255FFB, 0x324FFE, 0x4040FF, 0x4F32FE, 0x5F25FB, 0x6F1AF5, };
const uint32_t fade2_table[48] = {0xFF0000, 0xFF0001, 0xFF0004, 0xFF000E, 0xFF0020, 0xFF003E, 0xFF006B, 0xFF00AB, 0xFF00FF, 0xAB00FF, 0x6B00FF, 0x3E00FF, 0x2000FF, 0x0E00FF, 0x0400FF, 0x0100FF, 0x0000FF, 0x0001FF, 0x0004FF, 0x000EFF, 0x0020FF, 0x003EFF, 0x006BFF, 0x00ABFF, 0x00FFFF, 0x00FFAB, 0x00FF6B, 0x00FF3E, 0x00FF20, 0x00FF0E, 0x00FF04, 0x00FF01, 0x00FF00, 0x01FF00, 0x04FF00, 0x0EFF00, 0x20FF00, 0x3EFF00, 0x6BFF00, 0xABFF00, 0xFFFF00, 0xFFAB00, 0xFF6B00, 0xFF3E00, 0xFF2000, 0xFF0E00, 0xFF0400, 0xFF0100, };
uint8_t j = 0;
uint8_t i = 0;
uint16_t tim = 0;
uint8_t r = 5, g = 8, b = 20, rg = 40, br = 35, bg = 17;


LEDRing LEDRing(0x5A); // change the adress according to your board.
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;

LEDRing LEDRing(ISSI3745_SJ1 | ISSI3745_SJ5);

void setup(void) {

Wire.begin();

Wire.setClock(400000);
LEDRing.LEDRing_Reset();
delay(20);

LEDRing.LEDRing_EnableAllOutput();
LEDRing.LEDRing_Configuration(0x01); //Normal operation
LEDRing.LEDRing_GlobalCurrent(0xff); // maximum current output
LEDRing.LEDRing_PULLUP(0b111); // 32k pull-up resistor for avoid ghost effect
LEDRing.LEDRing_PULLDOWN(0b111); // 32k pull-down resistor for avoid ghost effect
LEDRing.LEDRing_PWM_MODE(); //Exit to the configuration mode and enter in PWM mode
LEDRing.LEDRing_SpreadSpectrum(0b0010110);
LEDRing.LEDRing_GlobalCurrent(0xFf); // maximum current output
LEDRing.LEDRing_SetScaling(0xFF);

LEDRing.LEDRing_PWM_MODE();
}

void loop() {
Expand Down Expand Up @@ -69,6 +66,13 @@ void loop() {
LEDRing.LEDRing_Set_RGB(i, 0xFF9933);
delay(15);
}

for (i = 0; i < 48; i++) {

LEDRing.LEDRing_Set_RGB(i, 0xFFFFFF);
delay(15);
}

LEDRing.LEDRing_ClearAll();


Expand Down Expand Up @@ -167,6 +171,6 @@ void loop() {
LEDRing.LEDRing_ClearAll();
LEDRing.LEDRing_GlobalCurrent(0xff);
delay(1000);
LEDRing.LEDRing_PWM_MODE(); //Exit to the configuration mode and enter in PWM mode
LEDRing.LEDRing_PWM_MODE();

}
Loading

0 comments on commit 310f7d6

Please sign in to comment.