add LED_PortOpenDrain
This commit is contained in:
parent
a3f2261625
commit
6a787b4155
@ -39,7 +39,7 @@ DESTINATION PIN PIN_NUMBER PIN DESTINATION
|
|||||||
//right matrix
|
//right matrix
|
||||||
#include <Port_MCP23018.h>
|
#include <Port_MCP23018.h>
|
||||||
#include <Scanner_IOE.h>
|
#include <Scanner_IOE.h>
|
||||||
#include <LED_Port.h>
|
#include <LED_PortOpenDrain.h>
|
||||||
|
|
||||||
// ============ SPEED CONFIGURATION ============
|
// ============ SPEED CONFIGURATION ============
|
||||||
ScanDelay scanDelay(9000);
|
ScanDelay scanDelay(9000);
|
||||||
@ -60,7 +60,7 @@ Port_MCP23018 portB(IOE_ADDR, 1, 0);
|
|||||||
Scanner_IOE scanner_R(LOW, portB, portA);
|
Scanner_IOE scanner_R(LOW, portB, portA);
|
||||||
|
|
||||||
// ================= RIGHT LED =================
|
// ================= RIGHT LED =================
|
||||||
LED_Port LED_capsLck(portA, 1<<7);
|
LED_PortOpenDrain LED_capsLck(portA, 1<<7);
|
||||||
|
|
||||||
// =================== CODES ===================
|
// =================== CODES ===================
|
||||||
Code_Sc s_a(KEY_A);
|
Code_Sc s_a(KEY_A);
|
||||||
|
@ -5,9 +5,12 @@
|
|||||||
#include <LEDInterface.h>
|
#include <LEDInterface.h>
|
||||||
#include <PortWriteInterface.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.
|
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:
|
Example initialization:
|
||||||
const uint8_t IOE_ADDR = 0x20;
|
const uint8_t IOE_ADDR = 0x20;
|
||||||
Port_MCP23S17 portA(IOE_ADDR, 0, 1<<0 | 1<<1 );
|
Port_MCP23S17 portA(IOE_ADDR, 0, 1<<0 | 1<<1 );
|
||||||
|
12
src/LED_PortOpenDrain.cpp
Normal file
12
src/LED_PortOpenDrain.cpp
Normal file
@ -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);
|
||||||
|
}
|
36
src/LED_PortOpenDrain.h
Normal file
36
src/LED_PortOpenDrain.h
Normal file
@ -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
|
Reference in New Issue
Block a user