From 5404ae451c7c887676ea982ca103cccc8ea1717c Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Wed, 2 Nov 2016 15:28:58 -0600 Subject: [PATCH] rename Scanner_ShiftRegsPISOSingleRow to Scanner_ShiftRegsRead, Scanner_ShiftRegsPISOMultiRow to Scanner_ShiftRegsReadStrobed --- ...gsPISOSingleRow.cpp => Scanner_ShiftRegsRead.cpp} | 10 +++++----- ...ftRegsPISOSingleRow.h => Scanner_ShiftRegsRead.h} | 10 +++++----- ...MultiRow.cpp => Scanner_ShiftRegsReadStrobed.cpp} | 12 ++++++------ ...PISOMultiRow.h => Scanner_ShiftRegsReadStrobed.h} | 10 +++++----- ...keybrd_4b_split_keyboard_with_shift_registers.ino | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) rename src/{Scanner_ShiftRegsPISOSingleRow.cpp => Scanner_ShiftRegsRead.cpp} (77%) rename src/{Scanner_ShiftRegsPISOSingleRow.h => Scanner_ShiftRegsRead.h} (87%) rename src/{Scanner_ShiftRegsPISOMultiRow.cpp => Scanner_ShiftRegsReadStrobed.cpp} (83%) rename src/{Scanner_ShiftRegsPISOMultiRow.h => Scanner_ShiftRegsReadStrobed.h} (87%) diff --git a/src/Scanner_ShiftRegsPISOSingleRow.cpp b/src/Scanner_ShiftRegsRead.cpp similarity index 77% rename from src/Scanner_ShiftRegsPISOSingleRow.cpp rename to src/Scanner_ShiftRegsRead.cpp index 8dd8fe6..5956165 100644 --- a/src/Scanner_ShiftRegsPISOSingleRow.cpp +++ b/src/Scanner_ShiftRegsRead.cpp @@ -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 diff --git a/src/Scanner_ShiftRegsPISOSingleRow.h b/src/Scanner_ShiftRegsRead.h similarity index 87% rename from src/Scanner_ShiftRegsPISOSingleRow.h rename to src/Scanner_ShiftRegsRead.h index 44f0204..3ba223c 100644 --- a/src/Scanner_ShiftRegsPISOSingleRow.h +++ b/src/Scanner_ShiftRegsRead.h @@ -7,18 +7,18 @@ #include #include -/* 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(); diff --git a/src/Scanner_ShiftRegsPISOMultiRow.cpp b/src/Scanner_ShiftRegsReadStrobed.cpp similarity index 83% rename from src/Scanner_ShiftRegsPISOMultiRow.cpp rename to src/Scanner_ShiftRegsReadStrobed.cpp index b23c539..7f7d505 100644 --- a/src/Scanner_ShiftRegsPISOMultiRow.cpp +++ b/src/Scanner_ShiftRegsReadStrobed.cpp @@ -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 diff --git a/src/Scanner_ShiftRegsPISOMultiRow.h b/src/Scanner_ShiftRegsReadStrobed.h similarity index 87% rename from src/Scanner_ShiftRegsPISOMultiRow.h rename to src/Scanner_ShiftRegsReadStrobed.h index b7999eb..45d83b8 100644 --- a/src/Scanner_ShiftRegsPISOMultiRow.h +++ b/src/Scanner_ShiftRegsReadStrobed.h @@ -7,14 +7,14 @@ #include #include -/* 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(); diff --git a/tutorials/keybrd_4b_split_keyboard_with_shift_registers/keybrd_4b_split_keyboard_with_shift_registers.ino b/tutorials/keybrd_4b_split_keyboard_with_shift_registers/keybrd_4b_split_keyboard_with_shift_registers.ino index e1de8ab..65ea317 100644 --- a/tutorials/keybrd_4b_split_keyboard_with_shift_registers/keybrd_4b_split_keyboard_with_shift_registers.ino +++ b/tutorials/keybrd_4b_split_keyboard_with_shift_registers/keybrd_4b_split_keyboard_with_shift_registers.ino @@ -17,7 +17,7 @@ Tested on Teensy LC and two 74HC165 shift registers. #include //Right matrix -#include +#include // =============== 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 -----------------