1010 The timer is used only for some effects... It's not mandatory
1111
1212
13- Connections with Arduino UNO:
13+ Connections with Arduino UNO:d:\Users\Saimon\Documents\Arduino\libraries\ArduinoDuPPaLib-master.zip
1414 - -> GND
1515 + -> 5V
1616 SDA -> A4
1717 SCL -> A5
1818 INT -> A3
1919*/
2020
21-
2221const 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 , };
2322const 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 , };
23+
2424uint8_t j = 0 ;
2525
2626uint8_t led_case = 5 ;
27- uint8_t led_pos[6 ] = {0 , 0 , 0 , 10 , 10 , 0 };
27+ uint8_t led_pos[6 ] = { 0 , 0 , 0 , 10 , 10 , 0 };
2828uint16_t sf_Timer;
2929
3030const int IntPin = A3; /* Definition of the interrupt pin. You can change according to your board */
3131// Class initialization with the I2C addresses
3232i2cEncoderLibV2 Encoder (0b1000000 ); /* A6 is soldered */
33- LEDRing LEDRing1 (0x5A );
33+ LEDRing LEDRing1 (ISSI3745_SJ1 | ISSI3745_SJ5 );
3434
3535void UpdateRing (uint8_t value);
3636void timer_callback (void );
@@ -49,7 +49,6 @@ void encoder_change(i2cEncoderLibV2* obj) {
4949 Serial.print (led_case);
5050 Serial.print (" val: " );
5151 Serial.println (led_pos[led_case]);
52-
5352}
5453
5554// Callback when the encoder is released
@@ -78,9 +77,9 @@ void encoder_released(i2cEncoderLibV2* obj) {
7877
7978 case 3 :
8079 Timer1.start ();
81- Encoder.writeMax ((int32_t ) 100 ); /* Set the maximum threshold*/
82- Encoder.writeMin ((int32_t ) 0 ); /* Set the minimum threshold */
83- Encoder.writeStep ((int32_t ) 1 ); /* Set the step to 1*/
80+ Encoder.writeMax ((int32_t )100 ); /* Set the maximum threshold*/
81+ Encoder.writeMin ((int32_t )0 ); /* Set the minimum threshold */
82+ Encoder.writeStep ((int32_t )1 ); /* Set the step to 1*/
8483 Encoder.writeRGBCode (0xFF00FF );
8584 obj->writeCounter ((int32_t )led_pos[led_case]);
8685 break ;
@@ -106,9 +105,9 @@ void encoder_released(i2cEncoderLibV2* obj) {
106105 UpdateRing (led_pos[led_case]);
107106 led_case = 5 ;
108107
109- Encoder.writeMax ((int32_t ) 47 ); /* Set the maximum threshold*/
110- Encoder.writeMin ((int32_t ) 0 ); /* Set the minimum threshold */
111- Encoder.writeStep ((int32_t ) 2 ); /* Set the step to 1*/
108+ Encoder.writeMax ((int32_t )47 ); /* Set the maximum threshold*/
109+ Encoder.writeMin ((int32_t )0 ); /* Set the minimum threshold */
110+ Encoder.writeStep ((int32_t )2 ); /* Set the step to 1*/
112111
113112 break ;
114113 }
@@ -150,7 +149,6 @@ void UpdateRing(uint8_t value) {
150149 LEDRing1.LEDRing_Set_BLUE (CheckRingBorder (value - 2 ), 0x03 );
151150 break ;
152151 }
153-
154152}
155153
156154// Callback when the Timer1 expire, used for make the LED pattern roatating
@@ -166,7 +164,7 @@ uint8_t CheckRingBorder(uint8_t in) {
166164 }
167165 if ((int8_t )in < 0 ) {
168166
169- return ( 48 + (int8_t )in);
167+ return (48 + (int8_t )in);
170168 }
171169 return in;
172170}
@@ -186,17 +184,17 @@ void setup(void) {
186184 | i2cEncoderLibV2::DIRE_LEFT | i2cEncoderLibV2::IPUP_ENABLE
187185 | i2cEncoderLibV2::RMOD_X2 | i2cEncoderLibV2::RGB_ENCODER);
188186
189- // 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.
187+ // 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.
190188
191- Encoder.writeCounter ((int32_t ) 0 ); /* Reset the counter value */
192- Encoder.writeMax ((int32_t ) 47 ); /* Set the maximum threshold*/
193- Encoder.writeMin ((int32_t ) 0 ); /* Set the minimum threshold */
194- Encoder.writeStep ((int32_t ) 1 ); /* Set the step to 1*/
189+ Encoder.writeCounter ((int32_t )0 ); /* Reset the counter value */
190+ Encoder.writeMax ((int32_t )47 ); /* Set the maximum threshold*/
191+ Encoder.writeMin ((int32_t )0 ); /* Set the minimum threshold */
192+ Encoder.writeStep ((int32_t )1 ); /* Set the step to 1*/
195193 Encoder.writeAntibouncingPeriod (1 ); /* Set an anti-bouncing of 200ms */
196- Encoder.writeDoublePushPeriod (0 ); /* Set a period for the double push of 500ms */
194+ Encoder.writeDoublePushPeriod (0 ); /* Set a period for the double push of 500ms */
197195
198196 // Definition of the encoder events
199- Encoder.onChange = encoder_change;
197+ Encoder.onChange = encoder_change;
200198 Encoder.onButtonRelease = encoder_released;
201199
202200
@@ -205,16 +203,20 @@ void setup(void) {
205203 LEDRing1.LEDRing_Reset ();
206204 delay (20 );
207205
208- LEDRing1.LEDRing_EnableAllOutput ();
209- LEDRing1.LEDRing_Configuration (0x01 );
210- LEDRing1.LEDRing_GlobalCurrent (0xff );
211- LEDRing1.LEDRing_PULLUP (0b110 );
212- LEDRing1.LEDRing_PULLDOWN (0b110 );
206+
207+
208+
209+
210+ LEDRing1.LEDRing_Configuration (0x01 ); // Normal operation
211+ LEDRing1.LEDRing_SpreadSpectrum (0b0010110 );
212+ LEDRing1.LEDRing_GlobalCurrent (0x0F ); // maximum current output
213+ LEDRing1.LEDRing_PULLUP_DOWN (0x1B );
214+ LEDRing1.LEDRing_SetScaling (0xFF );
215+
213216 LEDRing1.LEDRing_PWM_MODE ();
214-
215217 randomSeed (analogRead (0 ));
216218
217- // Showing some random pattern
219+ // Showing some random pattern
218220 for (uint8_t i = 0 ; i < 100 ; i++) {
219221 LEDRing1.LEDRing_Set_RGB (random (47 ), random (0xFFFFFF ));
220222 delay (20 );
0 commit comments