Skip to content

Commit ded4112

Browse files
committed
Added HW-Debounce
1 parent 7a6f8d8 commit ded4112

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

Examples/StandardColors/StandardColors.ino

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,17 @@
3535
** **
3636
*******************************************************************************************************************/
3737
#include <RotaryEncoder.h> // Include Encoder library //
38-
39-
/* //----------------------------------//
4038
const uint8_t ROTARY_PIN_1 = 0; // Pin for left rotary encoder pin //
4139
const uint8_t ROTARY_PIN_2 = 1; // Pin for right rotary encoder pin //
4240
const uint8_t PUSHBUTTON_PIN = 7; // Pin for pushbutton connector pin //
4341
const uint8_t RED_PIN = 11; // Red LED PWM pin. Ground = FULL //
4442
const uint8_t GREEN_PIN = 10; // Green LED PWM pin. Ground = FULL //
45-
const uint8_t BLUE_PIN = 9; // Blue LED PWM pin. Ground = FULL //
46-
*/
47-
const uint8_t ROTARY_PIN_1 = 6; // Pin for left rotary encoder pin //
48-
const uint8_t ROTARY_PIN_2 = 7; // Pin for right rotary encoder pin //
49-
const uint8_t PUSHBUTTON_PIN = 2; // Pin for pushbutton connector pin //
50-
const uint8_t RED_PIN = 30; // Red LED PWM pin. Ground = FULL //
51-
const uint8_t GREEN_PIN = 8; // Green LED PWM pin. Ground = FULL //
5243
const uint8_t BLUE_PIN = 9; // Blue LED PWM pin. Ground = FULL //
5344
//----------------------------------//
5445
EncoderClass Encoder(ROTARY_PIN_1, ROTARY_PIN_2, PUSHBUTTON_PIN, // Instantiate class defining all //
55-
RED_PIN, GREEN_PIN, BLUE_PIN, true); // of the pins that are used //
56-
// Using HW debounce, internal pull-//
57-
// ups disabled //
46+
RED_PIN, GREEN_PIN, BLUE_PIN, false); // of the pins that are used //
47+
// If using HW de-bounce, internal //
48+
// pull-ups disabled else enabled //
5849
//----------------------------------//
5950
void setup() { // Start One-Time run section //
6051
Serial.println(F("Starting Encoder Program...")); // //

RotaryEncoder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ void EncoderClass::SetEncoderValue(const int16_t NewValue = 0) { //
209209
** then gives us an identical trigger speed but different trigger point to the millis() function which triggers **
210210
** when the Timer0 overflows. The same setup is done for the TIMER0_COMPB_vect but that is set to trigger halfway **
211211
** along the full range of 255 at 192, thus giving an interrupt rate of 2 times per milli second. The FadeSpeed **
212-
** equates to how many milliseconds ther are between incremental fades, the fastest is 1 which is every 1/2 milli-**
213-
** second, 2 is every millisecond, etc. Each time the trigger is reached all of the LED values which are not "off"**
214-
** are dimmed by 1/255 of the total value. A setting of 10 would fade the LEDs from full on to OFF 1/255 of their **
215-
** brightness in 1.28 seconds **
212+
** equates to how many milliseconds there are between incremental fades, the fastest is 1 which is every 1/2 **
213+
** millisecond, 2 is every millisecond, etc. Each time the trigger is reached all of the LED values which are not **
214+
** "off" are dimmed by 1/255 of the total value. A setting of 10 would fade the LEDs from full on to OFF 1/255 of **
215+
** their brightness in 1.28 seconds **
216216
*******************************************************************************************************************/
217217
void EncoderClass::SetFadeRate(const uint8_t FadeSpeed) { // //
218218
_FadeMillis = FadeSpeed; // Set the private variable to value//

0 commit comments

Comments
 (0)