Senior design censored code to run freescale motor with X-NUCLEO-IM07M1. REFACTORED
Fork of Blue_Board_Test_2 by
Diff: AnalogInBuffered.h
- Revision:
- 6:f9aca07dbdb4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AnalogInBuffered.h Thu Apr 07 23:27:18 2016 +0000 @@ -0,0 +1,29 @@ +#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 \ No newline at end of file