Skip to content

Commit

Permalink
cleanup storage, variables and more
Browse files Browse the repository at this point in the history
no need to stay compatible to old storage structure, remove reserved or freetouse
rename a lot of vars
deleted missed coldstart stuff
set PID Mode based on pidPonmOn for regular and brew pid

d
  • Loading branch information
LoQue90 committed Sep 25, 2024
1 parent 1fabd22 commit 2d9b152
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 552 deletions.
2 changes: 1 addition & 1 deletion src/brewHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ double timeBrewed = 0; // total brewed time
double lastBrewTimeMillis = 0; // for shottimer delay after disarmed button
double lastBrewTime = 0;
unsigned long startingTime = 0; // start time of brew
boolean brewPIDDisabled = false; // is PID disabled for delay after brew has started?
boolean pidBrewDisabled = false; // is PID disabled for delay after brew has started?

// Shot timer with or without scale
#if FEATURE_SCALE == 1
Expand Down
58 changes: 25 additions & 33 deletions src/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,31 @@ 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_SW_TIME 25 // keep brew PID params for this many seconds after detection (only for software BD)
#define BREW_PID_DELAY 10 // delay until enabling PID controller during brew (no heating during this time)
#define PID_BREW_DELAY 10 // delay until enabling PID controller during brew (no heating during this time)
#define BD_SENSITIVITY 120 // brew detection sensitivity, be careful: if too low, then there is the risk of wrong brew detection and rising temperature
#define BREW_SW_TIME 25 // keep brew PID params for this many seconds after detection (only for software BD)
#define BREWTEMPOFFSET 0 // brew temperature setpoint
#define SETPOINT 95 // brew temperature setpoint
#define STEAMSETPOINT 120 // steam temperature setpoint
#define BREW_TIME 25 // brew time in seconds (only used if pump is being controlled)
#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 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 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 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
Expand All @@ -59,35 +53,33 @@ int writeSysParamsToStorage(void);
#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 PID_KP_STEAM_MIN 0
#define PID_KP_STEAM_MAX 500
#define PID_KP_BREW_MIN 0
#define PID_KP_BREW_MAX 999
#define PID_TN_BREW_MIN 0
#define PID_TN_BREW_MAX 999
#define PID_TV_BREW_MIN 0
#define PID_TV_BREW_MAX 999
#define PID_BREW_DELAY_MIN 0
#define PID_BREW_DELAY_MAX 60
#define BD_THRESHOLD_MIN 0
#define BD_THRESHOLD_MAX 999
#define BREW_SW_TIME_MIN 1
#define BREW_SW_TIME_MAX 180
#define BREW_TEMP_OFFSET_MIN 0
#define BREW_TEMP_OFFSET_MAX 20
#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 BREW_SW_TIME_MIN 1
#define BREW_SW_TIME_MAX 180
#define BD_THRESHOLD_MIN 0
#define BD_THRESHOLD_MAX 999
#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
6 changes: 3 additions & 3 deletions 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 33
#define EDITABLE_VARS_LEN 31
extern std::map<String, editable_t> editableVars;

// EEPROM
Expand Down Expand Up @@ -245,7 +245,7 @@ void serverSetup() {
// set up dynamic routes (endpoints)

server.on("/toggleSteam", HTTP_POST, [](AsyncWebServerRequest* request) {
int steam = flipUintValue(steamON);
int steam = flipUintValue(steamOn);

setSteamMode(steam);
LOGF(DEBUG, "Toggle steam mode: %i", steam);
Expand All @@ -255,7 +255,7 @@ void serverSetup() {

server.on("/togglePid", HTTP_POST, [](AsyncWebServerRequest* request) {
LOGF(DEBUG, "/togglePid requested, method: %d", request->method());
int status = flipUintValue(pidON);
int status = flipUintValue(pidOn);

setPidStatus(status);
LOGF(DEBUG, "Toggle PID state: %d\n", status);
Expand Down
Loading

0 comments on commit 2d9b152

Please sign in to comment.