Minimize contract, add ADC read and send its data to coonsole

This commit is contained in:
2026-04-13 00:04:48 +03:00
parent 732a2dfa32
commit 977227296e
12 changed files with 269 additions and 67 deletions

21
esp32/main/ringbuf.cpp Normal file
View 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];
}
}