This commit is contained in:
2026-04-24 16:37:04 +03:00
parent cb1014c950
commit 90037587c0
16 changed files with 224 additions and 3557 deletions

View File

@@ -11,35 +11,52 @@ extern "C" {
// буфер
static ringbuf_t rb;
ringbuf_t* sampler_get_buffer() {
ringbuf_t* sampler_get_buffer()
{
return &rb;
}
static void sampler_task(void *arg) {
static TaskHandle_t sampler_task_handle = nullptr;
static void sampler_task(void* arg)
{
const TickType_t period = pdMS_TO_TICKS(6000);
TickType_t last_wake = xTaskGetTickCount();
while (1) {
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 секунд
vTaskDelayUntil(&last_wake, period); // 6 секунд
}
}
void sampler_task_start() {
ringbuf_init(&rb);
ds18b20_init(GPIO_NUM_27); // новый драйвер
void sampler_task_start()
{
if (sampler_task_handle == nullptr)
{
ringbuf_init(&rb);
ds18b20_init(GPIO_NUM_27); // новый драйвер
xTaskCreate(
sampler_task,
"sampler",
4096,
NULL,
5,
NULL
);
}
xTaskCreate(
sampler_task,
"sampler",
4096,
nullptr,
5,
&sampler_task_handle
);
}
}
void sampler_task_stop()
{
if (sampler_task_handle != nullptr)
{
vTaskDelete(sampler_task_handle);
sampler_task_handle = nullptr;
}
}