Skip to content

Commit

Permalink
rename Shot timer, manual flush timer separated
Browse files Browse the repository at this point in the history
how brew timer is show isn´t nice, maybe a own state mashine?
&& lastBrewTimeMillis > 0 makes sure to not show brew timer during boot -> workaround for now
  • Loading branch information
LoQue90 committed Dec 13, 2024
1 parent 1304563 commit ab65ec9
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 171 deletions.
3 changes: 1 addition & 2 deletions src/brewHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
*
*/
// TODO:
// Flush Timer configurable and seperated from shottimer?
// show sections on website only if needed
// add pressure to shot timer?
// backflush also as bool, enable from website over diffrent var
// SteamOn also as bool, rething enable from website
// SteamOn also as bool, rethink enable from website
// handling !waterFull in backflush

#pragma once
Expand Down
69 changes: 35 additions & 34 deletions src/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,39 @@ int writeSysParamsToStorage(void);
#define STR(x) STR_HELPER(x)

// default parameters
#define SETPOINT 95 // brew temperature setpoint
#define TEMPOFFSET 0 // brew temperature setpoint
#define STEAMSETPOINT 120 // steam temperature setpoint
#define SCALE_CALIBRATION_FACTOR 1.00 // Raw data is divided by this value to convert to readable data
#define SCALE2_CALIBRATION_FACTOR 1.00 // Raw data is divided by this value to convert to readable data
#define SCALE_KNOWN_WEIGHT 267.00 // Calibration weight for scale (weight of the tray)
#define AGGKP 62 // PID Kp (regular phase)
#define AGGTN 52 // PID Tn (regular phase)
#define AGGTV 11.5 // PID Tv (regular phase)
#define AGGIMAX 55 // PID Integrator Max (regular phase)
#define STARTKP 45 // PID Kp (coldstart phase)
#define STARTTN 130 // PID Tn (coldstart phase)
#define STEAMKP 150 // PID kp (steam phase)
#define AGGBKP 50 // PID Kp (brew detection phase)
#define AGGBTN 0 // PID Tn (brew detection phase)
#define AGGBTV 20 // PID Tv (brew detection phase)
#define BREW_TIME 25 // brew time in seconds (only used if pump is being controlled)
#define BREW_PID_DELAY 10 // delay until enabling PID controller during brew (no heating during this time)
#define PRE_INFUSION_TIME 2 // pre-infusion time in seconds
#define PRE_INFUSION_PAUSE_TIME 5 // pre-infusion pause time in seconds
#define SCALE_WEIGHTSETPOINT 30 // Target weight in grams
#define WIFI_CREDENTIALS_SAVED 0 // Flag if wifi setup is done. 0: not set up, 1: credentials set up via wifi manager
#define STANDBY_MODE_ON 0 // Standby mode off by default
#define STANDBY_MODE_TIME 30 // Time in minutes until the heater is turned off
#define BACKFLUSH_CYCLES 5 // number of cycles the backflush should run
#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 FEATURE_BREW_CONTROL 0 // enables function to control pump and solenoid valve
#define FEATURE_SHOT_TIMER 0 // enables full screen shot timer
#define SHOT_TIMER_DISPLAY_DELAY 3 // time in seconds that shot timer will be shown after brew finished
#define FEATURE_HEATING_LOGO 1 // enables full screen logo if mashine is heating
#define FEATURE_PID_OFF_LOGO 1 // enables full screen logo if pid is switched off
#define SETPOINT 95 // brew temperature setpoint
#define TEMPOFFSET 0 // brew temperature setpoint
#define STEAMSETPOINT 120 // steam temperature setpoint
#define SCALE_CALIBRATION_FACTOR 1.00 // Raw data is divided by this value to convert to readable data
#define SCALE2_CALIBRATION_FACTOR 1.00 // Raw data is divided by this value to convert to readable data
#define SCALE_KNOWN_WEIGHT 267.00 // Calibration weight for scale (weight of the tray)
#define AGGKP 62 // PID Kp (regular phase)
#define AGGTN 52 // PID Tn (regular phase)
#define AGGTV 11.5 // PID Tv (regular phase)
#define AGGIMAX 55 // PID Integrator Max (regular phase)
#define STARTKP 45 // PID Kp (coldstart phase)
#define STARTTN 130 // PID Tn (coldstart phase)
#define STEAMKP 150 // PID kp (steam phase)
#define AGGBKP 50 // PID Kp (brew detection phase)
#define AGGBTN 0 // PID Tn (brew detection phase)
#define AGGBTV 20 // PID Tv (brew detection phase)
#define BREW_TIME 25 // brew time in seconds (only used if pump is being controlled)
#define BREW_PID_DELAY 10 // delay until enabling PID controller during brew (no heating during this time)
#define PRE_INFUSION_TIME 2 // pre-infusion time in seconds
#define PRE_INFUSION_PAUSE_TIME 5 // pre-infusion pause time in seconds
#define SCALE_WEIGHTSETPOINT 30 // Target weight in grams
#define WIFI_CREDENTIALS_SAVED 0 // Flag if wifi setup is done. 0: not set up, 1: credentials set up via wifi manager
#define STANDBY_MODE_ON 0 // Standby mode off by default
#define STANDBY_MODE_TIME 30 // Time in minutes until the heater is turned off
#define BACKFLUSH_CYCLES 5 // number of cycles the backflush should run
#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 FEATURE_BREW_CONTROL 0 // enables function to control pump and solenoid valve
#define FEATURE_FULLSCREEN_BREW_TIMER 0 // enables full screen brew timer
#define FEATURE_FULLSCREEN_MANUAL_FLUSH_TIMER 0 // enables full screen manual flush timer
#define POST_BREW_TIMER_DURATION 3 // time in seconds that brew timer will be shown after brew finished
#define FEATURE_HEATING_LOGO 1 // enables full screen logo if mashine is heating
#define FEATURE_PID_OFF_LOGO 1 // enables full screen logo if pid is switched off

