// set operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
lcdPrint("Error","The brewer has stoped working properly. Please shutdown NOW for your safety!");
state=state_error;
error=catastrofic_failure_program;
// Position the cursor at the begining of where the temperature template goes onto the screen
lcd.home();
// Print the target and measured temperature template
if(cooking){
lcd.print("ON : 000*C/000*C");
}
else{
lcd.print("OFF: 000*C/000*C");
}
}
voidrunWelcome(){
// Write welcome
lcd.clear();
lcd.home();// go home
lcd.print(" Let's start");
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print(" Brewing!");
delay(SETTING_WELCOME_TIMEOUT);
// Position the cursor at the begining of where the mode and time template goes onto the screen
lcd.setCursor(0,LCD_VERTICAL_RESOLUTION-1);
state=state_menu;
lcd.print("**** 00:00");
}
voidrunMenu(){
digitalWrite(HEATING_ELEMENT,LOW);
voiddisplayStatus(){
switch(menu_position[0]){
casemain_manual:{
switch(menu_position[1]){
casemanual_temperature:{
// do work
cookTemperature=getTemperature(cookTemperature);
// Check whether a template repaint is required
if(repaint){
// Repaint the LCD template
xPaintStatusTemplate();
menu_position[1]=-1;
rotaryEncoderVirtualPosition=manual_temperature;
// Reset the repaint flag after the repaint has been done
repaint=false;
}
break;
// Print positions with no numbers, before the measured temperature value
lcd.setCursor(3,0);
if(basePT100.getCurrentTemperature()<10){
lcd.print(" ");
}
else{
if(basePT100.getCurrentTemperature()<100){
lcd.print(" ");
}
}
casemanual_time:{
// do work
cookTime=getTimer(cookTime);
menu_position[1]=-1;
rotaryEncoderVirtualPosition=manual_time;
// Print measured temperature value onto the LCD
lcd.print(basePT100.getCurrentTemperature(),1);
break;
// Print positions with no numbers, before the target temperature value
lcd.setCursor(11,0);
if(cookTemperature<10){
lcd.print(" ");
}
else{
if(cookTemperature<100){
lcd.print(" ");
}
casemanual_mode:{
// do work
intreturnMode=getMode();
switch(returnMode){
casequick_start:{
cookMode=quick_start;
break;
}
casestart_at_temperature:{
cookMode=start_at_temperature;
break;
// Print target temperature value onto the LCD
lcd.print(cookTemperature);
// Calculate the numbers on the timer clock
intminutes=(clockCounter-clockIgnore)/60;
intseconds=(clockCounter-clockIgnore)-minutes*60;
// Position the cursor at the begining of where the timer goes onto the screen
lcd.setCursor(10,1);
// Print the timer values onto the LCD
if(minutes<10){
lcd.print(" 0");
}
else{
if(minutes<100){
lcd.print(" ");
}
default:{
cookMode=quick_start;
}
lcd.print(minutes);
lcd.print(":");
if(seconds<10){
lcd.print("0");
}
lcd.print(seconds);
}
menu_position[1]=-1;
rotaryEncoderVirtualPosition=manual_mode;
voiddisplayMainMenu(){
switch(menu_position[0]){
caseeMainMenu_GO:{
MainMenu_GO();
menu_position[0]=-1;
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
if(!(digitalRead(PinSW))){// check if pushbutton is pressed
menu_position[1]=rotaryEncoderVirtualPosition;
while(!digitalRead(PinSW)){}// wait til switch is released
delay(10);// debounce
break;
}
caseeMainMenu_Sparge:{
MainMenu_Sparge();
menu_position[0]=-1;
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
if(!(digitalRead(PinSW))){// check if pushbutton is pressed
menu_position[1]=rotaryEncoderVirtualPosition;
while(!digitalRead(PinSW)){}// wait til switch is released
delay(10);// debounce
caseeMainMenu_Proteolytic:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Proteolytic ");
break;
}
caseeMainMenu_BetaAmylase:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Beta Amylase ");
break;
}
caseeMainMenu_AlphaAmylase:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Alpha Amylase");
break;
}
caseeMainMenu_Mashout:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Mashout ");
break;
}
caseeMainMenu_Recirculation:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Recirculation");
break;
}
default:{
// reset menu variables
//rotaryEncoderVirtualPosition = 0;
menuSize=2;
// display menu
lcd.clear();
lcd.home();// go home
lcd.print("Main Menu");
while(true){
switch(rotaryEncoderVirtualPosition){
casemain_manual:{
caseeMainMenu_Sparge:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Sparge ");
break;
}
caseeMainMenu_Boil:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Manual ");
delay(100);
lcd.print("-> Boil ");
break;
}
casemain_auto:{
caseeMainMenu_Hops:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Automatic ");
delay(100);
lcd.print("-> Hops ");
break;
}
caseeMainMenu_Cooling:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Cooling ");
break;
}
caseeMainMenu_Settings:{
lcd.setCursor(0,1);// go to start of 2nd line
lcd.print("-> Settings ");
break;
}
default:{
//lcd.setCursor (0,1); // go to start of 2nd line
//lcd.print("*** Error ***");
rotaryEncoderVirtualPosition=0;
// reset operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// Update the recorded time for the begining of the window, if the previous window has passed
while((millis()-windowStartTime)>WindowSize){// Check if it's time to vary the pulse width modulation and if so do it by shifting the "Relay in ON" Window
// #################################################### Set Variables ##################################################################
intgetTimer(intinit){
// set operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
// set operation state | INPUT : TRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep