Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix brew timer during coldstart #376

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/js/temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function makeHeaterChart(data) {
scales: {
"%": {
auto: false,
range: [0, 100],
range: [0, 105],
}
},
series: [
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ lib_deps =
milesburton/DallasTemperature @ 3.11.0
paulstoffregen/OneWire @ 2.3.7
olkal/HX711_ADC @ 1.2.12
olikraus/U8g2 @ 2.34.5
olikraus/U8g2 @ 2.34.18
git+https://github.com/rancilio-pid/Arduino-PID-Library#d6d3c69
knolleary/PubSubClient @ 2.8.0
me-no-dev/AsyncTCP @ 1.1.1
bblanchon/ArduinoJson @ 6.19.4
bblanchon/ArduinoJson @ 6.21.3
tobiasschuerg/ESP8266 Influxdb @ 3.13.1
git+https://github.com/me-no-dev/ESPAsyncWebServer#f71e3d4
git+https://github.com/tzapu/WiFiManager#71937d1
Expand Down
2 changes: 1 addition & 1 deletion src/Displaytemplateminimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @brief Send data to display
*/
void printScreen() {
if ((machineState == kBelowSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
if ((machineState == kAtSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
((machineState == kBrew || machineState == kShotTimerAfterBrew) && SHOTTIMER == 0) || // shottimer == 0, auch Bezug anzeigen
machineState == kCoolDown || ((machineState == kColdStart) && HEATINGLOGO == 0) || ((machineState == kPidOffline) && OFFLINEGLOGO == 0))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Displaytemplatescale.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @brief Send data to display
*/
void printScreen() {
if ((machineState == kBelowSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
if ((machineState == kAtSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
((machineState == kBrew || machineState == kShotTimerAfterBrew) && SHOTTIMER == 0) || // shottimer == 0, auch Bezug anzeigen
machineState == kCoolDown || ((machineState == kInit || machineState == kColdStart) &&
HEATINGLOGO == 0) || ((machineState == kPidOffline) && OFFLINEGLOGO == 0))
Expand Down
2 changes: 1 addition & 1 deletion src/Displaytemplatestandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
void printScreen()
{
if ((machineState == kBelowSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
if ((machineState == kAtSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
((machineState == kBrew || machineState == kShotTimerAfterBrew) && SHOTTIMER == 0) || // shottimer == 0, also show brew
machineState == kCoolDown || ((machineState == kInit || machineState == kColdStart ) && HEATINGLOGO == 0) ||
((machineState == kPidOffline) && OFFLINEGLOGO == 0))
Expand Down
2 changes: 1 addition & 1 deletion src/Displaytemplatetemponly.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ float blinkingtempoffset = 0.3; // offset for blinking
* @brief Send data to display
*/
void printScreen() {
if ((machineState == kBelowSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
if ((machineState == kAtSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
((machineState == kBrew || machineState == kShotTimerAfterBrew) && SHOTTIMER == 0) || // shottimer == 0, auch Bezug anzeigen
machineState == kCoolDown || ((machineState == kInit || machineState == kColdStart) && HEATINGLOGO == 0) ||
((machineState == kPidOffline) && OFFLINEGLOGO == 0)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Displaytemplateupright.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @brief Send data to display
*/
void printScreen() {
if ((machineState == kBelowSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
if ((machineState == kAtSetpoint || machineState == kPidNormal || machineState == kBrewDetectionTrailing) ||
((machineState == kBrew || machineState == kShotTimerAfterBrew) && SHOTTIMER == 0) ||// shottimer == 0, auch Bezug anzeigen
machineState == kCoolDown || ((machineState == kInit || machineState == kColdStart ) && HEATINGLOGO == 0) ||
((machineState == kPidOffline) && OFFLINEGLOGO == 0))
Expand Down
14 changes: 0 additions & 14 deletions src/EmbeddedWebserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ String getHeader(String varName) {
}

String staticProcessor(const String& var) {
skipHeaterISR = true;

//try replacing var for variables in editableVars
if (var.startsWith("VAR_SHOW_")) {
return getValue(var.substring(9)); // cut off "VAR_SHOW_"
Expand All @@ -230,8 +228,6 @@ String staticProcessor(const String& var) {
debugPrintf("Fragment %s not found\n", varLower.c_str());
}

skipHeaterISR = false;

//didn't find a value for the var, replace var with empty string
return String();
}
Expand Down Expand Up @@ -268,10 +264,6 @@ void serverSetup() {
});

server.on("/parameters", HTTP_GET | HTTP_POST, [](AsyncWebServerRequest *request) {
// stop writing to heater in ISR method (digitalWrite) as it causes
// crashes when called at the same time as flash is read or written
skipHeaterISR = true;

// Determine the size of the document to allocate based on the number
// of parameters
// GET = either
Expand Down Expand Up @@ -361,7 +353,6 @@ void serverSetup() {
request->send(404, "application/json",
F("{ \"code\": 404, \"message\": "
"\"Parameter not found\"}"));
skipHeaterISR = false;
return;
}

Expand All @@ -380,23 +371,18 @@ void serverSetup() {
}
const String& varValue = p->value();

skipHeaterISR = true;

try {
editable_t e = editableVars.at(varValue);
doc["name"] = varValue;
doc["helpText"] = e.helpText;
} catch (const std::out_of_range &exc) {
request->send(404, "application/json", "parameter not found");
skipHeaterISR = false;
return;
}

String helpJson;
serializeJson(doc, helpJson);
request->send(200, "application/json", helpJson);

skipHeaterISR = false;
});

server.on("/temperatures", HTTP_GET, [](AsyncWebServerRequest *request) {
Expand Down
7 changes: 3 additions & 4 deletions src/ISR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
unsigned int isrCounter = 0; // counter for ISR
unsigned long windowStartTime;
unsigned int windowSize = 1000;
bool skipHeaterISR = false;


void IRAM_ATTR onTimer(){
Expand All @@ -37,9 +36,9 @@ void IRAM_ATTR onTimer(){
* @brief Initialize hardware timers
*/
void initTimer1(void) {
timer = timerBegin(0, 80, true); //m
timerAttachInterrupt(timer, &onTimer, true);//m
timerAlarmWrite(timer, 10000, true);//m
timer = timerBegin(0, 80, true); //m
timerAttachInterrupt(timer, &onTimer, true);//m
timerAlarmWrite(timer, 10000, true);//m
}


Expand Down
1 change: 0 additions & 1 deletion src/ISR.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ extern unsigned long windowStartTime;
extern double pidOutput;
extern unsigned int isrCounter;
extern unsigned int windowSize;
extern bool skipHeaterISR;

extern hw_timer_t *timer;

Expand Down
8 changes: 1 addition & 7 deletions src/Storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,11 @@ int storageSet(sto_item_id_t itemId, String& itemValue, bool commit) {
* <0 - failed
*/
int storageCommit(void) {
debugPrintf("%s(): save all data to NV memory\n", __func__);

//While Flash memory erase/write operations no other code must be executed from
//Flash
skipHeaterISR = true;
debugPrintf("%s(): save all data to EEPROM memory\n", __func__);

// really write data to storage...
int returnCode = EEPROM.commit() ? 0 : -1;

skipHeaterISR = false;

return returnCode;
}

Expand Down
2 changes: 0 additions & 2 deletions src/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ int writeSysParamsToStorage(void);
#define BREW_SW_TIME_MAX 180
#define BD_THRESHOLD_MIN 0
#define BD_THRESHOLD_MAX 999
#define WIFI_CREDENTIALS_SAVED_MIN 0
#define WIFI_CREDENTIALS_SAVED_MAX 1
#define PRE_INFUSION_TIME_MIN 0
#define PRE_INFUSION_TIME_MAX 60
#define PRE_INFUSION_PAUSE_MIN 0
Expand Down
2 changes: 1 addition & 1 deletion src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void Displaymachinestate() {
}
}

// PID Off Logo
// PID Off
if (machineState == kEmergencyStop) {
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_profont11_tf);
Expand Down
Loading