From 3f0d27ec87eab38325d0e89f85d65ebf4b33a2d2 Mon Sep 17 00:00:00 2001 From: rmackay9 Date: Sun, 26 Feb 2012 15:36:23 +0900 Subject: [PATCH] ModeFilter - remove older ModeFilter library (new library is now in Filter directory) --- libraries/ModeFilter/ModeFilter.cpp | 87 ------------------- libraries/ModeFilter/ModeFilter.h | 26 ------ .../ModeFilter/examples/ModeFilter/Makefile | 2 - .../examples/ModeFilter/ModeFilter.pde | 51 ----------- libraries/ModeFilter/keywords.txt | 8 -- 5 files changed, 174 deletions(-) delete mode 100644 libraries/ModeFilter/ModeFilter.cpp delete mode 100644 libraries/ModeFilter/ModeFilter.h delete mode 100644 libraries/ModeFilter/examples/ModeFilter/Makefile delete mode 100644 libraries/ModeFilter/examples/ModeFilter/ModeFilter.pde delete mode 100644 libraries/ModeFilter/keywords.txt diff --git a/libraries/ModeFilter/ModeFilter.cpp b/libraries/ModeFilter/ModeFilter.cpp deleted file mode 100644 index cf282d56f0..0000000000 --- a/libraries/ModeFilter/ModeFilter.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - ModeFilter.cpp - Mode Filter Library for Ardupilot Mega. Arduino - Code by Jason Short. DIYDrones.com - Adapted from code by Jason Lessels(June 6, 2011), Bill Gentles (Nov. 12, 2010) - - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - -*/ -#include "ModeFilter.h" - -#include -#if defined(ARDUINO) && ARDUINO >= 100 - #include "Arduino.h" -#else - #include "WProgram.h" -#endif - - -// Constructors //////////////////////////////////////////////////////////////// - -ModeFilter::ModeFilter() : - _sample_index(0) -{ -} - -// Public Methods ////////////////////////////////////////////////////////////// - //Sorting function - // sort function (Author: Bill Gentles, Nov. 12, 2010) - // *a is an array pointer function - -int ModeFilter::get_filtered_with_sample(int _sample){ - _samples[_sample_index] = _sample; - - _sample_index++; - - if (_sample_index >= MOD_FILTER_SIZE) - _sample_index = 0; - - isort(); - - return mode(); -} - - -void ModeFilter::isort() -{ - for (int i = 1; i < MOD_FILTER_SIZE; ++i) { - int j = _samples[i]; - int k; - for (k = i - 1; (k >= 0) && (j < _samples[k]); k--){ - _samples[k + 1] = _samples[k]; - } - _samples[k + 1] = j; - } -} - -//Mode function, returning the mode or median. -int16_t ModeFilter::mode(){ - int fmode = 0; - byte i = 0; - byte count = 0; - byte maxCount = 0; - byte bimodal = 0; - - while(count > maxCount){ - fmode = _samples[i]; - maxCount = count; - bimodal = 0; - } - - if(count == 0) i++; - - if(count == maxCount){ //If the dataset has 2 or more modes. - bimodal = 1; - } - - if(fmode == 0 || bimodal == 1){ //Return the median if there is no mode. - fmode = _samples[(MOD_FILTER_SIZE / 2)]; - } - - return fmode; -} diff --git a/libraries/ModeFilter/ModeFilter.h b/libraries/ModeFilter/ModeFilter.h deleted file mode 100644 index 7cd93017ae..0000000000 --- a/libraries/ModeFilter/ModeFilter.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef ModeFilter_h -#define ModeFilter_h - -#define MOD_FILTER_SIZE 6 - -#include - -class ModeFilter -{ - private: - public: - ModeFilter(); - - int get_filtered_with_sample(int _sample); - int16_t _samples[MOD_FILTER_SIZE]; - - private: - void isort(); - int16_t mode(); - int8_t _sample_index; -}; - -#endif - - - diff --git a/libraries/ModeFilter/examples/ModeFilter/Makefile b/libraries/ModeFilter/examples/ModeFilter/Makefile deleted file mode 100644 index 85b4d8856b..0000000000 --- a/libraries/ModeFilter/examples/ModeFilter/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -BOARD = mega -include ../../../AP_Common/Arduino.mk diff --git a/libraries/ModeFilter/examples/ModeFilter/ModeFilter.pde b/libraries/ModeFilter/examples/ModeFilter/ModeFilter.pde deleted file mode 100644 index f07b442184..0000000000 --- a/libraries/ModeFilter/examples/ModeFilter/ModeFilter.pde +++ /dev/null @@ -1,51 +0,0 @@ -/* - Example of APM_RC library. - Code by Jordi MuĂ’oz and Jose Julio. DIYDrones.com - - Print Input values and send Output to the servos - (Works with last PPM_encoder firmware) -*/ - -#include // ArduPilot Mega RC Library - -int rangevalue[] = {31000, 31000, 50, 55, 60, 55, 10, 0, 31000}; - -ModeFilter mfilter; -byte i = 0; - -void setup() -{ - //Open up a serial connection - Serial.begin(115200); - //Wait for the serial connection - delay(500); -} - -//Main loop where the action takes place -void loop() -{ - while(i < 9){ - printArray(mfilter._samples, 6); - int modE = mfilter.get_filtered_with_sample(rangevalue[i]); - i++; - - Serial.print("The mode/median is: "); - Serial.print(modE); - Serial.println(); - } - delay(100000); -} - -/*-----------Functions------------*/ -//Function to print the arrays. -void printArray(int *a, int n) -{ - for (int i = 0; i < n; i++) - { - Serial.print(a[i], DEC); - Serial.print(' '); - } - - Serial.println(); -} - diff --git a/libraries/ModeFilter/keywords.txt b/libraries/ModeFilter/keywords.txt deleted file mode 100644 index 3efcc0fa52..0000000000 --- a/libraries/ModeFilter/keywords.txt +++ /dev/null @@ -1,8 +0,0 @@ -APM_RC KEYWORD1 -begin KEYWORD2 -InputCh KEYWORD2 -OutputCh KEYWORD2 -GetState KEYWORD2 -Force_Out0_Out1 KEYWORD2 -Force_Out2_Out3 KEYWORD2 -Force_Out6_Out7 KEYWORD2