// Button Debouncer
// 
// Red button has bouncing simulation enabled,
// Blue button has bouncing simulation disabled.

//#include "debouncer.h"
#include "debouncer_integrator.h"

#define BUTTON_PIN 4

void setup() 
{
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop() 
{
  /**

  static Debouncer button(BUTTON_PIN);
  button.Update();
  if (button.Fall())
  {
    Serial.println("Pressed.");
  }
  else if (button.Rise())
  {
    Serial.println("Released.");
  }

  /**/

  static DebouncerIntegrator button_int(BUTTON_PIN, 1000);  // Large debounce time to see integration sum on serial plotter.
  button_int.Update();
  if (button_int.Fall())
  {
    Serial.println("Pressed.");
  }
  else if (button_int.Rise())
  {
    Serial.println("Released.");
  }
#if DEBOUNCER_REPEAT_COUNT
  static unsigned long previous_repeat_count = 0;
  unsigned long repeat_count = button_int.RepeatCount();
  if (repeat_count != previous_repeat_count)
  {
    Serial.print("Repeat count = ");
    Serial.println(repeat_count);
    previous_repeat_count = repeat_count;
  }
#endif
}