Archived
1
0

RowScanner_Arduino, add stobePin, 2 rows

This commit is contained in:
wolfv6 2016-06-06 15:11:19 -06:00
parent bf0cfd608a
commit f368c1fdad
4 changed files with 14 additions and 11 deletions

View File

@ -24,7 +24,7 @@ class Row : public RowBase
Debouncer_4Samples debouncer; Debouncer_4Samples debouncer;
public: public:
//Row constructor was like Row_DH constructor //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(); virtual void process();
}; };
#endif #endif

View File

@ -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 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. 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: Polling I2C may slow the scan rate enough so that no additional delay is needed:
const unsigned int Row::DELAY_MICROSECONDS = 0; const unsigned int Row::DELAY_MICROSECONDS = 0;
Slow-scan trick for debug messages that print too fast: Slow-scan trick for debug messages that print too fast, add delay:
change DELAY_MICROSECONDS to a large number like 10000 delay(1000);
That way debug messages are printed at a managable rate. That way debug messages are printed at a managable rate.
*/ */
void RowBase::wait() void RowBase::wait()

View File

@ -1,7 +1,7 @@
#include "RowScanner_Arduino.h" #include "RowScanner_Arduino.h"
/* /*
Strobes the row and reads the columns. 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) uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd)
{ {
@ -10,11 +10,11 @@ uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd)
//strobe row on //strobe row on
if (activeHigh) if (activeHigh)
{ {
digitalWrite(0, HIGH); digitalWrite(stobePin, HIGH);
} }
else //activeLow else //activeLow
{ {
digitalWrite(0, LOW); digitalWrite(stobePin, LOW);
} }
delayMicroseconds(3); //time to stablize voltage delayMicroseconds(3); //time to stablize voltage

View File

@ -7,7 +7,7 @@
#include <ColPort.h> #include <ColPort.h>
/* rowPin > stobePins[] /* rowPin > stobePins[]
replace port calls with 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 2: pins[] array - first strobe, then read
pass 3: move calls to IC classes - Strobe_uC, Read_uC pass 3: move calls to IC classes - Strobe_uC, Read_uC
pass 4: add IC classes Strobe_MCP23018, Read_MCP23018 */ pass 4: add IC classes Strobe_MCP23018, Read_MCP23018 */
@ -15,13 +15,14 @@ class RowScanner_Arduino : public RowScannerInterface
{ {
private: private:
static const bool activeHigh; //logic level of strobe pin: 0=activeLow, 1=activeHigh 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* readPins; //array of read pins
//const uint8_t readPinCount; //const uint8_t readPinCount;
public: public:
/*RowScanner_Arduino() RowScanner_Arduino(const uint8_t stobePin)
: : stobePin(stobePin)
readPinCount(readPinCount) {}*/ // readPinCount(readPinCount)
{}
virtual uint8_t scan(uint16_t& rowEnd); virtual uint8_t scan(uint16_t& rowEnd);
uint8_t getRowState(uint16_t& rowEnd); uint8_t getRowState(uint16_t& rowEnd);
}; };