Skip to content

Commit

Permalink
fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
LoQue90 committed Oct 11, 2024
1 parent d6f2190 commit 893da19
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 129 deletions.
84 changes: 0 additions & 84 deletions src/brewHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,90 +157,6 @@ void checkbrewswitch() {
}
}

/**
* @brief Backflush
*/
void backflush() {
if (backflushState != kBackflushWaitBrewswitchOn && backflushOn == 0) {
backflushState = kBackflushWaitBrewswitchOff; // Force reset in case backflushOn is reset during backflush!
LOG(INFO, "Backflush: Disabled via Webinterface");
}
else if (offlineMode == 1 || currBrewState > kBrewIdle || backflushCycles <= 0 || backflushOn == 0) {
return;
}

if (bPID.GetMode() == 1) { // Deactivate PID
bPID.SetMode(0);
pidOutput = 0;
}

heaterRelay.off(); // Stop heating

checkbrewswitch();

if (currStateBrewSwitch == LOW && backflushState != kBackflushWaitBrewswitchOn) { // Abort function for state machine from every state
backflushState = kBackflushWaitBrewswitchOff;
}

// State machine for backflush
switch (backflushState) {
case kBackflushWaitBrewswitchOn:
if (currStateBrewSwitch == HIGH && backflushOn) {
startingTime = millis();
backflushState = kBackflushFillingStart;
}

break;

case kBackflushFillingStart:
LOG(INFO, "Backflush: Portafilter filling...");
valveRelay.on();
pumpRelay.on();
backflushState = kBackflushFilling;

break;

case kBackflushFilling:
if (millis() - startingTime > (backflushFillTime * 1000)) {
startingTime = millis();
backflushState = kBackflushFlushingStart;
}

break;

case kBackflushFlushingStart:
LOG(INFO, "Backflush: Flushing to drip tray...");
valveRelay.off();
pumpRelay.off();
currBackflushCycles++;
backflushState = kBackflushFlushing;

break;

case kBackflushFlushing:
if (millis() - startingTime > (backflushFlushTime * 1000) && currBackflushCycles < backflushCycles) {
startingTime = millis();
backflushState = kBackflushFillingStart;
}
else if (currBackflushCycles >= backflushCycles) {
backflushState = kBackflushWaitBrewswitchOff;
}

break;

case kBackflushWaitBrewswitchOff:
if (currStateBrewSwitch == LOW) {
LOG(INFO, "Backflush: Finished!");
valveRelay.off();
pumpRelay.off();
currBackflushCycles = 0;
backflushState = kBackflushWaitBrewswitchOn;
}

break;
}
}

