MrYsLab / pymata4

A High Performance Python Client For Arduino Firmata
GNU Affero General Public License v3.0
76 stars 30 forks source link

Allow sonar updates regardless of last measured values #45

Closed Jack92829 closed 2 years ago

Jack92829 commented 2 years ago

When using set_pin_mode_sonar and a callback, the callback only triggers if the value being read has changed since the last reading. This can introduce issues and/or extra work for the user in situations such as collecting sonar data via a callback and graphing it at a later date. If the sonar were to continue reading the same value, the callback would not trigger, resulting in the collected data being inaccurate as it does not include the readings where the sonar was reading a constant value, thereby preventing horizontal straight lines from ever appearing on the graph. This can be worked around pretty easily, but it adds extra work for the user, especially if they want to incorporate threading into their work which callbacks would already do behind the scenes. This PR simply adds another optional parameter to set_pin_mode_sonar that allows the user to make the callback trigger regardless of whether or not the value read by the sonar sensor has changed.

MrYsLab commented 2 years ago

@Jack92829 Thanks for the pull request. I had temporarily "unarchived" this repository to fix an issue and forgot to re-archive. I apologize for this oversight. The repository is frozen, so it cannot accept any new pull requests. Since you have a version that contains the changes that address your issue and the fact that no new features will be added in the future, using your custom version results in a very low risk. Thanks again for submitting the pull request. Since you will not be able to comment in this PR section, if you wish to contact me, please use the email address in the profile section of my GitHub homepage.