#define PID_KP_START_MIN 0
#define PID_KP_START_MAX 999
Expand Down Expand Up @@ -97,5 +98,5 @@ int writeSysParamsToStorage(void);
#define BACKFLUSH_FILL_TIME_MAX 20
#define BACKFLUSH_FLUSH_TIME_MIN 5
#define BACKFLUSH_FLUSH_TIME_MAX 20
#define SHOT_TIMER_DISPLAY_DELAY_MIN 0
#define SHOT_TIMER_DISPLAY_DELAY_MAX 60
#define POST_BREW_TIMER_DURATION_MIN 0
#define POST_BREW_TIMER_DURATION_MAX 60
54 changes: 33 additions & 21 deletions src/display/displayCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,36 +234,48 @@ void displayLogo(String displaymessagetext, String displaymessagetext2) {
}

/**
* @brief display shot and flush timer
* @brief display fullscreen brew timer
*/
bool displayShottimer() {
if (featureShotTimer == 0) {
bool displayFullscreenBrewTimer() {
if (featureFullscreenBrewTimer == 0) {
return false;
}

if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000) || machineState == kManualFlush) {
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
u8g2.clearBuffer();

if (machineState != kManualFlush) {
u8g2.drawXBMP(-1, 11, Brew_Cup_Logo_width, Brew_Cup_Logo_height, Brew_Cup_Logo);
u8g2.drawXBMP(-1, 11, Brew_Cup_Logo_width, Brew_Cup_Logo_height, Brew_Cup_Logo);
#if (FEATURE_SCALE == 1)
u8g2.setFont(u8g2_font_profont22_tf);
u8g2.setCursor(64, 15);
u8g2.print(timeBrewed / 1000, 1);
u8g2.print("s");
u8g2.setCursor(64, 38);
u8g2.print(weightBrewed, 1);
u8g2.print("g");
u8g2.setFont(u8g2_font_profont11_tf);
u8g2.setFont(u8g2_font_profont22_tf);
u8g2.setCursor(64, 15);
u8g2.print(timeBrewed / 1000, 1);
u8g2.print("s");
u8g2.setCursor(64, 38);
u8g2.print(weightBrewed, 1);
u8g2.print("g");
u8g2.setFont(u8g2_font_profont11_tf);
#else
displayBrewtime(48, 25, timeBrewed);
displayBrewtime(48, 25, timeBrewed);
#endif
}
else {
u8g2.drawXBMP(0, 12, Manual_Flush_Logo_width, Manual_Flush_Logo_height, Manual_Flush_Logo);
displayBrewtime(48, 25, timeBrewed);
}
displayWaterIcon(119, 1);
u8g2.sendBuffer();
return true;
}

return false;
}

