Aufgeräumt
This commit is contained in:
parent
0e1965a987
commit
2343a99d68
1 changed files with 29 additions and 44 deletions
|
|
@ -212,7 +212,7 @@ int getTempInC(uint8_t senTemp){
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFilteredTemp(int rawSensorPin) {
|
int getFilteredTemp(int rawSensorPin) {
|
||||||
constexpr uint8_t FILTER_SAMPLES = 10; // Puffergröße (10 Messwerte)
|
constexpr uint8_t FILTER_SAMPLES = 100; // Puffergröße (100 Messwerte) Mittelwert über 10s
|
||||||
static int readings[FILTER_SAMPLES];
|
static int readings[FILTER_SAMPLES];
|
||||||
static uint8_t readIndex = 0;
|
static uint8_t readIndex = 0;
|
||||||
static int32_t total = 0;
|
static int32_t total = 0;
|
||||||
|
|
@ -417,6 +417,22 @@ if (settings.editAcc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prüft ob der Motor zu heiß wird.
|
||||||
|
// return: true wenn zu heiß
|
||||||
|
// false wenn unter der Grenze
|
||||||
|
bool checkOverHeat(int sensorPin){
|
||||||
|
curTemp = getFilteredTemp(sensorPin);
|
||||||
|
|
||||||
|
if (curTemp >= settings.maxTemp) {
|
||||||
|
return true;
|
||||||
|
} else if (curTemp <= settings.coldTemp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ################## TODO #########################
|
||||||
|
// Betriebsmodi in funktions auslagern
|
||||||
|
|
||||||
void printStatus(FastAccelStepper *stepper, int speed, int clickPlus, int clickMinus){
|
void printStatus(FastAccelStepper *stepper, int speed, int clickPlus, int clickMinus){
|
||||||
// Plotter-Ausgabe alle 50 ms (überflutet den Bus nicht)
|
// Plotter-Ausgabe alle 50 ms (überflutet den Bus nicht)
|
||||||
if (millis() - lastPlotTime >= 50) {
|
if (millis() - lastPlotTime >= 50) {
|
||||||
|
|
@ -451,17 +467,6 @@ void loop() {
|
||||||
|
|
||||||
// 1. Eingaben & Sensoren lesen
|
// 1. Eingaben & Sensoren lesen
|
||||||
getInputs(clickPlus, clickMinus, clickStop, holdPlus, holdMinus, holdStop);
|
getInputs(clickPlus, clickMinus, clickStop, holdPlus, holdMinus, holdStop);
|
||||||
curTemp = getFilteredTemp(senTemp);
|
|
||||||
|
|
||||||
// 2. Discord Überhitzungs-Alarm
|
|
||||||
static bool send = false;
|
|
||||||
if (curTemp >= settings.maxTemp && !send) {
|
|
||||||
String message = "⚠️ **Kugelmuehle ueberhitzt!** Aktuelle Temp: " + String(curTemp) + " °C";
|
|
||||||
sendDiscordNotification(message);
|
|
||||||
send = true;
|
|
||||||
} else if (curTemp < settings.coldTemp) {
|
|
||||||
send = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Zeitschaltuhr & NTP prüfen
|
// 3. Zeitschaltuhr & NTP prüfen
|
||||||
int curH, curM, curS;
|
int curH, curM, curS;
|
||||||
|
|
@ -474,40 +479,20 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Schutz-Verriegelung (Überhitzung)
|
// 4. Schutz-Verriegelung (Überhitzung)
|
||||||
//static bool tempOverheat = false;
|
static bool tempOverheat;
|
||||||
//if (curTemp >= settings.maxTemp) {
|
tempOverheat = checkOverHeat(senTemp);
|
||||||
// tempOverheat = true;
|
///######################################### TODO
|
||||||
//Serial.print("OverHeat ON");
|
// Discord Überhitzungs-Alarm
|
||||||
//Serial.println();
|
static bool send = false;
|
||||||
//} else if (curTemp <= settings.coldTemp) {
|
if (tempOverheat && !send) {
|
||||||
// if(tempOverheat){
|
String message = "⚠️ **Kugelmuehle ueberhitzt!** Aktuelle Temp: " + String(curTemp) + " °C";
|
||||||
// Serial.print("OverHeat OFF");
|
sendDiscordNotification(message);
|
||||||
// Serial.println();
|
send = true;
|
||||||
//}
|
} else if (tempOverheat) {
|
||||||
//tempOverheat = false;
|
send = false;
|
||||||
//}
|
|
||||||
|
|
||||||
// TEST BLOCK Filter logik gegeg STörunegn ############################
|
|
||||||
static bool tempOverheat = false;
|
|
||||||
static int32_t overheatCounter = 0;
|
|
||||||
|
|
||||||
if (curTemp >= settings.maxTemp && curTemp <= settings.maxTemp + 5) {
|
|
||||||
overheatCounter++;
|
|
||||||
} else{
|
|
||||||
overheatCounter = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(overheatCounter > 10000){
|
// ################# Menü / Hotkey auswerten ###################
|
||||||
tempOverheat = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tempOverheat && curTemp <= settings.coldTemp){
|
|
||||||
tempOverheat = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #########################################
|
|
||||||
|
|
||||||
// 5. Menü aufrufen
|
|
||||||
if (holdStop && clickPlus) {
|
if (holdStop && clickPlus) {
|
||||||
bSettings = true;
|
bSettings = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue