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.

LED_Port.h 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef LED_PORT_H
  2. #define LED_PORT_H
  3. #include <Arduino.h>
  4. #include <inttypes.h>
  5. #include "LEDInterface.h"
  6. #include "PortWriteInterface.h"
  7. /* An LED_Port object is an I/O expander output pin that is connected to an LED indicator light.
  8. LED_Port functions turn LED on and off.
  9. LED anode connected to ouput pin. LED cathode grounded.
  10. This class is for push-pull ouput pins.
  11. For LEDs connected to open drain output types, use LED_Port class.
  12. Example initialization:
  13. const uint8_t IOE_ADDR = 0x20;
  14. Port_MCP23S17 portA(IOE_ADDR, 0, 1<<0 | 1<<1 );
  15. LED_Port LED_fn(portA, 1<<5);
  16. Example initialization:
  17. Port_ShiftRegs shiftRegs(8);
  18. LED_Port LED_fn(shiftRegs, 1<<6);
  19. */
  20. class LED_Port : public LEDInterface
  21. {
  22. private:
  23. PortWriteInterface& refPort;
  24. const uint8_t pin; //bit pattern, 1 is pin connected to LED
  25. public:
  26. LED_Port(PortWriteInterface& refPort, const uint8_t pin)
  27. : refPort(refPort), pin(pin) {}
  28. virtual void on();
  29. virtual void off();
  30. };
  31. #endif