Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/src/RowScanner_SPIShiftRegisters.h

38 lines
1.4 KiB
C
Raw Normal View History

#ifndef ROWSCANNER_SPI_SHIFTREGISTERS_H
#define ROWSCANNER_SPI_SHIFTREGISTERS_H
#include <Arduino.h>
#include <inttypes.h>
#include <SPI.h>
#include <RowScannerInterface.h>
#include <RowPort.h>
#include <ColPort.h>
2016-07-02 11:18:45 +00:00
/* RowScanner_SPIShiftRegisters reads shift registers.
shift registers 74HC165 Parallel-In-Serial-Out (PISO)
in sketch:
const uint8_t RowScanner_SPIShiftRegisters::SHIFT_LOAD = 10;
call begin() from setup()
2016-07-02 11:18:45 +00:00
Upto 4 shift registers can be in a daisy chained.
The maximum keys per row is 31, because Arduino's largest type is 32 bits and rowEnd consumes the last bit.
2016-07-02 11:18:45 +00:00
The shift registers are active high:
10k pull-down resistors are grounded
connect controller's MISO pin to shift register's QH pin
*/
class RowScanner_SPIShiftRegisters : public RowScannerInterface
{
private:
2016-07-02 11:18:45 +00:00
static const uint8_t SHIFT_LOAD; //controller's pin number that is connected to shift register's SHIFT_LOAD pin
const uint8_t STROBE_PIN; //Arduino pin number connected to this row
2016-07-02 11:18:45 +00:00
const read_pins_mask_t ROW_END; //bitwise, 1 bit marks positioned after last key of row
const uint8_t BYTE_COUNT; //number of bytes to read from shift registers
public:
RowScanner_SPIShiftRegisters(const uint8_t STROBE_PIN, uint8_t KEY_COUNT);
virtual read_pins_t scan(read_pins_mask_t& rowEnd);
void begin();
};
#endif