2016-09-28 19:56:10 +00:00
|
|
|
#ifndef LED_PORT_H
|
|
|
|
#define LED_PORT_H
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <LEDInterface.h>
|
2016-10-31 01:46:23 +00:00
|
|
|
#include <PortWriteInterface.h>
|
2016-09-28 19:56:10 +00:00
|
|
|
|
|
|
|
/* An LED_Port object is an I/O expander pin that is connected to an LED indicator light.
|
2016-10-31 01:46:23 +00:00
|
|
|
LED_Port functions turn LED on and off.
|
2016-09-28 19:56:10 +00:00
|
|
|
|
|
|
|
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);
|
2016-10-31 01:46:23 +00:00
|
|
|
|
|
|
|
Example initialization:
|
|
|
|
Port_ShiftRegs shiftRegs(8);
|
|
|
|
LED_Port LED_fn(shiftRegs, 1<<6);
|
|
|
|
|
2016-09-28 19:56:10 +00:00
|
|
|
*/
|
|
|
|
class LED_Port : public LEDInterface
|
|
|
|
{
|
|
|
|
private:
|
2016-10-31 01:46:23 +00:00
|
|
|
PortWriteInterface& refPort;
|
|
|
|
const uint8_t pin; //bit pattern, 1 is pin connected to LED
|
2016-09-28 19:56:10 +00:00
|
|
|
|
|
|
|
public:
|
2016-10-31 01:46:23 +00:00
|
|
|
LED_Port(PortWriteInterface& refPort, const uint8_t pin)
|
2016-09-28 19:56:10 +00:00
|
|
|
: refPort(refPort), pin(pin) {}
|
|
|
|
virtual void on();
|
|
|
|
virtual void off();
|
|
|
|
};
|
|
|
|
#endif
|