Browse Source

add tri-state and right 74HC165 to sr0_LED_shiftRegs.ino

tags/v0.6.3
wolfv6 7 years ago
parent
commit
3fa0aee2e2
2 changed files with 9 additions and 5 deletions
  1. 6
    2
      src/Row.h
  2. 3
    3
      src/Scanner_ShiftRegsPISOMultiRow.cpp

+ 6
- 2
src/Row.h View File

/* /*
strobePin has one of two formats: strobePin has one of two formats:
* if refScanner a Scanner_uC, then strobePin is an Arduino pin number connected to this row
* otherwise strobePin is bit pattern, 1 indicating an IC pin connected to this row
1. if strobe pin is on uC (Scanner_uC or Scanner_ShiftRegsPISOMultiRow),
then strobePin is an Arduino pin number connected to this row.
2. if strobe pin is on I/O expander (Scanner_IOE), then strobePin is bit pattern,
1 indicating the I/O expander pin connected to this row
todo instantiation examples - here or in Scanner?
*/ */
class Row class Row
{ {

+ 3
- 3
src/Scanner_ShiftRegsPISOMultiRow.cpp View File

*/ */
void Scanner_ShiftRegsPISOMultiRow::begin() void Scanner_ShiftRegsPISOMultiRow::begin()
{ {
SPI.begin();
SPI.begin(); //todo move this to constructor or init()
} }


/* scan() strobes the row's strobePin and returns state of the shift register's input pins. /* scan() strobes the row's strobePin and returns state of the shift register's input pins.
{ {
read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released


//SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz
SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz


digitalWrite(slaveSelect, LOW); //load parallel inputs to registers digitalWrite(slaveSelect, LOW); //load parallel inputs to registers




SPI.transfer(&readState, byte_count); SPI.transfer(&readState, byte_count);


//SPI.endTransaction();
SPI.endTransaction();


return readState; return readState;
} }