keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

Debouncer_4Samples.h 709B

12345678910111213141516171819202122
  1. #ifndef DEBOUNCER_4SAMPLES_H
  2. #define DEBOUNCER_4SAMPLES_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <DebouncerInterface.h>
  6. #define SAMPLE_COUNT 4 //number of consecutive equal bits needed to change a debounced bit
  7. /* Debouncer_4Samples
  8. Configuration: #define SAMPLE_COUNT in this header file.
  9. */
  10. class Debouncer_4Samples : public DebouncerInterface
  11. {
  12. private:
  13. uint8_t samples[SAMPLE_COUNT]; //bitwise, one bit per key, most recent readings
  14. uint8_t samplesIndex; //samples[] current write index
  15. public:
  16. Debouncer_4Samples(): samplesIndex(0) {}
  17. virtual uint8_t debounce(const uint8_t rawSignal, uint8_t& debounced);
  18. };
  19. #endif