diff --git a/src/Row.h b/src/Row.h index b8c7f7c..717caef 100644 --- a/src/Row.h +++ b/src/Row.h @@ -2,7 +2,8 @@ #define ROW_H #include -#include +//#include +#include #include /* @@ -18,12 +19,12 @@ Instantiation class Row : public RowBase { private: - RowScanner_BitManipulation scanner; + //RowScanner_BitManipulation scanner; + RowScanner_Arduino scanner; Debouncer_4Samples debouncer; public: - Row( RowPort &refRowPort, const uint8_t rowPin, - ColPort *const ptrsColPorts[], const uint8_t colPortCount, Key *const ptrsKeys[]) - : RowBase(ptrsKeys), scanner(refRowPort, rowPin, ptrsColPorts, colPortCount) { } + //Row constructor was like Row_DH constructor + Row(Key *const ptrsKeys[]) : RowBase(ptrsKeys) { } virtual void process(); }; #endif diff --git a/src/RowBase.cpp b/src/RowBase.cpp index cc28cf9..8e5cebd 100644 --- a/src/RowBase.cpp +++ b/src/RowBase.cpp @@ -33,6 +33,8 @@ 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 "); } /* diff --git a/src/RowScanner_Arduino.cpp b/src/RowScanner_Arduino.cpp new file mode 100644 index 0000000..dc4e967 --- /dev/null +++ b/src/RowScanner_Arduino.cpp @@ -0,0 +1,58 @@ +#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. +*/ +uint8_t RowScanner_Arduino::scan(uint16_t& rowEnd) +{ + uint8_t rowState = 0; + + //strobe row on + if (activeHigh) + { + digitalWrite(0, HIGH); + } + else //activeLow + { + digitalWrite(0, LOW); + } + delayMicroseconds(3); //time to stablize voltage + +/* + uint8_t col = 1; + + //read all the column ports + for (uint8_t i=0; i < readPinCount; i++) + { + if (digitalRead(6)) + { + rowState |= col; + //ptrsColPorts[i]->read(); + } + col <<= 1; + } +*/ + if (digitalRead(6) == 0) + { + rowState |= 1<<0; + } + if (digitalRead(7) == 0) + { + rowState |= 1<<1; + } + + //strobe row off + if (activeHigh) + { + digitalWrite(0, LOW); + } + else //activeLow + { + digitalWrite(0, HIGH); + } + + rowEnd = 4; //only read first two col, a1 b2 4 + +Keyboard.print(rowState); // prints 2b, not 1a, what happened to col0? + return rowState; +} diff --git a/src/RowScanner_Arduino.h b/src/RowScanner_Arduino.h new file mode 100644 index 0000000..05c3f41 --- /dev/null +++ b/src/RowScanner_Arduino.h @@ -0,0 +1,29 @@ +#ifndef ROWSCANNER_ARDUINO_H +#define ROWSCANNER_ARDUINO_H +#include +#include +#include +#include +#include +/* rowPin > stobePins[] +replace port calls with + x pass 1: hard coded 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 */ +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* readPins; //array of read pins + //const uint8_t readPinCount; + public: + /*RowScanner_Arduino() + : + readPinCount(readPinCount) {}*/ + virtual uint8_t scan(uint16_t& rowEnd); + uint8_t getRowState(uint16_t& rowEnd); +}; +#endif +