Row_ShiftRegisters row_R0(8, ptrsKeys_R0, KEY_R0_COUNT); | Row_ShiftRegisters row_R0(8, ptrsKeys_R0, KEY_R0_COUNT); | ||||
*/ | */ | ||||
//prints 0 1 2 3 4 5 6 7 8, microseconds_per_scan=87 | |||||
//prints 0 1 2 3 4 5 6 7 8, microseconds_per_scan=87 with SAMPLE_COUNT 4 | |||||
Key* ptrsKeys_R0[] = { &s_0, &s_z, &s_z, &s_z, &s_1, &s_z, &s_z, &s_z, | 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_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, | &s_4, &s_z, &s_z, &s_z, &s_5, &s_z, &s_z, &s_z, | ||||
//delay(100); | //delay(100); | ||||
//Keyboard.println(""); | //Keyboard.println(""); | ||||
debug.print_microseconds_per_scan(); | |||||
//debug.print_microseconds_per_scan(); | |||||
} | } |
#include "Debouncer_Not.h" | |||||
/* debounce() sets debounced and returns debouncedChanged. All variables are bitwise. | |||||
For parameters, 1 means pressed, 0 means released. | |||||
For return, 1 means debounced changed. | |||||
*/ | |||||
read_pins_t Debouncer_Not::debounce(const read_pins_t rawSignal, read_pins_t& debounced) | |||||
{ | |||||
read_pins_t previousDebounced; //bitwise, 1 means pressed, 0 means released | |||||
previousDebounced = debounced; | |||||
debounced = rawSignal; | |||||
return debounced xor previousDebounced; | |||||
} | |||||
#ifndef DEBOUNCER_NOT_H | |||||
#define DEBOUNCER_NOT_H | |||||
#include <Arduino.h> | |||||
#include <inttypes.h> | |||||
#include <config_keybrd.h> | |||||
#include <DebouncerInterface.h> | |||||
/* Debouncer_Not does not debounce. | |||||
debounce() returns raw signal, no debouncing is performed. | |||||
A keyboard does not need a debouncing if one of the following is true: | |||||
* keypad has hardware debouncers | |||||
* poling I2C makes scan rate slower than debounce time | |||||
* optic switches are used (because they don't bounce) | |||||
*/ | |||||
class Debouncer_Not : public DebouncerInterface | |||||
{ | |||||
public: | |||||
virtual read_pins_t debounce(const read_pins_t rawSignal, read_pins_t& debounced); | |||||
}; | |||||
#endif |
class RowScanner_PinsArray : public RowScannerInterface | class RowScanner_PinsArray : public RowScannerInterface | ||||
{ | { | ||||
private: | private: | ||||
static const bool ACTIVE_HIGH; //logic level of strobe pin: 0=activeLow, 1=activeHigh | |||||
const uint8_t STROBE_PIN; //Arduino pin number connected to this row | |||||
const uint8_t* const READ_PINS; //array of read pin numbers | |||||
const uint8_t READ_PIN_COUNT; //number of read pins | |||||
static const bool ACTIVE_HIGH; //logic level of strobe pin: 0=activeLow, 1=activeHigh | |||||
const uint8_t STROBE_PIN; //Arduino pin number connected to this row | |||||
const uint8_t* const READ_PINS; //array of read pin numbers | |||||
const uint8_t READ_PIN_COUNT; //number of read pins | |||||
public: | public: | ||||
RowScanner_PinsArray(const uint8_t STROBE_PIN, | RowScanner_PinsArray(const uint8_t STROBE_PIN, | ||||
const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT); | const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT); |
digitalWrite(STROBE_PIN, LOW); | digitalWrite(STROBE_PIN, LOW); | ||||
rowEnd = ROW_END; | rowEnd = ROW_END; | ||||
//rowEnd = 1 << 8; | |||||
//clear unpowered pins (for testing bb) todo | //clear unpowered pins (for testing bb) todo | ||||
rowState &= 0b01010001000100010001000100010001; //also 31st key | rowState &= 0b01010001000100010001000100010001; //also 31st key |
10k pull-down resistors are grounded | 10k pull-down resistors are grounded | ||||
connect controller's MISO pin to shift register's QH pin | connect controller's MISO pin to shift register's QH pin | ||||
The shift register needs 5 wires. | |||||
In addition, each row needs to be connected to a strobe pin from controller. | |||||
The two parts of a split keyboard can be connected by one of: | |||||
* eSATA cable (has 7 wires, good for 2 rows) | |||||
* Ethernet cable (has 8 wires, good for 3 rows) | |||||
*/ | */ | ||||
class RowScanner_SPIShiftRegisters : public RowScannerInterface | class RowScanner_SPIShiftRegisters : public RowScannerInterface | ||||
{ | { |
#include <RowBase.h> | #include <RowBase.h> | ||||
#include <RowScanner_SPIShiftRegisters.h> | #include <RowScanner_SPIShiftRegisters.h> | ||||
#include <Debouncer_4Samples.h> | #include <Debouncer_4Samples.h> | ||||
//todo #include <Debouncer_Not.h> | |||||
//#include <Debouncer_Not.h> | |||||
/* Row_DH_IOE is a row connected to an Input/Output Expander. | /* Row_DH_IOE is a row connected to an Input/Output Expander. | ||||
private: | private: | ||||
RowScanner_SPIShiftRegisters scanner; | RowScanner_SPIShiftRegisters scanner; | ||||
Debouncer_4Samples debouncer; | Debouncer_4Samples debouncer; | ||||
//Debouncer_Not debouncer; //todo test | |||||
//Debouncer_Not debouncer; //tested | |||||
public: | public: | ||||
Row_ShiftRegisters(const uint8_t STROBE_PIN, Key *const ptrsKeys[], uint8_t KEY_COUNT) | Row_ShiftRegisters(const uint8_t STROBE_PIN, Key *const ptrsKeys[], uint8_t KEY_COUNT) | ||||
: RowBase(ptrsKeys), scanner(STROBE_PIN, KEY_COUNT) { } | : RowBase(ptrsKeys), scanner(STROBE_PIN, KEY_COUNT) { } |