Bläddra i källkod

Reduce size of menu code

- Get rid of _selected functions, passing selected state instead
Scott Lahteine 9 år sedan
förälder
incheckning
3405f85a6a
3 ändrade filer med 193 tillägg och 307 borttagningar
  1. 40
    64
      Marlin/dogm_lcd_implementation.h
  2. 64
    44
      Marlin/ultralcd.cpp
  3. 89
    199
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 40
- 64
Marlin/dogm_lcd_implementation.h Visa fil

@@ -282,7 +282,7 @@ static void lcd_implementation_status_screen() {
282 282
 }
283 283
 
284 284
 static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
285
-  if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0] )) {
285
+  if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0])) {
286 286
     u8g.setColorIndex(1);  // black on white
287 287
     u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
288 288
     u8g.setColorIndex(0);  // following text must be white on black
@@ -293,29 +293,29 @@ static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
293 293
   u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
294 294
 }
295 295
 
296
-static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
296
+static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) {
297 297
   char c;
298 298
   uint8_t n = LCD_WIDTH - 2;
299 299
 
300
-  lcd_implementation_mark_as_selected(row, pre_char);
300
+  lcd_implementation_mark_as_selected(row, sel ? pre_char : ' ');
301 301
 
302
-  while((c = pgm_read_byte(pstr))) {
302
+  while ((c = pgm_read_byte(pstr))) {
303 303
     u8g.print(c);
304 304
     pstr++;
305 305
     n--;
306 306
   }
307
-  while(n--) u8g.print(' ');
307
+  while (n--) u8g.print(' ');
308 308
   u8g.print(post_char);
309 309
   u8g.print(' ');
310 310
 }
311 311
 
312
-static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
312
+static void _drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, const char* data, bool pgm) {
313 313
   char c;
314 314
   uint8_t n = LCD_WIDTH - 2 - (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
315 315
 
316
-  lcd_implementation_mark_as_selected(row, pre_char);
316
+  lcd_implementation_mark_as_selected(row, sel ? '>' : ' ');
317 317
 
318
-  while( (c = pgm_read_byte(pstr))) {
318
+  while ((c = pgm_read_byte(pstr))) {
319 319
     u8g.print(c);
320 320
     pstr++;
321 321
     n--;
@@ -325,47 +325,29 @@ static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char p
325 325
   if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
326 326
 }
327 327
 
328
-#define lcd_implementation_drawmenu_setting_edit_generic(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, false)
329
-#define lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, true)
330
-
331
-#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
332
-#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
333
-#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
334
-#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
335
-#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
336
-#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
337
-#define lcd_implementation_drawmenu_setting_edit_float43_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
338
-#define lcd_implementation_drawmenu_setting_edit_float43(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
339
-#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
340
-#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
341
-#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
342
-#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
343
-#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
344
-#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
345
-#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
346
-#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
347
-#define lcd_implementation_drawmenu_setting_edit_bool_selected(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
348
-#define lcd_implementation_drawmenu_setting_edit_bool(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
328
+#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
329
+#define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
330
+
331
+#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
332
+#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
333
+#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
334
+#define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43(*(data)))
335
+#define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
336
+#define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52(*(data)))
337
+#define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51(*(data)))
338
+#define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
339
+#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
349 340
 
350 341
 //Add version for callback functions
351
-#define lcd_implementation_drawmenu_setting_edit_callback_int3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
352
-#define lcd_implementation_drawmenu_setting_edit_callback_int3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
353
-#define lcd_implementation_drawmenu_setting_edit_callback_float3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
354
-#define lcd_implementation_drawmenu_setting_edit_callback_float3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
355
-#define lcd_implementation_drawmenu_setting_edit_callback_float32_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
356
-#define lcd_implementation_drawmenu_setting_edit_callback_float32(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
357
-#define lcd_implementation_drawmenu_setting_edit_callback_float43_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
358
-#define lcd_implementation_drawmenu_setting_edit_callback_float43(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
359
-#define lcd_implementation_drawmenu_setting_edit_callback_float5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
360
-#define lcd_implementation_drawmenu_setting_edit_callback_float5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
361
-#define lcd_implementation_drawmenu_setting_edit_callback_float52_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
362
-#define lcd_implementation_drawmenu_setting_edit_callback_float52(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
363
-#define lcd_implementation_drawmenu_setting_edit_callback_float51_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
364
-#define lcd_implementation_drawmenu_setting_edit_callback_float51(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
365
-#define lcd_implementation_drawmenu_setting_edit_callback_long5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
366
-#define lcd_implementation_drawmenu_setting_edit_callback_long5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
367
-#define lcd_implementation_drawmenu_setting_edit_callback_bool_selected(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
368
-#define lcd_implementation_drawmenu_setting_edit_callback_bool(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
342
+#define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
343
+#define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
344
+#define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
345
+#define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43(*(data)))
346
+#define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
347
+#define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52(*(data)))
348
+#define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51(*(data)))
349
+#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
350
+#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
369 351
 
370 352
 void lcd_implementation_drawedit(const char* pstr, char* value) {
371 353
   uint8_t rows = 1;
@@ -396,19 +378,19 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
396 378
   u8g.print(value);
397 379
 }
398 380
 
399
-static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir, bool isSelected) {
381
+static void _drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir) {
400 382
   char c;
401 383
   uint8_t n = LCD_WIDTH - 1;
402 384
 
403
-  if (longFilename[0] != '\0') {
385
+  if (longFilename[0]) {
404 386
     filename = longFilename;
405 387
     longFilename[n] = '\0';
406 388
   }
407 389
 
408
-  lcd_implementation_mark_as_selected(row, ((isSelected) ? '>' : ' '));
390
+  lcd_implementation_mark_as_selected(row, sel ? '>' : ' ');
409 391
 
410 392
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
411
-  while((c = *filename) != '\0') {
393
+  while ((c = *filename)) {
412 394
     u8g.print(c);
413 395
     filename++;
414 396
     n--;
@@ -416,19 +398,13 @@ static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, ch
416 398
   while(n--) u8g.print(' ');
417 399
 }
418 400
 
419
-#define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)
420
-#define lcd_implementation_drawmenu_sdfile(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, false)
421
-#define lcd_implementation_drawmenu_sddirectory_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, true)
422
-#define lcd_implementation_drawmenu_sddirectory(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, false)
423
-
424
-#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
425
-#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
426
-#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
427
-#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
428
-#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
429
-#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
430
-#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
431
-#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
401
+#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)
402
+#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, true)
403
+
404
+#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
405
+#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
406
+#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
407
+#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
432 408
 
433 409
 static void lcd_implementation_quick_feedback() {
434 410
   #if BEEPER > -1

+ 64
- 44
Marlin/ultralcd.cpp Visa fil

@@ -116,64 +116,84 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
116 116
 
117 117
 
118 118
 /* Helper macros for menus */
119
+
120
+/**
121
+ * START_MENU generates the init code for a menu function
122
+ */
119 123
 #define START_MENU() do { \
120
-	encoderRateMultiplierEnabled = false; \
121
-    if (encoderPosition > 0x8000) encoderPosition = 0; \
122
-    if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
123
-    uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
124
-    bool wasClicked = LCD_CLICKED;\
125
-    for(uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
126
-        _menuItemNr = 0;
124
+  encoderRateMultiplierEnabled = false; \
125
+  if (encoderPosition > 0x8000) encoderPosition = 0; \
126
+  uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
127
+  if (encoderLine < currentMenuViewOffset) currentMenuViewOffset = encoderLine; \
128
+  uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
129
+  bool wasClicked = LCD_CLICKED, itemSelected; \
130
+  if (wasClicked) lcd_quick_feedback(); \
131
+  for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
132
+    _menuItemNr = 0;
133
+
134
+/**
135
+ * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
136
+ *
137
+ *   lcd_implementation_drawmenu_[type](sel, row, label, arg3...)
138
+ *   menu_action_[type](arg3...)
139
+ *
140
+ * Examples:
141
+ *   MENU_ITEM(back, MSG_WATCH, lcd_status_screen)
142
+ *     lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH), lcd_status_screen)
143
+ *     menu_action_back(lcd_status_screen)
144
+ *
145
+ *   MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
146
+ *     lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
147
+ *     menu_action_function(lcd_sdcard_pause)
148
+ *
149
+ *   MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999)
150
+ *   MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedmultiply, 10, 999)
151
+ *     lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedmultiply, 10, 999)
152
+ *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedmultiply, 10, 999)
153
+ *
154
+ */
127 155
 #define MENU_ITEM(type, label, args...) do { \
128
-    if (_menuItemNr == _lineNr) { \
129
-        if (lcdDrawUpdate) { \
130
-            const char* _label_pstr = PSTR(label); \
131
-            if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
132
-                lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \
133
-            }else{\
134
-                lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
135
-            }\
136
-        }\
137
-        if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\
138
-            lcd_quick_feedback(); \
139
-            menu_action_ ## type ( args ); \
140
-            return;\
141
-        }\
142
-    }\
143
-    _menuItemNr++;\
156
+  if (_menuItemNr == _lineNr) { \
157
+    itemSelected = encoderLine == _menuItemNr; \
158
+    if (lcdDrawUpdate) \
159
+      lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
160
+    if (wasClicked && itemSelected) { \
161
+      menu_action_ ## type(args); \
162
+      return; \
163
+    } \
164
+  } \
165
+  _menuItemNr++; \
144 166
 } while(0)
167
+
145 168
 #ifdef ENCODER_RATE_MULTIPLIER
169
+  /**
170
+   * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
171
+   */
146 172
   #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
147 173
     if (_menuItemNr == _lineNr) { \
148
-      if (lcdDrawUpdate) { \
149
-        const char* _label_pstr = PSTR(label); \
150
-        if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
151
-          lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \
152
-        } \
153
-        else { \
154
-          lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
155
-        } \
156
-      } \
157
-      if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
158
-        lcd_quick_feedback(); \
174
+      itemSelected = encoderLine == _menuItemNr; \
175
+      if (lcdDrawUpdate) \
176
+        lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
177
+      if (wasClicked && itemSelected) { \
159 178
         encoderRateMultiplierEnabled = true; \
160 179
         lastEncoderMovementMillis = 0; \
161
-        menu_action_ ## type ( args ); \
180
+        menu_action_ ## type(args); \
162 181
         return; \
163 182
       } \
164 183
     } \
165 184
     _menuItemNr++; \
166 185
   } while(0)
167 186
 #endif //ENCODER_RATE_MULTIPLIER
187
+
168 188
 #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
169
-#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
170
-#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
189
+#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
190
+#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
171 191
 #ifdef ENCODER_RATE_MULTIPLIER
172
-  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
173
-  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
192
+  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
193
+  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
174 194
 #else //!ENCODER_RATE_MULTIPLIER
175
-  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
176
-  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
195
+  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
196
+  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
177 197
 #endif //!ENCODER_RATE_MULTIPLIER
178 198
 #define END_MENU() \
179 199
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
@@ -461,9 +481,9 @@ static void lcd_tune_menu() {
461 481
   #if TEMP_SENSOR_BED != 0
462 482
     MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
463 483
   #endif
464
-    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
465
-    MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
466
-    MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F0, &extruder_multiply[0], 10, 999);
484
+  MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
485
+  MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
486
+  MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F0, &extruder_multiply[0], 10, 999);
467 487
   #if TEMP_SENSOR_1 != 0
468 488
     MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F1, &extruder_multiply[1], 10, 999);
