wobblyhead hg > arduino > Potentiometer
changeset 1:c74204ea535c
added isStopped
| author | ark |
|---|---|
| date | 2017-01-25 23:01 +0100 |
| parents | 4c32c9d4b94f |
| children | a5e06e87f081 |
| files | .hgignore Potentiometer.cpp Potentiometer.h |
| diffstat | 3 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Wed Jan 25 23:01:54 2017 +0100 @@ -0,0 +1,1 @@ +.DS_Store
--- a/Potentiometer.cpp Mon Jan 23 01:50:42 2017 +0100 +++ b/Potentiometer.cpp Wed Jan 25 23:01:54 2017 +0100 @@ -24,6 +24,7 @@ if(this->num == Potentiometer::MAX_SAMPLES) { this->sum -= this->avg; this->num--; + this->isStopped = true; } this->sum += v; this->num++; @@ -36,6 +37,7 @@ this->sum = v; this->avg = v; this->num = 1; + this->isStopped = false; } #ifdef DEBUG Serial.print("pin="); @@ -46,6 +48,8 @@ Serial.print(num); Serial.print(", avg="); Serial.println(avg); + Serial.print(", isStopped="); + Serial.println(this->isStopped); #endif }
--- a/Potentiometer.h Mon Jan 23 01:50:42 2017 +0100 +++ b/Potentiometer.h Wed Jan 25 23:01:54 2017 +0100 @@ -11,6 +11,9 @@ public: // dejittered pot value int value; + + // flag, if true the pot is not moving + bool isStopped; /** create an uninitialised Potentiometer. @@ -19,7 +22,7 @@ Potentiometer(); /** - setup pod instance. + setup pot instance. @param {byte} pin input pin */ void setup(byte pin);
