From ba86fe918f2906e64399f8f414f0bb433a502234 Mon Sep 17 00:00:00 2001 From: Simone Caron Desktop Date: Tue, 12 Mar 2024 21:11:57 +0100 Subject: [PATCH] Fixed some bugs in the examples --- .../LEDRingI2CEncoder/LEDRingI2CEncoder.ino | 56 ++++++++++--------- src/LEDRing.cpp | 8 +-- src/LEDRing.h | 6 +- src/LEDRingSmall.cpp | 8 +-- src/LEDRingSmall.h | 7 ++- 5 files changed, 43 insertions(+), 42 deletions(-) diff --git a/examples/RGB LED Ring/LEDRingI2CEncoder/LEDRingI2CEncoder.ino b/examples/RGB LED Ring/LEDRingI2CEncoder/LEDRingI2CEncoder.ino index 5b30e91..2d96d5d 100644 --- a/examples/RGB LED Ring/LEDRingI2CEncoder/LEDRingI2CEncoder.ino +++ b/examples/RGB LED Ring/LEDRingI2CEncoder/LEDRingI2CEncoder.ino @@ -10,7 +10,7 @@ The timer is used only for some effects... It's not mandatory - Connections with Arduino UNO: + Connections with Arduino UNO:d:\Users\Saimon\Documents\Arduino\libraries\ArduinoDuPPaLib-master.zip - -> GND + -> 5V SDA -> A4 @@ -18,19 +18,19 @@ 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 led_case = 5; -uint8_t led_pos[6] = {0, 0, 0, 10, 10, 0}; +uint8_t led_pos[6] = { 0, 0, 0, 10, 10, 0 }; uint16_t sf_Timer; const int IntPin = A3; /* Definition of the interrupt pin. You can change according to your board */ //Class initialization with the I2C addresses i2cEncoderLibV2 Encoder(0b1000000); /* A6 is soldered */ -LEDRing LEDRing1(0x5A); +LEDRing LEDRing1(ISSI3745_SJ1 | ISSI3745_SJ5 ); void UpdateRing(uint8_t value); void timer_callback(void); @@ -49,7 +49,6 @@ void encoder_change(i2cEncoderLibV2* obj) { Serial.print(led_case); Serial.print(" val: "); Serial.println(led_pos[led_case]); - } //Callback when the encoder is released @@ -78,9 +77,9 @@ void encoder_released(i2cEncoderLibV2* obj) { case 3: Timer1.start(); - Encoder.writeMax((int32_t) 100); /* Set the maximum threshold*/ - Encoder.writeMin((int32_t) 0); /* Set the minimum threshold */ - Encoder.writeStep((int32_t) 1); /* Set the step to 1*/ + Encoder.writeMax((int32_t)100); /* Set the maximum threshold*/ + Encoder.writeMin((int32_t)0); /* Set the minimum threshold */ + Encoder.writeStep((int32_t)1); /* Set the step to 1*/ Encoder.writeRGBCode(0xFF00FF); obj->writeCounter((int32_t)led_pos[led_case]); break; @@ -106,9 +105,9 @@ void encoder_released(i2cEncoderLibV2* obj) { UpdateRing(led_pos[led_case]); led_case = 5; - Encoder.writeMax((int32_t) 47); /* Set the maximum threshold*/ - Encoder.writeMin((int32_t) 0); /* Set the minimum threshold */ - Encoder.writeStep((int32_t) 2); /* Set the step to 1*/ + Encoder.writeMax((int32_t)47); /* Set the maximum threshold*/ + Encoder.writeMin((int32_t)0); /* Set the minimum threshold */ + Encoder.writeStep((int32_t)2); /* Set the step to 1*/ break; } @@ -150,7 +149,6 @@ void UpdateRing(uint8_t value) { LEDRing1.LEDRing_Set_BLUE(CheckRingBorder(value - 2), 0x03); break; } - } // Callback when the Timer1 expire, used for make the LED pattern roatating @@ -166,7 +164,7 @@ uint8_t CheckRingBorder(uint8_t in) { } if ((int8_t)in < 0) { - return ( 48 + (int8_t)in); + return (48 + (int8_t)in); } return in; } @@ -186,17 +184,17 @@ void setup(void) { | i2cEncoderLibV2::DIRE_LEFT | i2cEncoderLibV2::IPUP_ENABLE | i2cEncoderLibV2::RMOD_X2 | i2cEncoderLibV2::RGB_ENCODER); -// The i2c encoder is set to RMOD_X2, in this way you will see the LED dot moving meawhile the encoder is in the middle of a step. + // The i2c encoder is set to RMOD_X2, in this way you will see the LED dot moving meawhile the encoder is in the middle of a step. - Encoder.writeCounter((int32_t) 0); /* Reset the counter value */ - Encoder.writeMax((int32_t) 47); /* Set the maximum threshold*/ - Encoder.writeMin((int32_t) 0); /* Set the minimum threshold */ - Encoder.writeStep((int32_t) 1); /* Set the step to 1*/ + Encoder.writeCounter((int32_t)0); /* Reset the counter value */ + Encoder.writeMax((int32_t)47); /* Set the maximum threshold*/ + Encoder.writeMin((int32_t)0); /* Set the minimum threshold */ + Encoder.writeStep((int32_t)1); /* Set the step to 1*/ Encoder.writeAntibouncingPeriod(1); /* Set an anti-bouncing of 200ms */ - Encoder.writeDoublePushPeriod(0); /*Set a period for the double push of 500ms */ + Encoder.writeDoublePushPeriod(0); /*Set a period for the double push of 500ms */ // Definition of the encoder events - Encoder.onChange = encoder_change; + Encoder.onChange = encoder_change; Encoder.onButtonRelease = encoder_released; @@ -205,16 +203,20 @@ void setup(void) { LEDRing1.LEDRing_Reset(); delay(20); - LEDRing1.LEDRing_EnableAllOutput(); - LEDRing1.LEDRing_Configuration(0x01); - LEDRing1.LEDRing_GlobalCurrent(0xff); - LEDRing1.LEDRing_PULLUP(0b110); - LEDRing1.LEDRing_PULLDOWN(0b110); + + + + + LEDRing1.LEDRing_Configuration(0x01); //Normal operation + LEDRing1.LEDRing_SpreadSpectrum(0b0010110); + LEDRing1.LEDRing_GlobalCurrent(0x0F); // maximum current output + LEDRing1.LEDRing_PULLUP_DOWN(0x1B); + LEDRing1.LEDRing_SetScaling(0xFF); + LEDRing1.LEDRing_PWM_MODE(); - randomSeed(analogRead(0)); - // Showing some random pattern + // Showing some random pattern for (uint8_t i = 0; i < 100; i++) { LEDRing1.LEDRing_Set_RGB(random(47), random(0xFFFFFF)); delay(20); diff --git a/src/LEDRing.cpp b/src/LEDRing.cpp index 170f78a..92189ea 100644 --- a/src/LEDRing.cpp +++ b/src/LEDRing.cpp @@ -1,10 +1,10 @@ // // FILE: LEDRing.c -// VERSION: 1.0.. -// PURPOSE: Library for LEDRing from DUPPA +// VERSION: 1.2.. +// PURPOSE: Library for LEDRing from DUPPA. chip used IS31FL3745 // LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html) // -// DATASHEET: +// DATASHEET: https://www.lumissil.com/assets/pdf/core/IS31FL3745_DS.pdf // // URL: // @@ -12,8 +12,6 @@ // Simone Caron // -// datasheet of the controller: https://www.lumISSI3745l.com/assets/pdf/core/IS31FL3745_DS.pdf - #include "LEDRing.h" #include diff --git a/src/LEDRing.h b/src/LEDRing.h index 6193e45..3372beb 100644 --- a/src/LEDRing.h +++ b/src/LEDRing.h @@ -1,10 +1,10 @@ // // FILE: LEDRing.h -// VERSION: 1.0.. -// PURPOSE: Library for LEDRing from DUPPA +// VERSION: 1.2.. +// PURPOSE: Library for LEDRing from DUPPA. chip used IS31FL3745 // LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html) // -// DATASHEET: +// DATASHEET: https://www.lumissil.com/assets/pdf/core/IS31FL3745_DS.pdf // // URL: // diff --git a/src/LEDRingSmall.cpp b/src/LEDRingSmall.cpp index 4105cc0..9182d7a 100644 --- a/src/LEDRingSmall.cpp +++ b/src/LEDRingSmall.cpp @@ -1,10 +1,10 @@ // // FILE: LEDRingSmall.c -// VERSION: 1.0.. -// PURPOSE: Library for LEDRingSmall from DUPPA +// VERSION: 1.2.. +// PURPOSE: Library for LEDRingSmall from DUPPA. chip used IS31FL3746A // LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html) // -// DATASHEET: +// DATASHEET: https://www.lumissil.com/assets/pdf/core/IS31FL3746A_DS.pdf // // URL: // @@ -12,7 +12,7 @@ // Simone Caron // -// datasheet of the controller: https://www.lumissil.com/assets/pdf/core/IS31FL3746A_DS.pdf + #include "LEDRingSmall.h" #include diff --git a/src/LEDRingSmall.h b/src/LEDRingSmall.h index 794ad0a..84d8c80 100644 --- a/src/LEDRingSmall.h +++ b/src/LEDRingSmall.h @@ -1,10 +1,10 @@ // // FILE: LEDRingSmall.h -// VERSION: 1.0.. -// PURPOSE: Library for LEDRingSmall from DUPPA +// VERSION: 1.2.. +// PURPOSE: Library for LEDRingSmall from DUPPA. chip used IS31FL3746A // LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html) // -// DATASHEET: +// DATASHEET: https://www.lumissil.com/assets/pdf/core/IS31FL3746A_DS.pdf // // URL: // @@ -12,6 +12,7 @@ // Simone Caron // + #ifndef LEDRingSmall_H #define LEDRingSmall_H