Browse Source

add RowScanner_Arduino, hard code pins for row0 and col6, init in setup()

tags/v0.5.0
wolfv6 8 years ago
parent
commit
bf0cfd608a
4 changed files with 95 additions and 5 deletions
  1. 6
    5
      src/Row.h
  2. 2
    0
      src/RowBase.cpp
  3. 58
    0
      src/RowScanner_Arduino.cpp
  4. 29
    0
      src/RowScanner_Arduino.h

+ 6
- 5
src/Row.h View File

@@ -2,7 +2,8 @@
#define ROW_H

#include <RowBase.h>
#include <RowScanner_BitManipulation.h>
//#include <RowScanner_BitManipulation.h>
#include <RowScanner_Arduino.h>
#include <Debouncer_4Samples.h>

/*
@@ -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

+ 2
- 0
src/RowBase.cpp View File

@@ -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 ");
}
/*

+ 58
- 0
src/RowScanner_Arduino.cpp View File

@@ -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;
}

+ 29
- 0
src/RowScanner_Arduino.h View File

@@ -0,0 +1,29 @@
#ifndef ROWSCANNER_ARDUINO_H
#define ROWSCANNER_ARDUINO_H
#include <Arduino.h>
#include <inttypes.h>
#include <RowScannerInterface.h>
#include <RowPort.h>
#include <ColPort.h>
/* 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