fuck this
Dependencies: BMP280
Sampling.h
- Committer:
- mwthewsey
- Date:
- 2018-01-09
- Revision:
- 12:03589f1d5c30
- Parent:
- 10:261f2b69c4c7
- Child:
- 19:40c721f01ed2
File content as of revision 12:03589f1d5c30:
#ifndef __Sampling__ #define __Sampling__ #include "mbed.h" #include "BMP280.h" #include "rtos.h" #define BUFFERSIZE 120 #define SAMPLERATE 7 //Thread Sync Tools extern Mutex tempReadingsLock; extern Mutex presReadingsLock; extern Mutex LDRReadingsLock; extern Mutex timeReadingsLock; //Buffers extern float tempReadings[BUFFERSIZE]; extern float presReadings[BUFFERSIZE]; extern float LDRReadings[BUFFERSIZE]; extern time_t timeReadings[BUFFERSIZE]; extern volatile unsigned short currentIndex; //Position in the buffer of the newest sample extern volatile unsigned short nextIndex; //Position in the buffer where the next sample needs to be writen to extern volatile unsigned short oldestIndex; //Position in the buffer of the oldest sample extern bool firstSample; //Used to indicate this is the first sample to be taken. used in IncrementIndex func extern Thread t1; //Sample Enviromental Sensor extern Thread t2; //Sample LDR Sensor extern Ticker sampleRate; extern Timeout SampleLEDTimeout; //Hardware extern BMP280 sensor; extern AnalogIn LDRSensor; //Input pin for LDR extern DigitalOut SamplingLED; //Onboard LED showing when a sample happens /*These can be deleted I think extern float fLatestTemp; extern float fLatestLDR; extern float fLatestPres; */ extern bool NewEnvSample; //Is there new data from the envirom sensor to output? extern bool NewLDRSample; //Is there new data from the LDR to output? void SampleTimerISR(void); //Called by ticker. Calls the sample funcs of each device by flagging the threads void ConfigThreadsAndIR(void); //Setup Interrupts and Threads void ThreadSampleEnvSensor(void); //when flagged by interrupt will capture a sample then calls the addtobufferfuncs void AddTempSample(float temp); //Producer function void AddPresSample(float pres); //Producer Function void ThreadSampleLDR(void); //When flagged by interrupt will read time and LDR value. void AddLDRSample(float LDR); //Producer Function void AddTimeSample(time_t sampledTime); //Producer Function void IncrementIndex(void); //Called after samples are added. Increments the index and moves the oldest //along if necessary void FlipSamplingLED(void); //Called by timeout, turns of LED unsigned short IndexIncrement(unsigned short thisIndex); //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