Initial thermocouple impl
This commit is contained in:
@@ -19,3 +19,4 @@ monitor_filters = send_on_enter
|
||||
lib_deps =
|
||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||
mikalhart/TinyGPSPlus@^1.1.0
|
||||
adafruit/MAX6675 library@^1.1.2
|
||||
|
||||
@@ -61,10 +61,10 @@ void setup() {
|
||||
driver_display->print_message("GPS Init Complete");
|
||||
delay(1000);
|
||||
|
||||
driver_display->print_message("Bat Init...");
|
||||
driver_display->print_message("Sensors Init...");
|
||||
battery_handler->init();
|
||||
delay(1000);
|
||||
driver_display->print_message("Bat Init Complete");
|
||||
driver_display->print_message("Sensors Init Complete");
|
||||
delay(1000);
|
||||
router::send(MOD_LCD, TASK_DISPLAY_DRIVER_PRIMARY);
|
||||
}
|
||||
|
||||
24
src/modules/thermocouple/thermocouple.cpp
Normal file
24
src/modules/thermocouple/thermocouple.cpp
Normal 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();
|
||||
}
|
||||
}
|
||||
31
src/modules/thermocouple/thermocouple.h
Normal file
31
src/modules/thermocouple/thermocouple.h
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user