Skip to content

Commit

Permalink
rework scale shottimer
Browse files Browse the repository at this point in the history
cleanup in main.cpp
adding translations
rename some scale vars to be more precice
rename Display settings on website
do not  show weight in full screen shot timer during manual flush
  • Loading branch information
LoQue90 committed Oct 18, 2024
1 parent 79b984f commit db7e1d8
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 130 deletions.
10 changes: 5 additions & 5 deletions src/brewHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
// TODO:
// Flush Timer configurable and seperated from shottimer?
// check all Scale stuff
// show heating logo if steam temp isn´t reached?
// show sections on website only if needed
// add pressure to shot timer?

#pragma once

Expand Down Expand Up @@ -76,9 +76,9 @@ boolean scaleCalibrationOn = 0;
boolean scaleTareOn = 0;
int shottimerCounter = 10;
float calibrationValue = SCALE_CALIBRATION_FACTOR; // use calibration example to get value
float weight = 0; // value from HX711
float weightPreBrew = 0; // value of scale before wrew started
float weightBrew = 0; // weight value of brew
float currWeight = 0; // value from HX711
float weightPreBrew = 0; // value of scale before brew started
float weightBrewed = 0; // weight value of brew
float scaleDelayValue = 2.5; // value in gramm that takes still flows onto the scale after brew is stopped
bool scaleFailure = false;
const unsigned long intervalWeight = 200; // weight scale
Expand Down Expand Up @@ -248,7 +248,7 @@ bool brew() {
}
#if (FEATURE_SCALE == 1)
// stop brew if target-weight is reached --> No stop if stop by weight is deactivated via Parameter (0)
else if (((FEATURE_SCALE == 1) && (weightBrew > weightSetpoint)) && (weightSetpoint > 0)) {
else if (((FEATURE_SCALE == 1) && (weightBrewed > weightSetpoint)) && (weightSetpoint > 0)) {
LOG(INFO, "Brew reached weight target");
currBrewState = kBrewFinished;
}
Expand Down
26 changes: 13 additions & 13 deletions src/display/displayCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,24 @@ bool displayShottimer() {

if (machineState != kManualFlush) {
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);
#else
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);
}

#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(weightBrew, 1);
u8g2.print("g");
u8g2.setFont(u8g2_font_profont11_tf);
#else
displayBrewtime(48, 25, timeBrewed);
#endif

displayWaterIcon(119, 1);
u8g2.sendBuffer();
return true;
Expand Down
104 changes: 71 additions & 33 deletions src/display/displayTemplateScale.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,53 +51,91 @@ void printScreen() {
u8g2.print("/");
u8g2.print(setpoint, 1);

/**
* @brief Shot timer for scale
*
* If scale has an error show fault on the display otherwise show current reading of the scale
* if brew is running show current brew time and current brew weight
* 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
*/

// Show current weight if scale has no error
u8g2.setCursor(32, 26);
u8g2.print("W: ");

u8g2.print(langstring_weight);
u8g2.setCursor(82, 26);
if (scaleFailure) {
u8g2.print("fault");
}
else {
if (machineState == kBrew) {
u8g2.print(weightBrew, 0);
}
else {
u8g2.print(weight, 0);
}

if (weightSetpoint > 0) {
u8g2.print("/");
u8g2.print(weightSetpoint, 0);
}

u8g2.print(" (");
u8g2.print(weightBrew, 1);
u8g2.print(")");
u8g2.print(currWeight, 0);
u8g2.print(" g");
}

// Brew
u8g2.setCursor(32, 36);
u8g2.print("t: ");
u8g2.print(timeBrewed / 1000, 0);

if (FEATURE_BREWCONTROL == 0) {
u8g2.print("/");
u8g2.print(brewtimesoftware, 0);
if (featureBrewControl) {
// Shown brew time and weight while machine is brewing and after the brewing during shotTimerDisplayDelay
if (machineState == kBrew || (millis() - lastBrewTimeMillis) < (shotTimerDisplayDelay * 1000)) {

// weight
u8g2.setCursor(32, 26);
u8g2.print(langstring_weight);
u8g2.setCursor(82, 26);
u8g2.print(weightBrewed, 0);

if (weightSetpoint > 0) {
u8g2.print("/");
u8g2.print(weightSetpoint, 0);
u8g2.print(" g");
}
// time
u8g2.setCursor(32, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(82, 36);
u8g2.print(timeBrewed / 1000, 0);

if (brewTime > 0) {
u8g2.print("/");
u8g2.print(totalBrewTime / 1000, 0);
u8g2.print(" s");
}
}
// Shown flush time while machine is flushing
if (machineState == kManualFlush) {
u8g2.setDrawColor(0);
u8g2.drawBox(32, 26, 100, 40);
u8g2.setDrawColor(1);
u8g2.setCursor(32, 26);
u8g2.print(langstring_manual_flush);
u8g2.setCursor(82, 26);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print(" s");
}
}
else {
if (brewTime > 0) {
u8g2.print("/");
u8g2.print(totalBrewTime / 1000, 0);
// 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)) {
// weight
u8g2.setCursor(32, 26);
u8g2.print(langstring_weight);
u8g2.setCursor(82, 26);
u8g2.print(weightBrewed, 0);
u8g2.print(" g");
// time
u8g2.setCursor(32, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(82, 36);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print(" s");
}

u8g2.print(" (");
u8g2.print(lastBrewTime / 1000, 1);
u8g2.print(")");
}

#if (FEATURE_PRESSURESENSOR == 1)
u8g2.setCursor(32, 46);
u8g2.print("P: ");
u8g2.print(langstring_pressure);
u8g2.print(inputPressure, 1);
#endif

Expand Down
112 changes: 54 additions & 58 deletions src/display/displayTemplateStandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,78 +59,74 @@ void printScreen() {
drawTemperaturebar(8, 50, 30);
}

// Brew time
// Brew and flush 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)) {
u8g2.setFontMode(1);
u8g2.setCursor(34, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(84, 36);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print("/");
u8g2.print(totalBrewTime / 1000, 0);
u8g2.print(" s");
}

// Flush time

// Shown flush time while machine is flushing
if (machineState == kManualFlush) {
u8g2.setDrawColor(0);
u8g2.drawBox(34, 36, 100, 10);
u8g2.setDrawColor(1);
u8g2.setCursor(34, 36);
u8g2.print(langstring_manual_flush);
u8g2.setCursor(84, 36);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print(" s");
}
u8g2.setCursor(34, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(84, 36);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print("/");
u8g2.print(totalBrewTime / 1000, 0);
u8g2.print(" s");
}
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)) {
u8g2.setCursor(34, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(84, 36);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print(" s");
}
// Shown flush time while machine is flushing
if (machineState == kManualFlush) {
u8g2.setDrawColor(0);
u8g2.drawBox(34, 36, 100, 10);
u8g2.setDrawColor(1);
u8g2.setCursor(34, 36);
u8g2.print(langstring_manual_flush);
u8g2.setCursor(84, 36);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print(" s");
}
}
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)) {
u8g2.setCursor(34, 36);
u8g2.print(langstring_brew);
u8g2.setCursor(84, 36);
u8g2.print(timeBrewed / 1000, 0);
u8g2.print(" s");
}
}
#endif

