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_IOE.cpp 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "Scanner_IOE.h"
  2. /* init() is called once for each row from Row constructor.
  3. */
  4. void Scanner_IOE::init(const uint8_t strobePin)
  5. {
  6. //empty
  7. }
  8. /* begin() should be called once from sketch setup().
  9. Initiates communication protocal and configs ports.
  10. */
  11. void Scanner_IOE::begin()
  12. {
  13. refPortRead.begin(strobeOn);
  14. refPortWrite.begin(strobeOn);
  15. }
  16. /* scan() is called on every iteration of sketch loop().
  17. strobePin is a bit pattern, 1 means that row pin is active.
  18. scan() strobes the row's strobePin and retuns state of port's input pins.
  19. */
  20. read_pins_t Scanner_IOE::scan(const uint8_t strobePin)
  21. {
  22. uint8_t readState; //bits, 1 means key is pressed, 0 means released
  23. //strobe on
  24. refPortWrite.write(strobePin, strobeOn);
  25. delayMicroseconds(3); //time to stabilize voltage
  26. //read the port pins
  27. readState = refPortRead.read();
  28. //strobe off
  29. refPortWrite.write(strobePin, strobeOff);
  30. if (strobeOn == LOW) //if active low
  31. {
  32. readState = ~readState;
  33. }
  34. return readState;
  35. }