Minimize contract, add ADC read and send its data to coonsole
This commit is contained in:
21
esp32/main/ringbuf.cpp
Normal file
21
esp32/main/ringbuf.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "ringbuf.h"
|
||||
|
||||
void ringbuf_init(ringbuf_t *rb) {
|
||||
rb->head = 0;
|
||||
for (int i = 0; i < RINGBUF_SIZE; i++) {
|
||||
rb->values[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ringbuf_push(ringbuf_t *rb, int v) {
|
||||
rb->values[rb->head] = v;
|
||||
rb->head = (rb->head + 1) % RINGBUF_SIZE;
|
||||
}
|
||||
|
||||
void ringbuf_copy(const ringbuf_t *rb, int *out) {
|
||||
int idx = rb->head;
|
||||
|
||||
for (int i = 0; i < RINGBUF_SIZE; i++) {
|
||||
out[i] = rb->values[(idx + i) % RINGBUF_SIZE];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user