// PID values over heat bar
u8g2.setCursor(38, 47);
// PID values over heat bar
u8g2.setCursor(38, 47);

u8g2.print(bPID.GetKp(), 0);
u8g2.print("|");
u8g2.print(bPID.GetKp(), 0);
u8g2.print("|");

if (bPID.GetKi() != 0) {
u8g2.print(bPID.GetKp() / bPID.GetKi(), 0);
}
else {
u8g2.print("0");
}
if (bPID.GetKi() != 0) {
u8g2.print(bPID.GetKp() / bPID.GetKi(), 0);
}
else {
u8g2.print("0");
}

u8g2.print("|");
u8g2.print(bPID.GetKd() / bPID.GetKp(), 0);
u8g2.setCursor(96, 47);
u8g2.print("|");
u8g2.print(bPID.GetKd() / bPID.GetKp(), 0);
u8g2.setCursor(96, 47);

if (pidOutput < 99) {
u8g2.print(pidOutput / 10, 1);
}
else {
u8g2.print(pidOutput / 10, 0);
}
if (pidOutput < 99) {
u8g2.print(pidOutput / 10, 1);
}
else {
u8g2.print(pidOutput / 10, 0);
}

u8g2.print("%");
u8g2.print("%");

// Show heater output in %
displayProgressbar(pidOutput / 10, 30, 60, 98);
// Show heater output in %
displayProgressbar(pidOutput / 10, 30, 60, 98);

u8g2.sendBuffer();
u8g2.sendBuffer();
}
6 changes: 6 additions & 0 deletions src/languages.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
static const char* langstring_set_temp = "Soll: ";
static const char* langstring_current_temp = "Ist: ";
static const char* langstring_brew = "Bezug: ";
static const char* langstring_weight = "Gewicht: ";
static const char* langstring_manual_flush = "Spuelen: ";
static const char* langstring_pressure = "Druck: ";
static const char* langstring_uptime = "Uptime: ";
#endif
#if (DISPLAYTEMPLATE >= 20) // vertical templates
Expand All @@ -39,7 +41,9 @@ static const char* langstring_backflush_finish = "um zu beenden...";
static const char* langstring_set_temp = "Set: ";
static const char* langstring_current_temp = "Temp: ";
static const char* langstring_brew = "Brew: ";
static const char* langstring_weight = "Weight: ";
static const char* langstring_manual_flush = "Flush: ";
static const char* langstring_pressure = "Pressure: ";
static const char* langstring_uptime = "Uptime: ";
#endif
#if (DISPLAYTEMPLATE >= 20) // vertical templates
Expand All @@ -66,7 +70,9 @@ static const char* langstring_backflush_finish = "to finish...";
static const char* langstring_set_temp = "Obj: ";
static const char* langstring_current_temp = "T: ";
static const char* langstring_brew = "Brew: ";
static const char* langstring_weight = "Peso: ";
static const char* langstring_manual_flush = "Fregar: ";
static const char* langstring_pressure = "Presión: ";
static const char* langstring_uptime = "Uptime: ";
#endif
#if (DISPLAYTEMPLATE >= 20) // vertical templates
Expand Down
Loading

0 comments on commit db7e1d8

Please sign in to comment.