#if (FEATURE_BREWCONTROL == 0)
/**
* @brief Brew timer
Expand Down
79 changes: 38 additions & 41 deletions src/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,50 +48,47 @@ int writeSysParamsToStorage(void);
#define BACKFLUSH_FILL_TIME 5 // time in seconds the pump is running during backflush
#define BACKFLUSH_FLUSH_TIME 10 // time in seconds the 3-way valve is open during backflush

#define PID_KP_START_MIN 0
#define PID_KP_START_MAX 999
#define PID_TN_START_MIN 0
#define PID_TN_START_MAX 999
#define PID_KP_REGULAR_MIN 0
#define PID_KP_REGULAR_MAX 999
#define PID_TN_REGULAR_MIN 0
#define PID_TN_REGULAR_MAX 999
#define PID_TV_REGULAR_MIN 0
#define PID_TV_REGULAR_MAX 999
#define PID_I_MAX_REGULAR_MIN 0
#define PID_I_MAX_REGULAR_MAX 999
#define PID_KP_BD_MIN 0
#define PID_KP_BD_MAX 999
#define PID_TN_BD_MIN 0
#define PID_TN_BD_MAX 999
#define PID_TV_BD_MIN 0
#define PID_TV_BD_MAX 999
#define BREW_SETPOINT_MIN 20
#define BREW_SETPOINT_MAX 110
#define STEAM_SETPOINT_MIN 100
#define STEAM_SETPOINT_MAX 140
#define BREW_TEMP_OFFSET_MIN 0
#define BREW_TEMP_OFFSET_MAX 20
#define BREW_TEMP_TIME_MIN 1
#define BREW_TEMP_TIME_MAX 180
#define BREW_TIME_MIN 0
#define BREW_TIME_MAX 180
#define BREW_PID_DELAY_MIN 0
#define BREW_PID_DELAY_MAX 60
#define PRE_INFUSION_TIME_MIN 0
#define PRE_INFUSION_TIME_MAX 60
#define PRE_INFUSION_PAUSE_MIN 0
#define PRE_INFUSION_PAUSE_MAX 60
#define WEIGHTSETPOINT_MIN 0
#define WEIGHTSETPOINT_MAX 500
#define PID_KP_STEAM_MIN 0
#define PID_KP_STEAM_MAX 500
#define STANDBY_MODE_TIME_MIN 30
#define STANDBY_MODE_TIME_MAX 120
#define PID_KP_START_MIN 0
#define PID_KP_START_MAX 999
#define PID_TN_START_MIN 0
#define PID_TN_START_MAX 999
#define PID_KP_REGULAR_MIN 0
#define PID_KP_REGULAR_MAX 999
#define PID_TN_REGULAR_MIN 0
#define PID_TN_REGULAR_MAX 999
#define PID_TV_REGULAR_MIN 0
#define PID_TV_REGULAR_MAX 999
#define PID_I_MAX_REGULAR_MIN 0
#define PID_I_MAX_REGULAR_MAX 999
#define PID_KP_BD_MIN 0
#define PID_KP_BD_MAX 999
#define PID_TN_BD_MIN 0
#define PID_TN_BD_MAX 999
#define PID_TV_BD_MIN 0
#define PID_TV_BD_MAX 999
#define BREW_SETPOINT_MIN 20
#define BREW_SETPOINT_MAX 110
#define STEAM_SETPOINT_MIN 100
#define STEAM_SETPOINT_MAX 140
#define BREW_TEMP_OFFSET_MIN 0
#define BREW_TEMP_OFFSET_MAX 20
#define BREW_TIME_MIN 0
#define BREW_TIME_MAX 180
#define BREW_PID_DELAY_MIN 0
#define BREW_PID_DELAY_MAX 60
#define PRE_INFUSION_TIME_MIN 0
#define PRE_INFUSION_TIME_MAX 60
#define PRE_INFUSION_PAUSE_MIN 0
#define PRE_INFUSION_PAUSE_MAX 60
#define WEIGHTSETPOINT_MIN 0
#define WEIGHTSETPOINT_MAX 500
#define PID_KP_STEAM_MIN 0
#define PID_KP_STEAM_MAX 500
#define STANDBY_MODE_TIME_MIN 30
#define STANDBY_MODE_TIME_MAX 120
#define BACKFLUSH_CYCLES_MIN 2
#define BACKFLUSH_CYCLES_MAX 20
#define BACKFLUSH_FILL_TIME_MIN 5
#define BACKFLUSH_FILL_TIME_MAX 20
#define BACKFLUSH_FLUSH_TIME_MIN 5
#define BACKFLUSH_FLUSH_TIME_MAX 20

8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ void setup() {
.type = kUInt8,
.section = sBDSection,
.position = 22,
.show = [] { return true && FEATURE_BREWDETECTION == 1; },
.show = [] { return true && FEATURE_BREWSWITCH == 1; },
.minValue = 0,
.maxValue = 1,
.ptr = (void*)&useBDPID};
Expand All @@ -1185,7 +1185,7 @@ void setup() {
.type = kDouble,
.section = sBDSection,
.position = 23,
.show = [] { return true && FEATURE_BREWDETECTION == 1 && useBDPID; },
.show = [] { return true && FEATURE_BREWSWITCH == 1 && useBDPID; },
.minValue = PID_KP_BD_MIN,
.maxValue = PID_KP_BD_MAX,
.ptr = (void*)&aggbKp};
Expand All @@ -1197,7 +1197,7 @@ void setup() {
.type = kDouble,
.section = sBDSection,
.position = 24,
.show = [] { return true && FEATURE_BREWDETECTION == 1 && useBDPID; },
.show = [] { return true && FEATURE_BREWSWITCH == 1 && useBDPID; },
.minValue = PID_TN_BD_MIN,
.maxValue = PID_TN_BD_MAX,
.ptr = (void*)&aggbTn};
Expand All @@ -1209,7 +1209,7 @@ void setup() {
.type = kDouble,
.section = sBDSection,
.position = 25,
.show = [] { return true && FEATURE_BREWDETECTION == 1 && useBDPID; },
.show = [] { return true && FEATURE_BREWSWITCH == 1 && useBDPID; },
.minValue = PID_TV_BD_MIN,
.maxValue = PID_TV_BD_MAX,
.ptr = (void*)&aggbTv};
Expand Down

0 comments on commit 893da19

Please sign in to comment.