@@ -39,7 +39,7 @@ DESTINATION PIN PIN_NUMBER PIN DESTINATION | |||
//right matrix | |||
#include <Port_MCP23018.h> | |||
#include <Scanner_IOE.h> | |||
#include <LED_Port.h> | |||
#include <LED_PortOpenDrain.h> | |||
// ============ SPEED CONFIGURATION ============ | |||
ScanDelay scanDelay(9000); | |||
@@ -60,7 +60,7 @@ Port_MCP23018 portB(IOE_ADDR, 1, 0); | |||
Scanner_IOE scanner_R(LOW, portB, portA); | |||
// ================= RIGHT LED ================= | |||
LED_Port LED_capsLck(portA, 1<<7); | |||
LED_PortOpenDrain LED_capsLck(portA, 1<<7); | |||
// =================== CODES =================== | |||
Code_Sc s_a(KEY_A); |
@@ -5,9 +5,12 @@ | |||
#include <LEDInterface.h> | |||
#include <PortWriteInterface.h> | |||
/* An LED_Port object is an I/O expander pin that is connected to an LED indicator light. | |||
/* 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. | |||
This is for push-pull ouput pins. | |||
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 ); |
@@ -0,0 +1,12 @@ | |||
#include "LED_PortOpenDrain.h" | |||
/* functions are like LED_Port, but writeLow() writeHigh() are swapped. | |||
*/ | |||
void LED_PortOpenDrain::on() | |||
{ | |||
refPort.writeLow(pin); | |||
} | |||
void LED_PortOpenDrain::off() | |||
{ | |||
refPort.writeHigh(pin); | |||
} |
@@ -0,0 +1,36 @@ | |||
#ifndef LED_PORT_H | |||
#define LED_PORT_H | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <LEDInterface.h> | |||
#include <PortWriteInterface.h> | |||
/* 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. | |||
This is for open drain ouput pins. | |||
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 |