fuck this
Dependencies: BMP280
Sampling.h
- Committer:
- Swaggie
- Date:
- 2018-01-04
- Revision:
- 8:dbb57b4d5ba4
- Parent:
- 7:bf9f92ff02e8
- Child:
- 9:ac5673cca703
File content as of revision 8:dbb57b4d5ba4:
#ifndef __Sampling__ #define __Sampling__ #include "mbed.h" #include "BMP280.h" #include "rtos.h" #define BUFFERSIZE 120 //Thread Sync Tools Mutex tempReadingsLock; Mutex presReadingsLock; Mutex LDRReadingsLock; Mutex timeReadingsLock; //Buffers float tempReadings[BUFFERSIZE]; float presReadings[BUFFERSIZE]; float LDRReadings[BUFFERSIZE]; float timeReadings[BUFFERSIZE]; extern unsigned short newestIndex; //Position in the buffer of the newest sample extern 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 Thread t1; //Sample Enviromental Sensor Thread t2; //Sample LDR Sensor Ticker sampleRate; Timeout SampleLEDTimeout; 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; */ bool NewEnvSample; //Is there new data from the envirom sensor to output? 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); //Poducer Function void AddTimeSample(/*Whatever time*/); //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 #endif