diff --git a/FilterDerivative.cpp b/FilterDerivative.cpp index 6446267..5e101bf 100644 --- a/FilterDerivative.cpp +++ b/FilterDerivative.cpp @@ -2,7 +2,7 @@ #include "Arduino.h" float FilterDerivative::input( float inVal ) { - long thisUS = micros(); + unsigned long thisUS = micros(); float dt = 1e-6*float(thisUS - LastUS); // cast to float here, for math LastUS = thisUS; // update this now diff --git a/FilterDerivative.h b/FilterDerivative.h index 30aa2f1..c49cc96 100644 --- a/FilterDerivative.h +++ b/FilterDerivative.h @@ -3,7 +3,7 @@ // returns the derivative struct FilterDerivative { - long LastUS; + unsigned long LastUS; float LastInput; float Derivative; diff --git a/FilterOnePole.cpp b/FilterOnePole.cpp index 8c42eb7..7dae08f 100644 --- a/FilterOnePole.cpp +++ b/FilterOnePole.cpp @@ -17,7 +17,7 @@ void FilterOnePole::setFilter( FILTER_TYPE ft, float fc, float initialValue ) { } float FilterOnePole::input( float inVal ) { - long time = micros(); + unsigned long time = micros(); ElapsedUS = float(time - LastUS); // cast to float here, for math LastUS = time; // update this now diff --git a/FilterOnePole.h b/FilterOnePole.h index 8035759..c0ab393 100755 --- a/FilterOnePole.h +++ b/FilterOnePole.h @@ -25,11 +25,11 @@ struct FilterOnePole { float X; // most recent input value - // elapsed times are kept in long, and will wrap every - // 35 mins, 47 seconds ... however, the wrap does not matter, + // elapsed times are kept in unsigned long, and will wrap every + // 71 mins, 35 seconds ... however, the wrap does not matter, // because the delta will still be correct (always positive and small) float ElapsedUS; // time since last update - long LastUS; // last time measured + unsigned long LastUS; // last time measured FilterOnePole( FILTER_TYPE ft=LOWPASS, float fc=1.0, float initialValue=0 ); diff --git a/FilterTwoPole.cpp b/FilterTwoPole.cpp index 7a8c6fa..3d1ed1d 100755 --- a/FilterTwoPole.cpp +++ b/FilterTwoPole.cpp @@ -120,7 +120,7 @@ void FilterTwoPole::setAsFilter( OSCILLATOR_TYPE ft, float frequency3db, float i float FilterTwoPole::input( float drive ) { Fprev = drive; // needed when using filter as a highpass - long now = micros(); // get current time + unsigned long now = micros(); // get current time float dt = 1e-6*float(now - LastTimeUS); // find dt LastTimeUS = now; // save the last time diff --git a/FilterTwoPole.h b/FilterTwoPole.h index 9b63f1c..4d0384e 100755 --- a/FilterTwoPole.h +++ b/FilterTwoPole.h @@ -41,7 +41,7 @@ struct FilterTwoPole { bool IsHighpass; // false for normal output, true will make a lowpass into a highpass - long LastTimeUS; // last time measured + unsigned long LastTimeUS; // last time measured FilterTwoPole( float frequency0 = 1, float qualityFactor = 1, float xInit = 0);