fuck this

Dependencies:   BMP280

Sampling.cpp

Committer:
Swaggie
Date:
2018-01-03
Revision:
6:8e1795a5886b
Parent:
5:bea93c8e50b7
Child:
7:bf9f92ff02e8

File content as of revision 6:8e1795a5886b:

#include "Sampling.h"
#include "mbed.h"

//Thread Sync Tools
Mutex tempReadingsLock;
Mutex presReadingsLock;
Mutex LDRReadingsLock;

//Buffers
float tempReadings[BUFFERSIZE];
float presReadings[BUFFERSIZE];
float LDRReadings[BUFFERSIZE];

unsigned short newestTempIndex = BUFFERSIZE-1;
unsigned short oldestTempIndex = BUFFERSIZE-1;

bool NewEnvSample = false;  //Is there new data from the envirom sensor to output?
bool NewLDRSample = false;  //Is there new data from the LDR to output?

void SampleTimerISR(void)
{
    //Flag Threads
}
    
void ConfigThreadsAndIR(void)
{
   sampleRate.attach(SampleTimerISR, 15); //15 second interval
}

void AddPresSample(float* Pres)
{
   tempReadingsLock.lock(); //Take the key
   tempReadings[newestTempIndex+1] = Pres; //Add the sample after the most recet
   tempReadingsLock.unlock(); // Release the key
}

void threadSampleEnvSensor(void)
{
    //Get readings
    //float temp =
    //float pres = 
    AddPresSample(pres);