Архівний
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/src/LED_PortOpenDrain.h

38 рядки
1.1 KiB
C

2016-11-16 03:01:42 +00:00
#ifndef LED_PORT_H
#define LED_PORT_H
#include <Arduino.h>
#include <inttypes.h>
#include "LEDInterface.h"
#include "PortWriteInterface.h"
2016-11-16 03:01:42 +00:00
/* An LED_PortOpenDrain object is an I/O expander ouput pin that is connected to an LED.
LED_PortOpenDrain functions turn LED on and off.
LED anode connected to power. LED cathode connected to open-drain ouput pin.
2016-11-16 03:01:42 +00:00
This class is for open drain ouput pins.
2016-11-16 03:01:42 +00:00
For LEDs connected to push-pull output types, use LED_Port class.
Example initialization:
const uint8_t IOE_ADDR = 0x20;
Port_MCP23S17 portA(IOE_ADDR, 0, 1<<0 | 1<<1 );
LED_PortOpenDrain LED_fn(portA, 1<<5);
Example initialization:
Port_ShiftRegs shiftRegs(8);
LED_PortOpenDrain LED_fn(shiftRegs, 1<<6);
*/
class LED_PortOpenDrain : public LEDInterface
{
private:
PortWriteInterface& refPort;
const uint8_t pin; //bit pattern, 1 is pin connected to LED
public:
LED_PortOpenDrain(PortWriteInterface& refPort, const uint8_t pin)
: refPort(refPort), pin(pin) {}
virtual void on();
virtual void off();
};
#endif