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.

RowBase.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef ROWBASE_H
  2. #define ROWBASE_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <Key.h>
  6. #include <RowPort.h>
  7. #include <ColPort.h>
  8. /* RowBase is an abstract base class.
  9. */
  10. class RowBase
  11. {
  12. private:
  13. static const unsigned int DELAY_MICROSECONDS; //delay between each Row scan for debouncing
  14. Key *const *const ptrsKeys; //array of Key pointers
  15. RowPort &refRowPort; //this row's IC port
  16. const uint8_t rowPin; //bitwise, 1 indicates IC pin connected to this row
  17. ColPort *const *const ptrsColPorts; //array of column ports
  18. const uint8_t colPortCount;
  19. void wait();
  20. void scan(const bool activeHigh);
  21. uint8_t getRowState(uint16_t& rowEnd, const bool activeHigh);
  22. virtual uint8_t debounce(const uint8_t rowState)=0;
  23. void pressRelease(const uint16_t rowEnd, const uint8_t debouncedChanged);
  24. virtual void keyWasPressed();
  25. protected:
  26. uint8_t previousDebounced; //bitwise, one bit per key
  27. public:
  28. RowBase( RowPort &refRowPort, const uint8_t rowPin,
  29. ColPort *const ptrsColPorts[], const uint8_t colPortCount,
  30. Key *const ptrsKeys[])
  31. : ptrsKeys(ptrsKeys), refRowPort(refRowPort), rowPin(rowPin),
  32. ptrsColPorts(ptrsColPorts), colPortCount(colPortCount),
  33. previousDebounced(0) { }
  34. //Key* getPtrKey(uint8_t col) const; todo delete, no longer needed 5/31/16
  35. void process(const bool activeHigh);
  36. };
  37. #endif