Commit 79b4a630 authored by João Lino's avatar João Lino

Further tuned debounce to super fast triggering.

Removed multistep from rotary encoder.
parent cd68831a
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#define ROTARY_ENCODER_CLK_PIN 3 // Used for generating interrupts using CLK signal #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_DT_PIN 22 // Used for reading DT signal
#define ROTARY_ENCODER_SW_PIN 23 // Used for the push button switch #define ROTARY_ENCODER_SW_PIN 23 // Used for the push button switch
#define ROTARY_ENCODER_DEBOUNCE_TIME 40 // Number of miliseconds to ignore new signals a signal is received #define ROTARY_ENCODER_DEBOUNCE_TIME 20 // Number of miliseconds to ignore new signals a signal is received
// ++++++++++++++++++++++++ State Machine ++++++++++++++++++++++++ // ++++++++++++++++++++++++ State Machine ++++++++++++++++++++++++
#define SETTING_WELCOME_TIMEOUT 100 #define SETTING_WELCOME_TIMEOUT 100
...@@ -236,20 +236,10 @@ void isr () { // Interrupt service routine is executed when a HIGH to LOW tr ...@@ -236,20 +236,10 @@ void isr () { // Interrupt service routine is executed when a HIGH to LOW tr
// Input of rotary encoder controling generic integer variables within a range between rotaryEncoderMinPosition and rotaryEncoderMaxPosition // Input of rotary encoder controling generic integer variables within a range between rotaryEncoderMinPosition and rotaryEncoderMaxPosition
case eRotaryEncoderMode_Generic: { case eRotaryEncoderMode_Generic: {
if (!digitalRead(ROTARY_ENCODER_DT_PIN)) { if (!digitalRead(ROTARY_ENCODER_DT_PIN)) {
if ((interruptTime - lastInterruptTime) < ROTARY_ENCODER_DEBOUNCE_TIME) { rotaryEncoderVirtualPosition = (rotaryEncoderVirtualPosition + rotaryEncoderSingleStep);
rotaryEncoderVirtualPosition = (rotaryEncoderVirtualPosition + rotaryEncoderMultiStep);
}
else {
rotaryEncoderVirtualPosition = (rotaryEncoderVirtualPosition + rotaryEncoderSingleStep);
}
} }
else { else {
if ((interruptTime - lastInterruptTime) < ROTARY_ENCODER_DEBOUNCE_TIME) { rotaryEncoderVirtualPosition = (rotaryEncoderVirtualPosition - rotaryEncoderSingleStep);
rotaryEncoderVirtualPosition = (rotaryEncoderVirtualPosition - rotaryEncoderMultiStep);
}
else {
rotaryEncoderVirtualPosition = (rotaryEncoderVirtualPosition - rotaryEncoderSingleStep);
}
} }
if (rotaryEncoderVirtualPosition > rotaryEncoderMaxPosition) { if (rotaryEncoderVirtualPosition > rotaryEncoderMaxPosition) {
rotaryEncoderVirtualPosition = rotaryEncoderMaxPosition; rotaryEncoderVirtualPosition = rotaryEncoderMaxPosition;
...@@ -378,7 +368,7 @@ void setup() { ...@@ -378,7 +368,7 @@ void setup() {
xSafeHardwarePowerOff (); xSafeHardwarePowerOff ();
displayWelcome (); displayWelcome ();
xSetupRotaryEncoder ( eRotaryEncoderMode_Menu, eMainMenu_GO, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder ( eRotaryEncoderMode_Menu, eMainMenu_GO, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
} }
// ######################### START ######################### // ######################### START #########################
...@@ -492,7 +482,7 @@ void displayMainMenu() { ...@@ -492,7 +482,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_GO, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_GO, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -502,7 +492,7 @@ void displayMainMenu() { ...@@ -502,7 +492,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Presets, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Presets, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -512,7 +502,7 @@ void displayMainMenu() { ...@@ -512,7 +502,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Malt, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Malt, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -522,7 +512,7 @@ void displayMainMenu() { ...@@ -522,7 +512,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Startpoint, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Startpoint, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -532,7 +522,7 @@ void displayMainMenu() { ...@@ -532,7 +522,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_BetaGlucanase, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_BetaGlucanase, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -542,7 +532,7 @@ void displayMainMenu() { ...@@ -542,7 +532,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Settings, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Settings, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -552,7 +542,7 @@ void displayMainMenu() { ...@@ -552,7 +542,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Proteolytic, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Proteolytic, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -562,7 +552,7 @@ void displayMainMenu() { ...@@ -562,7 +552,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_BetaAmylase, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_BetaAmylase, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -572,7 +562,7 @@ void displayMainMenu() { ...@@ -572,7 +562,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_AlphaAmylase, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_AlphaAmylase, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -582,7 +572,7 @@ void displayMainMenu() { ...@@ -582,7 +572,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Mashout, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Mashout, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -592,7 +582,7 @@ void displayMainMenu() { ...@@ -592,7 +582,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Recirculation, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Recirculation, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -602,7 +592,7 @@ void displayMainMenu() { ...@@ -602,7 +592,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Sparge, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Sparge, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -612,7 +602,7 @@ void displayMainMenu() { ...@@ -612,7 +602,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Boil, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Boil, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -622,7 +612,7 @@ void displayMainMenu() { ...@@ -622,7 +612,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Hops, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Hops, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -632,7 +622,7 @@ void displayMainMenu() { ...@@ -632,7 +622,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Cooling, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Cooling, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -642,7 +632,7 @@ void displayMainMenu() { ...@@ -642,7 +632,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Settings, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Settings, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -652,7 +642,7 @@ void displayMainMenu() { ...@@ -652,7 +642,7 @@ void displayMainMenu() {
menu_position[0] = -1; menu_position[0] = -1;
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Settings, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_Settings, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
break; break;
} }
...@@ -752,7 +742,7 @@ void displayMainMenu() { ...@@ -752,7 +742,7 @@ void displayMainMenu() {
} }
default: { default: {
// reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep // reset operation state | INPUT : eRotaryEncoderMode newMode, int newPosition, int newMaxPosition, int newMinPosition, int newSingleStep, int newMultiStep
xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_GO, MENU_SIZE_MAIN_MENU - 1, 0, 1, 1 ); xSetupRotaryEncoder( eRotaryEncoderMode_Menu, eMainMenu_GO, MENU_SIZE_MAIN_MENU - 1, 0, 1, 0 );
} }
} }
......
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