Archived
1
0

in RowScanner_PinsArray, make all const CAPS

This commit is contained in:
wolfv6 2016-06-30 04:40:39 -06:00
parent 363194d70b
commit fd7da5aebb
2 changed files with 18 additions and 18 deletions

View File

@ -2,16 +2,16 @@
/* constructor
*/
RowScanner_PinsArray::RowScanner_PinsArray(const uint8_t strobePin,
const uint8_t readPins[], const uint8_t READ_PIN_COUNT)
: strobePin(strobePin), readPins(readPins), READ_PIN_COUNT(READ_PIN_COUNT)
RowScanner_PinsArray::RowScanner_PinsArray(const uint8_t STROBE_PIN,
const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT)
: STROBE_PIN(STROBE_PIN), READ_PINS(READ_PINS), READ_PIN_COUNT(READ_PIN_COUNT)
{
uint8_t mode;
//configure row
pinMode(strobePin, OUTPUT);
pinMode(STROBE_PIN, OUTPUT);
if (activeHigh)
if (ACTIVE_HIGH)
{
mode = INPUT; //requires external pull-down resistor
}
@ -23,7 +23,7 @@ RowScanner_PinsArray::RowScanner_PinsArray(const uint8_t strobePin,
//configure cols
for (uint8_t i=0; i < READ_PIN_COUNT; i++)
{
pinMode(readPins[i], mode);
pinMode(READ_PINS[i], mode);
}
}
@ -45,20 +45,20 @@ read_pins_t RowScanner_PinsArray::scan(read_pins_mask_t& rowEnd)
rowEnd = 1;
//strobe row on
if (activeHigh)
if (ACTIVE_HIGH)
{
digitalWrite(strobePin, HIGH);
digitalWrite(STROBE_PIN, HIGH);
}
else //activeLow
{
digitalWrite(strobePin, LOW);
digitalWrite(STROBE_PIN, LOW);
}
delayMicroseconds(3); //time to stablize voltage
//read all the column pins
for (uint8_t i=0; i < READ_PIN_COUNT; i++)
{
if ( digitalRead(readPins[i]) == activeHigh )
if ( digitalRead(READ_PINS[i]) == ACTIVE_HIGH )
{
rowState |= rowEnd;
}
@ -66,13 +66,13 @@ read_pins_t RowScanner_PinsArray::scan(read_pins_mask_t& rowEnd)
}
//strobe row off
if (activeHigh)
if (ACTIVE_HIGH)
{
digitalWrite(strobePin, LOW);
digitalWrite(STROBE_PIN, LOW);
}
else //activeLow
{
digitalWrite(strobePin, HIGH);
digitalWrite(STROBE_PIN, HIGH);
}
return rowState;

View File

@ -14,13 +14,13 @@ Constructor is in RowScanner_PinsArray.cpp
class RowScanner_PinsArray : public RowScannerInterface
{
private:
static const bool activeHigh; //logic level of strobe pin: 0=activeLow, 1=activeHigh
const uint8_t strobePin; //Arduino pin number connected to this row
const uint8_t* readPins; //array of read pin numbers
static const bool ACTIVE_HIGH; //logic level of strobe pin: 0=activeLow, 1=activeHigh
const uint8_t STROBE_PIN; //Arduino pin number connected to this row
const uint8_t* const READ_PINS; //array of read pin numbers
const uint8_t READ_PIN_COUNT; //number of read pins
public:
RowScanner_PinsArray(const uint8_t strobePin,
const uint8_t readPins[], const uint8_t READ_PIN_COUNT);
RowScanner_PinsArray(const uint8_t STROBE_PIN,
const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT);
virtual read_pins_t scan(read_pins_mask_t& rowEnd);
//read_pins_t getRowState(read_pins_mask_t& rowEnd);
};