HB, OTA etc

This commit is contained in:
2026-04-22 20:11:55 +03:00
parent 4100931deb
commit cb1014c950
76 changed files with 3157 additions and 232 deletions

View File

@@ -1,37 +1,43 @@
#include "sampler_task.h"
#include "adc_reader.h"
#include "ringbuf.h"
#include "ds18b20.h" // добавим
extern "C" {
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_timer.h"
}
// буфер объявим здесь (глобальный для простоты)
// буфер
static ringbuf_t rb;
// дать доступ другим модулям (sender потом возьмёт)
ringbuf_t* sampler_get_buffer() {
return &rb;
}
static void sampler_task(void *arg) {
while (1) {
int val = adc_reader_read();
ringbuf_push(&rb, val);
const TickType_t period = pdMS_TO_TICKS(6000);
TickType_t last_wake = xTaskGetTickCount();
vTaskDelay(pdMS_TO_TICKS(100)); // 10 Гц
while (1) {
int64_t now_ms = esp_timer_get_time() / 1000;
float temp = ds18b20_read();
ringbuf_push(&rb, now_ms, (int)(temp * 100));
vTaskDelayUntil(&last_wake, period);// 6 секунд
}
}
void sampler_task_start() {
ringbuf_init(&rb);
adc_reader_init();
ds18b20_init(GPIO_NUM_27); // новый драйвер
xTaskCreate(
sampler_task,
"sampler",
2048,
4096,
NULL,
5,
NULL