Ries Twisk / Mbed 2 deprecated JoyStick

Dependencies:   USBDevice mbed-rtos mbed

Fork of JoyStick by Ries Twisk

Committer:
rvt
Date:
Wed Jun 22 12:50:16 2016 +0000
Revision:
5:a0bb17c379ce
Parent:
1:5b2ab44eb31f
Latest

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 smoothedValue = 0.0;
rvt 0:33bc88c4ab31 6 }
rvt 0:33bc88c4ab31 7
rvt 0:33bc88c4ab31 8 LowPassFilter::~LowPassFilter() {
rvt 0:33bc88c4ab31 9 }
rvt 0:33bc88c4ab31 10
rvt 0:33bc88c4ab31 11
rvt 0:33bc88c4ab31 12 void LowPassFilter::setData(long dataPoint) {
rvt 0:33bc88c4ab31 13 getChain()->setData(dataPoint);
rvt 1:5b2ab44eb31f 14 smoothedValue = (getChain()->getData() * (1.0 - _alpha)) + (smoothedValue * _alpha);
rvt 0:33bc88c4ab31 15 }
rvt 0:33bc88c4ab31 16
rvt 5:a0bb17c379ce 17 long LowPassFilter::getData() const {
rvt 0:33bc88c4ab31 18 return smoothedValue;
rvt 0:33bc88c4ab31 19 }
rvt 0:33bc88c4ab31 20