Archived
1
0

moved Debouncer_Not to Keybrd lib

This commit is contained in:
wolfv6 2016-07-02 15:10:02 -06:00
parent c026df8aa4
commit 9c9bc8d949
7 changed files with 50 additions and 9 deletions

View File

@ -104,7 +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, 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,
&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,
@ -163,5 +163,5 @@ void loop()
//delay(100);
//Keyboard.println("");
debug.print_microseconds_per_scan();
//debug.print_microseconds_per_scan();
}

15
src/Debouncer_Not.cpp Normal file
View File

@ -0,0 +1,15 @@
#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;
}

21
src/Debouncer_Not.h Normal file
View File

@ -0,0 +1,21 @@
#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

View File

@ -35,7 +35,6 @@ read_pins_t RowScanner_SPIShiftRegisters::scan(read_pins_mask_t& rowEnd)
digitalWrite(STROBE_PIN, LOW);
rowEnd = ROW_END;
//rowEnd = 1 << 8;
//clear unpowered pins (for testing bb) todo
rowState &= 0b01010001000100010001000100010001; //also 31st key

View File

@ -21,6 +21,12 @@ The shift registers are active high:
10k pull-down resistors are grounded
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
{

View File

@ -4,7 +4,7 @@
#include <RowBase.h>
#include <RowScanner_SPIShiftRegisters.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.
@ -29,7 +29,7 @@ class Row_ShiftRegisters : public RowBase
private:
RowScanner_SPIShiftRegisters scanner;
Debouncer_4Samples debouncer;
//Debouncer_Not debouncer; //todo test
//Debouncer_Not debouncer; //tested
public:
Row_ShiftRegisters(const uint8_t STROBE_PIN, Key *const ptrsKeys[], uint8_t KEY_COUNT)
: RowBase(ptrsKeys), scanner(STROBE_PIN, KEY_COUNT) { }