Fermenter History
This commit is contained in:
parent
732f88aec3
commit
17b520f3f2
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"pid": {
|
"pid": {
|
||||||
"p": 5,
|
"p": 1,
|
||||||
"i": 0,
|
"i": 0,
|
||||||
"d": 0,
|
"d": 0,
|
||||||
"target": 0
|
"target": 0
|
||||||
|
|||||||
@ -16,7 +16,7 @@ void patrixSetup() {
|
|||||||
heater.setup();
|
heater.setup();
|
||||||
rotary.setup();
|
rotary.setup();
|
||||||
|
|
||||||
pid.setup();
|
pidSetup();
|
||||||
httpSetup2();
|
httpSetup2();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ void patrixLoop() {
|
|||||||
|
|
||||||
ds18b20.loop();
|
ds18b20.loop();
|
||||||
temperature.loop();
|
temperature.loop();
|
||||||
pid.loop();
|
pidLoop();
|
||||||
rotary.loop();
|
rotary.loop();
|
||||||
program.loop();
|
program.loop();
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,25 @@
|
|||||||
|
#include <patrix/Patrix.h>
|
||||||
#ifdef NODE_FERMENTER
|
#ifdef NODE_FERMENTER
|
||||||
|
|
||||||
#include "pid.h"
|
#include "pid.h"
|
||||||
#include "config.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 ds18b20(
|
||||||
"DS18B20",
|
"DS18B20",
|
||||||
D4
|
D4
|
||||||
@ -39,4 +56,20 @@ void addTarget(const double delta) {
|
|||||||
config.markDirty();
|
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
|
#endif
|
||||||
|
|||||||
@ -17,4 +17,8 @@ extern PIDController pid;
|
|||||||
|
|
||||||
void addTarget(double delta);
|
void addTarget(double delta);
|
||||||
|
|
||||||
|
void pidSetup();
|
||||||
|
|
||||||
|
void pidLoop();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
|
||||||
#include "Patrix.h"
|
#include "Patrix.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
#include "mqtt.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
#ifndef PATRIX_H
|
#ifndef PATRIX_H
|
||||||
#define PATRIX_H
|
#define PATRIX_H
|
||||||
|
|
||||||
#include "wifi.h"
|
|
||||||
#include "mqtt.h"
|
|
||||||
|
|
||||||
void patrixSetup();
|
void patrixSetup();
|
||||||
|
|
||||||
void patrixLoop();
|
void patrixLoop();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user