Senior design censored code to run freescale motor with X-NUCLEO-IM07M1. REFACTORED

Dependencies:   mbed

Fork of Blue_Board_Test_2 by Brad VanderWilp

AnalogInBuffered.h

Committer:
vicyap
Date:
2016-04-07
Revision:
7:b8ef1960498e
Parent:
6:f9aca07dbdb4

File content as of revision 7:b8ef1960498e:

#ifndef ANALOGINBUFFERED_H
#define ANALOGINBUFFERED_H

#include "mbed.h"

/*
    This class extends the mbed AnalogIn class to include a buffered_read()
    
    buffered_read() will save values to a buffer each time it is called.
    Once the buffer reaches a buffer size, it will save the average.
    Then it returns the last saved values (default: 0.0)
*/

class AnalogInBuffered : public AnalogIn
{
    public:
    AnalogInBuffered(PinName pin, int buffer_size);
    
    float buffered_read();
    
    private:
    int mBufferSize;
    
    int mCount;
    float mSum;
    float mLastValue;
};

#endif