469 489
   #endif

+ 89
- 199
Marlin/ultralcd_implementation_hitachi_HD44780.h Visa fil

@@ -610,214 +610,104 @@ static void lcd_implementation_status_screen()
610 610
 
611 611
   lcd.print(lcd_status_message);
612 612
 }
613
-static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
614
-{
615
-    char c;
616
-    //Use all characters in narrow LCDs
617
-  #if LCD_WIDTH < 20
618
-      uint8_t n = LCD_WIDTH - 1 - 1;
619
-    #else
620
-      uint8_t n = LCD_WIDTH - 1 - 2;
621
-  #endif
622
-    lcd.setCursor(0, row);
623
-    lcd.print(pre_char);
624
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
625
-    {
626
-        lcd.print(c);
627
-        pstr++;
628
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
629
-    }
630
-    while(n--)
631
-        lcd.print(' ');
632
-    lcd.print(post_char);
633
-    lcd.print(' ');
613
+
614
+static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) {
615
+  char c;
616
+  uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2);
617
+  lcd.setCursor(0, row);
618
+  lcd.print(sel ? pre_char : ' ');
619
+  while ((c = pgm_read_byte(pstr)) && n > 0) {
620
+    lcd.print(c);
621
+    pstr++;
622
+    if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
623
+  }
624
+  while(n--) lcd.print(' ');
625
+  lcd.print(post_char);
626
+  lcd.print(' ');
634 627
 }
