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
 static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
76
 static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
77
 static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc);
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
 #if !defined(LCD_I2C_VIKI)
81
 #if !defined(LCD_I2C_VIKI)
80
   #define ENCODER_STEPS_PER_MENU_ITEM 5
82
   #define ENCODER_STEPS_PER_MENU_ITEM 5
81
 #else
83
 #else
82
   #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
84
   #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
83
 #endif
85
 #endif
84
 
86
 
87
+
85
 /* Helper macros for menus */
88
 /* Helper macros for menus */
86
 #define START_MENU() do { \
89
 #define START_MENU() do { \
87
     if (encoderPosition > 0x8000) encoderPosition = 0; \
90
     if (encoderPosition > 0x8000) encoderPosition = 0; \
165
     if (LCD_CLICKED)
168
     if (LCD_CLICKED)
166
     {
169
     {
167
         currentMenu = lcd_main_menu;
170
         currentMenu = lcd_main_menu;
171
+        encoderPosition = 0;
168
         lcd_quick_feedback();
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
     if (feedmultiply < 10)
199
     if (feedmultiply < 10)
173
         feedmultiply = 10;
200
         feedmultiply = 10;
174
     if (feedmultiply > 999)
201
     if (feedmultiply > 999)

Loading…
Cancel
Save