Explorar el Código

Merge https://github.com/MarlinFirmware/Marlin into tm2-utf-minus-kanji

Conflicts:
	Marlin/dogm_lcd_implementation.h
	Marlin/ultralcd_implementation_hitachi_HD44780.h
Fixed conflicts 1
AnHardt hace 10 años
padre
commit
6bfccaf99e

+ 2
- 2
Marlin/SdBaseFile.h Ver fichero

@@ -171,9 +171,9 @@ static inline uint8_t FAT_SECOND(uint16_t fatTime) {
171 171
   return 2*(fatTime & 0X1F);
172 172
 }
173 173
 /** Default date for file timestamps is 1 Jan 2000 */
174
-uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | BIT(5) | 1;
174
+uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1;
175 175
 /** Default time for file timestamp is 1 am */
176
-uint16_t const FAT_DEFAULT_TIME = BIT(11);
176
+uint16_t const FAT_DEFAULT_TIME = (1 << 11);
177 177
 //------------------------------------------------------------------------------
178 178
 /**
179 179
  * \class SdBaseFile

+ 0
- 1
Marlin/cardreader.cpp Ver fichero

@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() {
504 504
     startFileprint();
505 505
   }
506 506
   else {
507
-    quickStop();
508 507
     file.close();
509 508
     sdprinting = false;
510 509
     if (SD_FINISHED_STEPPERRELEASE) {

+ 51
- 74
Marlin/dogm_lcd_implementation.h Ver fichero

@@ -218,7 +218,7 @@ static void lcd_implementation_init()
218 218
       u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
219 219
       u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
220 220
     #endif
221
-	} while(u8g.nextPage());
221
+	} while (u8g.nextPage());
222 222
 }
223 223
 
224 224
 static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
@@ -295,6 +295,7 @@ static void lcd_implementation_status_screen() {
295 295
   #if defined(FAN_PIN) && FAN_PIN > -1
296 296
     int per = ((fanSpeed + 1) * 100) / 256;
297 297
     if (per) {
298
+
298 299
       lcd_print(itostr3(per));
299 300
       lcd_print('%');
300 301
     }
@@ -365,10 +366,10 @@ static void lcd_implementation_status_screen() {
365 366
   #endif
366 367
 }
367 368
 
368
-static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
369
-  if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0] )) {
369
+static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
370
+  if (isSelected) {
370 371
     u8g.setColorIndex(1);  // black on white
371
-    u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
372
+    u8g.drawBox(0, row * DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
372 373
     u8g.setColorIndex(0);  // following text must be white on black
373 374
   }
374 375
   else {
@@ -377,96 +378,78 @@ static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
377 378
   u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
378 379
 }
379 380
 
380
-static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
381
+static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
381 382
   char c;
382 383
   uint8_t n = LCD_WIDTH - 2;
383 384
 
384
-  lcd_implementation_mark_as_selected(row, pre_char);
385
+  lcd_implementation_mark_as_selected(row, isSelected);
385 386
 
386
-  while((c = pgm_read_byte(pstr))) {
387
+  while (c = pgm_read_byte(pstr)) {
387 388
     n -= lcd_print(c);
388 389
     pstr++;
389 390
   }
390
-  while(n--) lcd_print(' ');
391
+  while (n--) lcd_print(' ');
391 392
   lcd_print(post_char);
392 393
   lcd_print(' ');
393 394
 }
394 395
 
395
-static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
396
+static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
396 397
   char c;
397 398
   uint8_t n = LCD_WIDTH - 2 - (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
398 399
 
399
-  lcd_implementation_mark_as_selected(row, pre_char);
400
+  lcd_implementation_mark_as_selected(row, isSelected);
400 401
 
401
-  while( (c = pgm_read_byte(pstr))) {
402
+  while (c = pgm_read_byte(pstr)) {
402 403
     n -= lcd_print(c);
403 404
     pstr++;
404 405
   }
405 406
   lcd_print(':');
406
-  while(n--) lcd_print(' ');
407
+  while (n--) lcd_print(' ');
407 408
   if (pgm) { lcd_printPGM(data); } else { lcd_print((char *)data); }
408 409
 }
409 410
 
410
-#define lcd_implementation_drawmenu_setting_edit_generic(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, false)
411
-#define lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, true)
412
-
413
-#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
414
-#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
415
-#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
416
-#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
417
-#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
418
-#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
419
-#define lcd_implementation_drawmenu_setting_edit_float43_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
420
-#define lcd_implementation_drawmenu_setting_edit_float43(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
421
-#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
422
-#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
423
-#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
424
-#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
425
-#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
426
-#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
427
-#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
428
-#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
429
-#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))
430
-#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))
411
+#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
412
+#define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
413
+
414
+#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)))
415
+#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)))
416
+#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)))
417
+#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)))
418
+#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)))
419
+#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)))
420
+#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)))
421
+#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)))
422
+#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))
431 423
 
432 424
 //Add version for callback functions
433
-#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)))
434
-#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)))
435
-#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)))
436
-#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)))
437
-#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)))
438
-#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)))
439
-#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)))
440
-#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)))
441
-#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)))
442
-#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)))
443
-#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)))
444
-#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)))
445
-#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)))
446
-#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)))
447
-#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)))
448
-#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)))
449
-#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))
450
-#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))
425
+#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)))
426
+#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)))
427
+#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)))
428
+#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)))
429
+#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)))
430
+#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)))
431
+#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)))
432
+#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)))
433
+#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))
451 434
 
452 435
 void lcd_implementation_drawedit(const char* pstr, char* value) {
453 436
   uint8_t rows = 1;
454
-  uint8_t lcd_width = LCD_WIDTH;
455
-  uint8_t char_width = DOG_CHAR_WIDTH;
437
+  uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
438
+  uint8_t vallen = lcd_strlen(value);
456 439
 
457 440
   #ifdef USE_BIG_EDIT_FONT
458 441
     if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
459 442
       lcd_setFont(FONT_MENU_EDIT);
460 443
       lcd_width = LCD_WIDTH_EDIT + 1;
461 444
       char_width = DOG_CHAR_WIDTH_EDIT;
462
-      if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - lcd_strlen(value)) rows = 2;
445
+      if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
463 446
     }
464 447
     else {
465 448
       lcd_setFont(FONT_MENU);
466 449
     }
467 450
   #endif
468 451
 
469
-  if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - lcd_strlen(value)) rows = 2;
452
+  if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
470 453
 
471 454
   const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
472 455
   float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
@@ -474,42 +457,36 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
474 457
   u8g.setPrintPos(0, rowHeight + kHalfChar);
475 458
   lcd_printPGM(pstr);
476 459
   lcd_print(':');
477
-  u8g.setPrintPos((lcd_width-1-lcd_strlen(value)) * char_width, rows * rowHeight + kHalfChar);
460
+  u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
478 461
   lcd_print(value);
479 462
 }
480 463
 
481
-static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir, bool isSelected) {
464
+static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir) {
482 465
   char c;
483 466
   uint8_t n = LCD_WIDTH - 1;
484 467
 
485
-  if (longFilename[0] != '\0') {
468
+  if (longFilename[0]) {
486 469
     filename = longFilename;
487 470
     longFilename[n] = '\0';
488 471
   }
489 472
 
490
-  lcd_implementation_mark_as_selected(row, ((isSelected) ? '>' : ' '));
473
+  lcd_implementation_mark_as_selected(row, isSelected);
491 474
 
492 475
   if (isDir) lcd_print(LCD_STR_FOLDER[0]);
493
-  while((c = *filename) != '\0') {
476
+  while (c = *filename) {
494 477
     n -= lcd_print(c);
495 478
     filename++;
496 479
   }
497
-  while(n--) lcd_print(' ');
480
+  while (n--) lcd_print(' ');
498 481
 }
499 482
 
500
-#define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)
501
-#define lcd_implementation_drawmenu_sdfile(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, false)
502
-#define lcd_implementation_drawmenu_sddirectory_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, true)
503
-#define lcd_implementation_drawmenu_sddirectory(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, false)
504
-
505
-#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
506
-#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
507
-#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
508
-#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
509
-#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
510
-#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
511
-#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
512
-#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
483
+#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)
484
+#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, true)
485
+
486
+#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
487
+#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
488
+#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
489
+#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
513 490
 
514 491
 static void lcd_implementation_quick_feedback() {
515 492
   #if BEEPER > -1

+ 13
- 0
Marlin/stepper.cpp Ver fichero

@@ -46,6 +46,7 @@ block_t *current_block;  // A pointer to the block currently being traced
46 46
 
47 47
 // Variables used by The Stepper Driver Interrupt
48 48
 static unsigned char out_bits;        // The next stepping-bits to be output
49
+static unsigned int cleaning_buffer_counter;  
49 50
 
50 51
 // Counter variables for the bresenham line tracer
51 52
 static long counter_x, counter_y, counter_z, counter_e;
@@ -346,6 +347,17 @@ FORCE_INLINE void trapezoid_generator_reset() {
346 347
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
347 348
 // It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
348 349
 ISR(TIMER1_COMPA_vect) {
350
+
351
+  if(cleaning_buffer_counter)
352
+  {
353
+    current_block = NULL;
354
+    plan_discard_current_block();
355
+    if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
356
+    cleaning_buffer_counter--;
357
+    OCR1A = 200;
358
+    return;
359
+  }
360
+  
349 361
   // If there is no current block, attempt to pop one from the buffer
350 362
   if (!current_block) {
351 363
     // Anything in the buffer?
@@ -972,6 +984,7 @@ void finishAndDisableSteppers() {
972 984
 }
973 985
 
974 986
 void quickStop() {
987
+  cleaning_buffer_counter = 5000;
975 988
   DISABLE_STEPPER_DRIVER_INTERRUPT();
976 989
   while (blocks_queued()) plan_discard_current_block();
977 990
   current_block = NULL;

+ 65
- 50
Marlin/ultralcd.cpp Ver fichero

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

+ 84
- 181
Marlin/ultralcd_implementation_hitachi_HD44780.h Ver fichero

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

Loading…
Cancelar
Guardar