Ries Twisk / Mbed 2 deprecated JoyStick

Dependencies:   USBDevice mbed-rtos mbed

Fork of JoyStick by Ries Twisk

Committer:
rvt
Date:
Wed Aug 28 02:33:03 2013 +0000
Revision:
0:33bc88c4ab31
Child:
1:5b2ab44eb31f
Initial release with RTOS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rvt 0:33bc88c4ab31 1 #include "LowPassFilter.h"
rvt 0:33bc88c4ab31 2
rvt 0:33bc88c4ab31 3 LowPassFilter::LowPassFilter(AnalogFilterInterface *chain,double alpha) : AnalogFilterInterface(chain) {
rvt 0:33bc88c4ab31 4 _alpha = alpha;
rvt 0:33bc88c4ab31 5 _beta = 1.0 - _alpha;
rvt 0:33bc88c4ab31 6 smoothedValue = 0.0;
rvt 0:33bc88c4ab31 7 }
rvt 0:33bc88c4ab31 8
rvt 0:33bc88c4ab31 9 LowPassFilter::~LowPassFilter() {
rvt 0:33bc88c4ab31 10 }
rvt 0:33bc88c4ab31 11
rvt 0:33bc88c4ab31 12
rvt 0:33bc88c4ab31 13 void LowPassFilter::setData(long dataPoint) {
rvt 0:33bc88c4ab31 14 getChain()->setData(dataPoint);
rvt 0:33bc88c4ab31 15 smoothedValue = (getChain()->getData() * _beta) + (smoothedValue * _alpha);
rvt 0:33bc88c4ab31 16 }
rvt 0:33bc88c4ab31 17
rvt 0:33bc88c4ab31 18 long LowPassFilter::getData() {
rvt 0:33bc88c4ab31 19 return smoothedValue;
rvt 0:33bc88c4ab31 20 }
rvt 0:33bc88c4ab31 21