ADC
8.0
Analog to Digital Conversor library for the Teensy 3.6 microprocessor
RingBuffer.h
1
/* Teensy 4, 3.x, LC ADC library
2
* https://github.com/pedvide/ADC
3
* Copyright (c) 2019 Pedro Villanueva
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining
6
* a copy of this software and associated documentation files (the
7
* "Software"), to deal in the Software without restriction, including
8
* without limitation the rights to use, copy, modify, merge, publish,
9
* distribute, sublicense, and/or sell copies of the Software, and to
10
* permit persons to whom the Software is furnished to do so, subject to
11
* the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be
14
* included in all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
* SOFTWARE.
24
*/
25
26
#ifndef RINGBUFFER_H
27
#define RINGBUFFER_H
28
29
// include new and delete
30
//#include <Arduino.h>
31
32
// THE SIZE MUST BE A POWER OF 2!!
33
#define RING_BUFFER_DEFAULT_BUFFER_SIZE 8
34
35
36
40
class
RingBuffer
41
{
42
public
:
44
RingBuffer
();
45
47
virtual
~RingBuffer
();
48
50
int
isFull
();
51
53
int
isEmpty
();
54
56
void
write
(
int
value);
57
59
int
read
();
60
61
protected
:
62
private
:
63
64
int
increase(
int
p);
65
66
int
b_size = RING_BUFFER_DEFAULT_BUFFER_SIZE;
67
int
b_start = 0;
68
int
b_end = 0;
69
//int *elems;
70
int
elems[RING_BUFFER_DEFAULT_BUFFER_SIZE];
71
};
72
73
74
#endif // RINGBUFFER_H
RingBuffer::~RingBuffer
virtual ~RingBuffer()
RingBuffer::isEmpty
int isEmpty()
Returns 1 (true) if the buffer is empty.
RingBuffer::isFull
int isFull()
Returns 1 (true) if the buffer is full.
RingBuffer::write
void write(int value)
Write a value into the buffer.
RingBuffer
Definition:
RingBuffer.h:40
RingBuffer::read
int read()
Read a value from the buffer.
RingBuffer::RingBuffer
RingBuffer()
Default constructor, buffer has a size DEFAULT_BUFFER_SIZE.
RingBuffer.h
Generated on Tue Dec 31 2019 14:32:53 for ADC by
1.8.17