Archivováno
1
0
Tento repozitář je archivovaný. Můžete prohlížet soubory, klonovat, ale nemůžete nahrávat a vytvářet nové úkoly nebo pull requesty.
keybrd/src/LED_Port.h

38 řádky
1.1 KiB
C
Surový Trvalý odkaz Normální zobrazení Historie

#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_Port object is an I/O expander output pin that is connected to an LED indicator light.
LED_Port functions turn LED on and off.
LED anode connected to ouput pin. LED cathode grounded.
This class is for push-pull ouput pins.
2016-11-16 03:01:42 +00:00
For LEDs connected to open drain 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_Port LED_fn(portA, 1<<5);
Example initialization:
Port_ShiftRegs shiftRegs(8);
LED_Port LED_fn(shiftRegs, 1<<6);
*/
class LED_Port : public LEDInterface
{
private:
PortWriteInterface& refPort;
const uint8_t pin; //bit pattern, 1 is pin connected to LED
public:
LED_Port(PortWriteInterface& refPort, const uint8_t pin)
: refPort(refPort), pin(pin) {}
virtual void on();
virtual void off();
};
#endif