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. }