@@ -24,7 +24,8 @@ class Row : public RowBase | |||
Debouncer_4Samples debouncer; | |||
public: | |||
//Row constructor was like Row_DH constructor | |||
Row(const uint8_t rowPin, Key *const ptrsKeys[]) : RowBase(ptrsKeys), scanner(rowPin) { } | |||
Row(const uint8_t strobePin, const uint8_t readPins[], const uint8_t READ_PIN_COUNT, Key *const ptrsKeys[]) | |||
: RowBase(ptrsKeys), scanner(strobePin, readPins, READ_PIN_COUNT) { } | |||
virtual void process(); | |||
}; | |||
#endif |
@@ -28,15 +28,13 @@ 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, add delay: | |||
Slow-scan trick for debug messages that print too fast, add delay to sketch loop(): | |||
delay(1000); | |||
That way debug messages are printed at a managable rate. | |||
*/ | |||
void RowBase::wait() | |||
{ | |||
delayMicroseconds(DELAY_MICROSECONDS); //delay between Row scans to debounce switches | |||
delay(500); | |||
Keyboard.print(" w "); | |||
} | |||
/* |
@@ -1,11 +1,11 @@ | |||
#include "RowScanner_Arduino.h" | |||
/* | |||
Strobes the row and reads the columns. | |||
Strobe is on for shortest possible time. | |||
*/ | |||
uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd) | |||
{ | |||
uint8_t rowState = 0; | |||
uint8_t col = 1; | |||
//strobe row on | |||
if (activeHigh) | |||
@@ -18,28 +18,26 @@ uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd) | |||
} | |||
delayMicroseconds(3); //time to stablize voltage | |||
/* | |||
uint8_t col = 1; | |||
//read all the column ports | |||
for (uint8_t i=0; i < readPinCount; i++) | |||
for (uint8_t i=0; i < READ_PIN_COUNT; i++) | |||
{ | |||
if (digitalRead(6)) | |||
if ( digitalRead(readPins[i]) == activeHigh ) | |||
{ | |||
rowState |= col; | |||
//ptrsColPorts[i]->read(); | |||
} | |||
/* | |||
Keyboard.print(" stobePin"); | |||
Keyboard.print(stobePin); | |||
Keyboard.print(" readPins["); | |||
Keyboard.print(i); | |||
Keyboard.print("]"); | |||
Keyboard.print((int)readPins[i]); | |||
Keyboard.print(" col"); | |||
Keyboard.print(col); | |||
Keyboard.print(" "); | |||
*/ | |||
col <<= 1; | |||
} | |||
*/ | |||
if (digitalRead(6) == 0) | |||
{ | |||
rowState |= 1<<0; | |||
} | |||
if (digitalRead(7) == 0) | |||
{ | |||
rowState |= 1<<1; | |||
} | |||
//strobe row off | |||
if (activeHigh) | |||
@@ -53,6 +51,6 @@ uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd) | |||
rowEnd = 4; //only read first two col, a1 b2 4 | |||
Keyboard.print(rowState); // prints 2b, not 1a, what happened to col0? | |||
//Keyboard.print(rowState); | |||
return rowState; | |||
} |
@@ -8,7 +8,7 @@ | |||
/* rowPin > stobePins[] | |||
replace port calls with | |||
x pass 1: hard code pins for row0 and col6, init in setup() | |||
pass 2: pins[] array - first strobe, then read | |||
x 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 */ | |||
class RowScanner_Arduino : public RowScannerInterface | |||
@@ -16,13 +16,12 @@ class RowScanner_Arduino : public RowScannerInterface | |||
private: | |||
static const bool activeHigh; //logic level of strobe pin: 0=activeLow, 1=activeHigh | |||
const uint8_t stobePin; //Arduino pin number connected to this row | |||
//const uint8_t* readPins; //array of read pins | |||
//const uint8_t readPinCount; | |||
const uint8_t* readPins; //array of read pins | |||
const uint8_t READ_PIN_COUNT;//todo READ_PIN_COUNT | |||
public: | |||
RowScanner_Arduino(const uint8_t stobePin) | |||
: stobePin(stobePin) | |||
// readPinCount(readPinCount) | |||
{} | |||
RowScanner_Arduino(const uint8_t stobePin, | |||
const uint8_t readPins[], const uint8_t READ_PIN_COUNT) | |||
: stobePin(stobePin), readPins(readPins), READ_PIN_COUNT(READ_PIN_COUNT) {} | |||
virtual uint8_t scan(uint16_t& rowEnd); | |||
uint8_t getRowState(uint16_t& rowEnd); | |||
}; |