From fa4f07cc9d6da68c4ebdbe7a3522894576c11ae4 Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Sun, 30 Oct 2016 14:36:34 -0600 Subject: [PATCH] update Scanner_ShiftRegsPISOMultiRow::scan(), rename LED_shiftRegs to LED_ShiftRegs --- src/{LED_shiftRegs.cpp => LED_ShiftRegs.cpp} | 10 ++++---- src/{LED_shiftRegs.h => LED_ShiftRegs.h} | 6 ++--- src/Scanner_ShiftRegsPISOMultiRow.cpp | 26 ++++++++------------ 3 files changed, 18 insertions(+), 24 deletions(-) rename src/{LED_shiftRegs.cpp => LED_ShiftRegs.cpp} (76%) rename src/{LED_shiftRegs.h => LED_ShiftRegs.h} (74%) diff --git a/src/LED_shiftRegs.cpp b/src/LED_ShiftRegs.cpp similarity index 76% rename from src/LED_shiftRegs.cpp rename to src/LED_ShiftRegs.cpp index fada75e..e4fd549 100644 --- a/src/LED_shiftRegs.cpp +++ b/src/LED_ShiftRegs.cpp @@ -1,8 +1,8 @@ -#include "LED_shiftRegs.h" +#include "LED_ShiftRegs.h" /* constructor */ -LED_shiftRegs::LED_shiftRegs(const uint8_t slaveSelect, const uint8_t pin) +LED_ShiftRegs::LED_ShiftRegs(const uint8_t slaveSelect, const uint8_t pin) :slaveSelect(slaveSelect), pin(pin) { pinMode(slaveSelect, OUTPUT); @@ -11,21 +11,21 @@ LED_shiftRegs::LED_shiftRegs(const uint8_t slaveSelect, const uint8_t pin) /* begin() should be called once from sketch setup(). Initializes shift register's shift/load pin. */ -void LED_shiftRegs::begin() +void LED_ShiftRegs::begin() { SPI.begin(); digitalWrite(slaveSelect, HIGH); } //todo preserve other LED values, similar to Port_PCA9655E outputVal -void LED_shiftRegs::on() +void LED_ShiftRegs::on() { digitalWrite(slaveSelect, LOW); SPI.transfer(pin); digitalWrite (slaveSelect, HIGH); } -void LED_shiftRegs::off() +void LED_ShiftRegs::off() { digitalWrite(slaveSelect, LOW); SPI.transfer(0); diff --git a/src/LED_shiftRegs.h b/src/LED_ShiftRegs.h similarity index 74% rename from src/LED_shiftRegs.h rename to src/LED_ShiftRegs.h index 1fc3fc2..9bc14e6 100644 --- a/src/LED_shiftRegs.h +++ b/src/LED_ShiftRegs.h @@ -5,16 +5,16 @@ #include #include -/* A LED_shiftRegs turns LED on and off. +/* A LED_ShiftRegs turns LED on and off. shift register RCLK pin a.k.a. SS or ST */ -class LED_shiftRegs: public LEDInterface +class LED_ShiftRegs: public LEDInterface { private: const uint8_t slaveSelect;//controller pin number connected to shift register RCLK const uint8_t pin; //bit pattern, shift register pin that is connected to an LED public: - LED_shiftRegs(const uint8_t slaveSelect, const uint8_t pin); + LED_ShiftRegs(const uint8_t slaveSelect, const uint8_t pin); void begin(); virtual void on(); virtual void off(); diff --git a/src/Scanner_ShiftRegsPISOMultiRow.cpp b/src/Scanner_ShiftRegsPISOMultiRow.cpp index f37bc46..b868002 100644 --- a/src/Scanner_ShiftRegsPISOMultiRow.cpp +++ b/src/Scanner_ShiftRegsPISOMultiRow.cpp @@ -16,7 +16,6 @@ Configures controller to communicate with shift register matrix. void Scanner_ShiftRegsPISOMultiRow::init(const uint8_t strobePin) { pinMode(strobePin, OUTPUT); - //digitalWrite(strobePin, strobeOff);//todo is this needed? } /* begin() should be called once from sketch setup(). @@ -35,26 +34,21 @@ read_pins_t Scanner_ShiftRegsPISOMultiRow::scan(const uint8_t strobePin) { read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released - //strobe on - digitalWrite(strobePin, strobeOn); - //SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz - //digitalWrite(slaveSelect, LOW); //assert slave - delayMicroseconds(3); //time to stabilize photo-transistor todo needed? - delayMicroseconds(50); //todo for sr2_LEDs_strobe.ino - - //read all the column pins - digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output - - SPI.transfer(&readState, byte_count); digitalWrite(slaveSelect, LOW); //load parallel inputs to registers - //digitalWrite(slaveSelect, HIGH); //de-assert slave - //SPI.endTransaction(); + digitalWrite(strobePin, strobeOn); //strobe on - //strobe off - digitalWrite(strobePin, strobeOff); + delayMicroseconds(3); //time to stabilize photo-transistor todo need? + delayMicroseconds(50); //todo for sr2_LEDs_strobe.ino + digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output + + digitalWrite(strobePin, strobeOff); //strobe off + + SPI.transfer(&readState, byte_count); + + //SPI.endTransaction(); return readState; }