Archived
1
0

change activeHigh to static

This commit is contained in:
wolfv6 2016-06-06 00:52:14 -06:00
parent cd8de41339
commit 45477a954d
8 changed files with 14 additions and 16 deletions

View File

@ -7,6 +7,6 @@ void Matrix::scan()
{
for (uint8_t i=0; i < rowCount; i++)
{
ptrsRows[i]->process(activeHigh);
ptrsRows[i]->process();
}
}

View File

@ -30,12 +30,9 @@ class Matrix
private:
RowBase *const *const ptrsRows; //array of row pointers
const uint8_t rowCount;
const bool activeHigh; //logic level of strobe pin: 0=activeLow, 1=activeHigh
public:
Matrix( RowBase *const ptrsRows[], const uint8_t rowCount, const bool activeHigh)
: ptrsRows(ptrsRows), rowCount(rowCount), activeHigh(activeHigh) {}
Matrix( RowBase *const ptrsRows[], const uint8_t rowCount)
: ptrsRows(ptrsRows), rowCount(rowCount) {}
void scan();
};
#endif

View File

@ -7,7 +7,7 @@ For return, 1 means debounced changed.
/*
process() scans the row and calls any newly pressed or released keys.
*/
void Row::process(const bool activeHigh)
void Row::process()
{
//these variables are all bitwise, one bit per key
uint8_t rowState; //1 means pressed, 0 means released
@ -15,7 +15,7 @@ void Row::process(const bool activeHigh)
uint8_t debouncedChanged; //1 means debounced changed
wait();
rowState = scanner.scan(rowEnd, activeHigh);
rowState = scanner.scan(rowEnd);
debouncedChanged = debouncer.debounce(rowState, debounced);
pressRelease(rowEnd, debouncedChanged);
}

View File

@ -24,6 +24,6 @@ class Row : public RowBase
Row( RowPort &refRowPort, const uint8_t rowPin,
ColPort *const ptrsColPorts[], const uint8_t colPortCount, Key *const ptrsKeys[])
: RowBase(ptrsKeys), scanner(refRowPort, rowPin, ptrsColPorts, colPortCount) { }
virtual void process(const bool activeHigh);
virtual void process();
};
#endif

View File

@ -20,6 +20,6 @@ class RowBase
void pressRelease(const uint16_t rowEnd, const uint8_t debouncedChanged);
public:
RowBase(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { }
virtual void process(const bool activeHigh)=0;
virtual void process()=0;
};
#endif

View File

@ -12,7 +12,7 @@ rowEnd and rowMask are larger type than portMask so that they can not overflow.
class RowScannerInterface
{
public:
virtual uint8_t scan(uint16_t& rowEnd, const bool activeHigh)=0;
virtual uint8_t scan(uint16_t& rowEnd)=0;
};
#endif

View File

@ -3,7 +3,7 @@
Strobes the row and reads the columns.
Strobe is on for shortest possible time to preserve IR LED on DodoHand's optic switch.
*/
uint8_t RowScanner_BitManipulation::scan(uint16_t& rowEnd, const bool activeHigh)
uint8_t RowScanner_BitManipulation::scan(uint16_t& rowEnd)
{
//strobe row on
if (activeHigh)
@ -31,7 +31,7 @@ uint8_t RowScanner_BitManipulation::scan(uint16_t& rowEnd, const bool activeHigh
refRowPort.setActivePinHigh(rowPin);
}
return getRowState(rowEnd, activeHigh);
return getRowState(rowEnd);
}
/*
@ -40,7 +40,7 @@ Sets rowEnd and returns rowState.
rowEnd is bitwise, where 1 bit corrsiponds to place immediatly after last key of row.
rowEnd and rowMask are larger type than portMask so that they can not overflow.
*/
uint8_t RowScanner_BitManipulation::getRowState(uint16_t& rowEnd, const bool activeHigh)
uint8_t RowScanner_BitManipulation::getRowState(uint16_t& rowEnd)
{
uint16_t rowMask = 1; //bitwise, one col per bit, active col bit is 1
uint8_t rowState = 0; //bitwise, one key per bit, 1 means key is pressed

View File

@ -9,6 +9,7 @@
class RowScanner_BitManipulation : public RowScannerInterface
{
private:
static const bool activeHigh; //logic level of strobe pin: 0=activeLow, 1=activeHigh
RowPort &refRowPort; //this row's IC port
const uint8_t rowPin; //bitwise, 1 indicates IC pin connected to this row
@ -20,7 +21,7 @@ class RowScanner_BitManipulation : public RowScannerInterface
ColPort *const ptrsColPorts[], const uint8_t colPortCount)
: refRowPort(refRowPort), rowPin(rowPin),
ptrsColPorts(ptrsColPorts), colPortCount(colPortCount) {}
virtual uint8_t scan(uint16_t& rowEnd, const bool activeHigh);
uint8_t getRowState(uint16_t& rowEnd, const bool activeHigh);
virtual uint8_t scan(uint16_t& rowEnd);
uint8_t getRowState(uint16_t& rowEnd);
};
#endif