Archived
1
0
This commit is contained in:
wolfv6 2016-11-06 02:41:56 -07:00
parent 31fed09b6b
commit 31e0fa5ae0
11 changed files with 33 additions and 36 deletions

View File

@ -134,6 +134,8 @@ A healthy project needs the perspective of many people.
Submitting a pull request Submitting a pull request
------------------------- -------------------------
Pull request is the preferred way to contribute code and documentation. Pull request is the preferred way to contribute code and documentation.
[How to contribute to an open source project on GitHub](http://blog.davidecoppola.com/2016/11/howto-contribute-to-open-source-project-on-github/)
If you want to contribute some other way, please make a request in If you want to contribute some other way, please make a request in
[GitHub issues](https://github.com/wolfv6/Keybrd/issues) [GitHub issues](https://github.com/wolfv6/Keybrd/issues)
or [geekhack thread](https://geekhack.org/index.php?topic=83599.0). or [geekhack thread](https://geekhack.org/index.php?topic=83599.0).

View File

@ -43,7 +43,7 @@ keybrd_DH and its instantiation files contain about 800 lines of code.
[keybrd_DH_library_developer_guide.md](https://github.com/wolfv6/keybrd_DH/blob/master/doc/keybrd_DH_library_developer_guide.md)<br> [keybrd_DH_library_developer_guide.md](https://github.com/wolfv6/keybrd_DH/blob/master/doc/keybrd_DH_library_developer_guide.md)<br>
[mainSketch.ino](https://github.com/wolfv6/keybrd_DH/blob/master/examples/keybrd_DH/mainSketch.cpp)<br> [mainSketch.ino](https://github.com/wolfv6/keybrd_DH/blob/master/examples/keybrd_DH/mainSketch.cpp)<br>
[instantiations_scannersLEDs.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_pins.h)<br> [instantiations_scannersLEDs.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_scannersLEDs.h)<br>
[instantiations_scancodes.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_scancodes.h)<br> [instantiations_scancodes.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_scancodes.h)<br>
[instantiations_layercodes.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_layercodes.h)<br> [instantiations_layercodes.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_layercodes.h)<br>
[instantiations_rows_L.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_rows_L.h)<br> [instantiations_rows_L.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_rows_L.h)<br>

View File

@ -1,5 +1,5 @@
name=keybrd name=keybrd
version=0.5.0 version=0.6.1
author=Wolfram Volpi author=Wolfram Volpi
maintainer=Wolfram Volpi maintainer=Wolfram Volpi
sentence=A library for creating custom-keyboard firmware. sentence=A library for creating custom-keyboard firmware.

View File

@ -13,8 +13,8 @@ Initiates communication protocal and configs ports.
void Scanner_IOE::begin() void Scanner_IOE::begin()
{ {
refPortWrite.beginProtocol(); refPortWrite.beginProtocol();
refPortWrite.begin(strobeOn); refPortWrite.begin(activeState);
refPortRead.begin(strobeOn); refPortRead.begin(activeState);
} }
/* scan() is called on every iteration of sketch loop(). /* scan() is called on every iteration of sketch loop().
@ -26,16 +26,16 @@ read_pins_t Scanner_IOE::scan(const uint8_t strobePin)
uint8_t readState; //bits, 1 means key is pressed, 0 means released uint8_t readState; //bits, 1 means key is pressed, 0 means released
//strobe on //strobe on
refPortWrite.write(strobePin, strobeOn); refPortWrite.write(strobePin, activeState);
delayMicroseconds(3); //time to stabilize voltage delayMicroseconds(3); //time to stabilize voltage
//read the port pins //read the port pins
readState = refPortRead.read(); readState = refPortRead.read();
//strobe off //strobe off
refPortWrite.write(strobePin, strobeOff); refPortWrite.write(strobePin, !activeState);
if (strobeOn == LOW) //if active low if (activeState == LOW) //if active low
{ {
readState = ~readState; readState = ~readState;
} }

View File

@ -16,15 +16,12 @@ keybrd_library_developer_guide.md has instructions for ## Active state and diode
class Scanner_IOE : public ScannerInterface class Scanner_IOE : public ScannerInterface
{ {
private: private:
const bool strobeOn; //logic level of strobe on, HIGH or LOW const bool activeState; //logic level of strobe on, HIGH or LOW
const bool strobeOff; //logic level of strobe off, complement of strobeOn
PortInterface& refPortWrite; //the IC port containing the strobePin PortInterface& refPortWrite; //the IC port containing the strobePin
PortInterface& refPortRead; //the IC's read port PortInterface& refPortRead; //the IC's read port
public: public:
Scanner_IOE(const bool strobeOn, Scanner_IOE(const bool activeState, PortInterface &refPortWrite, PortInterface& refPortRead)
PortInterface &refPortWrite, PortInterface& refPortRead) : activeState(activeState) refPortWrite(refPortWrite), refPortRead(refPortRead) {}
: strobeOn(strobeOn), strobeOff(!strobeOn),
refPortWrite(refPortWrite), refPortRead(refPortRead) {}
void init(const uint8_t strobePin); void init(const uint8_t strobePin);
void begin(); void begin();
read_pins_t scan(const uint8_t strobePin); read_pins_t scan(const uint8_t strobePin);

View File

@ -1,9 +1,9 @@
#include "Scanner_ShiftRegsRead.h" #include "Scanner_ShiftRegsRead.h"
/* constructor /* constructor
Parameter strobeOn is not used. Parameter activeState is not used.
*/ */
Scanner_ShiftRegsRead::Scanner_ShiftRegsRead(const bool strobeOn, Scanner_ShiftRegsRead::Scanner_ShiftRegsRead(const bool activeState,
const uint8_t slaveSelect, const uint8_t byte_count) const uint8_t slaveSelect, const uint8_t byte_count)
: slaveSelect(slaveSelect), byte_count(byte_count) : slaveSelect(slaveSelect), byte_count(byte_count)
{ {

View File

@ -20,7 +20,7 @@ Example instantiation:
In the above Row instantiation, argument 0 for "strobePin" is ignored because there is no strobe. In the above Row instantiation, argument 0 for "strobePin" is ignored because there is no strobe.
There are three Scanner_ShiftRegsRead parameters. There are three Scanner_ShiftRegsRead parameters.
1. "strobeOn" paramter is ignored, but should be active state HIGH or LOW for ScannerInterface. 1. "activeState" paramter is ignored, but should be active state HIGH or LOW for ScannerInterface.
2. "slaveSelect" paramter can be any controller pin connected to shift register's SHIFT-LOAD pin. 2. "slaveSelect" paramter can be any controller pin connected to shift register's SHIFT-LOAD pin.
3. "byte_count" is the number of bytes to read from shift registers (1 to 4). 3. "byte_count" is the number of bytes to read from shift registers (1 to 4).
byte_count should cover all the row's keys: byte_count*8 >= row's keyCount byte_count should cover all the row's keys: byte_count*8 >= row's keyCount
@ -54,7 +54,7 @@ class Scanner_ShiftRegsRead : public ScannerInterface
const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
const uint8_t byte_count; //number of bytes to read from shift registers const uint8_t byte_count; //number of bytes to read from shift registers
public: public:
Scanner_ShiftRegsRead(const bool strobeOn, Scanner_ShiftRegsRead(const bool activeState,
const uint8_t slaveSelect, const uint8_t byte_count); const uint8_t slaveSelect, const uint8_t byte_count);
void init(const uint8_t strobePin); void init(const uint8_t strobePin);
void begin(); void begin();

View File

@ -1,8 +1,8 @@
#include "Scanner_ShiftRegsReadStrobed.h" #include "Scanner_ShiftRegsReadStrobed.h"
Scanner_ShiftRegsReadStrobed::Scanner_ShiftRegsReadStrobed(const bool strobeOn, Scanner_ShiftRegsReadStrobed::Scanner_ShiftRegsReadStrobed(const bool activeState,
const uint8_t slaveSelect, const uint8_t byte_count) const uint8_t slaveSelect, const uint8_t byte_count)
: strobeOn(strobeOn), strobeOff(!strobeOn), : activeState(activeState),
slaveSelect(slaveSelect), byte_count(byte_count) slaveSelect(slaveSelect), byte_count(byte_count)
{ {
pinMode(slaveSelect, OUTPUT); pinMode(slaveSelect, OUTPUT);
@ -44,7 +44,7 @@ read_pins_t Scanner_ShiftRegsReadStrobed::scan(const uint8_t strobePin)
{ {
read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released
digitalWrite(strobePin, strobeOn); //strobe on digitalWrite(strobePin, activeState); //strobe on
//SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz //SPI.beginTransaction( SPISettings(5000000, MSBFIRST, SPI_MODE0) ); //control SPI bus, 5 MHz
@ -53,7 +53,7 @@ read_pins_t Scanner_ShiftRegsReadStrobed::scan(const uint8_t strobePin)
digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output digitalWrite(slaveSelect, HIGH); //shift the data toward a serial output
digitalWrite(strobePin, strobeOff); //strobe off digitalWrite(strobePin, !activeState); //strobe off to preserv IR LED life
SPI.transfer(&readState, byte_count); SPI.transfer(&readState, byte_count);

View File

@ -19,7 +19,7 @@ Example instantiation:
Scanner_ShiftRegsReadStrobed scanner_R(HIGH, 6, 4); Scanner_ShiftRegsReadStrobed scanner_R(HIGH, 6, 4);
There are three Scanner_ShiftRegsReadStrobed parameters. There are three Scanner_ShiftRegsReadStrobed parameters.
1. "strobeOn" paramter is active state HIGH or LOW. 1. "activeState" paramter is active state HIGH or LOW.
2. "slaveSelect" paramter is controller pin connected to shift register's SHIFT-LOAD pin. 2. "slaveSelect" paramter is controller pin connected to shift register's SHIFT-LOAD pin.
3. "byte_count" is the number of bytes to read from shift registers (1 to 4). 3. "byte_count" is the number of bytes to read from shift registers (1 to 4).
byte_count should cover all the row's keys: byte_count*8 >= row's keyCount byte_count should cover all the row's keys: byte_count*8 >= row's keyCount
@ -48,12 +48,11 @@ If multiple rows (or any SPI divice) share a MISO line, the shift registers need
class Scanner_ShiftRegsReadStrobed : public ScannerInterface class Scanner_ShiftRegsReadStrobed : public ScannerInterface
{ {
private: private:
const bool strobeOn; //logic level of strobe on, active state HIGH or LOW const bool activeState; //logic level of strobe on, active state HIGH or LOW
const bool strobeOff; //logic level of strobe off, complement of strobeOn
const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin const uint8_t slaveSelect;//controller pin number connected to shift register SHIFT-LOAD pin
const uint8_t byte_count; //number of bytes to read from shift registers const uint8_t byte_count; //number of bytes to read from shift registers
public: public:
Scanner_ShiftRegsReadStrobed(const bool strobeOn, Scanner_ShiftRegsReadStrobed(const bool activeState,
const uint8_t slaveSelect, const uint8_t byte_count); const uint8_t slaveSelect, const uint8_t byte_count);
virtual void init(const uint8_t strobePin); virtual void init(const uint8_t strobePin);
virtual void begin(); virtual void begin();

View File

@ -10,13 +10,13 @@ https://www.arduino.cc/en/Reference/Constants > Digital Pins modes: INPUT, INPUT
/* constructor /* constructor
*/ */
Scanner_uC::Scanner_uC(const bool strobeOn, const uint8_t readPins[], const uint8_t readPinCount) Scanner_uC::Scanner_uC(const bool activeState, const uint8_t readPins[], const uint8_t readPinCount)
: strobeOn(strobeOn), strobeOff(!strobeOn), readPins(readPins), readPinCount(readPinCount) : activeState(activeState), readPins(readPins), readPinCount(readPinCount)
{ {
uint8_t mode; uint8_t mode;
//configure read pins //configure read pins
if (strobeOn == LOW) //if active low if (activeState == LOW) //if active low
{ {
mode = INPUT_PULLUP; //use internal pull-up resistor mode = INPUT_PULLUP; //use internal pull-up resistor
} }
@ -48,22 +48,22 @@ read_pins_t Scanner_uC::scan(const uint8_t strobePin)
read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released read_pins_t readState = 0; //bits, 1 means key is pressed, 0 means released
read_pins_t readMask = 1; //bits, active bit is 1 read_pins_t readMask = 1; //bits, active bit is 1
//strobe row on //strobe on
digitalWrite(strobePin, strobeOn); digitalWrite(strobePin, activeState);
delayMicroseconds(3); //time to stablize voltage delayMicroseconds(3); //time to stablize voltage
//read all the read pins //read all the read pins
for (uint8_t i=0; i < readPinCount; i++) for (uint8_t i=0; i < readPinCount; i++)
{ {
if ( digitalRead(readPins[i]) == strobeOn ) if ( digitalRead(readPins[i]) == activeState )
{ {
readState |= readMask; readState |= readMask;
} }
readMask <<= 1; readMask <<= 1;
} }
//strobe row off //strobe off
digitalWrite(strobePin, strobeOff); digitalWrite(strobePin, !activeState);
return readState; return readState;
} }

View File

@ -12,12 +12,11 @@ Limit number of readPins to size of read_pins_t, which is defined in config_keyb
class Scanner_uC : public ScannerInterface class Scanner_uC : public ScannerInterface
{ {
private: private:
const bool strobeOn; //logic level of strobe on, HIGH or LOW const bool activeState; //logic level of strobe on, HIGH or LOW
const bool strobeOff; //logic level of strobe off, complement of strobeOn
const uint8_t* const readPins; //array of read pin numbers const uint8_t* const readPins; //array of read pin numbers
const uint8_t readPinCount; //number of readPins const uint8_t readPinCount; //number of readPins
public: public:
Scanner_uC(const bool strobeOn, const uint8_t readPins[], const uint8_t readPinCount); Scanner_uC(const bool activeState, const uint8_t readPins[], const uint8_t readPinCount);
void init(const uint8_t strobePin); void init(const uint8_t strobePin);
virtual read_pins_t scan(const uint8_t strobePin); virtual read_pins_t scan(const uint8_t strobePin);
}; };