@@ -1,16 +1,15 @@ | |||
#ifndef PORTREAD_H | |||
#define PORTREAD_H | |||
#ifndef PORTREADINTERFACE_H | |||
#define PORTREADINTERFACE_H | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
/* | |||
PortRead is an abstract base class. | |||
Port classes are the keybrd library's interface to microcontroller ports or I/O expander ports. | |||
If your 8-bit AVR (Teensy 2) is running low on memory, using a smaller read_pins_t type saves SRAM. | |||
Details are in config_key.h | |||
*/ | |||
class PortRead | |||
class PortReadInterface | |||
{ | |||
public: | |||
virtual uint8_t read()=0; |
@@ -3,7 +3,7 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <SPI.h> | |||
#include <PortRead.h> | |||
#include <PortReadInterface.h> | |||
#include "PortIOE.h" | |||
#include "Scanner_Port.h" | |||
@@ -25,7 +25,7 @@ Example instantiation for column port 1, with pins 2 and 3 connected to columns: | |||
readPins are read from pin 0 on up. | |||
*/ | |||
class PortRead_MCP23S17 : public PortRead | |||
class PortRead_MCP23S17 : public PortReadInterface | |||
{ | |||
private: | |||
PortIOE& port; |
@@ -3,7 +3,7 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <Wire.h> | |||
#include <PortRead.h> | |||
#include <PortReadInterface.h> | |||
#include "PortIOE.h" | |||
/* One PCA9655E I/O expander port connected to matrix columns. | |||
@@ -25,7 +25,7 @@ Example instantiation for column port 1, with pins 2 and 3 connected to columns: | |||
readPins are read from pin 0 on up. | |||
*/ | |||
class PortRead_PCA9655E : public PortRead | |||
class PortRead_PCA9655E : public PortReadInterface | |||
{ | |||
private: | |||
PortIOE& port; |
@@ -1,16 +1,15 @@ | |||
#ifndef PORTWRITE_H | |||
#define PORTWRITE_H | |||
#ifndef PORTWRITEINTERFACE_H | |||
#define PORTWRITEINTERFACE_H | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
/* | |||
PortWrite is an abstract base class. | |||
Port classes are the keybrd library's interface to microcontroller ports or I/O expander ports. | |||
If your 8-bit AVR (Teensy 2) is running low on memory, using a smaller read_pins_t type saves SRAM. | |||
Details are in config_key.h | |||
*/ | |||
class PortWrite | |||
class PortWriteInterface | |||
{ | |||
public: | |||
virtual void write(const uint8_t pin, const bool level)=0; |
@@ -3,7 +3,7 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <SPI.h> | |||
#include <PortWrite.h> | |||
#include <PortWriteInterface.h> | |||
#include "PortIOE.h" | |||
/* One MCP23S17 I/O expander port connected to matrix rows. | |||
@@ -33,7 +33,7 @@ MCP23S17 data sheet | |||
http://www.onsemi.com/pub_link/Collateral/MCP23S17-D.PDF | |||
*/ | |||
class PortWrite_MCP23S17 : public PortWrite | |||
class PortWrite_MCP23S17 : public PortWriteInterface | |||
{ | |||
private: | |||
PortIOE& port; |
@@ -3,7 +3,7 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <Wire.h> | |||
#include <PortWrite.h> | |||
#include <PortWriteInterface.h> | |||
#include "PortIOE.h" | |||
/* One PCA9655E I/O expander port connected to matrix rows. | |||
@@ -33,7 +33,7 @@ PCA9655E data sheet | |||
http://www.onsemi.com/pub_link/Collateral/PCA9655E-D.PDF | |||
*/ | |||
class PortWrite_PCA9655E : public PortWrite | |||
class PortWrite_PCA9655E : public PortWriteInterface | |||
{ | |||
private: | |||
PortIOE& port; |
@@ -4,8 +4,8 @@ | |||
#include <Row.h> | |||
#include <Scanner_Port.h> | |||
#include <Debouncer_Samples.h> | |||
class PortWrite; | |||
class PortRead; | |||
class PortWriteInterface; | |||
class PortReadInterface; | |||
/* Row_IOE is a row connected to an Input/Output Expander. | |||
Configuration and Instantiation instructions are in keybrd/src/Row_IOE.h | |||
@@ -17,8 +17,8 @@ class Row_IOE : public Row | |||
Debouncer_Samples debouncer; | |||
const uint8_t readPinCount; //number of read pins | |||
public: | |||
Row_IOE(PortWrite& refPortWrite, const uint8_t strobePin, | |||
PortRead& refPortRead, const uint8_t readPinCount, Key *const ptrsKeys[]) | |||
Row_IOE(PortWriteInterface& refPortWrite, const uint8_t strobePin, | |||
PortReadInterface& refPortRead, const uint8_t readPinCount, Key *const ptrsKeys[]) | |||
: Row(ptrsKeys), scanner(refPortWrite, strobePin, refPortRead), | |||
readPinCount(readPinCount) { } | |||
void process(); |
@@ -3,8 +3,8 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <PortWrite.h> | |||
#include <PortRead.h> | |||
#include <PortWriteInterface.h> | |||
#include <PortReadInterface.h> | |||
/* Scanner_Port uses bit manipulation to read all pins of one port. | |||
The ports are normally from an I/O Expander, but could also be ports from an AVR uC. | |||
@@ -17,12 +17,14 @@ class Scanner_Port | |||
private: | |||
static const bool STROBE_ON; //HIGH or LOW logic level of strobe on, active state | |||
static const bool STROBE_OFF; //logic level of strobe off, complement of STROBE_ON | |||
PortWrite& refPortWrite; //the IC port containing the strobePin | |||
PortWriteInterface& refPortWrite; //the IC port containing the strobePin | |||
const uint8_t strobePin; //bitwise, 1 indicates IC pin connected to this row | |||
PortRead& refPortRead; //the IC's read port | |||
PortReadInterface& refPortRead; //the IC's read port | |||
public: | |||
Scanner_Port(PortWrite &refPortWrite, const uint8_t strobePin, PortRead& refPortRead) | |||
: refPortWrite(refPortWrite), strobePin(strobePin), refPortRead(refPortRead) {} | |||
Scanner_Port(PortWriteInterface &refPortWrite, const uint8_t strobePin, | |||
PortReadInterface& refPortRead) | |||
: refPortWrite(refPortWrite), strobePin(strobePin), | |||
refPortRead(refPortRead) {} | |||
uint8_t scan(); | |||
}; | |||
#endif |
@@ -5,8 +5,8 @@ | |||
#include <inttypes.h> | |||
#include <config_keybrd.h> | |||
#include <SPI.h> | |||
#include <PortWrite.h> | |||
#include <PortRead.h> | |||
#include <PortWriteInterface.h> | |||
#include <PortReadInterface.h> | |||
/* Scanner_ShiftRegs74HC165 reads shift registers. | |||
shift registers 74HC165 are Parallel-In-Serial-Out (PISO) |
@@ -4,8 +4,8 @@ | |||
#include <Arduino.h> | |||
#include <inttypes.h> | |||
#include <config_keybrd.h> | |||
#include <PortWrite.h> | |||
#include <PortRead.h> | |||
#include <PortWriteInterface.h> | |||
#include <PortReadInterface.h> | |||
/* Scanner_uC class uses Arduino pin numbers (not port pin numbers). | |||
Constructor is in Scanner_uC.cpp |