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.

RowScanner_Arduino.h 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef ROWSCANNER_ARDUINO_H
  2. #define ROWSCANNER_ARDUINO_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <RowScannerInterface.h>
  6. #include <RowPort.h>
  7. #include <ColPort.h>
  8. /* RowScanner_Arduino class uses Arduino pin numbers (no port name).
  9. */
  10. class RowScanner_Arduino : public RowScannerInterface
  11. {
  12. private:
  13. static const bool activeHigh; //logic level of strobe pin: 0=activeLow, 1=activeHigh
  14. const uint8_t strobePin; //Arduino pin number connected to this row
  15. const uint8_t* readPins; //array of read pin numbers
  16. const uint8_t READ_PIN_COUNT; //number of read pins
  17. public:
  18. RowScanner_Arduino(const uint8_t strobePin,
  19. const uint8_t readPins[], const uint8_t READ_PIN_COUNT)
  20. : strobePin(strobePin), readPins(readPins), READ_PIN_COUNT(READ_PIN_COUNT)
  21. {
  22. //row
  23. pinMode(strobePin, OUTPUT);
  24. //cols
  25. for (uint8_t i=0; i < READ_PIN_COUNT; i++)
  26. {
  27. pinMode(readPins[i], INPUT_PULLUP);
  28. }
  29. }
  30. virtual uint8_t scan(uint16_t& rowEnd);
  31. uint8_t getRowState(uint16_t& rowEnd);
  32. };
  33. #endif