-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffer.cpp
51 lines (48 loc) · 1.36 KB
/
buffer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "PCT2075_setup.h"
///This array functions as the main buffer to store measured values.
float buffer[36];
/// This string holds the name/identifier of the buffer.
char buffername[15];
/**
* Sets the identifier for the buffer to indicate what kind of storage the type of storage the buffer is used for.
* This identifier/name is also used when the buffer prints its outptut.
* @param name the identifier/name that is given to the buffer. Max length 15 characters.
*/
void namebuffer(const char name[]){
uint8_t i;
for(i = 0; i < 14 && name[i] != '\0'; i++){
buffername[i] = name[i];
}
}
/**
* Inserts a value in a given position into the buffer
* @param index the place to insert the value into the bufer
* @param value that will be added to the buffer
*/
void bufferinsert(int index, float value){
if(index >= 36) return;
buffer[index] = value;
Serial.print("Number: "); Serial.print(index);
Serial.print("\tValue: "); Serial.println(value);
}
/**
* Prints the name/identifier and all values in the buffer to the Serial output,
* separated by comma's.
*/
void printbuffer(void){
uint8_t i;
Serial.print(buffername);
for(i = 0; i < 36; i++){
Serial.print(", ");
Serial.print(buffer[i]);
}
}
/**
* Initializes the buffer by setting all the values in the buffer to zero.
*/
void clearbuffer(void){
uint8_t i;
for(i = 0; i < 36; i++){
buffer[i] = 0;
}
}