Skip to content

Commit f35f1a7

Browse files
authored
Merge pull request #286 from Zer0-bit/release-nano-final-patch2
descale final fix
2 parents 846a592 + 3b8565a commit f35f1a7

File tree

1 file changed

+51
-26
lines changed

1 file changed

+51
-26
lines changed

src/gaggiuino.ino

+51-26
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@
8888
#define GET_PRESSURE_READ_EVERY 50
8989
#define GET_SCALES_READ_EVERY 100
9090
#define REFRESH_SCREEN_EVERY 150 // Screen refresh interval (ms)
91-
#define DESCALE_PHASE1_EVERY 500 // short pump pulses during descale
92-
#define DESCALE_PHASE2_EVERY 5000 // short pause for pulse effficience activation
93-
#define DESCALE_PHASE3_EVERY 120000 // long pause for scale softening
91+
#define DESCALE_PHASE1_EVERY 60000 // short pump pulses during descale
92+
#define DESCALE_PHASE2_EVERY 120000 // long pause for scale softening
93+
#define DESCALE_PHASE3_EVERY 4000 // short pause for pulse effficience activation
9494
#define MAX_SETPOINT_VALUE 110 //Defines the max value of the setpoint
9595
#define EEPROM_RESET 1 //change this value if want to reset to defaults
9696
#define PUMP_RANGE 127
@@ -878,58 +878,83 @@ void setBoiler(int val) {
878878

879879
void deScale() {
880880
static bool blink = true;
881-
static long timer = millis();
882-
static int currentCycleRead = myNex.readNumber("j0.val");
883-
static int lastCycleRead = 10;
881+
static long timer = 0;
882+
static int currentCycleRead = 0;
883+
static int lastCycleRead = 0;
884884
static bool descaleFinished = false;
885885
if (brewActive && !descaleFinished) {
886886
if (currentCycleRead < lastCycleRead) { // descale in cycles for 5 times then wait according to the below condition
887887
if (blink == true) { // Logic that switches between modes depending on the $blink value
888-
pump.set(15);
889-
if (millis() - timer > DESCALE_PHASE1_EVERY) { //set dimmer power to max descale value for 10 sec
890-
if (currentCycleRead >=100) descaleFinished = true;
888+
pump.set(10);
889+
if (millis() - timer > DESCALE_PHASE1_EVERY) { // 60 sec
891890
blink = false;
892-
currentCycleRead = myNex.readNumber("j0.val");
891+
currentCycleRead += 2;
893892
timer = millis();
894893
}
895894
} else {
896-
pump.set(30);
897-
if (millis() - timer > DESCALE_PHASE2_EVERY) { //set dimmer power to min descale value for 20 sec
895+
pump.set(0);
896+
if (millis() - timer > DESCALE_PHASE2_EVERY) { // nothing for 120 sec
898897
blink = true;
899-
currentCycleRead++;
900-
if (currentCycleRead<100) myNex.writeNum("j0.val", currentCycleRead);
898+
currentCycleRead += 4;
901899
timer = millis();
902900
}
903901
}
904902
} else {
905-
pump.set(0);
906-
if ((millis() - timer) > DESCALE_PHASE3_EVERY) { //nothing for 5 minutes
907-
if (currentCycleRead*3 < 100) myNex.writeNum("j0.val", currentCycleRead*3);
908-
else {
909-
myNex.writeNum("j0.val", 100);
910-
descaleFinished = true;
911-
}
912-
lastCycleRead = currentCycleRead*3;
903+
pump.set(30);
904+
if ((millis() - timer) > DESCALE_PHASE3_EVERY) { //set dimmer power to max descale value for 4 sec
905+
solenoidBeat();
906+
blink = true;
907+
currentCycleRead += 4; // need an overflow on 3rd cycle (34 -> 68 -> 102)
908+
lastCycleRead += 33;
913909
timer = millis();
914910
}
915911
}
916-
} else if (brewActive && descaleFinished == true){
912+
913+
if (currentCycleRead >= 100) {
914+
descaleFinished = true;
915+
}
916+
917+
if (millis() > pageRefreshTimer) {
918+
if (currentCycleRead < 100) {
919+
myNex.writeNum("j0.val", currentCycleRead);
920+
} else {
921+
myNex.writeNum("j0.val", 100);
922+
}
923+
}
924+
} else if (brewActive && descaleFinished) {
917925
pump.set(0);
918926
if ((millis() - timer) > 1000) {
919-
brewTimer(false);
927+
brewTimer(0);
920928
myNex.writeStr("t14.txt", "FINISHED!");
921-
timer=millis();
929+
timer = millis();
922930
}
923931
} else {
932+
pump.set(0);
933+
blink = true;
924934
currentCycleRead = 0;
925-
lastCycleRead = 10;
935+
lastCycleRead = 30;
926936
descaleFinished = false;
927937
timer = millis();
928938
}
929939
//keeping it at temp
930940
justDoCoffee();
931941
}
932942

943+
void solenoidBeat() {
944+
pump.set(PUMP_RANGE);
945+
digitalWrite(valvePin, LOW);
946+
delay(200);
947+
digitalWrite(valvePin, HIGH);
948+
delay(200);
949+
digitalWrite(valvePin, LOW);
950+
delay(200);
951+
digitalWrite(valvePin, HIGH);
952+
delay(200);
953+
digitalWrite(valvePin, LOW);
954+
delay(200);
955+
digitalWrite(valvePin, HIGH);
956+
pump.set(0);
957+
}
933958

934959
//#############################################################################################
935960
//###############################____PRESSURE_CONTROL____######################################

0 commit comments

Comments
 (0)