Browse Source

Merge pull request #486 from xifle/Marlin_v1

LCD: Added Deadzone at 100% Feedrate
ErikZalm 12 years ago
parent
commit
273502a172
1 changed files with 29 additions and 2 deletions
  1. 29
    2
      Marlin/ultralcd.cpp

+ 29
- 2
Marlin/ultralcd.cpp View File

@@ -76,12 +76,15 @@ static void menu_action_setting_edit_callback_float51(const char* pstr, float* p
76 76
 static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
77 77
 static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc);
78 78
 
79
+#define ENCODER_FEEDRATE_DEADZONE 10
80
+
79 81
 #if !defined(LCD_I2C_VIKI)
80 82
   #define ENCODER_STEPS_PER_MENU_ITEM 5
81 83
 #else
82 84
   #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
83 85
 #endif
84 86
 
87
+
85 88
 /* Helper macros for menus */
86 89
 #define START_MENU() do { \
87 90
     if (encoderPosition > 0x8000) encoderPosition = 0; \
@@ -165,10 +168,34 @@ static void lcd_status_screen()
165 168
     if (LCD_CLICKED)
166 169
     {
167 170
         currentMenu = lcd_main_menu;
171
+        encoderPosition = 0;
168 172
         lcd_quick_feedback();
169 173
     }
170
-    feedmultiply += int(encoderPosition);
171
-    encoderPosition = 0;
174
+
175
+    // Dead zone at 100% feedrate
176
+    if (feedmultiply < 100 && (feedmultiply + int(encoderPosition)) > 100 ||
177
+            feedmultiply > 100 && (feedmultiply + int(encoderPosition)) < 100)
178
+    {
179
+        encoderPosition = 0;
180
+        feedmultiply = 100;
181
+    }
182
+
183
+    if (feedmultiply == 100 && int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE)
184
+    {
185
+        feedmultiply += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE;
186
+        encoderPosition = 0;
187
+    }
188
+    else if (feedmultiply == 100 && int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE)
189
+    {
190
+        feedmultiply += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE;
191
+        encoderPosition = 0;	
192
+    }
193
+    else if (feedmultiply != 100)
194
+    {
195
+        feedmultiply += int(encoderPosition);
196
+        encoderPosition = 0;
197
+    }
198
+
172 199
     if (feedmultiply < 10)
173 200
         feedmultiply = 10;
174 201
     if (feedmultiply > 999)

Loading…
Cancel
Save