From 45477a954dfb243d1dab82d638339ff924904629 Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Mon, 6 Jun 2016 00:52:14 -0600 Subject: [PATCH] change activeHigh to static --- src/Matrix.cpp | 2 +- src/Matrix.h | 7 ++----- src/Row.cpp | 4 ++-- src/Row.h | 2 +- src/RowBase.h | 2 +- src/RowScannerInterface.h | 2 +- src/RowScanner_BitManipulation.cpp | 6 +++--- src/RowScanner_BitManipulation.h | 5 +++-- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index a508e09..5904205 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -7,6 +7,6 @@ void Matrix::scan() { for (uint8_t i=0; i < rowCount; i++) { - ptrsRows[i]->process(activeHigh); + ptrsRows[i]->process(); } } diff --git a/src/Matrix.h b/src/Matrix.h index d1474e5..8107dd4 100644 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -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 diff --git a/src/Row.cpp b/src/Row.cpp index b72e1b6..d1bbd56 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -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); } diff --git a/src/Row.h b/src/Row.h index 759d006..b8c7f7c 100644 --- a/src/Row.h +++ b/src/Row.h @@ -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 diff --git a/src/RowBase.h b/src/RowBase.h index 20212cc..7074f13 100644 --- a/src/RowBase.h +++ b/src/RowBase.h @@ -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 diff --git a/src/RowScannerInterface.h b/src/RowScannerInterface.h index a7284ff..ca45a0f 100644 --- a/src/RowScannerInterface.h +++ b/src/RowScannerInterface.h @@ -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 diff --git a/src/RowScanner_BitManipulation.cpp b/src/RowScanner_BitManipulation.cpp index 7e33b14..2599d70 100644 --- a/src/RowScanner_BitManipulation.cpp +++ b/src/RowScanner_BitManipulation.cpp @@ -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 diff --git a/src/RowScanner_BitManipulation.h b/src/RowScanner_BitManipulation.h index 2cb93c1..3db523d 100644 --- a/src/RowScanner_BitManipulation.h +++ b/src/RowScanner_BitManipulation.h @@ -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