635
-static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data)
636
-{
637
-    char c;
638
-    //Use all characters in narrow LCDs
639
-  #if LCD_WIDTH < 20
640
-      uint8_t n = LCD_WIDTH - 1 - 1 - lcd_strlen(data);
641
-    #else
642
-      uint8_t n = LCD_WIDTH - 1 - 2 - lcd_strlen(data);
643
-  #endif
644
-    lcd.setCursor(0, row);
645
-    lcd.print(pre_char);
646
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
647
-    {
648
-        lcd.print(c);
649
-        pstr++;
650
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
651
-    }
652
-    lcd.print(':');
653
-    while(n--)
654
-        lcd.print(' ');
655
-    lcd.print(data);
628
+static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) {
629
+  char c;
630
+  uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen(data);
631
+  lcd.setCursor(0, row);
632
+  lcd.print(sel ? pre_char : ' ');
633
+  while ((c = pgm_read_byte(pstr)) && n > 0) {
634
+    lcd.print(c);
635
+    pstr++;
636
+    if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
637
+  }
638
+  lcd.print(':');
639
+  while (n--) lcd.print(' ');
640
+  lcd.print(data);
656 641
 }
657
-static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
658
-{
659
-    char c;
660
-    //Use all characters in narrow LCDs
661
-  #if LCD_WIDTH < 20
662
-      uint8_t n = LCD_WIDTH - 1 - 1 - lcd_strlen_P(data);
663
-    #else
664
-      uint8_t n = LCD_WIDTH - 1 - 2 - lcd_strlen_P(data);
665
-  #endif
666
-    lcd.setCursor(0, row);
667
-    lcd.print(pre_char);
668
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
669
-    {
670
-        lcd.print(c);
671
-        pstr++;
672
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
673
-    }
674
-    lcd.print(':');
675
-    while(n--)
676
-        lcd.print(' ');
677
-    lcd_printPGM(data);
642
+static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) {
643
+  char c;
644
+  uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen_P(data);
645
+  lcd.setCursor(0, row);
646
+  lcd.print(sel ? pre_char : ' ');
647
+  while ((c = pgm_read_byte(pstr)) && n > 0) {
648
+    lcd.print(c);
649
+    pstr++;
650
+    if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
651
+  }
652
+  lcd.print(':');
653
+  while (n--) lcd.print(' ');
654
+  lcd_printPGM(data);
678 655
 }
