document
This commit is contained in:
parent
fb38aa95a9
commit
c026df8aa4
@ -1,8 +1,11 @@
|
||||
/* keybrd_shift_reg.ino
|
||||
tested on Teensy LC and daisy chained 74HC165 shift registers
|
||||
add this line to RowScanner_SPIShiftRegisters::scan():
|
||||
//clear unpowered pins (for testing bb)
|
||||
rowState &= 0b01010001000100010001000100010001; //also 31st key
|
||||
|
||||
the keyboard hardware for this sketch has 4 shift registers,
|
||||
with every 4th input pins connected to a pull-down resistor and matrix column.
|
||||
unused input pins are not grounded, so add this line to RowScanner_SPIShiftRegisters::scan():
|
||||
//clear unpowered pins (for testing on breadboard)
|
||||
rowState &= 0b01010001000100010001000100010001;
|
||||
|
||||
Layout
|
||||
| Left |**0**|**1**| | Right |**0**|**1**|**2**|**3**|**4**|**5**|**6**|**7**|**8**|
|
||||
@ -23,14 +26,10 @@ Layout
|
||||
#include <Row_ShiftRegisters.h>
|
||||
|
||||
// =============== CONFIGURATION ===============
|
||||
const unsigned int RowBase::DELAY_MICROSECONDS = 500; //500
|
||||
const unsigned int RowBase::DELAY_MICROSECONDS = 0; //500
|
||||
const bool RowScanner_PinsArray::ACTIVE_HIGH = 0; //left matrix is active low
|
||||
const uint8_t RowScanner_SPIShiftRegisters::SHIFT_LOAD = 10;
|
||||
|
||||
//activeLow has diode cathode (band) on row
|
||||
//activeHigh has diode cathode (band) on col, and pull down resistors on cols
|
||||
//0=active low, 1= active high
|
||||
const bool RowScanner_PinsArray::ACTIVE_HIGH = 0;
|
||||
|
||||
Debug debug;
|
||||
|
||||
// ================= LEFT PINS =================
|
||||
@ -71,6 +70,7 @@ Row_uC row_L1(1, readPins, READ_PIN_COUNT, ptrsKeys_L1);
|
||||
//Row_ShiftRegisters(STROBE_PIN, ptrsKeys[], KEY_COUNT)
|
||||
//the s_z are place holders and should not print
|
||||
|
||||
/*
|
||||
//prints 0 1
|
||||
Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z };
|
||||
const uint8_t KEY_R0_COUNT = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0);
|
||||
@ -80,6 +80,7 @@ Row_ShiftRegisters row_R0(8, ptrsKeys_R0, KEY_R0_COUNT);
|
||||
Key* ptrsKeys_R1[] = { &s_a, &s_z, &s_z, &s_z, &s_b, &s_z, &s_z, &s_z };
|
||||
const uint8_t KEY_R1_COUNT = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1);
|
||||
Row_ShiftRegisters row_R1(9, ptrsKeys_R1, KEY_R1_COUNT);
|
||||
*/
|
||||
/*
|
||||
//prints 0 1 2
|
||||
Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z,
|
||||
@ -103,8 +104,7 @@ const uint8_t KEY_R0_COUNT = sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0);
|
||||
Row_ShiftRegisters row_R0(8, ptrsKeys_R0, KEY_R0_COUNT);
|
||||
*/
|
||||
|
||||
/*
|
||||
//prints 0 1 2 3 4 5 6 7 8
|
||||
//prints 0 1 2 3 4 5 6 7 8, microseconds_per_scan=87
|
||||
Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z,
|
||||
&s_2, &s_z, &s_z, &s_z, &s_3, &s_z, &s_z, &s_z,
|
||||
&s_4, &s_z, &s_z, &s_z, &s_5, &s_z, &s_z, &s_z,
|
||||
@ -119,14 +119,13 @@ Key* ptrsKeys_R1[] = { &s_a, &s_z, &s_z, &s_z, &s_b, &s_z, &s_z, &s_z,
|
||||
&s_g, &s_z, &s_z, &s_z, &s_h, &s_z, &s_i }; //31-key limit because endRow
|
||||
const uint8_t KEY_R1_COUNT = sizeof(ptrsKeys_R1)/sizeof(*ptrsKeys_R1);
|
||||
Row_ShiftRegisters row_R1(9, ptrsKeys_R1, KEY_R1_COUNT);
|
||||
*/
|
||||
|
||||
const uint8_t LED_PIN = 16; //indicates wait
|
||||
|
||||
//sometimes OS takes 6 seconds to recongnize keyboard, LED blinks from the begining
|
||||
void wait()
|
||||
{
|
||||
for (uint8_t count = 0; count < 7; count++)
|
||||
for (uint8_t count = 0; count < 6; count++)
|
||||
{
|
||||
//print count
|
||||
Keyboard.print(count);
|
||||
@ -164,5 +163,5 @@ void loop()
|
||||
|
||||
//delay(100);
|
||||
//Keyboard.println("");
|
||||
//debug.print_microseconds_per_scan();
|
||||
debug.print_microseconds_per_scan();
|
||||
}
|
||||
|
@ -7,33 +7,27 @@
|
||||
#include <RowPort.h>
|
||||
#include <ColPort.h>
|
||||
|
||||
/* RowScanner_SPIShiftRegisters reads all shift registers in a daisy chain.
|
||||
/* 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()
|
||||
|
||||
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.
|
||||
//todo delete: Assumes only one row of shift registers is connected (no Slave Select).
|
||||
|
||||
For active low:
|
||||
10k pull-up resistor are connected to power
|
||||
connect controller's MISO pin to shift register's /QH pin
|
||||
in sketch, const bool RowScanner_PinsArray::ACTIVE_HIGH = 0;
|
||||
|
||||
For active high:
|
||||
The shift registers are active high:
|
||||
10k pull-down resistors are grounded
|
||||
connect controller's MISO pin to shift register's QH pin
|
||||
in sketch, const bool RowScanner_PinsArray::ACTIVE_HIGH = 1;
|
||||
|
||||
shift registers 74HC165 Parallel-In-Serial-Out (PISO) are Daisy chained
|
||||
|
||||
The maximum keys per row is 31, because Arduino's largest type is 32 bits and rowEnd consumes the last bit.
|
||||
call begin() from setup()
|
||||
|
||||
*/
|
||||
class RowScanner_SPIShiftRegisters : public RowScannerInterface
|
||||
{
|
||||
private:
|
||||
//todo static const bool ACTIVE_HIGH; //logic level of strobe pin: 0=activeLow, 1=activeHigh
|
||||
static const uint8_t SHIFT_LOAD; //controller's pin number that is connected to shift register's SHIFT_LOAD pin
|
||||
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
|
||||
const read_pins_mask_t ROW_END; //number of keys in row + 1
|
||||
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);
|
||||
|
Reference in New Issue
Block a user