Filter: added a butter filter to example

This commit is contained in:
Andrew Tridgell 2013-01-16 09:15:35 +11:00
parent befc6b7b9b
commit d00b06d449

View File

@ -7,7 +7,8 @@
#include <AP_Progmem.h>
#include <AP_HAL.h>
#include <AP_HAL_AVR.h>
#include <AP_HAL_PX4.h>
#include <AP_HAL_Empty.h>
#include <AP_Param.h>
#include <AP_Math.h> // ArduPilot Mega Vector/Matrix math Library
#include <Filter.h> // Filter library
@ -24,6 +25,8 @@ ModeFilterInt16_Size5 mfilter(2); // buffer of 5 values, result will be from bu
AverageFilterUInt16_Size4 _temp_filter;
butter50hz8_0 butter;
void setup()
{
// introduction
@ -50,7 +53,11 @@ void readTemp()
raw_temp = _temp_filter.apply(_temp_sensor);
hal.console->printf("RT: %ld\n", raw_temp);
// use a butter filter on the result, just so we have a
// butterworth filter example
butter.filter(raw_temp);
hal.console->printf("RT: %lu\n", (unsigned long)raw_temp);
}
//Main loop where the action takes place