Skip to content

Commit

Permalink
Fixed some bugs in the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Fattoresaimon committed Mar 12, 2024
1 parent 328aaab commit ba86fe9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 42 deletions.
56 changes: 29 additions & 27 deletions examples/RGB LED Ring/LEDRingI2CEncoder/LEDRingI2CEncoder.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@
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
SCL -> A5
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);
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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;


Expand All @@ -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);
Expand Down
8 changes: 3 additions & 5 deletions src/LEDRing.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
//
// 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:
//
// AUTHOR:
// Simone Caron
//

// datasheet of the controller: https://www.lumISSI3745l.com/assets/pdf/core/IS31FL3745_DS.pdf

#include "LEDRing.h"
#include <Wire.h>

Expand Down
6 changes: 3 additions & 3 deletions src/LEDRing.h
Original file line number Diff line number Diff line change
@@ -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:
//
Expand Down
8 changes: 4 additions & 4 deletions src/LEDRingSmall.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//
// 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:
//
// AUTHOR:
// Simone Caron
//

// datasheet of the controller: https://www.lumissil.com/assets/pdf/core/IS31FL3746A_DS.pdf


#include "LEDRingSmall.h"
#include <Wire.h>
Expand Down
7 changes: 4 additions & 3 deletions src/LEDRingSmall.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
//
// 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:
//
// AUTHOR:
// Simone Caron
//


#ifndef LEDRingSmall_H
#define LEDRingSmall_H

Expand Down

0 comments on commit ba86fe9

Please sign in to comment.