From 03141a5ef4bd6d57c82116814c8d41dc08b288c0 Mon Sep 17 00:00:00 2001
From: xifle <felix@viki.local>
Date: Sat, 18 May 2013 19:53:46 +0200
Subject: [PATCH 1/3] LCD: Added Deadzone at 100% Feedrate

This adds a deadzone at 100% Feedrate when changing it at the status
screen/main menu. Prevents from unwanted feedrate-changing when
navigating back to the main menu and makes it easier to return to 100%.
---
 Marlin/ultralcd.cpp | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index 4d4f1ce65d..13f2116237 100644
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -77,6 +77,7 @@ static void menu_action_setting_edit_callback_float52(const char* pstr, float* p
 static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc);
 
 #define ENCODER_STEPS_PER_MENU_ITEM 5
+#define ENCODER_FEEDRATE_DEADZONE 10
 
 /* Helper macros for menus */
 #define START_MENU() do { \
@@ -158,10 +159,34 @@ static void lcd_status_screen()
     if (LCD_CLICKED)
     {
         currentMenu = lcd_main_menu;
+		encoderPosition = 0;
         lcd_quick_feedback();
     }
-    feedmultiply += int(encoderPosition);
-    encoderPosition = 0;
+
+	// Dead zone at 100% feedrate
+	if (feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100 ||
+			feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100)
+	{
+		encoderPosition = 0;
+		feedmultiply = 100;
+	}
+	
+	if (feedmultiply == 100 && int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE)
+	{
+		feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE;
+		encoderPosition = 0;
+	}
+	else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE)
+	{
+		feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
+		encoderPosition = 0;	
+	}
+	else if (feedmultiply != 100)
+	{
+    	feedmultiply += int(encoderPosition);
+		encoderPosition = 0;
+    }
+
     if (feedmultiply < 10)
         feedmultiply = 10;
     if (feedmultiply > 999)

From bbe67fca5a24f21fe4774b5a7e3b6a908b4b1962 Mon Sep 17 00:00:00 2001
From: xifle <felix@viki.local>
Date: Mon, 20 May 2013 14:50:39 +0200
Subject: [PATCH 2/3] soft tab correction

---
 Marlin/ultralcd.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index 95ad59d24b..8354c88665 100644
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -169,7 +169,7 @@ static void lcd_status_screen()
     if (LCD_CLICKED)
     {
         currentMenu = lcd_main_menu;
-		encoderPosition = 0;
+        encoderPosition = 0;
         lcd_quick_feedback();
     }
 

From 98d0d4819107fe05dde5561efd652d56f676e688 Mon Sep 17 00:00:00 2001
From: xifle <felix@viki.local>
Date: Mon, 20 May 2013 14:52:35 +0200
Subject: [PATCH 3/3] fixed merge

---
 Marlin/ultralcd.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index 8354c88665..4a9042116f 100644
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -76,7 +76,6 @@ static void menu_action_setting_edit_callback_float51(const char* pstr, float* p
 static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
 static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc);
 
-#define ENCODER_STEPS_PER_MENU_ITEM 5
 #define ENCODER_FEEDRATE_DEADZONE 10
 
 #if !defined(LCD_I2C_VIKI)