Skip to content

Commit

Permalink
+ more granular pressure and other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0-bit committed Jan 14, 2023
1 parent 07d4589 commit a3b7cfd
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 53 deletions.
Binary file modified lcd-hmi/nextion-lcd.HMI
Binary file not shown.
Binary file modified nextion-basic-lcd.tft
Binary file not shown.
Binary file modified nextion-discovery-lcd.tft
Binary file not shown.
10 changes: 5 additions & 5 deletions src/eeprom_data/eeprom_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ struct eepromValues_t {
uint16_t hpwr;
uint16_t mainDivider;
uint16_t brewDivider;
uint16_t pressureProfilingStart;
uint16_t pressureProfilingFinish;
float pressureProfilingStart;
float pressureProfilingFinish;
uint16_t pressureProfilingHold;
uint16_t pressureProfilingLength;
bool pressureProfilingState;
bool preinfusionState;
uint16_t preinfusionSec;
uint16_t preinfusionBar;
float preinfusionBar;
uint16_t preinfusionSoak;
uint16_t preinfusionRamp;
bool preinfusionFlowState;
float preinfusionFlowVol;
uint16_t preinfusionFlowTime;
uint16_t preinfusionFlowSoakTime;
uint16_t preinfusionFlowPressureTarget;
float preinfusionFlowPressureTarget;
bool flowProfileState;
float flowProfileStart;
float flowProfileEnd;
uint16_t flowProfilePressureTarget;
float flowProfilePressureTarget;
uint16_t flowProfileCurveSpeed;
uint16_t powerLineFrequency;
uint16_t lcdSleep;
Expand Down
10 changes: 5 additions & 5 deletions src/eeprom_data/legacy/eeprom_data_v4.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ struct eepromValues_t_v4 {
uint16_t hpwr;
uint16_t mainDivider;
uint16_t brewDivider;
uint16_t pressureProfilingStart;
uint16_t pressureProfilingFinish;
float pressureProfilingStart;
float pressureProfilingFinish;
uint16_t pressureProfilingHold;
uint16_t pressureProfilingLength;
bool pressureProfilingState;
bool preinfusionState;
uint16_t preinfusionSec;
uint16_t preinfusionBar;
float preinfusionBar;
uint16_t preinfusionSoak;
uint16_t preinfusionRamp;
bool preinfusionFlowState;
float preinfusionFlowVol;
uint16_t preinfusionFlowTime;
uint16_t preinfusionFlowSoakTime;
uint16_t preinfusionFlowPressureTarget;
float preinfusionFlowPressureTarget;
bool flowProfileState;
float flowProfileStart;
float flowProfileEnd;
uint16_t flowProfilePressureTarget;
float flowProfilePressureTarget;
uint16_t flowProfileCurveSpeed;
uint16_t powerLineFrequency;
uint16_t lcdSleep;
Expand Down
17 changes: 9 additions & 8 deletions src/functional/predictive_weight.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ class PredictiveWeight {

float pressure = fmax(state.smoothedPressure, 0.f);

float previousPuckResistance = puckResistance;
puckResistance = pressure * 1000.f / state.smoothedPumpFlow; // Resistance in mBar * s / g
resistanceDelta = puckResistance - previousPuckResistance;
// float previousPuckResistance = puckResistance;
// puckResistance = pressure * 1000.f / state.smoothedPumpFlow; // Resistance in mBar * s / g
// resistanceDelta = puckResistance - previousPuckResistance;

// Through empirical testing it's been observed that ~2 bars is the indicator of the pf headspace being full
// as well as there being enough pressure for water to wet the puck enough to start the output
float pressureTarget = phase.getType() == PHASE_TYPE_PRESSURE ? phase.getTarget() : phase.getRestriction();
bool phaseTypePressure = phase.getType() == PHASE_TYPE_PRESSURE;
float pressureTarget = phaseTypePressure ? phase.getTarget() : phase.getRestriction();
pressureTarget = (pressureTarget == 0.f || pressureTarget > 1.2f) ? 1.2f : pressureTarget;
// We need to watch when pressure goes above the PI pressure which is a better indicator of headspace being filled.
// float preinfusionPressure = cfg.preinfusionFlowState ? cfg.preinfusionFlowPressureTarget : cfg.preinfusionBar;
Expand All @@ -42,10 +43,10 @@ class PredictiveWeight {
if (state.isPressureRisingFast || state.isPumpFlowRisingFast) {
return;
}
// If flow is too big for given pressure or the delta is changing too quickly we're not there yet
if (resistanceDelta > 500.f || puckResistance < 1100.f) {
return;
}
// // If flow is too big for given pressure or the delta is changing too quickly we're not there yet
// if (phaseTypePressure && (resistanceDelta > 400.f || puckResistance < 1100.f)) {
// return;
// }

// Pressure has to reach at least half way to pressureTarget
if (pressure < pressureTarget) {
Expand Down
2 changes: 1 addition & 1 deletion src/gaggiuino.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define TRAY_FULL_THRESHOLD 700.f
#define HEALTHCHECK_EVERY 30000 // system checks happen every 30sec
#define BOILER_FILL_TIMEOUT 8000UL
#define BOILER_FILL_PRESSURE 1.8f
#define BOILER_FILL_PRESSURE 1.75f



Expand Down
30 changes: 15 additions & 15 deletions src/lcd/nextion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ void lcdUploadCfg(eepromValues_t &eepromCurrentValues) {
myNex.writeNum("bDiv", eepromCurrentValues.brewDivider);
myNex.writeNum("moreTemp.n5.val", eepromCurrentValues.brewDivider);

myNex.writeNum("ppStart", eepromCurrentValues.pressureProfilingStart);
myNex.writeNum("brewAuto.n2.val", eepromCurrentValues.pressureProfilingStart);
myNex.writeNum("ppStart", eepromCurrentValues.pressureProfilingStart * 10.f);
myNex.writeNum("brewAuto.pStartBar.val", eepromCurrentValues.pressureProfilingStart * 10.f);

myNex.writeNum("ppFlowStart", eepromCurrentValues.flowProfileStart * 10.f);
myNex.writeNum("brewAuto.flowStartBox.val", eepromCurrentValues.flowProfileStart * 10.f);

myNex.writeNum("ppFin", eepromCurrentValues.pressureProfilingFinish);
myNex.writeNum("brewAuto.n3.val", eepromCurrentValues.pressureProfilingFinish);
myNex.writeNum("ppFin", eepromCurrentValues.pressureProfilingFinish * 10.f);
myNex.writeNum("brewAuto.pEndBar.val", eepromCurrentValues.pressureProfilingFinish * 10.f);

myNex.writeNum("ppFlowFinish", eepromCurrentValues.flowProfileEnd * 10.f);
myNex.writeNum("brewAuto.flowEndBox.val", eepromCurrentValues.flowProfileEnd * 10.f);

myNex.writeNum("ppHold", eepromCurrentValues.pressureProfilingHold);
myNex.writeNum("brewAuto.n5.val", eepromCurrentValues.pressureProfilingHold);

myNex.writeNum("ppFlowPressure", eepromCurrentValues.flowProfilePressureTarget);
myNex.writeNum("brewAuto.flowBarBox.val", eepromCurrentValues.flowProfilePressureTarget);
myNex.writeNum("ppFlowPressure", eepromCurrentValues.flowProfilePressureTarget * 10.f);
myNex.writeNum("brewAuto.flowBarBox.val", eepromCurrentValues.flowProfilePressureTarget * 10.f);

myNex.writeNum("ppLength", eepromCurrentValues.pressureProfilingLength);
myNex.writeNum("brewAuto.n6.val", eepromCurrentValues.pressureProfilingLength);
Expand All @@ -86,8 +86,8 @@ void lcdUploadCfg(eepromValues_t &eepromCurrentValues) {
myNex.writeNum("piFlow", eepromCurrentValues.preinfusionFlowVol * 10.f);
myNex.writeNum("brewAuto.flowPIbox.val", eepromCurrentValues.preinfusionFlowVol * 10.f);

myNex.writeNum("piBar", eepromCurrentValues.preinfusionBar);
myNex.writeNum("brewAuto.n1.val", eepromCurrentValues.preinfusionBar);
myNex.writeNum("piBar", eepromCurrentValues.preinfusionBar * 10.f);
myNex.writeNum("brewAuto.piTargetBar.val", eepromCurrentValues.preinfusionBar * 10.f);

myNex.writeNum("piFlowTime", eepromCurrentValues.preinfusionFlowTime);
myNex.writeNum("brewAuto.flowPiSecBox.val", eepromCurrentValues.preinfusionFlowTime);
Expand All @@ -98,8 +98,8 @@ void lcdUploadCfg(eepromValues_t &eepromCurrentValues) {
myNex.writeNum("piFlowSoak", eepromCurrentValues.preinfusionFlowSoakTime);
myNex.writeNum("brewAuto.flowPiSoakBox.val", eepromCurrentValues.preinfusionFlowSoakTime);

myNex.writeNum("piFlowPressure", eepromCurrentValues.preinfusionFlowPressureTarget);
myNex.writeNum("brewAuto.flowPiBarBox.val", eepromCurrentValues.preinfusionFlowPressureTarget);
myNex.writeNum("piFlowPressure", eepromCurrentValues.preinfusionFlowPressureTarget * 10.f);
myNex.writeNum("brewAuto.flowPiBarBox.val", eepromCurrentValues.preinfusionFlowPressureTarget * 10.f);

myNex.writeNum("piRamp", eepromCurrentValues.preinfusionRamp);
myNex.writeNum("brewAuto.rampSpeed.val", eepromCurrentValues.preinfusionRamp);
Expand Down Expand Up @@ -139,25 +139,25 @@ eepromValues_t lcdDownloadCfg(void) {

lcdCfg.preinfusionState = myNex.readNumber("piState");
lcdCfg.preinfusionSec = myNex.readNumber("piSec");
lcdCfg.preinfusionBar = myNex.readNumber("piBar");
lcdCfg.preinfusionBar = myNex.readNumber("piBar") / 10.f;
lcdCfg.preinfusionSoak = myNex.readNumber("piSoak");
lcdCfg.preinfusionRamp = myNex.readNumber("piRamp");

lcdCfg.pressureProfilingState = myNex.readNumber("ppState");
lcdCfg.pressureProfilingStart = myNex.readNumber("ppStart");
lcdCfg.pressureProfilingFinish = myNex.readNumber("ppFin");
lcdCfg.pressureProfilingStart = myNex.readNumber("ppStart") / 10.f;
lcdCfg.pressureProfilingFinish = myNex.readNumber("ppFin") / 10.f;
lcdCfg.pressureProfilingHold = myNex.readNumber("ppHold");
lcdCfg.pressureProfilingLength = myNex.readNumber("ppLength");

lcdCfg.preinfusionFlowState = myNex.readNumber("piFlowState");
lcdCfg.preinfusionFlowVol = myNex.readNumber("piFlow") / 10.f;
lcdCfg.preinfusionFlowTime = myNex.readNumber("piFlowTime" );
lcdCfg.preinfusionFlowSoakTime = myNex.readNumber("piFlowSoak");
lcdCfg.preinfusionFlowPressureTarget = myNex.readNumber("piFlowPressure");
lcdCfg.preinfusionFlowPressureTarget = myNex.readNumber("piFlowPressure") / 10.f;
lcdCfg.flowProfileState = myNex.readNumber("ppFlowState");
lcdCfg.flowProfileStart = myNex.readNumber("ppFlowStart") / 10.f;
lcdCfg.flowProfileEnd = myNex.readNumber("ppFlowFinish") / 10.f;
lcdCfg.flowProfilePressureTarget = myNex.readNumber("ppFlowPressure");
lcdCfg.flowProfilePressureTarget = myNex.readNumber("ppFlowPressure") / 10.f;
lcdCfg.flowProfileCurveSpeed = myNex.readNumber("ppFlowCurveSpeed");

lcdCfg.stopOnWeightState = myNex.readNumber("shotState");
Expand Down
106 changes: 87 additions & 19 deletions webserver/web-interface/src/pages/home/Profiles.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useCallback } from 'react';
import {
Card, Container, useTheme, Typography, CardContent, CardActions,
} from '@mui/material';
Expand All @@ -15,28 +15,32 @@ import RemoveIcon from '@mui/icons-material/Remove';
import AutoGraphIcon from '@mui/icons-material/AutoGraph';
import DeleteIcon from '@mui/icons-material/Delete';
import TextField from '@mui/material/TextField';
import InputAdornment from '@mui/material/InputAdornment';
import Grid from '@mui/material/Unstable_Grid2';

export default function Profiles() {
const theme = useTheme();

const [inputList, setInputList] = useState([]);
const [inputList, setInputList] = useState('');

const [profile, setProfile] = useState([]);
const [profile, setProfile] = useState('Fill');
const [profileType, setProfileType] = useState('Pressure');

const addProfileStep = (event) => {
const addProfileStep = useCallback((event) => {
setProfile(event.target.value);
};
}, [inputList]);

const remProfileStep = () => {
setInputList(inputList.slice(0, -5));
setProfile('');
};
const addProfileType = useCallback((event) => {
setProfileType(event.target.value);
}, [inputList]);

const remProfile = () => {
setInputList(inputList.slice(-1, -1));
setProfile('');
};
const remProfileStep = useCallback(() => {
setInputList(inputList.slice(0, -7));
}, [inputList]);

const remProfile = useCallback(() => {
setInputList(inputList.slice(0, 0));
}, [inputList]);

const handleButtonClick = () => {
setInputList([...inputList,
Expand All @@ -48,17 +52,81 @@ export default function Profiles() {
mt: theme.spacing(2),
}}
>
<FormControl focused size>
<InputLabel id="demo-simple-select-label">Type</InputLabel>
<Select onChange={addProfileStep} labelId="phase-select" key={inputList.length} size="small" id="phase-type-select" value={profile} label="Type" variant="outlined">
<FormControl focused sx={{ mr: theme.spacing(2), minWidth: '9ch' }}>
<InputLabel id="phase-step">Stage</InputLabel>
<Select onChange={addProfileStep} labelId="phase-profile-select" key={inputList.length + 1} size="small" id="phase-profile-select" value={profile} label="Profile" variant="outlined">
<MenuItem value={1}>Fill</MenuItem>
<MenuItem value={2}>Infusion</MenuItem>
<MenuItem value={3}>Soak</MenuItem>
<MenuItem value={4}>Ramp</MenuItem>
<MenuItem value={5}>Profiling</MenuItem>
</Select>
</FormControl>
<FormControl focused sx={{ mr: theme.spacing(2), minWidth: '9ch' }}>
<InputLabel id="phase-type">Type</InputLabel>
<Select onChange={addProfileType} labelId="phase-type-select" key={inputList.length + 1} size="small" id="phase-type-select" value={profileType} label="Type" variant="outlined">
<MenuItem value={1}>Pressure</MenuItem>
<MenuItem value={2}>Flow</MenuItem>
<MenuItem value={3}>Adaptive</MenuItem>
<MenuItem value={4}>Semi-auto</MenuItem>
</Select>
</FormControl>
</Box>,
<TextField id="outlined-basic" key={inputList.length + 1} size="small" label="Bar" variant="outlined" sx={{ mr: theme.spacing(2), mt: theme.spacing(1) }} />,
<TextField id="outlined-basic" key={inputList.length + 1} size="small" label="Flow" variant="outlined" sx={{ mr: theme.spacing(2), mt: theme.spacing(1) }} />,
<TextField id="outlined-basic" key={inputList.length + 1} size="small" label="Time" variant="outlined" sx={{ mr: theme.spacing(2), mt: theme.spacing(1) }} />,
<TextField
id="outlined-basic"
key={inputList.length + 1}
size="small"
label="Pressure"
variant="outlined"
sx={{ mr: theme.spacing(2), mt: theme.spacing(1), width: '9ch' }}
InputProps={{
endAdornment: <InputAdornment position="end">bar</InputAdornment>,
}}
/>,
<TextField
id="outlined-basic"
key={inputList.length + 1}
size="small"
label="Flow"
variant="outlined"
sx={{ mr: theme.spacing(2), mt: theme.spacing(1), width: '9ch' }}
InputProps={{
endAdornment: <InputAdornment position="end">ml/s</InputAdornment>,
}}
/>,
<TextField
id="outlined-basic"
key={inputList.length + 1}
size="small"
label="Time"
variant="outlined"
sx={{ mr: theme.spacing(2), mt: theme.spacing(1), width: '9ch' }}
InputProps={{
endAdornment: <InputAdornment position="end">sec</InputAdornment>,
}}
/>,
<TextField
id="outlined-basic"
key={inputList.length + 1}
size="small"
label="Slope"
variant="outlined"
sx={{ mr: theme.spacing(2), mt: theme.spacing(1), width: '9ch' }}
InputProps={{
endAdornment: <InputAdornment position="end">sec</InputAdornment>,
}}
/>,
<TextField
id="outlined-basic"
key={inputList.length + 1}
size="small"
label="Weight"
variant="outlined"
sx={{ mr: theme.spacing(2), mt: theme.spacing(1), width: '9ch' }}
InputProps={{
endAdornment: <InputAdornment position="end">gram</InputAdornment>,
}}
/>,
]);
};

Expand Down

0 comments on commit a3b7cfd

Please sign in to comment.