fuck this

Dependencies:   BMP280

Revision:
9:ac5673cca703
Parent:
8:dbb57b4d5ba4
Child:
10:261f2b69c4c7
Child:
15:e61297f9bae9
--- a/Sampling.h	Thu Jan 04 19:32:30 2018 +0000
+++ b/Sampling.h	Sat Jan 06 16:13:37 2018 +0000
@@ -5,34 +5,36 @@
 #include "BMP280.h"
 #include "rtos.h"
 
-#define BUFFERSIZE 120
+#define BUFFERSIZE 8
 
 
 //Thread Sync Tools
-Mutex tempReadingsLock;
-Mutex presReadingsLock;
-Mutex LDRReadingsLock;
-Mutex timeReadingsLock;
+extern Mutex tempReadingsLock;
+extern Mutex presReadingsLock;
+extern Mutex LDRReadingsLock;
+extern Mutex timeReadingsLock;
 
 //Buffers
-float tempReadings[BUFFERSIZE];
-float presReadings[BUFFERSIZE];
-float LDRReadings[BUFFERSIZE];
-float timeReadings[BUFFERSIZE];
+extern float tempReadings[BUFFERSIZE];
+extern float presReadings[BUFFERSIZE];
+extern float LDRReadings[BUFFERSIZE];
+extern float timeReadings[BUFFERSIZE];
 
-extern unsigned short newestIndex;
+extern unsigned short currentIndex;
 //Position in the buffer of the newest sample
+extern unsigned short nextIndex;
+//Position in the buffer where the next sample needs to be writen to
 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
+extern Thread t1; //Sample Enviromental Sensor
+extern Thread t2; //Sample LDR Sensor
 
-Ticker sampleRate;
-Timeout SampleLEDTimeout;
+extern Ticker sampleRate;
+extern Timeout SampleLEDTimeout;
 extern BMP280 sensor;
 extern AnalogIn LDRSensor; //Input pin for LDR
 extern DigitalOut SamplingLED; //Onboard LED showing when a sample happens
@@ -43,8 +45,8 @@
 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?
+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
@@ -77,4 +79,7 @@
 void FlipSamplingLED(void);
 //Called by timeout, turns of LED
 
+unsigned short IndexIncrement(unsigned short thisIndex);
+//Incrementing the index with respect for the buffersize
+
 #endif
\ No newline at end of file