Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BMP280
Diff: Sampling.h
- Revision:
- 10:261f2b69c4c7
- Parent:
- 9:ac5673cca703
- Child:
- 12:03589f1d5c30
--- a/Sampling.h Sat Jan 06 16:13:37 2018 +0000 +++ b/Sampling.h Sun Jan 07 23:40:10 2018 +0000 @@ -5,7 +5,8 @@ #include "BMP280.h" #include "rtos.h" -#define BUFFERSIZE 8 +#define BUFFERSIZE 16 +#define SAMPLERATE 1 //Thread Sync Tools @@ -18,13 +19,13 @@ extern float tempReadings[BUFFERSIZE]; extern float presReadings[BUFFERSIZE]; extern float LDRReadings[BUFFERSIZE]; -extern float timeReadings[BUFFERSIZE]; +extern time_t timeReadings[BUFFERSIZE]; -extern unsigned short currentIndex; +extern volatile unsigned short currentIndex; //Position in the buffer of the newest sample -extern unsigned short nextIndex; +extern volatile unsigned short nextIndex; //Position in the buffer where the next sample needs to be writen to -extern unsigned short oldestIndex; +extern volatile unsigned short oldestIndex; //Position in the buffer of the oldest sample extern bool firstSample; @@ -67,9 +68,9 @@ //When flagged by interrupt will read time and LDR value. void AddLDRSample(float LDR); -//Poducer Function +//Producer Function -void AddTimeSample(/*Whatever time*/); +void AddTimeSample(time_t sampledTime); //Producer Function void IncrementIndex(void); @@ -80,6 +81,15 @@ //Called by timeout, turns of LED unsigned short IndexIncrement(unsigned short thisIndex); -//Incrementing the index with respect for the buffersize +//Incrementing the index with respect for the buffersize. Used to prevent overflow. + +unsigned short IndexDecrement(unsigned short thisIndex); +//Decrementing the index with respect for the buffersize. Used to prevent overflow. + +void Sampling(bool inputState); +//Start or stop sampling. true = start, false = stop. + +void TakeKeys(bool inputState); +//Lock or unlock sampling variables. true = take keys. false = return keys #endif \ No newline at end of file