DVT2023/DVT_FilamentClass.h

48 lines
1.3 KiB
C++

#ifndef DVT_FILAMENTCLASS_H
#define DVT_FILAMENTCLASS_H
#include "DVT_Types.h"
#include "DVT_MainClass.h"
class Filament {
private:
DVT_State_t CurState;
bool Heat = false;
public:
Filament(bool State) {
this->CurState.State = State;
FILAMENT_SWITCH.SetState(State);
}
void SetFilamentState(bool State) {
if (State != this->CurState.State) {
this->CurState.State = State;
this->CurState.Time = millis();
FILAMENT_SWITCH.SetState(State);
debugMSG("New State : " + String(this->CurState.State) + " Time: " + String(this->CurState.Time));
} else {
debugMSG("Same as Old State : " + String(this->CurState.State) + " Time: " + String(this->CurState.Time));
}
}
bool GetFilamentState() {
return FILAMENT_SWITCH.GetState();
}
bool Heated() {
if (this->CurState.State == HIGH && this->CurState.Time + PreHeatTime <= millis() && Heat == false) {
Heat = true;
sysMSG("SYSTEM: Heated");
return true;
}
if (Heat && this->CurState.State == LOW && this->CurState.Time + CoolDownTime <= millis() && Heat == true) {
Heat = false;
sysMSG("SYSTEM: Cold");
}
return Heat;
}
};
Filament FILAMENT = Filament(false);
#endif