/**
* @brief display fullscreen manual flush timer
*/
bool displayFullscreenManualFlushTimer() {
if (featureFullscreenManualFlushTimer == 0) {
return false;
}

if (machineState == kManualFlush) {
u8g2.clearBuffer();
u8g2.drawXBMP(0, 12, Manual_Flush_Logo_width, Manual_Flush_Logo_height, Manual_Flush_Logo);
displayBrewtime(48, 25, timeBrewed);
displayWaterIcon(119, 1);
u8g2.sendBuffer();
return true;
Expand Down
8 changes: 2 additions & 6 deletions src/display/displayRotateUpright.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ void displayEmergencyStop(void) {
* @brief display shot timer
*/
bool displayShottimer() {
if (((timeBrewed > 0 && featureBrewControl == 0) || (featureBrewControl > 0 && currBrewState > kBrewIdle && currBrewState <= kBrewFinished)) && featureShotTimer == 1) {
if (((timeBrewed > 0 && featureBrewControl == 0) || (featureBrewControl > 0 && currBrewState > kBrewIdle && currBrewState <= kBrewFinished)) && featureFullscreenBrewTimer == 1) {
u8g2.clearBuffer();

// draw temp icon
u8g2.drawXBMP(0, 0, Brew_Cup_Logo_width, Brew_Cup_Logo_height, Brew_Cup_Logo);
u8g2.setFont(u8g2_font_profont22_tf);
u8g2.setCursor(5, 70);
Expand All @@ -100,10 +99,7 @@ bool displayShottimer() {
u8g2.sendBuffer();
return true;
}
else if (featureShotTimer == 1 && millis() >= lastBrewTimeMillis && // directly after creating lastbrewTimeMillis (happens when turning off the brew switch, case 43 in the code) should be started
lastBrewTimeMillis + (shotTimerDisplayDelay * 1000) >= millis() && // should run until millis() has caught up with shotTimerDisplayDelay, this can be used to control the display duration
lastBrewTimeMillis < totalBrewTime) // if the totalBrewTime is reached automatically, nothing should be done, otherwise wrong time will be displayed because switch is pressed later than totalBrewTime
{
else if (featureFullscreenBrewTimer == 1 && millis() >= lastBrewTimeMillis && lastBrewTimeMillis + (postBrewTimerDuration * 1000) >= millis() && lastBrewTimeMillis < totalBrewTime) {
u8g2.clearBuffer();
u8g2.drawXBMP(0, 0, Brew_Cup_Logo_width, Brew_Cup_Logo_height, Brew_Cup_Logo);
u8g2.setFont(u8g2_font_profont22_tf);
Expand Down
16 changes: 8 additions & 8 deletions src/display/displayTemplateMinimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
*/
void printScreen() {

// Show shot timer:
if (displayShottimer()) {
// Show fullscreen brew timer:
if (displayFullscreenBrewTimer()) {
// Display was updated, end here
return;
}

// Print the machine state
if (displayMachineState()) {
// Show fullscreen manual flush timer:
if (displayFullscreenManualFlushTimer()) {
// Display was updated, end here
return;
}
Expand Down Expand Up @@ -81,8 +81,8 @@ void printScreen() {
// Brew time
#if (FEATURE_BREWSWITCH == 1)
if (featureBrewControl) {
// Shown brew time while machine is brewing and after the brewing during shotTimerDisplayDelay
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000)) {
// Shown brew time while machine is brewing and after the brewing during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
u8g2.setCursor(34, 44);
u8g2.print(langstring_brew);
u8g2.print(timeBrewed / 1000, 0);
Expand All @@ -102,8 +102,8 @@ void printScreen() {
}
else {
// Brew Timer with optocoupler
// Shown brew time while machine is brewing and after the brewing during shotTimerDisplayDelay
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000)) {
// Shown brew time while machine is brewing and after the brewing during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
u8g2.setCursor(34, 44);
u8g2.print(langstring_brew);
u8g2.print(timeBrewed / 1000, 0);
Expand Down
20 changes: 13 additions & 7 deletions src/display/displayTemplateScale.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
*/
void printScreen() {

// Show shot timer:
if (displayShottimer()) {
// Show fullscreen brew timer:
if (displayFullscreenBrewTimer()) {
// Display was updated, end here
return;
}

// Show fullscreen manual flush timer:
if (displayFullscreenManualFlushTimer()) {
// Display was updated, end here
return;
}
Expand Down Expand Up @@ -59,7 +65,7 @@ void printScreen() {
* if brewControl is enabled and time or weight target is set show targets
* if brewControl is enabled show flush time during manualFlush
* if FEATURE_PRESSURESENSOR is enabled show current pressure during brew
* if brew is finished show brew values for shotTimerDisplayDelay
* if brew is finished show brew values for postBrewTimerDuration
*/

// Show current weight if scale has no error
Expand All @@ -75,8 +81,8 @@ void printScreen() {
}

if (featureBrewControl) {
// Shown brew time and weight while machine is brewing and after the brewing during shotTimerDisplayDelay
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000)) {
// Shown brew time and weight while machine is brewing and after the brewing during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {

// weight
u8g2.setCursor(32, 26);
Expand Down Expand Up @@ -116,8 +122,8 @@ void printScreen() {
else {
// Brew Timer with optocoupler

// Shown brew time and weight while machine is brewing and after the brewing during shotTimerDisplayDelay
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000)) {
// Shown brew time and weight while machine is brewing and after the brewing during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
// weight
u8g2.setCursor(32, 26);
u8g2.print(langstring_weight);
Expand Down
18 changes: 12 additions & 6 deletions src/display/displayTemplateStandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
*/
void printScreen() {

// Show shot timer:
if (displayShottimer()) {
// Show fullscreen brew timer:
if (displayFullscreenBrewTimer()) {
// Display was updated, end here
return;
}

// Show fullscreen manual flush timer:
if (displayFullscreenManualFlushTimer()) {
// Display was updated, end here
return;
}
Expand Down Expand Up @@ -63,8 +69,8 @@ void printScreen() {
#if (FEATURE_BREWSWITCH == 1)

if (featureBrewControl) {
// Shown brew time while machine is brewing and after the brewing during shotTimerDisplayDelay
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000)) {
// Shown brew time while machine is brewing and after the brewing during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
u8g2.setCursor(34, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(84, 36);
Expand All @@ -88,8 +94,8 @@ void printScreen() {
else {
// Brew Timer with optocoupler

// Shown brew time while machine is brewing and after the brewing during shotTimerDisplayDelay
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000)) {
// Shown brew time while machine is brewing and after the brewing during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
u8g2.setCursor(34, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(84, 36);
Expand Down
10 changes: 8 additions & 2 deletions src/display/displayTemplateTempOnly.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ float blinkingtempoffset = 0.3; // offset for blinking
*/
void printScreen() {

// Show shot timer:
if (displayShottimer()) {
// Show fullscreen brew timer:
if (displayFullscreenBrewTimer()) {
// Display was updated, end here
return;
}

// Show fullscreen manual flush timer:
if (displayFullscreenManualFlushTimer()) {
// Display was updated, end here
return;
}
Expand Down
19 changes: 13 additions & 6 deletions src/display/displayTemplateUpright.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
* @brief Send data to display
*/
void printScreen() {
// Show shot timer:
if (displayShottimer()) {

// Show fullscreen brew timer:
if (displayFullscreenBrewTimer()) {
// Display was updated, end here
return;
}

// Show fullscreen manual flush timer:
if (displayFullscreenManualFlushTimer()) {
// Display was updated, end here
return;
}
Expand Down Expand Up @@ -89,8 +96,8 @@ void printScreen() {
// Brew time
#if (FEATURE_BREWSWITCH == 1)
if (featureBrewControl) {
// Show brew time; after brew finished show lastBrewTime during SHOTTIMERDISPLAYDELAY
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < SHOTTIMERDISPLAYDELAY) {
// Show brew time; after brew finished show lastBrewTime during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
u8g2.setCursor(1, 34);
u8g2.print(langstring_brew_rot_ur);
u8g2.print(timeBrewed / 1000, 0);
Expand All @@ -112,8 +119,8 @@ void printScreen() {
}
else {
// Brew Timer with optocoupler
// Shown brew time while machine is brewing and after the brewing during SHOTTIMERDISPLAYDELAY
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < SHOTTIMERDISPLAYDELAY) {
// Shown brew time while machine is brewing and after the brewing during postBrewTimerDuration
if (machineState == kBrew || ((millis() - lastBrewTimeMillis) < (postBrewTimerDuration * 1000) && lastBrewTimeMillis > 0)) {
u8g2.setCursor(1, 34);
u8g2.print(langstring_brew_rot_ur);
u8g2.print(timeBrewed / 1000, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/embeddedWebserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void serverSetup();
void setEepromWriteFcn(int (*fcnPtr)(void));

// editable vars are specified in main.cpp
#define EDITABLE_VARS_LEN 41
#define EDITABLE_VARS_LEN 42
extern std::map<String, editable_t> editableVars;

// EEPROM
Expand Down
Loading

0 comments on commit ab65ec9

Please sign in to comment.