Fermenter History
This commit is contained in:
parent
732f88aec3
commit
17b520f3f2
@ -1,6 +1,6 @@
|
||||
{
|
||||
"pid": {
|
||||
"p": 5,
|
||||
"p": 1,
|
||||
"i": 0,
|
||||
"d": 0,
|
||||
"target": 0
|
||||
|
||||
@ -16,7 +16,7 @@ void patrixSetup() {
|
||||
heater.setup();
|
||||
rotary.setup();
|
||||
|
||||
pid.setup();
|
||||
pidSetup();
|
||||
httpSetup2();
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ void patrixLoop() {
|
||||
|
||||
ds18b20.loop();
|
||||
temperature.loop();
|
||||
pid.loop();
|
||||
pidLoop();
|
||||
rotary.loop();
|
||||
program.loop();
|
||||
|
||||
|
||||
@ -1,8 +1,25 @@
|
||||
#include <patrix/Patrix.h>
|
||||
#ifdef NODE_FERMENTER
|
||||
|
||||
#include "pid.h"
|
||||
#include "config.h"
|
||||
|
||||
struct History {
|
||||
|
||||
int16_t target;
|
||||
|
||||
int16_t temperature;
|
||||
|
||||
uint8_t heater;
|
||||
|
||||
};
|
||||
|
||||
History history[3 * 60];
|
||||
|
||||
History* historyPtr = history;
|
||||
|
||||
unsigned long historyLastMinute = 0;
|
||||
|
||||
DS18B20 ds18b20(
|
||||
"DS18B20",
|
||||
D4
|
||||
@ -39,4 +56,20 @@ void addTarget(const double delta) {
|
||||
config.markDirty();
|
||||
}
|
||||
|
||||
void pidSetup() {
|
||||
pid.setup();
|
||||
}
|
||||
|
||||
void pidLoop() {
|
||||
pid.loop();
|
||||
const auto currentMinute = millis() / 60000;
|
||||
if (historyLastMinute != currentMinute) {
|
||||
historyLastMinute = currentMinute;
|
||||
historyPtr = (historyPtr - history + 1) % std::size(history) + history;
|
||||
}
|
||||
historyPtr->heater = static_cast<uint8_t>(heater.getPercent());
|
||||
historyPtr->target = static_cast<int16_t>(pid.getTarget() * 10);
|
||||
historyPtr->temperature = static_cast<int16_t>(temperature.getValue() * 10);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -17,4 +17,8 @@ extern PIDController pid;
|
||||
|
||||
void addTarget(double delta);
|
||||
|
||||
void pidSetup();
|
||||
|
||||
void pidLoop();
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#include <LittleFS.h>
|
||||
|
||||
#include "Patrix.h"
|
||||
#include "http.h"
|
||||
#include "mqtt.h"
|
||||
#include "system.h"
|
||||
|
||||
void setup() {
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
#ifndef PATRIX_H
|
||||
#define PATRIX_H
|
||||
|
||||
#include "wifi.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
void patrixSetup();
|
||||
|
||||
void patrixLoop();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user