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_PortOpenDrain.h 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  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_PortOpenDrain object is an I/O expander ouput pin that is connected to an LED.
  8. LED_PortOpenDrain functions turn LED on and off.
  9. This is for open drain ouput pins.
  10. For LEDs connected to push-pull output types, use LED_Port class.
  11. Example initialization:
  12. const uint8_t IOE_ADDR = 0x20;
  13. Port_MCP23S17 portA(IOE_ADDR, 0, 1<<0 | 1<<1 );
  14. LED_PortOpenDrain LED_fn(portA, 1<<5);
  15. Example initialization:
  16. Port_ShiftRegs shiftRegs(8);
  17. LED_PortOpenDrain LED_fn(shiftRegs, 1<<6);
  18. */
  19. class LED_PortOpenDrain : public LEDInterface
  20. {
  21. private:
  22. PortWriteInterface& refPort;
  23. const uint8_t pin; //bit pattern, 1 is pin connected to LED
  24. public:
  25. LED_PortOpenDrain(PortWriteInterface& refPort, const uint8_t pin)
  26. : refPort(refPort), pin(pin) {}
  27. virtual void on();
  28. virtual void off();
  29. };
  30. #endif