rename Scanner_ShiftRegsPISOSingleRow to Scanner_ShiftRegsRead, Scanner_ShiftRegsPISOMultiRow to Scanner_ShiftRegsReadStrobed
This commit is contained in:
parent
d9465be221
commit
5404ae451c
@ -1,9 +1,9 @@
|
||||
#include "Scanner_ShiftRegsPISOSingleRow.h"
|
||||
#include "Scanner_ShiftRegsRead.h"
|
||||
|
||||
/* constructor
|
||||
Parameter strobeOn is not used.
|
||||
*/
|
||||
Scanner_ShiftRegsPISOSingleRow::Scanner_ShiftRegsPISOSingleRow(const bool strobeOn,
|
||||
Scanner_ShiftRegsRead::Scanner_ShiftRegsRead(const bool strobeOn,
|
||||
const uint8_t slaveSelect, const uint8_t byte_count)
|
||||
: slaveSelect(slaveSelect), byte_count(byte_count)
|
||||
{
|
||||
@ -12,7 +12,7 @@ Scanner_ShiftRegsPISOSingleRow::Scanner_ShiftRegsPISOSingleRow(const bool strobe
|
||||
|
||||
/* init() is called once for each row from Row constructor.
|
||||
*/
|
||||
void Scanner_ShiftRegsPISOSingleRow::init(const uint8_t strobePin)
|
||||
void Scanner_ShiftRegsRead::init(const uint8_t strobePin)
|
||||
{
|
||||
//empty function
|
||||
}
|
||||
@ -20,7 +20,7 @@ void Scanner_ShiftRegsPISOSingleRow::init(const uint8_t strobePin)
|
||||
/* begin() should be called once from sketch setup().
|
||||
Initializes shift register's shift/load pin.
|
||||
*/
|
||||
void Scanner_ShiftRegsPISOSingleRow::begin()
|
||||
void Scanner_ShiftRegsRead::begin()
|
||||
{
|
||||
SPI.begin();
|
||||
digitalWrite(slaveSelect, HIGH);
|
||||
@ -31,7 +31,7 @@ Parameter strobePin is not used.
|
||||
No strobe pin is needed, the shift register is wired so the strobe is effectivley always "on".
|
||||
Bit patterns are 1 bit per key.
|
||||
*/
|
||||
read_pins_t Scanner_ShiftRegsPISOSingleRow::scan(const uint8_t strobePin)
|
||||
read_pins_t Scanner_ShiftRegsRead::scan(const uint8_t strobePin)
|
||||
{
|
||||
read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released
|
||||
|
@ -7,18 +7,18 @@
|
||||
#include <SPI.h>
|
||||
#include <ScannerInterface.h>
|
||||
|
||||
/* Scanner_ShiftRegsPISOSingleRow reads shift registers.
|
||||
/* Scanner_ShiftRegsRead reads shift registers.
|
||||
This was tested on 74HC165 shift registers, which are Parallel-In-Serial-Out (PISO).
|
||||
Upto 4 shift registers can be in a daisy chained for a total of 32 read pins.
|
||||
|
||||
Example instantiation:
|
||||
Row row_R0(scanner_R, 0, ptrsKeys_R0, sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0));
|
||||
Scanner_ShiftRegsPISOSingleRow scanner_R(HIGH, SS, 4);
|
||||
Scanner_ShiftRegsRead scanner_R(HIGH, SS, 4);
|
||||
|
||||
The Row "strobePin" parameter is ignored.
|
||||
In the above example, the "strobePin" argument is 0, but it doesn't matter what value is given.
|
||||
|
||||
There are three Scanner_ShiftRegsPISOSingleRow parameters.
|
||||
There are three Scanner_ShiftRegsRead parameters.
|
||||
"strobeOn" paramter is ignored, but should be active state HIGH or LOW required by ScannerInterface.
|
||||
|
||||
"slaveSelect" paramter can be any controller pin connected to shift register's SHIFT-LOAD pin.
|
||||
@ -42,13 +42,13 @@ Shift-register parallel-input pins need 10k pull-down resistors grounded.
|
||||
Switches connect grouned row to parallel-input pins.
|
||||
Controller's MISO pin is connected to shift register's serial output (QH) pin
|
||||
*/
|
||||
class Scanner_ShiftRegsPISOSingleRow : public ScannerInterface
|
||||
class Scanner_ShiftRegsRead : public ScannerInterface
|
||||
{
|
||||
private:
|
||||
const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
|
||||
const uint8_t byte_count; //number of bytes to read from shift registers
|
||||
public:
|
||||
Scanner_ShiftRegsPISOSingleRow(const bool strobeOn,
|
||||
Scanner_ShiftRegsRead(const bool strobeOn,
|
||||
const uint8_t slaveSelect, const uint8_t byte_count);
|
||||
void init(const uint8_t strobePin);
|
||||
void begin();
|
@ -1,6 +1,6 @@
|
||||
#include "Scanner_ShiftRegsPISOMultiRow.h"
|
||||
#include "Scanner_ShiftRegsReadStrobed.h"
|
||||
|
||||
Scanner_ShiftRegsPISOMultiRow::Scanner_ShiftRegsPISOMultiRow(const bool strobeOn,
|
||||
Scanner_ShiftRegsReadStrobed::Scanner_ShiftRegsReadStrobed(const bool strobeOn,
|
||||
const uint8_t slaveSelect, const uint8_t byte_count)
|
||||
: strobeOn(strobeOn), strobeOff(!strobeOn),
|
||||
slaveSelect(slaveSelect), byte_count(byte_count)
|
||||
@ -11,7 +11,7 @@ Scanner_ShiftRegsPISOMultiRow::Scanner_ShiftRegsPISOMultiRow(const bool strobeOn
|
||||
/* init() is called once for each row from Row constructor.
|
||||
Configures controller to communicate with shift register matrix.
|
||||
*/
|
||||
void Scanner_ShiftRegsPISOMultiRow::init(const uint8_t strobePin)
|
||||
void Scanner_ShiftRegsReadStrobed::init(const uint8_t strobePin)
|
||||
{
|
||||
pinMode(strobePin, OUTPUT);
|
||||
}
|
||||
@ -19,7 +19,7 @@ void Scanner_ShiftRegsPISOMultiRow::init(const uint8_t strobePin)
|
||||
/* begin() should be called once from sketch setup().
|
||||
Initializes shift register's shift/load pin.
|
||||
*/
|
||||
void Scanner_ShiftRegsPISOMultiRow::begin()
|
||||
void Scanner_ShiftRegsReadStrobed::begin()
|
||||
{
|
||||
digitalWrite(slaveSelect, HIGH); //initialize ??only needed for first scan
|
||||
SPI.begin(); //todo move this to constructor or init()
|
||||
@ -29,7 +29,7 @@ void Scanner_ShiftRegsPISOMultiRow::begin()
|
||||
strobePin is Arduino pin number connected to this row.
|
||||
Bit patterns are 1 bit per key.
|
||||
|
||||
Scanner_ShiftRegsPISOMultiRow class was tested on two sets of 74HC165 shift registers
|
||||
Scanner_ShiftRegsReadStrobed class was tested on two sets of 74HC165 shift registers
|
||||
and 74AHC1G126 tri-state buffer chips
|
||||
|
||||
74HC165 is not an SPI device.
|
||||
@ -40,7 +40,7 @@ To use SPI-like protocol, 74HC*126 will high-Z the MISO pin when the slave selec
|
||||
SPI.beginTransaction() and SPI.endTransaction() are not needed,
|
||||
but would be needed if trackball uses interrupts.
|
||||
*/
|
||||
read_pins_t Scanner_ShiftRegsPISOMultiRow::scan(const uint8_t strobePin)
|
||||
read_pins_t Scanner_ShiftRegsReadStrobed::scan(const uint8_t strobePin)
|
||||
{
|
||||
read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released
|
||||
|
@ -7,14 +7,14 @@
|
||||
#include <SPI.h>
|
||||
#include <ScannerInterface.h>
|
||||
|
||||
/* Scanner_ShiftRegsPISOMultiRow reads shift registers.
|
||||
/* Scanner_ShiftRegsReadStrobed reads shift registers.
|
||||
This was tested on 74HC165 shift registers, which are Parallel-In-Serial-Out (PISO).
|
||||
Shift registers can be daisy chained for a total of 32 read pins.
|
||||
|
||||
Example instantiation:
|
||||
Scanner_ShiftRegsPISOMultiRow scanner_R(HIGH, SS, 4);
|
||||
Scanner_ShiftRegsReadStrobed scanner_R(HIGH, SS, 4);
|
||||
|
||||
There are three Scanner_ShiftRegsPISOMultiRow parameters.
|
||||
There are three Scanner_ShiftRegsReadStrobed parameters.
|
||||
"strobeOn" paramter is active state HIGH or LOW.
|
||||
|
||||
"slaveSelect" paramter can be any controller pin connected to shift register's SHIFT-LOAD pin.
|
||||
@ -37,7 +37,7 @@ Shift-register parallel-input pins need 10k pull-down resistors grounded.
|
||||
Orient diodes with cathode (banded end) towards the read pins.
|
||||
Controller's MISO pin is connected to shift register's serial output (QH) pin
|
||||
*/
|
||||
class Scanner_ShiftRegsPISOMultiRow : public ScannerInterface
|
||||
class Scanner_ShiftRegsReadStrobed : public ScannerInterface
|
||||
{
|
||||
private:
|
||||
const bool strobeOn; //logic level of strobe on, active state HIGH or LOW
|
||||
@ -45,7 +45,7 @@ class Scanner_ShiftRegsPISOMultiRow : public ScannerInterface
|
||||
const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
|
||||
const uint8_t byte_count; //number of bytes to read from shift registers
|
||||
public:
|
||||
Scanner_ShiftRegsPISOMultiRow(const bool strobeOn,
|
||||
Scanner_ShiftRegsReadStrobed(const bool strobeOn,
|
||||
const uint8_t slaveSelect, const uint8_t byte_count);
|
||||
virtual void init(const uint8_t strobePin);
|
||||
virtual void begin();
|
@ -17,7 +17,7 @@ Tested on Teensy LC and two 74HC165 shift registers.
|
||||
#include <Row.h>
|
||||
|
||||
//Right matrix
|
||||
#include <Scanner_ShiftRegsPISOSingleRow.h>
|
||||
#include <Scanner_ShiftRegsRead.h>
|
||||
|
||||
// =============== CONFIGURATION ===============
|
||||
ScanDelay scanDelay(9000);
|
||||
@ -50,7 +50,7 @@ uint8_t readPinCount_L = sizeof(readPins_L)/sizeof(*readPins_L);
|
||||
Scanner_uC scanner_L(LOW, readPins_L, readPinCount_L); //active LOW
|
||||
|
||||
// --------------- RIGHT SCANNER ---------------
|
||||
Scanner_ShiftRegsPISOSingleRow scanner_R(HIGH, 10, 2); //active HIGH
|
||||
Scanner_ShiftRegsRead scanner_R(HIGH, 10, 2); //active HIGH
|
||||
|
||||
// =================== ROWS ====================
|
||||
// ----------------- LEFT ROWS -----------------
|
||||
|
Reference in New Issue
Block a user