fuck this
Dependencies: BMP280
Diff: Sampling.h
- Revision:
- 19:40c721f01ed2
- Parent:
- 12:03589f1d5c30
- Child:
- 21:6e733076f49c
--- a/Sampling.h Tue Jan 09 10:25:17 2018 +0000 +++ b/Sampling.h Tue Jan 09 11:39:59 2018 +0000 @@ -1,6 +1,23 @@ #ifndef __Sampling__ #define __Sampling__ - +/* +* This module relates to the handling and sampling of enviromental data. +* Sampled data is held in 4 arrays. One for each different reading. Each +* of these is protected by a mutex lock, which is taken when data is being +* written to the registers. +* There are common indexes for the positions in the array. Stored is the position +* position of the oldest sample, the most recent sample, and where the next +* sample is to be written to. These operate in such a way that the array will fill +* and when fill will start to overwrite the oldest sample. +* Producer functions write samples to nextIndex position, allowing the most +* recent complete sample to continue to be read by consumers. +* +* A ticker runs at the sample rate interval. This signals two sampling threads. +* Two threads were used to prevent against delay from I2C interface. +* These threads take the samples then write them to the nextIndex, then signal done. +* On seeing that both threads are complete, the main thread then increments the +* indexes and passes the latest variables to the LCD. +*/ #include "mbed.h" #include "BMP280.h" #include "rtos.h"