Skip to content

Commit

Permalink
Moved skip if _interrupt is hot
Browse files Browse the repository at this point in the history
We used to skip the next sensor if the interrupt pin is still high.

Change it to not move to the next sensore if high
  • Loading branch information
arielnh56 committed Mar 13, 2017
1 parent 954d621 commit d1040d6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions LICENSE.md
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013,2015,2017 Alastair Young

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion src/SonarI2C.cpp
Expand Up @@ -29,7 +29,6 @@ void SonarI2C::init() {
// private member functions
// send the trigger signal and attach the interrupt
void SonarI2C::_send_ping() {
if (digitalRead(_interrupt) == inverse ? LOW : HIGH) return; // interrupt pin is active - skip
_pulseBegin = 0; // cleared until we see it
attachInterrupt(digitalPinToInterrupt(_interrupt), _startPulse, inverse ? FALLING : RISING); // NOR gate - pulse is inverted
Wire.beginTransmission(_address);
Expand Down Expand Up @@ -118,6 +117,7 @@ void SonarI2C::begin(uint8_t interrupt) {
// call from loop() every cycle
void SonarI2C::doSonar() {
if (!_currentSonar) return; // no sonars initiated
if (digitalRead(_interrupt) == inverse ? LOW : HIGH) return; // interrupt pin is active - skip
if (_last_sonar_millis + _spacing < millis()) {
// look for next enabled sonar
SonarI2C *thisSonar = _currentSonar->_nextSonar;
Expand Down

0 comments on commit d1040d6

Please sign in to comment.