keybrd library is an open source library for creating custom-keyboard firmware.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

Scanner_ShiftRegs74HC165.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef ROWSCANNER_SHIFTREGS74HC165_H
  2. #define ROWSCANNER_SHIFTREGS74HC165_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <config_keybrd.h>
  6. #include <SPI.h>
  7. #include <PortWrite.h>
  8. #include <PortRead.h>
  9. /* Scanner_ShiftRegs74HC165 reads shift registers.
  10. shift registers 74HC165 are Parallel-In-Serial-Out (PISO)
  11. Upto 4 shift registers can be in a daisy chained for a total of 32 read pins.
  12. For active low:
  13. Shift register parallel input pins have 10k pull-up resistors powered
  14. Orient diodes with cathode (banded end) towards the write pins (row)
  15. Controller's MISO pin is connected to shift register's complementary serial output (/QH) pin
  16. Use these two lines in the sketch:
  17. const bool Scanner_ShiftRegs74HC165::STROBE_ON = LOW;
  18. const bool Scanner_ShiftRegs74HC165::STROBE_OFF = HIGH;
  19. For active high:
  20. Shift register parallel input pins have 10k pull-down resistors grounded
  21. Orient diodes with cathode (banded end) towards the read pins.
  22. Controller's MISO pin is connected to shift register's serial output (QH) pin
  23. Use these two lines in the sketch:
  24. const bool Scanner_ShiftRegs74HC165::STROBE_ON = HIGH;
  25. const bool Scanner_ShiftRegs74HC165::STROBE_OFF = LOW;
  26. In addition, each row needs to be connected to a strobe pin from the controller.
  27. */
  28. class Scanner_ShiftRegs74HC165
  29. {
  30. private:
  31. static const uint8_t SHIFT_LOAD; //controller's pin number that is
  32. // connected to shift register's SHIFT_LOAD pin
  33. static const bool STROBE_ON; //logic level of strobe on, active state HIGH or LOW
  34. static const bool STROBE_OFF; //logic level of strobe off, complement of active state
  35. const uint8_t strobePin; //Arduino pin number connected to this row
  36. const uint8_t byte_count; //number of bytes to read from shift registers
  37. public:
  38. Scanner_ShiftRegs74HC165(const uint8_t strobePin, const uint8_t readPinCount);
  39. virtual read_pins_t scan();
  40. void begin();
  41. };
  42. #endif