679
-#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
680
-#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
681
-#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
682
-#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
683
-#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
684
-#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
685
-#define lcd_implementation_drawmenu_setting_edit_float43_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
686
-#define lcd_implementation_drawmenu_setting_edit_float43(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
687
-#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
688
-#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
689
-#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
690
-#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
691
-#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
692
-#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
693
-#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
694
-#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
695
-#define lcd_implementation_drawmenu_setting_edit_bool_selected(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
696
-#define lcd_implementation_drawmenu_setting_edit_bool(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
656
+#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', itostr3(*(data)))
657
+#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr3(*(data)))
658
+#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr32(*(data)))
659
+#define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr43(*(data)))
660
+#define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
661
+#define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr52(*(data)))
662
+#define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr51(*(data)))
663
+#define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
664
+#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
697 665
 
698 666
 //Add version for callback functions
699
-#define lcd_implementation_drawmenu_setting_edit_callback_int3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
700
-#define lcd_implementation_drawmenu_setting_edit_callback_int3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
701
-#define lcd_implementation_drawmenu_setting_edit_callback_float3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
702
-#define lcd_implementation_drawmenu_setting_edit_callback_float3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
703
-#define lcd_implementation_drawmenu_setting_edit_callback_float32_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
704
-#define lcd_implementation_drawmenu_setting_edit_callback_float32(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
705
-#define lcd_implementation_drawmenu_setting_edit_callback_float43_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
706
-#define lcd_implementation_drawmenu_setting_edit_callback_float43(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
707
-#define lcd_implementation_drawmenu_setting_edit_callback_float5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
708
-#define lcd_implementation_drawmenu_setting_edit_callback_float5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
709
-#define lcd_implementation_drawmenu_setting_edit_callback_float52_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
710
-#define lcd_implementation_drawmenu_setting_edit_callback_float52(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
711
-#define lcd_implementation_drawmenu_setting_edit_callback_float51_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
712
-#define lcd_implementation_drawmenu_setting_edit_callback_float51(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
713
-#define lcd_implementation_drawmenu_setting_edit_callback_long5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
714
-#define lcd_implementation_drawmenu_setting_edit_callback_long5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
715
-#define lcd_implementation_drawmenu_setting_edit_callback_bool_selected(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
716
-#define lcd_implementation_drawmenu_setting_edit_callback_bool(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
717
-
718
-
719
-void lcd_implementation_drawedit(const char* pstr, char* value)
720
-{
721
-    lcd.setCursor(1, 1);
722
-    lcd_printPGM(pstr);
723
-    lcd.print(':');
724
-   #if LCD_WIDTH < 20
725
-      lcd.setCursor(LCD_WIDTH - lcd_strlen(value), 1);
726
-    #else
727
-      lcd.setCursor(LCD_WIDTH -1 - lcd_strlen(value), 1);
728
-   #endif
729
-    lcd.print(value);
730
-}
731
-static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
732
-{
733
-    char c;
734
-    uint8_t n = LCD_WIDTH - 1;
735
-    lcd.setCursor(0, row);
736
-    lcd.print('>');
737
-    if (longFilename[0] != '\0')
738
-    {
739
-        filename = longFilename;
740
-        longFilename[LCD_WIDTH-1] = '\0';
741
-    }
742
-    while( ((c = *filename) != '\0') && (n>0) )
743
-    {
744
-        lcd.print(c);
745
-        filename++;
746
-        n--;
747
-    }
748
-    while(n--)
749
-        lcd.print(' ');
667
+#define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', itostr3(*(data)))
668
+#define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr3(*(data)))
669
+#define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr32(*(data)))
670
+#define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr43(*(data)))
671
+#define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
672
+#define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr52(*(data)))
673
+#define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr51(*(data)))
674
+#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
675
+#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
676
+
677
+void lcd_implementation_drawedit(const char* pstr, char* value) {
678
+  lcd.setCursor(1, 1);
679
+  lcd_printPGM(pstr);
680
+  lcd.print(':');
681
+  lcd.setCursor(LCD_WIDTH - (LCD_WIDTH < 20 ? 0 : 1) - lcd_strlen(value), 1);
682
+  lcd.print(value);
750 683
 }
751
-static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
752
-{
753
-    char c;
754
-    uint8_t n = LCD_WIDTH - 1;
755
-    lcd.setCursor(0, row);
756
-    lcd.print(' ');
757
-    if (longFilename[0] != '\0')
758
-    {
759
-        filename = longFilename;
760
-        longFilename[LCD_WIDTH-1] = '\0';
761
-    }
762
-    while( ((c = *filename) != '\0') && (n>0) )
763
-    {
764
-        lcd.print(c);
765
-        filename++;
766
-        n--;
767
-    }
768
-    while(n--)
769
-        lcd.print(' ');
684
+static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat) {
685
+  char c;
686
+  uint8_t n = LCD_WIDTH - concat;
687
+  lcd.setCursor(0, row);
688
+  lcd.print(sel ? '>' : ' ');
689
+  if (longFilename[0]) {
690
+    filename = longFilename;
691
+    longFilename[n] = '\0';
692
+  }
693
+  while ((c = *filename) && n > 0) {
694
+    lcd.print(c);
695
+    filename++;
696
+    n--;
697
+  }
698
+  while (n--) lcd.print(' ');
770 699
 }
771
-static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
772
-{
773
-    char c;
774
-    uint8_t n = LCD_WIDTH - 2;
775
-    lcd.setCursor(0, row);
776
-    lcd.print('>');
777
-    lcd.print(LCD_STR_FOLDER[0]);
778
-    if (longFilename[0] != '\0')
779
-    {
780
-        filename = longFilename;
781
-        longFilename[LCD_WIDTH-2] = '\0';
782
-    }
783
-    while( ((c = *filename) != '\0') && (n>0) )
784
-    {
785
-        lcd.print(c);
786
-        filename++;
787
-        n--;
788
-    }
789
-    while(n--)
790
-        lcd.print(' ');
700
+
701
+static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
702
+  lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 1);
791 703
 }
792
-static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename)
793
-{
794
-    char c;
795
-    uint8_t n = LCD_WIDTH - 2;
796
-    lcd.setCursor(0, row);
797
-    lcd.print(' ');
798
-    lcd.print(LCD_STR_FOLDER[0]);
799
-    if (longFilename[0] != '\0')
800
-    {
801
-        filename = longFilename;
802
-        longFilename[LCD_WIDTH-2] = '\0';
803
-    }
804
-    while( ((c = *filename) != '\0') && (n>0) )
805
-    {
806
-        lcd.print(c);
807
-        filename++;
808
-        n--;
809
-    }
810
-    while(n--)
811
-        lcd.print(' ');
704
+static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
705
+  lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2);
812 706
 }
813
-#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
814
-#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
815
-#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
816
-#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
817
-#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
818
-#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
819
-#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
820
-#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
707
+#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
708
+#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
709
+#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, ' ', ' ')
710
+#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, ' ', ' ')
821 711
 
822 712
 static void lcd_implementation_quick_feedback()
823 713
 {

Laddar…
Avbryt
Spara