Initial thermocouple impl

This commit is contained in:
2026-03-27 23:23:14 +01:00
parent 3ea71788c2
commit 2c15ae43ae
4 changed files with 58 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
// Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include "thermocouple.h"
int thermocouple::push(const Task &task) { return _queue.push(task); }
thermocouple::thermocouple() : _logger(nullptr) {}
thermocouple::thermocouple(system_logger *logger) : _logger(logger) {}
thermocouple::~thermocouple() {}
int thermocouple::init() {
_thermocouple = new MAX6675(THERMO_SCK, THERMO_CS, THERMO_SO);
return 0;
}
int thermocouple::loop(unsigned long timeout_ms) {
if (millis() > _last_read + _update_interval) {
_temp = _thermocouple->readCelsius();
}
}

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#define THERMO_CS A1
#define THERMO_SO A0
#define THERMO_SCK A2
#include "base/module_base.h"
#include "base/ring_buffer.h"
#include "custom_types.h"
#include "modules/logger/system_logger.h"
#include <Arduino.h>
#include <max6675.h>
class thermocouple : public module_base {
private:
system_logger *_logger;
ring_buffer<Task, 16> _queue;
MAX6675 *_thermocouple;
double _temp;
unsigned long _update_interval = 1000;
unsigned long _last_read = 0;
public:
int push(const Task &task) override;
thermocouple();
thermocouple(system_logger *logger);
~thermocouple();
int init();
int loop(unsigned long timeout_ms = 500);
};