From f368c1fdad2671acebc1efa59c7ec2c88856ec26 Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Mon, 6 Jun 2016 15:11:19 -0600 Subject: [PATCH] RowScanner_Arduino, add stobePin, 2 rows --- src/Row.h | 2 +- src/RowBase.cpp | 6 ++++-- src/RowScanner_Arduino.cpp | 6 +++--- src/RowScanner_Arduino.h | 11 ++++++----- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Row.h b/src/Row.h index 717caef..a316c40 100644 --- a/src/Row.h +++ b/src/Row.h @@ -24,7 +24,7 @@ class Row : public RowBase Debouncer_4Samples debouncer; public: //Row constructor was like Row_DH constructor - Row(Key *const ptrsKeys[]) : RowBase(ptrsKeys) { } + Row(const uint8_t rowPin, Key *const ptrsKeys[]) : RowBase(ptrsKeys), scanner(rowPin) { } virtual void process(); }; #endif diff --git a/src/RowBase.cpp b/src/RowBase.cpp index 8e5cebd..50b5272 100644 --- a/src/RowBase.cpp +++ b/src/RowBase.cpp @@ -23,11 +23,13 @@ Tactile switch MJTP series bounce 10 ms http://www.apem.com/files/apem/brochures Avoid sampling the switch input at a rate synchronous to events in the environment that might create periodic EMI. For instance, 50 and 60 Hz. +The largest allowabl DELAY_MICROSECONDS is 65535 (.065535 second). + Polling I2C may slow the scan rate enough so that no additional delay is needed: const unsigned int Row::DELAY_MICROSECONDS = 0; -Slow-scan trick for debug messages that print too fast: - change DELAY_MICROSECONDS to a large number like 10000 +Slow-scan trick for debug messages that print too fast, add delay: + delay(1000); That way debug messages are printed at a managable rate. */ void RowBase::wait() diff --git a/src/RowScanner_Arduino.cpp b/src/RowScanner_Arduino.cpp index dc4e967..07c7353 100644 --- a/src/RowScanner_Arduino.cpp +++ b/src/RowScanner_Arduino.cpp @@ -1,7 +1,7 @@ #include "RowScanner_Arduino.h" /* Strobes the row and reads the columns. -Strobe is on for shortest possible time to preserve IR LED on DodoHand's optic switch. +Strobe is on for shortest possible time. */ uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd) { @@ -10,11 +10,11 @@ uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd) //strobe row on if (activeHigh) { - digitalWrite(0, HIGH); + digitalWrite(stobePin, HIGH); } else //activeLow { - digitalWrite(0, LOW); + digitalWrite(stobePin, LOW); } delayMicroseconds(3); //time to stablize voltage diff --git a/src/RowScanner_Arduino.h b/src/RowScanner_Arduino.h index 05c3f41..3328810 100644 --- a/src/RowScanner_Arduino.h +++ b/src/RowScanner_Arduino.h @@ -7,7 +7,7 @@ #include /* rowPin > stobePins[] replace port calls with - x pass 1: hard coded pins for row0 and col6, init in setup() + x pass 1: hard code pins for row0 and col6, init in setup() pass 2: pins[] array - first strobe, then read pass 3: move calls to IC classes - Strobe_uC, Read_uC pass 4: add IC classes Strobe_MCP23018, Read_MCP23018 */ @@ -15,13 +15,14 @@ class RowScanner_Arduino : public RowScannerInterface { private: static const bool activeHigh; //logic level of strobe pin: 0=activeLow, 1=activeHigh - //const uint8_t* stobePins; //array of strobe pins + const uint8_t stobePin; //Arduino pin number connected to this row //const uint8_t* readPins; //array of read pins //const uint8_t readPinCount; public: - /*RowScanner_Arduino() - : - readPinCount(readPinCount) {}*/ + RowScanner_Arduino(const uint8_t stobePin) + : stobePin(stobePin) + // readPinCount(readPinCount) + {} virtual uint8_t scan(uint16_t& rowEnd); uint8_t getRowState(uint16_t& rowEnd); };