Archived
1
0

rename Row::pressRelease() to send(), Debouncer_4Samples to Debouncer_Samples

This commit is contained in:
wolfv6 2016-07-14 04:47:23 -06:00
parent 1c3a85d832
commit cdeb855a1d
9 changed files with 15 additions and 15 deletions

View File

@ -246,7 +246,7 @@ Refer to it like a table of contents while reading the keybrd library.
set rowState bit set rowState bit
strobe row off strobe row off
Debouncer_4Samples::debounce() debounce Debouncer_4Samples::debounce() debounce
Row::pressRelease() for each key in row Row::send() for each key in row
if falling edge if falling edge
Key_*::release() scanCode->release() Key_*::release() scanCode->release()
Code_*::release() Keyboard.release(scancode) Code_*::release() Keyboard.release(scancode)

View File

@ -29,13 +29,13 @@ SAMPLE_COUNT = 4 is very reliable for a keyboard.
Split keyboards with a long connecting wire or in environment with Split keyboards with a long connecting wire or in environment with
strong electromagnetic interference (EMI) may need a larger SAMPLE_COUNT for reliability. strong electromagnetic interference (EMI) may need a larger SAMPLE_COUNT for reliability.
*/ */
#include "Debouncer_4Samples.h" #include "Debouncer_Samples.h"
/* debounce() sets debounced and returns debouncedChanged. All variables are bitwise. /* debounce() sets debounced and returns debouncedChanged. All variables are bitwise.
For parameters, 1 means pressed, 0 means released. For parameters, 1 means pressed, 0 means released.
For return, 1 means debounced changed. For return, 1 means debounced changed.
*/ */
read_pins_t Debouncer_4Samples::debounce(const read_pins_t rawSignal, read_pins_t& debounced) read_pins_t Debouncer_Samples::debounce(const read_pins_t rawSignal, read_pins_t& debounced)
{ {
read_pins_t previousDebounced; //bitwise, 1 means pressed, 0 means released read_pins_t previousDebounced; //bitwise, 1 means pressed, 0 means released
read_pins_t all_1 = ~0; //bitwise read_pins_t all_1 = ~0; //bitwise

View File

@ -5,16 +5,16 @@
#include <config_keybrd.h> #include <config_keybrd.h>
#include <DebouncerInterface.h> #include <DebouncerInterface.h>
/* Debouncer_4Samples /* Debouncer_Samples
Configuration: #define SAMPLE_COUNT in config_keybrd.h Configuration: #define SAMPLE_COUNT in config_keybrd.h
*/ */
class Debouncer_4Samples : public DebouncerInterface class Debouncer_Samples : public DebouncerInterface
{ {
private: private:
read_pins_t samples[SAMPLE_COUNT]; //bitwise, one bit per key, most recent readings read_pins_t samples[SAMPLE_COUNT]; //bitwise, one bit per key, most recent readings
uint8_t samplesIndex; //samples[] current write index uint8_t samplesIndex; //samples[] current write index
public: public:
Debouncer_4Samples(): samplesIndex(0) {} Debouncer_Samples(): samplesIndex(0) {}
virtual read_pins_t debounce(const read_pins_t rawSignal, read_pins_t& debounced); virtual read_pins_t debounce(const read_pins_t rawSignal, read_pins_t& debounced);
}; };
#endif #endif

View File

@ -1,9 +1,9 @@
#include "Row.h" #include "Row.h"
/* /*
pressRelease() calls key's press() or release() function if it was pressed or released. send() calls key's press() or release() function if it was pressed or released.
Both parameters are bitwise. Both parameters are bitwise.
*/ */
void Row::pressRelease(const uint8_t readPinCount, const read_pins_t debouncedChanged) void Row::send(const uint8_t readPinCount, const read_pins_t debouncedChanged)
{ {
read_pins_t isFallingEdge; //bitwise, 1 means falling edge read_pins_t isFallingEdge; //bitwise, 1 means falling edge
read_pins_t isRisingEdge; //bitwise, 1 means rising edge read_pins_t isRisingEdge; //bitwise, 1 means rising edge

View File

@ -14,7 +14,7 @@ class Row
virtual void keyWasPressed(); virtual void keyWasPressed();
protected: protected:
read_pins_t debounced; //bitwise, 1 means pressed, 0 means released read_pins_t debounced; //bitwise, 1 means pressed, 0 means released
void pressRelease(const uint8_t readPinCount, const read_pins_t debouncedChanged); void send(const uint8_t readPinCount, const read_pins_t debouncedChanged);
public: public:
Row(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { } Row(Key *const ptrsKeys[]) : ptrsKeys(ptrsKeys), debounced(0) { }
virtual void process()=0; virtual void process()=0;

View File

@ -8,7 +8,7 @@ void Row_ShiftRegisters::process()
readState = scanner.scan(); readState = scanner.scan();
debouncedChanged = debouncer.debounce(readState, debounced); debouncedChanged = debouncer.debounce(readState, debounced);
pressRelease(READ_PIN_COUNT, debouncedChanged); send(READ_PIN_COUNT, debouncedChanged);
} }
void Row_ShiftRegisters::begin() void Row_ShiftRegisters::begin()

View File

@ -3,7 +3,7 @@
#include <Row.h> #include <Row.h>
#include <Scanner_ShiftRegs74HC165.h> #include <Scanner_ShiftRegs74HC165.h>
#include <Debouncer_4Samples.h> #include <Debouncer_Samples.h>
//#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.
@ -28,7 +28,7 @@ class Row_ShiftRegisters : public Row
{ {
private: private:
Scanner_ShiftRegs74HC165 scanner; Scanner_ShiftRegs74HC165 scanner;
Debouncer_4Samples debouncer; Debouncer_Samples debouncer;
//Debouncer_Not debouncer; //passed test //Debouncer_Not debouncer; //passed test
const uint8_t READ_PIN_COUNT; //number of read pins const uint8_t READ_PIN_COUNT; //number of read pins
public: public:

View File

@ -11,5 +11,5 @@ void Row_uC::process()
readState = scanner.scan(); readState = scanner.scan();
debouncedChanged = debouncer.debounce(readState, debounced); debouncedChanged = debouncer.debounce(readState, debounced);
pressRelease(READ_PIN_COUNT, debouncedChanged); send(READ_PIN_COUNT, debouncedChanged);
} }

View File

@ -3,7 +3,7 @@
#include <Row.h> #include <Row.h>
#include <Scanner_uC.h> #include <Scanner_uC.h>
#include <Debouncer_4Samples.h> #include <Debouncer_Samples.h>
/* Row_uC is a row connected to a micro controller. /* Row_uC is a row connected to a micro controller.
@ -30,7 +30,7 @@ class Row_uC : public Row
{ {
private: private:
Scanner_uC scanner; Scanner_uC scanner;
Debouncer_4Samples debouncer; Debouncer_Samples debouncer;
const uint8_t READ_PIN_COUNT; //number of read pins const uint8_t READ_PIN_COUNT; //number of read pins
public: public:
Row_uC(const uint8_t strobePin, const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT, Row_uC(const uint8_t strobePin, const uint8_t READ_PINS[], const uint8_t READ_PIN_COUNT,