From 31e0fa5ae01c781d01979adfc191d08bd1bafe50 Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Sun, 6 Nov 2016 02:41:56 -0700 Subject: [PATCH] document --- CONTRIBUTING.md | 2 ++ README.md | 2 +- library.properties | 2 +- src/Scanner_IOE.cpp | 10 +++++----- src/Scanner_IOE.h | 9 +++------ src/Scanner_ShiftRegsRead.cpp | 4 ++-- src/Scanner_ShiftRegsRead.h | 4 ++-- src/Scanner_ShiftRegsReadStrobed.cpp | 8 ++++---- src/Scanner_ShiftRegsReadStrobed.h | 7 +++---- src/Scanner_uC.cpp | 16 ++++++++-------- src/Scanner_uC.h | 5 ++--- 11 files changed, 33 insertions(+), 36 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e794407..f14431e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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). diff --git a/README.md b/README.md index 45ee635..7150712 100644 --- a/README.md +++ b/README.md @@ -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)
[mainSketch.ino](https://github.com/wolfv6/keybrd_DH/blob/master/examples/keybrd_DH/mainSketch.cpp)
-[instantiations_scannersLEDs.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_pins.h)
+[instantiations_scannersLEDs.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_scannersLEDs.h)
[instantiations_scancodes.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_scancodes.h)
[instantiations_layercodes.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_layercodes.h)
[instantiations_rows_L.h](https://github.com/wolfv6/keybrd_DH/blob/master/src/instantiations_rows_L.h)
diff --git a/library.properties b/library.properties index 2c3f84c..b87c0dc 100644 --- a/library.properties +++ b/library.properties @@ -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. diff --git a/src/Scanner_IOE.cpp b/src/Scanner_IOE.cpp index dd4d9d6..ca02d2f 100644 --- a/src/Scanner_IOE.cpp +++ b/src/Scanner_IOE.cpp @@ -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; } diff --git a/src/Scanner_IOE.h b/src/Scanner_IOE.h index 3350edf..21c871f 100644 --- a/src/Scanner_IOE.h +++ b/src/Scanner_IOE.h @@ -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); diff --git a/src/Scanner_ShiftRegsRead.cpp b/src/Scanner_ShiftRegsRead.cpp index 5956165..a25aabf 100644 --- a/src/Scanner_ShiftRegsRead.cpp +++ b/src/Scanner_ShiftRegsRead.cpp @@ -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) { diff --git a/src/Scanner_ShiftRegsRead.h b/src/Scanner_ShiftRegsRead.h index 7f1060f..d531e03 100644 --- a/src/Scanner_ShiftRegsRead.h +++ b/src/Scanner_ShiftRegsRead.h @@ -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(); diff --git a/src/Scanner_ShiftRegsReadStrobed.cpp b/src/Scanner_ShiftRegsReadStrobed.cpp index c58915f..2e0e989 100644 --- a/src/Scanner_ShiftRegsReadStrobed.cpp +++ b/src/Scanner_ShiftRegsReadStrobed.cpp @@ -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); diff --git a/src/Scanner_ShiftRegsReadStrobed.h b/src/Scanner_ShiftRegsReadStrobed.h index 17db711..3d7f767 100644 --- a/src/Scanner_ShiftRegsReadStrobed.h +++ b/src/Scanner_ShiftRegsReadStrobed.h @@ -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(); diff --git a/src/Scanner_uC.cpp b/src/Scanner_uC.cpp index b22c4a6..8de55e6 100644 --- a/src/Scanner_uC.cpp +++ b/src/Scanner_uC.cpp @@ -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; } diff --git a/src/Scanner_uC.h b/src/Scanner_uC.h index 5ed8cf2..9c14ac3 100644 --- a/src/Scanner_uC.h +++ b/src/Scanner_uC.h @@ -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); };