Skip to content

Commit

Permalink
Added HW-Debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
SV-Zanshin committed Oct 8, 2017
1 parent 7a6f8d8 commit ded4112
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
15 changes: 3 additions & 12 deletions Examples/StandardColors/StandardColors.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,17 @@
** **
*******************************************************************************************************************/
#include <RotaryEncoder.h> // Include Encoder library //

/* //----------------------------------//
const uint8_t ROTARY_PIN_1 = 0; // Pin for left rotary encoder pin //
const uint8_t ROTARY_PIN_2 = 1; // Pin for right rotary encoder pin //
const uint8_t PUSHBUTTON_PIN = 7; // Pin for pushbutton connector pin //
const uint8_t RED_PIN = 11; // Red LED PWM pin. Ground = FULL //
const uint8_t GREEN_PIN = 10; // Green LED PWM pin. Ground = FULL //
const uint8_t BLUE_PIN = 9; // Blue LED PWM pin. Ground = FULL //
*/
const uint8_t ROTARY_PIN_1 = 6; // Pin for left rotary encoder pin //
const uint8_t ROTARY_PIN_2 = 7; // Pin for right rotary encoder pin //
const uint8_t PUSHBUTTON_PIN = 2; // Pin for pushbutton connector pin //
const uint8_t RED_PIN = 30; // Red LED PWM pin. Ground = FULL //
const uint8_t GREEN_PIN = 8; // Green LED PWM pin. Ground = FULL //
const uint8_t BLUE_PIN = 9; // Blue LED PWM pin. Ground = FULL //
//----------------------------------//
EncoderClass Encoder(ROTARY_PIN_1, ROTARY_PIN_2, PUSHBUTTON_PIN, // Instantiate class defining all //
RED_PIN, GREEN_PIN, BLUE_PIN, true); // of the pins that are used //
// Using HW debounce, internal pull-//
// ups disabled //
RED_PIN, GREEN_PIN, BLUE_PIN, false); // of the pins that are used //
// If using HW de-bounce, internal //
// pull-ups disabled else enabled //
//----------------------------------//
void setup() { // Start One-Time run section //
Serial.println(F("Starting Encoder Program...")); // //
Expand Down
8 changes: 4 additions & 4 deletions RotaryEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ void EncoderClass::SetEncoderValue(const int16_t NewValue = 0) { //
** then gives us an identical trigger speed but different trigger point to the millis() function which triggers **
** when the Timer0 overflows. The same setup is done for the TIMER0_COMPB_vect but that is set to trigger halfway **
** along the full range of 255 at 192, thus giving an interrupt rate of 2 times per milli second. The FadeSpeed **
** equates to how many milliseconds ther are between incremental fades, the fastest is 1 which is every 1/2 milli-**
** second, 2 is every millisecond, etc. Each time the trigger is reached all of the LED values which are not "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 their **
** brightness in 1.28 seconds **
** equates to how many milliseconds there are between incremental fades, the fastest is 1 which is every 1/2 **
** millisecond, 2 is every millisecond, etc. Each time the trigger is reached all of the LED values which are not **
** "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 **
** their brightness in 1.28 seconds **
*******************************************************************************************************************/
void EncoderClass::SetFadeRate(const uint8_t FadeSpeed) { // //
_FadeMillis = FadeSpeed; // Set the private variable to value//
Expand Down

0 comments on commit ded4112

Please sign in to comment.