Browse Source

rename strobeOn to activeState

tags/v0.6.4
wolfv6 7 years ago
parent
commit
b149a831de

+ 2
- 2
doc/keybrd_library_user_guide.md View File

For active low: For active low:
* Orient diodes with cathode (banded end) towards the write pins (row) * Orient diodes with cathode (banded end) towards the write pins (row)
* Instantiate the scanner in the sketch with strobeOn LOW, like this:
* Instantiate the scanner in the sketch with activeState LOW, like this:
``` ```
Scanner_uC scanner(LOW, readPins, readPinCount); Scanner_uC scanner(LOW, readPins, readPinCount);
``` ```
For active high: For active high:
* Add an external 10k pull-down resistor to each read pin. * Add an external 10k pull-down resistor to each read pin.
* Orient diodes with cathode (banded end) towards the read pins. * Orient diodes with cathode (banded end) towards the read pins.
* Instantiate the scanner in the sketch with strobeOn HIGH, like this:
* Instantiate the scanner in the sketch with activeState HIGH, like this:
``` ```
Scanner_uC scanner(HIGH, readPins, readPinCount); Scanner_uC scanner(HIGH, readPins, readPinCount);
``` ```

+ 1
- 1
src/PortInterface.h View File

{ {
public: public:
virtual void beginProtocol()=0; //SPI bus or I2C bus virtual void beginProtocol()=0; //SPI bus or I2C bus
virtual void begin(const uint8_t strobeOn)=0; //configure GPIO pins
virtual void begin(const uint8_t activeState)=0; //configure GPIO pins
virtual void setLow(const uint8_t pin)=0; virtual void setLow(const uint8_t pin)=0;
virtual void setHigh(const uint8_t pin)=0; virtual void setHigh(const uint8_t pin)=0;
virtual uint8_t read()=0; virtual uint8_t read()=0;

+ 2
- 2
src/Port_MCP23018.cpp View File

/* begin() is called from Scanner_IOE::begin(). /* begin() is called from Scanner_IOE::begin().
Configures port's IODIR and GPPU. Configures port's IODIR and GPPU.
*/ */
void Port_MCP23018::begin(const uint8_t strobeOn)
void Port_MCP23018::begin(const uint8_t activeState)
{ {
uint8_t pullUp; //bits, GPPU 0=pull-up disabled, 1=pull-up enabled uint8_t pullUp; //bits, GPPU 0=pull-up disabled, 1=pull-up enabled
if (strobeOn == LOW) //if active low
if (activeState == LOW) //if active low
{ {
pullUp = readPins; //0=pull-up disabled (for LED), 1=pull-up enabled (for read) pullUp = readPins; //0=pull-up disabled (for LED), 1=pull-up enabled (for read)
} }

+ 1
- 1
src/Port_MCP23018.h View File

Port_MCP23018(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins) Port_MCP23018(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins)
: deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {} : deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {}
void beginProtocol(); void beginProtocol();
void begin(const uint8_t strobeOn);
void begin(const uint8_t activeState);
virtual void setLow(const uint8_t pin); virtual void setLow(const uint8_t pin);
virtual void setHigh(const uint8_t pin); virtual void setHigh(const uint8_t pin);
virtual uint8_t read(); virtual uint8_t read();

+ 3
- 3
src/Port_MCP23S17.cpp View File

} }


/* begin() is called from Scanner_IOE::begin(). /* begin() is called from Scanner_IOE::begin().
strobeOn is logic level of strobe on, HIGH or LOW
activeState is logic level of strobe on, HIGH or LOW
configure IODIR and GPPU. configure IODIR and GPPU.
*/ */
void Port_MCP23S17::begin(const uint8_t strobeOn)
void Port_MCP23S17::begin(const uint8_t activeState)
{ {
uint8_t pullUp; //bits, GPPU 0=pull-up disabled, 1=pull-up enabled uint8_t pullUp; //bits, GPPU 0=pull-up disabled, 1=pull-up enabled


if (strobeOn == LOW) //if active low
if (activeState == LOW) //if active low
{ {
pullUp = readPins; //0=pull-up disabled (for LED), 1=pull-up enabled (for read) pullUp = readPins; //0=pull-up disabled (for LED), 1=pull-up enabled (for read)
} }

+ 1
- 1
src/Port_MCP23S17.h View File

Port_MCP23S17(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins) Port_MCP23S17(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins)
: deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {} : deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {}
void beginProtocol(); void beginProtocol();
void begin(const uint8_t strobeOn);
void begin(const uint8_t activeState);
virtual void setLow(const uint8_t pin); virtual void setLow(const uint8_t pin);
virtual void setHigh(const uint8_t pin); virtual void setHigh(const uint8_t pin);
virtual uint8_t read(); virtual uint8_t read();

+ 2
- 2
src/Port_PCA9655E.cpp View File

/* begin() is called from Scanner_IOE::begin(). /* begin() is called from Scanner_IOE::begin().
Configures read pins to input. Configures read pins to input.
strobeOn is not used because PCA9655E has no internal pull-up resistors.
activeState is not used because PCA9655E has no internal pull-up resistors.
*/ */
void Port_PCA9655E::begin(const uint8_t strobeOn)
void Port_PCA9655E::begin(const uint8_t activeState)
{ {
Wire.beginTransmission(deviceAddr); Wire.beginTransmission(deviceAddr);
Wire.write(portNum + 6); //configure direction Wire.write(portNum + 6); //configure direction

+ 1
- 1
src/Port_PCA9655E.h View File

Port_PCA9655E(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins) Port_PCA9655E(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins)
: deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {} : deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {}
void beginProtocol(); void beginProtocol();
void begin(const uint8_t strobeOn);
void begin(const uint8_t activeState);
virtual void setLow(const uint8_t pin); virtual void setLow(const uint8_t pin);
virtual void setHigh(const uint8_t pin); virtual void setHigh(const uint8_t pin);
virtual uint8_t read(); virtual uint8_t read();

+ 2
- 2
tutorials/keybrd_2_single-layer/keybrd_2_single-layer.ino View File

uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins); uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins);


/* /*
Scanner_uC constructor parameters are: strobeOn, readPins[], readPinCount.
strobeOn defines the logic level for strobes, HIGH or LOW.
Scanner_uC constructor parameters are: activeState, readPins[], readPinCount.
activeState defines the logic level for strobes, HIGH or LOW.
"Active low" means that if a switch is pressed (active), the read pin is low. "Active low" means that if a switch is pressed (active), the read pin is low.
The scanner uses readPins and readPinCount to read the colums. The scanner uses readPins and readPinCount to read the colums.
*/ */

+ 2
- 2
tutorials/keybrd_6_active_high/keybrd_6_active_high.ino View File

uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins); uint8_t readPinCount = sizeof(readPins)/sizeof(*readPins);


/* /*
Scanner_uC constructor parameters are: strobeOn, readPins[], readPinCount.
strobeOn defines the logic level for strobes, HIGH or LOW.
Scanner_uC constructor parameters are: activeState, readPins[], readPinCount.
activeState defines the logic level for strobes, HIGH or LOW.
"Active high" means that if a switch is pressed (active), the read pin is high. "Active high" means that if a switch is pressed (active), the read pin is high.
*/ */
Scanner_uC scanner(HIGH, readPins, readPinCount); Scanner_uC scanner(HIGH, readPins, readPinCount);

+ 2
- 2
tutorials/tutorial_6_active_high.md View File



To make a key matrix active low: To make a key matrix active low:
* Orient diodes with cathode (banded end) towards the strobe pins (row) * Orient diodes with cathode (banded end) towards the strobe pins (row)
* Instantiate the scanner in the sketch with strobeOn LOW, like this:
* Instantiate the scanner in the sketch with activeState LOW, like this:
``` ```
Scanner_uC scanner(LOW, readPins, readPinCount); Scanner_uC scanner(LOW, readPins, readPinCount);
``` ```
To make a key matrix active high: To make a key matrix active high:
* Add an external 10k Ohm pull-down resistor to each read pin * Add an external 10k Ohm pull-down resistor to each read pin
* Orient diodes with cathode (banded end) towards the read pins * Orient diodes with cathode (banded end) towards the read pins
* Instantiate the scanner in the sketch with strobeOn HIGH, like this:
* Instantiate the scanner in the sketch with activeState HIGH, like this:
``` ```
Scanner_uC scanner(HIGH, readPins, readPinCount); Scanner_uC scanner(HIGH, readPins, readPinCount);
``` ```