From b73a450c23e52b91362b2b27027093fe43ae14b0 Mon Sep 17 00:00:00 2001 From: SRGDamia1 Date: Wed, 14 Mar 2018 10:17:15 -0400 Subject: [PATCH 1/3] Added some notes --- examples/e_simple_parsing/e_simple_parsing.ino | 4 ++-- .../h_SDI-12_slave_implementation.ino | 2 +- examples/i_SDI-12_interface/i_SDI-12_interface.ino | 2 -- src/SDI12.cpp | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/e_simple_parsing/e_simple_parsing.ino b/examples/e_simple_parsing/e_simple_parsing.ino index 304f207..b7934f1 100644 --- a/examples/e_simple_parsing/e_simple_parsing.ino +++ b/examples/e_simple_parsing/e_simple_parsing.ino @@ -146,8 +146,6 @@ void printInfo(char i){ void printBufferToScreen(){ - flip = !flip; // flip the switch - if(flip){ // print out the buffer as a string, as in example D // boolean firstPass = true; String buffer = ""; @@ -350,6 +348,8 @@ void setup(){ void loop(){ + flip = !flip; // flip the switch between parsing and not parsing + // scan address space 0-9 for(char i = '0'; i <= '9'; i++) if(isTaken(i)){ Serial.print(millis()/1000); diff --git a/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino b/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino index de63685..f7656b0 100644 --- a/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino +++ b/examples/h_SDI-12_slave_implementation/h_SDI-12_slave_implementation.ino @@ -23,7 +23,7 @@ * hard-coded 9s interspersed throughout the code */ -// Requires modified SDI-12 libary with addition of public forceListen() and public sendResponse() + #include #define DATA_PIN 7 // The pin of the SDI-12 data bus diff --git a/examples/i_SDI-12_interface/i_SDI-12_interface.ino b/examples/i_SDI-12_interface/i_SDI-12_interface.ino index f03ad8c..88b9e88 100644 --- a/examples/i_SDI-12_interface/i_SDI-12_interface.ino +++ b/examples/i_SDI-12_interface/i_SDI-12_interface.ino @@ -28,10 +28,8 @@ * */ - #define HELPTEXT "OPTIONS:\n\rhelp : Print this message\n\rmode s : SDI-12 command mode (uppercase and ! automatically corrected) [default]\n\rmode v : verbatim mode (text will be sent verbatim)\n\rfb on : Enable feedback (characters visible while typing) [default]\n\rfb off : Disable feedback (characters not visible while typing; may be desired for developers)\n\r(else) : send command to SDI-12 bus" -// Requires modified SDI-12 libary with addition of public forceListen() and public sendResponse() #include #define SERIAL_BAUD 57600 // The baud rate for the output serial port diff --git a/src/SDI12.cpp b/src/SDI12.cpp index 998fa53..cf6061b 100644 --- a/src/SDI12.cpp +++ b/src/SDI12.cpp @@ -146,7 +146,7 @@ SDI-12.org, official site of the SDI-12 Support Group. #define HOLDING 2 // 0.5 value for DISABLED state #define TRANSMITTING 3 // 0.6 value for TRANSMITTING state #define LISTENING 4 // 0.7 value for LISTENING state -#define SPACING 830 // 0.8 bit timing in microseconds +#define SPACING 830 // 0.8 bit timing in microseconds (1200 baud = 1200 bits/second ~ 830 µs/bit) SDI12 *SDI12::_activeObject = NULL; // 0.10 pointer to active SDI12 object From 46000d5b51f8efdd97562e316f5ff421f371bb20 Mon Sep 17 00:00:00 2001 From: SRGDamia1 Date: Wed, 14 Mar 2018 12:23:42 -0400 Subject: [PATCH 2/3] Notes --- OverviewOfInterrupts.md | 13 +++++--- src/SDI12.cpp | 68 ++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/OverviewOfInterrupts.md b/OverviewOfInterrupts.md index 2954f24..aa5b729 100644 --- a/OverviewOfInterrupts.md +++ b/OverviewOfInterrupts.md @@ -120,15 +120,18 @@ So to finish our example: So only the interrupt on pin 13 remains set. As a matter of book keeping, if we unset the last bit in the PCMSK, we ought to also unset the respective bit in the PCICR. - !(\*digitalPinToPCMSK(9) - will evaluate TRUE if PCMSK {00000000} - will evaluate FALSE if PCMSK != {00000000} + + !(*digitalPinToPCMSK(9) + + will evaluate TRUE if PCMSK {00000000} + + will evaluate FALSE if PCMSK != {00000000} In this case, pin 13 is set, so the expression would be FALSE. If we go back to the original case without pin 13, the expression after disabling pin 9 would evaluate to TRUE. Therefore if we evaluate to TRUE, we should tidy up: ```cpp -if(!\*digitalPinToPCMSK(\_dataPin)){ - \*digitalPinToPCICR(\_dataPin) &= ~(1< Date: Thu, 15 Mar 2018 17:06:11 -0400 Subject: [PATCH 3/3] Added an empty constructor, for better integration in other libraries Also added a begin method that sets the data pin. And another method to return the data pin. --- library.json | 2 +- library.properties | 2 +- src/SDI12.cpp | 12 +++++++++++- src/SDI12.h | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/library.json b/library.json index 0f003a0..5320ca4 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Arduino-SDI-12", - "version": "1.0.6", + "version": "1.1.0", "keywords": "SDI-12, sdi12, communication, bus, sensor, Decagon", "description": "Arduino library for SDI-12 communications to a wide variety of environmental sensors.", "repository": diff --git a/library.properties b/library.properties index 2b45921..119cdbf 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino-SDI-12 -version=1.0.6 +version=1.1.0 author=Kevin M. Smith , Shannon Hicks maintainer=Sara Damiano sentence=Arduino library for SDI-12 communications to a wide variety of environmental sensors. diff --git a/src/SDI12.cpp b/src/SDI12.cpp index bd99bde..9ec8f2c 100644 --- a/src/SDI12.cpp +++ b/src/SDI12.cpp @@ -364,6 +364,9 @@ times out. By default this value is -9999. */ // 3.1 Constructor +SDI12::SDI12(){ + _bufferOverflow = false; +} SDI12::SDI12(uint8_t dataPin){ _bufferOverflow = false; _dataPin = dataPin; @@ -387,13 +390,20 @@ void SDI12::begin(){ // in-site environmental sensors. setTimeoutValue(-9999); } +void SDI12::begin(uint8_t dataPin){ + _dataPin = dataPin; + begin(); +} // 3.4 End void SDI12::end() { setState(DISABLED); } -// 3.4 Set the timeout return +// 3.5 Set the timeout return void SDI12::setTimeoutValue(int value) { TIMEOUT = value; } +// 3.6 Return the data pin for the SDI-12 instance +uint8_t SDI12::getDataPin() { return _dataPin; } + /* ============= 4. Waking up, and talking to, the sensors. =================== diff --git a/src/SDI12.h b/src/SDI12.h index 52aed18..3d49eea 100644 --- a/src/SDI12.h +++ b/src/SDI12.h @@ -95,12 +95,15 @@ class SDI12 : public Stream bool _bufferOverflow; // buffer overflow status public: + SDI12(); // constructor - without argument, for better library integration SDI12(uint8_t dataPin); // constructor ~SDI12(); // destructor void begin(); // enable SDI-12 object + void begin(uint8_t dataPin); // enable SDI-12 object - if you use the empty constuctor, USE THIS void end(); // disable SDI-12 object - void setTimeoutValue(int value); // sets the value to return if a parse int or parse float times out int TIMEOUT; // value to return if a parse times out + void setTimeoutValue(int value); // sets the value to return if a parse int or parse float times out + uint8_t getDataPin(); // returns the data pin for the current instace void forceHold(); // sets line state to HOLDING void forceListen(); // sets line state to LISTENING