added data structures

added audio support
added rfid support
added spi support
This commit is contained in:
2017-03-12 13:02:06 +01:00
parent cea1d5d164
commit d028b79325
12 changed files with 1373 additions and 0 deletions

59
data/LinearBuffer.h Normal file
View File

@@ -0,0 +1,59 @@
#ifndef LINEARBUFFER_H
#define LINEARBUFFER_H
template <typename Scalar, int _size> class LinearBuffer {
private:
Scalar _data[_size];
uint16_t head = 0;
public:
void add(const Scalar value) {
if (head >= _size) {return;}
_data[head] = value;
++head;
}
/** get the number of used entries */
uint16_t getNumUsed() const {
return head;
}
/** get the number of used bytes */
uint32_t getBytesUsed() const {
return getNumUsed() * sizeof(Scalar);
}
uint16_t size() const {
return _size;
}
/** set the buffer to empty */
void reset() {
head = 0;
}
const Scalar* data() const {
return _data;
}
/** constant array access */
const Scalar& operator [] (const size_t idx) const {
return _data[idx];
}
/** true if the buffer is currently empty */
bool isEmpty() const {
return head == 0;
}
bool isFull() const {
return head >= size;
}
};
#endif // LINEARBUFFER_H