Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FilterDerivative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion FilterDerivative.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// returns the derivative
struct FilterDerivative {
long LastUS;
unsigned long LastUS;
float LastInput;

float Derivative;
Expand Down
2 changes: 1 addition & 1 deletion FilterOnePole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions FilterOnePole.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion FilterTwoPole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion FilterTwoPole.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down