Browse Source

document

tags/v0.6.3
wolfv6 7 years ago
parent
commit
31e0fa5ae0

+ 2
- 0
CONTRIBUTING.md View File

@@ -134,6 +134,8 @@ A healthy project needs the perspective of many people.
Submitting a pull request
-------------------------
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
[GitHub issues](https://github.com/wolfv6/Keybrd/issues)
or [geekhack thread](https://geekhack.org/index.php?topic=83599.0).

+ 1
- 1
README.md 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>
[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_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>

+ 1
- 1
library.properties View File

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

+ 5
- 5
src/Scanner_IOE.cpp View File

@@ -13,8 +13,8 @@ Initiates communication protocal and configs ports.
void Scanner_IOE::begin()
{
refPortWrite.beginProtocol();
refPortWrite.begin(strobeOn);
refPortRead.begin(strobeOn);
refPortWrite.begin(activeState);
refPortRead.begin(activeState);
}

/* 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

//strobe on
refPortWrite.write(strobePin, strobeOn);
refPortWrite.write(strobePin, activeState);
delayMicroseconds(3); //time to stabilize voltage

//read the port pins
readState = refPortRead.read();

//strobe off
refPortWrite.write(strobePin, strobeOff);
refPortWrite.write(strobePin, !activeState);

if (strobeOn == LOW) //if active low
if (activeState == LOW) //if active low
{
readState = ~readState;
}

+ 3
- 6
src/Scanner_IOE.h View File

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

+ 2
- 2
src/Scanner_ShiftRegsRead.cpp View File

@@ -1,9 +1,9 @@
#include "Scanner_ShiftRegsRead.h"

/* 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)
: slaveSelect(slaveSelect), byte_count(byte_count)
{

+ 2
- 2
src/Scanner_ShiftRegsRead.h View File

@@ -20,7 +20,7 @@ Example instantiation:
In the above Row instantiation, argument 0 for "strobePin" is ignored because there is no strobe.

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.
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
@@ -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 byte_count; //number of bytes to read from shift registers
public:
Scanner_ShiftRegsRead(const bool strobeOn,
Scanner_ShiftRegsRead(const bool activeState,
const uint8_t slaveSelect, const uint8_t byte_count);
void init(const uint8_t strobePin);
void begin();

+ 4
- 4
src/Scanner_ShiftRegsReadStrobed.cpp View File

@@ -1,8 +1,8 @@
#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)
: strobeOn(strobeOn), strobeOff(!strobeOn),
: activeState(activeState),
slaveSelect(slaveSelect), byte_count(byte_count)
{
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

digitalWrite(strobePin, strobeOn); //strobe on
digitalWrite(strobePin, activeState); //strobe on

//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(strobePin, strobeOff); //strobe off
digitalWrite(strobePin, !activeState); //strobe off to preserv IR LED life

SPI.transfer(&readState, byte_count);


+ 3
- 4
src/Scanner_ShiftRegsReadStrobed.h View File

@@ -19,7 +19,7 @@ Example instantiation:
Scanner_ShiftRegsReadStrobed scanner_R(HIGH, 6, 4);

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.
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
@@ -48,12 +48,11 @@ If multiple rows (or any SPI divice) share a MISO line, the shift registers need
class Scanner_ShiftRegsReadStrobed : public ScannerInterface
{
private:
const bool strobeOn; //logic level of strobe on, active state HIGH or LOW
const bool strobeOff; //logic level of strobe off, complement of strobeOn
const bool activeState; //logic level of strobe on, active state HIGH or LOW
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
public:
Scanner_ShiftRegsReadStrobed(const bool strobeOn,
Scanner_ShiftRegsReadStrobed(const bool activeState,
const uint8_t slaveSelect, const uint8_t byte_count);
virtual void init(const uint8_t strobePin);
virtual void begin();

+ 8
- 8
src/Scanner_uC.cpp View File

@@ -10,13 +10,13 @@ https://www.arduino.cc/en/Reference/Constants > Digital Pins modes: INPUT, INPUT

/* constructor
*/
Scanner_uC::Scanner_uC(const bool strobeOn, const uint8_t readPins[], const uint8_t readPinCount)
: strobeOn(strobeOn), strobeOff(!strobeOn), readPins(readPins), readPinCount(readPinCount)
Scanner_uC::Scanner_uC(const bool activeState, const uint8_t readPins[], const uint8_t readPinCount)
: activeState(activeState), readPins(readPins), readPinCount(readPinCount)
{
uint8_t mode;

//configure read pins
if (strobeOn == LOW) //if active low
if (activeState == LOW) //if active low
{
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 readMask = 1; //bits, active bit is 1

//strobe row on
digitalWrite(strobePin, strobeOn);
//strobe on
digitalWrite(strobePin, activeState);
delayMicroseconds(3); //time to stablize voltage

//read all the read pins
for (uint8_t i=0; i < readPinCount; i++)
{
if ( digitalRead(readPins[i]) == strobeOn )
if ( digitalRead(readPins[i]) == activeState )
{
readState |= readMask;
}
readMask <<= 1;
}

//strobe row off
digitalWrite(strobePin, strobeOff);
//strobe off
digitalWrite(strobePin, !activeState);

return readState;
}

+ 2
- 3
src/Scanner_uC.h 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
{
private:
const bool strobeOn; //logic level of strobe on, HIGH or LOW
const bool strobeOff; //logic level of strobe off, complement of strobeOn
const bool activeState; //logic level of strobe on, HIGH or LOW
const uint8_t* const readPins; //array of read pin numbers
const uint8_t readPinCount; //number of readPins
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);
virtual read_pins_t scan(const uint8_t strobePin);
};