Commit 0c5f686d authored by João Lino's avatar João Lino

Rel.3

parent fe9b974d
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
Released into the public domain. Released into the public domain.
*/ */
#ifndef CustomDataStructures_h #ifndef CustomDataStructures_h
#define CustomDataStructures_h
enum eRotaryEncoderMode { enum eRotaryEncoderMode {
eRotaryEncoderMode_Menu, eRotaryEncoderMode_Menu,
...@@ -13,42 +14,65 @@ enum eRotaryEncoderMode { ...@@ -13,42 +14,65 @@ enum eRotaryEncoderMode {
}; };
// menu // menu
enum eMenuType {
eMenuType_Main,
eMenuType_BeerProfile,
eMenuType_Stage,
eMenuType_Malt,
eMenuType_Settings
};
enum eMainMenuOptions { enum eMainMenuOptions {
eMainMenu_NULL,
eMainMenu_GO, eMainMenu_GO,
eMainMenu_Presets, eMainMenu_STOP,
eMainMenu_SKIP,
eMainMenu_BeerProfile,
eMainMenu_Stage,
eMainMenu_Malt, eMainMenu_Malt,
eMainMenu_Startpoint,
eMainMenu_BetaGlucanase,
eMainMenu_Debranching,
eMainMenu_Proteolytic,
eMainMenu_BetaAmylase,
eMainMenu_AlphaAmylase,
eMainMenu_Mashout,
eMainMenu_Recirculation,
eMainMenu_Sparge,
eMainMenu_Boil,
eMainMenu_Hops, eMainMenu_Hops,
eMainMenu_Cooling, eMainMenu_Clean,
eMainMenu_Purge,
eMainMenu_Settings, eMainMenu_Settings,
eMainMenu_Back eMainMenu_Back
}; };
enum ePresetsMenuOptions { enum eStageMenuOptions {
ePresetsMenu_Trigo, eStageMenu_NULL,
ePresetsMenu_IPA, eStageMenu_Startpoint,
ePresetsMenu_Belga, eStageMenu_BetaGlucanase,
ePresetsMenu_Red, eStageMenu_Debranching,
ePresetsMenu_APA, eStageMenu_Proteolytic,
ePresetsMenu_Back eStageMenu_BetaAmylase,
eStageMenu_AlphaAmylase,
eStageMenu_Mashout,
eStageMenu_Recirculation,
eStageMenu_Sparge,
eStageMenu_Boil,
eStageMenu_Cooling,
eStageMenu_Back
};
enum eBeerProfileMenuOptions {
eBeerProfileMenu_NULL,
eBeerProfileMenu_Basic,
eBeerProfileMenu_Trigo,
eBeerProfileMenu_IPA,
eBeerProfileMenu_Belga,
eBeerProfileMenu_Red,
eBeerProfileMenu_APA,
eBeerProfileMenu_Custom,
eBeerProfileMenu_Back
}; };
enum eMaltMenuOptions { enum eMaltMenuOptions {
eMaltMenu_NULL,
eMaltMenu_CastleMalting_Chteau_Pilsen_2RS, eMaltMenu_CastleMalting_Chteau_Pilsen_2RS,
eMaltMenu_CastleMalting_Wheat_Blanc, eMaltMenu_CastleMalting_Wheat_Blanc,
eMaltMenu_Back eMaltMenu_Back
}; };
enum eSettingsMenuOptions { enum eSettingsMenuOptions {
eSettingsMenu_NULL,
eSettingsMenu_PT100_Element, eSettingsMenu_PT100_Element,
eSettingsMenu_PT100_Up, eSettingsMenu_PT100_Up,
eSettingsMenu_PT100_Down, eSettingsMenu_PT100_Down,
...@@ -68,7 +92,19 @@ enum eCookingStages { ...@@ -68,7 +92,19 @@ enum eCookingStages {
eCookingStage_Sparge, eCookingStage_Sparge,
eCookingStage_Boil, eCookingStage_Boil,
eCookingStage_Cooling, eCookingStage_Cooling,
eCookingStage_Clean,
eCookingStage_Purge,
eCookingStage_Done eCookingStage_Done
}; };
enum eBeerProfile {
eBeerProfile_Basic,
eBeerProfile_Trigo,
eBeerProfile_IPA,
eBeerProfile_Belga,
eBeerProfile_Red,
eBeerProfile_APA,
eBeerProfile_Custom
};
#endif #endif
\ No newline at end of file
This diff is collapsed.
/*
Display.h - Display functions header file.
Created by João Lino, September 25, 2015.
Released into the public domain.
*/
#ifndef DISPLAY_h
#define DISPLAY_h
#include <arduino.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include "config.h"
#include "CustomDataStructures.h"
boolean lcdPrint(LiquidCrystal_I2C *lcd, String title, String message);
void xPaintStatusTemplate(LiquidCrystal_I2C *lcd, boolean cooking);
boolean displayStatus(LiquidCrystal_I2C *lcd, boolean cooking, float cookTemperature, float baseTemperature, float upTemperature, float downTemperature, unsigned long clockCounter, boolean repaint);
boolean displayMainMenu(LiquidCrystal_I2C *lcd, eMainMenuOptions position, boolean repaint);
boolean displayBeerProfileMenu(LiquidCrystal_I2C *lcd, eBeerProfileMenuOptions position, boolean repaint);
boolean displayStageMenu(LiquidCrystal_I2C *lcd, eStageMenuOptions position, boolean repaint);
boolean displayMaltMenu(LiquidCrystal_I2C *lcd, eMaltMenuOptions position, boolean repaint);
boolean displaySettingsMenu(LiquidCrystal_I2C *lcd, eSettingsMenuOptions position, boolean repaint);
#endif
\ No newline at end of file
/*
void termometerCalibration() {
float temperaturePumpOFF = 200.0;
float temperaturePumpON = 200.0;
#ifdef DEBUG
debugPrintFunction("termometerCalibration");
#endif
for( int i = 0; i < 300; i++ ) {
basePT100.measure();
delay(100);
}
temperaturePumpOFF = basePT100.getCurrentTemperature();
analogWrite(PUMP_PIN, PUMP_SPEED_MAX);
for( int i = 0; i < 300; i++ ) {
basePT100.measure();
delay(100);
}
temperaturePumpON = basePT100.getCurrentTemperature();
analogWrite(PUMP_PIN, PUMP_SPEED_STOP);
#ifdef DEBUG
debugPrintVar("temperaturePumpOFF", temperaturePumpOFF);
debugPrintVar("temperaturePumpON", temperaturePumpON);
debugPrintVar("diff", temperaturePumpON - temperaturePumpOFF);
#endif
}
*/
\ No newline at end of file
...@@ -71,6 +71,18 @@ int supermario_tempo[] = { ...@@ -71,6 +71,18 @@ int supermario_tempo[] = {
12, 12, 12, 12, 12, 12, 12, 12,
}; };
//Underworld short melody
int underworld_melody_short[] = {
NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,
NOTE_AS3, NOTE_AS4
};
//Underwolrd short tempo
int underworld_tempo_short[] = {
12, 12, 12, 12,
12, 12
};
//Underworld melody //Underworld melody
int underworld_melody[] = { int underworld_melody[] = {
NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4, NOTE_C4, NOTE_C5, NOTE_A3, NOTE_A4,
...@@ -117,6 +129,16 @@ int underworld_tempo[] = { ...@@ -117,6 +129,16 @@ int underworld_tempo[] = {
3, 3, 3 3, 3, 3
}; };
int buzz_1_melody[] = {
NOTE_E7, NOTE_E7, NOTE_E7, NOTE_E7,
0, 0, 0, 0,
};
//Mario main them tempo
int buzz_1_tempo[] = {
12, 12, 12, 12,
12, 12, 12, 12,
};
int song = 0; int song = 0;
void buzz(int targetPin, long frequency, long length) { void buzz(int targetPin, long frequency, long length) {
...@@ -139,7 +161,7 @@ void sing(int s, int pin) { ...@@ -139,7 +161,7 @@ void sing(int s, int pin) {
song = s; song = s;
switch(song) { switch(song) {
case 1: { case MELODY_SUPER_MARIO: {
int size = sizeof(supermario_melody) / sizeof(int); int size = sizeof(supermario_melody) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) { for (int thisNote = 0; thisNote < size; thisNote++) {
...@@ -161,7 +183,7 @@ void sing(int s, int pin) { ...@@ -161,7 +183,7 @@ void sing(int s, int pin) {
} }
break; break;
} }
case 2: { case MELODY_UNDERWORLD: {
int size = sizeof(underworld_melody) / sizeof(int); int size = sizeof(underworld_melody) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) { for (int thisNote = 0; thisNote < size; thisNote++) {
...@@ -183,7 +205,7 @@ void sing(int s, int pin) { ...@@ -183,7 +205,7 @@ void sing(int s, int pin) {
} }
break; break;
} }
case 3: { case MELODY_SUPER_MARIO_START: {
int size = sizeof(supermario_start_melody) / sizeof(int); int size = sizeof(supermario_start_melody) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) { for (int thisNote = 0; thisNote < size; thisNote++) {
...@@ -205,6 +227,50 @@ void sing(int s, int pin) { ...@@ -205,6 +227,50 @@ void sing(int s, int pin) {
} }
break; break;
} }
case MELODY_UNDERWORLD_SHORT: {
int size = sizeof(underworld_melody_short) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / underworld_tempo_short[thisNote];
buzz(pin, underworld_melody_short[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
buzz(pin, 0, noteDuration);
}
break;
}
case BUZZ_1: {
int size = sizeof(buzz_1_melody) / sizeof(int);
for (int thisNote = 0; thisNote < size; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000 / buzz_1_tempo[thisNote];
buzz(pin, buzz_1_melody[thisNote], noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
buzz(pin, 0, noteDuration);
}
break;
}
} }
} }
\ No newline at end of file
...@@ -103,9 +103,11 @@ ...@@ -103,9 +103,11 @@
// Define a special note, 'R', to represent a rest // Define a special note, 'R', to represent a rest
#define _R 0 #define _R 0
#define MELODY_SUPER_MARIO 1 #define MELODY_SUPER_MARIO 1
#define MELODY_UNDERWORLD 2 #define MELODY_UNDERWORLD 2
#define MELODY_SUPER_MARIO_START 3 #define MELODY_SUPER_MARIO_START 3
#define MELODY_UNDERWORLD_SHORT 4
#define BUZZ_1 5
// melody[] is an array of notes, accompanied by beats[], // melody[] is an array of notes, accompanied by beats[],
......
This diff is collapsed.
/*
debug.h - Debug functions.
Created by João Lino, September 25, 2015.
Released into the public domain.
*/
#ifndef CONFIG_h
#define CONFIG_h
// ######################### SETTINGS #########################
#define SETTING_CLEANING_TIME 1200 //1200
#define SETTING_CLEANING_TEMPERATURE 45 //45
// ++++++++++++++++++++++++ Heating Element Relay ++++++++++++++++++++++++
#define HEATING_ELEMENT_DEFAULT_WINDOW_SIZE 1000
#define HEATING_ELEMENT_OUTPUT_PIN 24
#define HEATING_ELEMENT_MAX_HEAT_PWM_INTEGER 5
#define HEATING_ELEMENT_MAX_HEAT_PWM_FLOAT 5.0
#define HEATING_ELEMENT_MAX_WATTAGE 3000.0 // Minimum = 2000.0
#define HEATING_ELEMENT_AC_FREQUENCY_HZ 50.0
// ++++++++++++++++++++++++ Temperature ++++++++++++++++++++++++
#define PT100_BASE_INPUT_PIN A4
#define PT100_BASE_OUTPUT_PIN 32
#define PT100_BASE_INPUT_R_PIN A7
#define PT100_BASE_OUTPUT_R_PIN 7
#define PT100_BASE_TIME_BETWEEN_READINGS 1
#define PT100_UP_INPUT_PIN A5
#define PT100_UP_OUTPUT_PIN 30
#define PT100_UP_INPUT_R_PIN A8
#define PT100_UP_OUTPUT_R_PIN 9
#define PT100_UP_TIME_BETWEEN_READINGS 1
#define PT100_DOWN_INPUT_PIN A6
#define PT100_DOWN_OUTPUT_PIN 31
#define PT100_DOWN_INPUT_R_PIN A9
#define PT100_DOWN_OUTPUT_R_PIN 8
#define PT100_DOWN_TIME_BETWEEN_READINGS 1
#define PT100_BASE_DEFAULT_ADC_VMAX 1.1
#define PT100_BASE_DEFAULT_VS 5.0
#define PT100_BASE_DEFAULT_R1_RESISTENCE 605.2
#define PT100_BASE_DEFAULT_R2_RESISTENCE 605.2
#define PT100_UP_DEFAULT_ADC_VMAX 1.1
#define PT100_UP_DEFAULT_VS 5.0
#define PT100_UP_DEFAULT_R1_RESISTENCE 630.0 //620.0
#define PT100_UP_DEFAULT_R2_RESISTENCE 610.0
#define PT100_DOWN_DEFAULT_ADC_VMAX 1.1
#define PT100_DOWN_DEFAULT_VS 5.0
#define PT100_DOWN_DEFAULT_R1_RESISTENCE 616.0
#define PT100_DOWN_DEFAULT_R2_RESISTENCE 611.0
// ++++++++++++++++++++++++ Mixer ++++++++++++++++++++++++
//#define MIXER_PIN 12
//#define MIXER_MAX_POSITION 255
// ++++++++++++++++++++++++ Pump ++++++++++++++++++++++++
#define PIEZO_PIN 25
// ++++++++++++++++++++++++ Pump ++++++++++++++++++++++++
#define PUMP_PIN 6
#define PUMP_TEMPERATURE_MAX_OPERATION 90
#define PUMP_SPEED_STOP 0
#define PUMP_SPEED_SLOW 64
#define PUMP_SPEED_AVERAGE 128
#define PUMP_SPEED_FAST 192
#define PUMP_SPEED_MAX 255
// ++++++++++++++++++++++++ Rotary Encoder ++++++++++++++++++++++++
#define ROTARY_ENCODER_INTERRUPT_NUMBER 1 // On Mega2560 boards, interrupt 1 is on pin 3
#define ROTARY_ENCODER_CLK_PIN 3 // Used for generating interrupts using CLK signal
#define ROTARY_ENCODER_DT_PIN 22 // Used for reading DT signal
#define ROTARY_ENCODER_SW_PIN 23 // Used for the push button switch
#define ROTARY_ENCODER_DEBOUNCE_TIME 50 //20 // Number of miliseconds to ignore new signals a signal is received
// ++++++++++++++++++++++++ State Machine ++++++++++++++++++++++++
#define SETTING_WELCOME_TIMEOUT 100
#define SETTING_MAX_INACTIVITY_TIME 3000
#define MENU_SIZE_MAIN_MENU 12
#define MENU_SIZE_PROFILES_MENU 9
#define MENU_SIZE_STAGE_MENU 13
#define MENU_SIZE_MALT_MENU 4
#define MENU_SIZE_SETTINGS_MENU 5
#define SETTING_SERIAL_MONITOR_BAUD_RATE 9600
#define SETTING_SERIAL_MONITOR_WELCOME_MESSAGE "Let's start Brewing!"
// ######################### LIBRARIES #########################
// ++++++++++++++++++++++++ LiquidCrystal_I2C ++++++++++++++++++++++++
#define LCD_I2C_ADDR 0x27 // <<----- Add your address here. Find it from I2C Scanner
#define LCD_HORIZONTAL_RESOLUTION 16
#define LCD_VERTICAL_RESOLUTION 2
#define LCD_BACKLIGHT_PIN 3
#define LCD_EN_PIN 2
#define LCD_RW_PIN 1
#define LCD_RS_PIN 0
#define LCD_D4_PIN 4
#define LCD_D5_PIN 5
#define LCD_D6_PIN 6
#define LCD_D7_PIN 7
#endif
\ No newline at end of file
/*
debug.h - Debug functions.
Created by João Lino, September 25, 2015.
Released into the public domain.
*/
#ifndef DEBUG_h
#define DEBUB_h
// ######################### TEMPLATES #########################
template <class T> void debugPrintVar( char *name, const T& value );
template <class T> void debugPrintVar( char *name, const T& value ) {
Serial.print("[");
Serial.print(name);
Serial.print(":");
Serial.print(value);
Serial.println("]");
}
void debugPrintFunction( char *name ) {
Serial.print("++++++++++++++++++++++++ ");
Serial.print(name);
Serial.println("++++++++++++++++++++++++");
}
#endif
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment