keybrd library is an open source library for creating custom-keyboard firmware.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

RowPort_AVR_Optic.cpp 1.1KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "RowPort_AVR_Optic.h"
  2. /*
  3. configures row port's DDRx and PORTx pins as output.
  4. */
  5. RowPort_AVR_Optic::RowPort_AVR_Optic
  6. (volatile unsigned char& DDRx, volatile unsigned char& PORTx)
  7. : DDR(DDRx = ~0), PORT(PORTx)
  8. {}
  9. /*
  10. activePin is a port mask, where active pin is 1.
  11. */
  12. void RowPort_AVR_Optic::setActivePinLow(const uint8_t activePin)
  13. {
  14. PORT &= ~activePin;
  15. }
  16. /*
  17. activePin is port mask, where active pin is 1.
  18. The delayMicroseconds() is for DodoHand keyboard's optic switches.
  19. Strobe needs to be turned on for >= 300µs before the columns are read.
  20. During this time the state of the columns are settling into their actual values.
  21. Seems to be necessary in order to allow the phototransistors to turn completely off.
  22. (delay is not need for I/O expander because time between I2C Transmissions)
  23. (Teensy2 ATMEGA32U4 16 MHz is a 0.0625 µs period)
  24. */
  25. void RowPort_AVR_Optic::setActivePinHigh(const uint8_t activePin)
  26. {
  27. //strobe row on
  28. PORT |= activePin;
  29. delayMicroseconds(300); //wait for the column value to stabilize after strobe
  30. }