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.

ColPort_AVR.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef COLPORT_AVR_H
  2. #define COLPORT_AVR_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include <ColPort.h>
  6. /* One AVR microcontroller port connected to matrix columns.
  7. Instantiation
  8. ------------
  9. The constructor configures column's DDRx and PORTx.
  10. The 'x' in parameters DDRx, PORTx, and PINx should all be the same letter.
  11. colPins is port's bitwise pin configuration
  12. 1=configure as input (for pins connected to column)
  13. 0=configure as output (for LED or not connected to a column)
  14. Example instantiation on column port B, with pins 2 and 3 connected to columns:
  15. ColPort_AVR colPortB(DDRB, PORTB, PINB, 1<<2 | 1<<3 );
  16. colPins are read from pin 0 on up.
  17. Diode orientation
  18. ----------------
  19. Rows, columns, and diode orientation are explained in Matrix.h
  20. */
  21. class ColPort_AVR : public ColPort
  22. {
  23. private:
  24. const volatile unsigned char& DDR; //Data Direction Register, Direction: 0=Input
  25. const volatile unsigned char& PORT; //PORT register
  26. const volatile unsigned char& PIN; //PIN read register
  27. public:
  28. //The constructor initialization list is in .cpp
  29. ColPort_AVR(volatile unsigned char& DDRx, volatile unsigned char& PORTx,
  30. volatile unsigned char& PINx, const uint8_t colPins);
  31. //read port and store result in portState
  32. virtual void read();
  33. };
  34. #endif