2016-09-28 19:56:10 +00:00
# ifndef LED_PORT_H
# define LED_PORT_H
# include <Arduino.h>
# include <inttypes.h>
2016-11-18 10:21:50 +00:00
# include "LEDInterface.h"
# include "PortWriteInterface.h"
2016-09-28 19:56:10 +00:00
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.
2016-10-31 01:46:23 +00:00
LED_Port functions turn LED on and off .
2016-11-16 13:56:05 +00:00
LED anode connected to ouput pin . LED cathode grounded .
2016-09-28 19:56:10 +00:00
2016-11-16 13:56:05 +00:00
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 .
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