I was trying to reset the timer using the arduino platform but I can’t find the
time_reset()
function.
In wiring.h:
unsigned long millis(void);
void delay(unsigned long);
void delayMicroseconds(unsigned int us);
the only dirty solution I found is to include in the library OrangutanTIme and remove the quoted functions to avoid linking conflicts.
Nevertheless using the AVR compiler is working:
#include <math.h>
#include <pololu/OrangutanLCD.h>
#include <pololu/OrangutanPushbuttons.h>
#include <pololu/OrangutanTime.h>
/*
* Filter benchmark
*
* https://www.pololu.com/docs/0J17/5.c
* https://www.pololu.com
* https://forum.pololu.com
*/
int N=2;
float buffer[2]={0.0,0.0};
float a[2]={0.5,0.5};
OrangutanLCD lcd;
OrangutanPushbuttons buttons;
float filter(float x, float hist[],float a[],float N) {
int i;
float sum = 0;
hist[0] = x; //history of samples
for(i=N-1;i>=0;i--)
{
sum = sum + hist[i]*a[i];
if(i != 0)
{
hist[i] = hist[i-1];
}
}
return sum;
}
void setup() // run once, when the sketch starts
{
lcd.clear();
lcd.print("Setup done!");
}
int main() // run over and over again
{
setup();
buttons.waitForPress(TOP_BUTTON);
OrangutanTime::reset();
//time_reset();
float output=0.0;
lcd.clear();
for(float input=0.0;input<100.0;input=input+10.0)
{
output=filter(input, buffer,a,N);
}
lcd.print("Filtering done");
delay(100);
lcd.clear();
lcd.print(millis());
return 0;
}
I’m basically testing the code for an FIR filter.