Преглед изворни кода

Various fixes for MarlinUI and ExtUI (#12439)

Marcio Teixeira пре 5 година
родитељ
комит
c1e17037e5

+ 5
- 0
Marlin/Makefile Прегледај датотеку

@@ -510,6 +510,7 @@ else ifeq ($(HARDWARE_VARIANT), archim)
510 510
   VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/USB
511 511
   VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/Wire/src
512 512
   VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/SPI/src
513
+  VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/U8glib/src/clib
513 514
   VPATH   += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim
514 515
   LDSCRIPT = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/linker_scripts/gcc/flash.ld
515 516
   LDLIBS   = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/libsam_sam3x8e_gcc_rel.a
@@ -611,6 +612,10 @@ else ifeq ($(HARDWARE_VARIANT), archim)
611 612
   CDEFS      += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__ -DUSB_VID=0x27b1 -DUSB_PID=0x0001 -DUSBCON '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT="Archim"'
612 613
   LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp UARTClass.cpp  USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp PluggableUSB.cpp  USBCore.cpp
613 614
   LIB_SRC    += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
615
+
616
+  ifeq ($(U8GLIB), 1)
617
+    LIB_SRC += u8g_com_api.c u8g_pb32h1.c
618
+  endif
614 619
 endif
615 620
 
616 621
 # Add all the source directories as include directories too

+ 1
- 1
Marlin/src/core/macros.h Прегледај датотеку

@@ -196,7 +196,7 @@
196 196
 #define MMM_TO_MMS(MM_M) ((MM_M)/60.0f)
197 197
 #define MMS_TO_MMM(MM_S) ((MM_S)*60.0f)
198 198
 
199
-#define NOOP do{} while(0)
199
+#define NOOP (0)
200 200
 
201 201
 #define CEILING(x,y) (((x) + (y) - 1) / (y))
202 202
 

+ 2
- 2
Marlin/src/core/serial.cpp Прегледај датотеку

@@ -25,8 +25,8 @@
25 25
 
26 26
 uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE;
27 27
 
28
-const char errormagic[] PROGMEM = "Error:";
29
-const char echomagic[]  PROGMEM = "echo:";
28
+static const char errormagic[] PROGMEM = "Error:";
29
+static const char echomagic[]  PROGMEM = "echo:";
30 30
 
31 31
 #if NUM_SERIAL > 1
32 32
   void serialprintPGM_P(const int8_t p, const char * str) {

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Прегледај датотеку

@@ -917,7 +917,7 @@
917 917
     }
918 918
 
919 919
     inline void set_message_with_feedback(PGM_P const msg_P) {
920
-      ui.setstatusPGM(msg_P);
920
+      ui.set_status_P(msg_P);
921 921
       ui.quick_feedback();
922 922
     }
923 923
 

+ 7
- 2
Marlin/src/feature/pause.cpp Прегледај датотеку

@@ -399,14 +399,19 @@ bool pause_print(const float &retract, const point_t &park_point, const float &u
399 399
 }
400 400
 
401 401
 /**
402
+ * For Paused Print:
403
+ * - Show "Press button (or M108) to resume"
404
+ *
405
+ * For Filament Change:
402 406
  * - Show "Insert filament and press button to continue"
407
+ *
403 408
  * - Wait for a click before returning
404
- * - Heaters can time out, reheated before accepting a click
409
+ * - Heaters can time out and must reheat before continuing
405 410
  *
406 411
  * Used by M125 and M600
407 412
  */
408 413
 
409
-#if HAS_LCD_MENU && ENABLED(EMERGENCY_PARSER)
414
+#if (HAS_LCD_MENU || ENABLED(EXTENSIBLE_UI)) && ENABLED(EMERGENCY_PARSER)
410 415
   #define _PMSG(L) L
411 416
 #elif ENABLED(EMERGENCY_PARSER)
412 417
   #define _PMSG(L) L##_M108

+ 7
- 7
Marlin/src/gcode/bedlevel/G26.cpp Прегледај датотеку

@@ -164,7 +164,7 @@ int8_t g26_prime_flag;
164 164
    */
165 165
   bool user_canceled() {
166 166
     if (!ui.button_pressed()) return false; // Return if the button isn't pressed
167
-    ui.setstatusPGM(PSTR("Mesh Validation Stopped."), 99);
167
+    ui.set_status_P(PSTR("Mesh Validation Stopped."), 99);
168 168
     #if HAS_LCD_MENU
169 169
       ui.quick_feedback();
170 170
     #endif
@@ -414,7 +414,7 @@ inline bool turn_on_heaters() {
414 414
 
415 415
     if (g26_bed_temp > 25) {
416 416
       #if ENABLED(ULTRA_LCD)
417
-        ui.setstatusPGM(PSTR("G26 Heating Bed."), 99);
417
+        ui.set_status_P(PSTR("G26 Heating Bed."), 99);
418 418
         ui.quick_feedback();
419 419
         #if HAS_LCD_MENU
420 420
           ui.capture();
@@ -435,7 +435,7 @@ inline bool turn_on_heaters() {
435 435
 
436 436
   // Start heating the active nozzle
437 437
   #if ENABLED(ULTRA_LCD)
438
-    ui.setstatusPGM(PSTR("G26 Heating Nozzle."), 99);
438
+    ui.set_status_P(PSTR("G26 Heating Nozzle."), 99);
439 439
     ui.quick_feedback();
440 440
   #endif
441 441
   thermalManager.setTargetHotend(g26_hotend_temp, active_extruder);
@@ -469,7 +469,7 @@ inline bool prime_nozzle() {
469 469
     if (g26_prime_flag == -1) {  // The user wants to control how much filament gets purged
470 470
 
471 471
       ui.capture();
472
-      ui.setstatusPGM(PSTR("User-Controlled Prime"), 99);
472
+      ui.set_status_P(PSTR("User-Controlled Prime"), 99);
473 473
       ui.chirp();
474 474
 
475 475
       set_destination_from_current();
@@ -493,7 +493,7 @@ inline bool prime_nozzle() {
493 493
 
494 494
       ui.wait_for_release();
495 495
 
496
-      ui.setstatusPGM(PSTR("Done Priming"), 99);
496
+      ui.set_status_P(PSTR("Done Priming"), 99);
497 497
       ui.quick_feedback();
498 498
       ui.release();
499 499
     }
@@ -501,7 +501,7 @@ inline bool prime_nozzle() {
501 501
   #endif
502 502
   {
503 503
     #if ENABLED(ULTRA_LCD)
504
-      ui.setstatusPGM(PSTR("Fixed Length Prime."), 99);
504
+      ui.set_status_P(PSTR("Fixed Length Prime."), 99);
505 505
       ui.quick_feedback();
506 506
     #endif
507 507
     set_destination_from_current();
@@ -894,7 +894,7 @@ void GcodeSuite::G26() {
894 894
   } while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0);
895 895
 
896 896
   LEAVE:
897
-  ui.setstatusPGM(PSTR("Leaving G26"), -1);
897
+  ui.set_status_P(PSTR("Leaving G26"), -1);
898 898
 
899 899
   retract_filament(destination);
900 900
   destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES;

+ 4
- 4
Marlin/src/gcode/calibrate/G33.cpp Прегледај датотеку

@@ -522,7 +522,7 @@ void GcodeSuite::G33() {
522 522
   if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
523 523
   if (set_up) SERIAL_PROTOCOLPGM("  (SET-UP)");
524 524
   SERIAL_EOL();
525
-  ui.setstatusPGM(checkingac);
525
+  ui.set_status_P(checkingac);
526 526
 
527 527
   print_calibration_settings(_endstop_results, _angle_results);
528 528
 
@@ -683,7 +683,7 @@ void GcodeSuite::G33() {
683 683
           sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev_min * 1000.0));
684 684
         else
685 685
           sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev_min));
686
-        ui.setstatus(mess);
686
+        ui.set_status(mess);
687 687
         print_calibration_settings(_endstop_results, _angle_results);
688 688
         serialprintPGM(save_message);
689 689
         SERIAL_EOL();
@@ -699,7 +699,7 @@ void GcodeSuite::G33() {
699 699
         SERIAL_PROTOCOLPGM("std dev:");
700 700
         SERIAL_PROTOCOL_F(zero_std_dev, 3);
701 701
         SERIAL_EOL();
702
-        ui.setstatus(mess);
702
+        ui.set_status(mess);
703 703
         if (verbose_level > 1)
704 704
           print_calibration_settings(_endstop_results, _angle_results);
705 705
       }
@@ -719,7 +719,7 @@ void GcodeSuite::G33() {
719 719
         sprintf_P(&mess[15], PSTR("0.%03i"), (int)LROUND(zero_std_dev * 1000.0));
720 720
       else
721 721
         sprintf_P(&mess[15], PSTR("%03i.x"), (int)LROUND(zero_std_dev));
722
-      ui.setstatus(mess);
722
+      ui.set_status(mess);
723 723
     }
724 724
     ac_home();
725 725
   }

+ 1
- 1
Marlin/src/gcode/lcd/M0_M1.cpp Прегледај датотеку

@@ -62,7 +62,7 @@ void GcodeSuite::M0_M1() {
62 62
   #if HAS_LCD_MENU
63 63
 
64 64
     if (has_message)
65
-      ui.setstatus(args, true);
65
+      ui.set_status(args, true);
66 66
     else {
67 67
       LCD_MESSAGEPGM(MSG_USERWAIT);
68 68
       #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0

+ 1
- 1
Marlin/src/gcode/lcd/M117.cpp Прегледај датотеку

@@ -28,6 +28,6 @@
28 28
  */
29 29
 void GcodeSuite::M117() {
30 30
 
31
-  ui.setstatus(parser.string_arg);
31
+  ui.set_status(parser.string_arg);
32 32
 
33 33
 }

+ 3
- 0
Marlin/src/gcode/sdcard/M20-M30_M32-M34_M524_M928.cpp Прегледај датотеку

@@ -28,6 +28,7 @@
28 28
 #include "../../sd/cardreader.h"
29 29
 #include "../../module/printcounter.h"
30 30
 #include "../../module/stepper.h"
31
+#include "../../lcd/ultralcd.h"
31 32
 
32 33
 #if ENABLED(POWER_LOSS_RECOVERY)
33 34
   #include "../../feature/power_loss_recovery.h"
@@ -100,6 +101,8 @@ void GcodeSuite::M24() {
100 101
     else
101 102
   #endif
102 103
       print_job_timer.start();
104
+
105
+  ui.reset_status();
103 106
 }
104 107
 
105 108
 /**

+ 1
- 1
Marlin/src/gcode/stats/M31.cpp Прегледај датотеку

@@ -40,7 +40,7 @@ void GcodeSuite::M31() {
40 40
   char buffer[21];
41 41
   duration_t elapsed = print_job_timer.duration();
42 42
   elapsed.toString(buffer);
43
-  ui.setstatus(buffer);
43
+  ui.set_status(buffer);
44 44
 
45 45
   SERIAL_ECHO_START_P(port);
46 46
   SERIAL_ECHOLNPAIR_P(port, "Print time: ", buffer);

+ 1
- 1
Marlin/src/gcode/temperature/M140_M190.cpp Прегледај датотеку

@@ -64,7 +64,7 @@ void GcodeSuite::M190() {
64 64
   }
65 65
   else return;
66 66
 
67
-  ui.setstatusPGM(thermalManager.isHeatingBed() ? PSTR(MSG_BED_HEATING) : PSTR(MSG_BED_COOLING));
67
+  ui.set_status_P(thermalManager.isHeatingBed() ? PSTR(MSG_BED_HEATING) : PSTR(MSG_BED_COOLING));
68 68
 
69 69
   thermalManager.wait_for_bed(no_wait_for_cooling);
70 70
 }

+ 4
- 8
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp Прегледај датотеку

@@ -99,10 +99,6 @@ void ST7920_Lite_Status_Screen::write_str_P(PGM_P const str) {
99 99
   while (char c = pgm_read_byte(p_str++)) write_byte(c);
100 100
 }
101 101
 
102
-void ST7920_Lite_Status_Screen::write_str(progmem_str str) {
103
-  write_str_P((PGM_P)str);
104
-}
105
-
106 102
 void ST7920_Lite_Status_Screen::write_number(const int16_t value, const uint8_t digits/*=3*/) {
107 103
   char str[7];
108 104
   PGM_P fmt;
@@ -501,11 +497,11 @@ void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) {
501 497
   // Draw centered
502 498
   if (value > 9) {
503 499
     write_number(value, 4);
504
-    write_str(F("% "));
500
+    write_str_P(PSTR("% "));
505 501
   }
506 502
   else {
507 503
     write_number(value, 3);
508
-    write_str(F("%  "));
504
+    write_str_P(PSTR("%  "));
509 505
   }
510 506
 }
511 507
 
@@ -558,12 +554,12 @@ void ST7920_Lite_Status_Screen::draw_temps(uint8_t line, const int16_t temp, con
558 554
   write_number(temp);
559 555
 
560 556
   if (showTarget) {
561
-    write_str(F("\x1A"));
557
+    write_byte('\x1A');
562 558
     write_number(target);
563 559
   };
564 560
 
565 561
   if (targetStateChange) {
566
-    if (!showTarget) write_str(F("    "));
562
+    if (!showTarget) write_str_P(PSTR("    "));
567 563
     draw_degree_symbol(5, line, !showTarget);
568 564
     draw_degree_symbol(9, line,  showTarget);
569 565
   }

+ 0
- 3
Marlin/src/lcd/dogm/status_screen_lite_ST7920.h Прегледај датотеку

@@ -18,8 +18,6 @@
18 18
 #include "../../core/macros.h"
19 19
 #include "../../libs/duration_t.h"
20 20
 
21
-typedef const __FlashStringHelper *progmem_str;
22
-
23 21
 class ST7920_Lite_Status_Screen {
24 22
   private:
25 23
     static struct st7920_state_t {
@@ -47,7 +45,6 @@ class ST7920_Lite_Status_Screen {
47 45
     static void write_str(const char *str);
48 46
     static void write_str(const char *str, const uint8_t len);
49 47
     static void write_str_P(PGM_P const str);
50
-    static void write_str(progmem_str str);
51 48
     static void write_number(const int16_t value, const uint8_t digits=3);
52 49
 
53 50
     static void _extended_function_set(const bool extended, const bool graphics);

+ 1
- 2
Marlin/src/lcd/extensible_ui/lib/example.cpp Прегледај датотеку

@@ -55,8 +55,7 @@ namespace ExtUI {
55 55
   void onPrintTimerPaused() {}
56 56
   void onPrintTimerStopped() {}
57 57
   void onFilamentRunout() {}
58
-  void onStatusChanged(const char* msg) {}
59
-  void onStatusChanged(progmem_str msg) {}
58
+  void onStatusChanged(const char * const msg) {}
60 59
   void onFactoryReset() {}
61 60
   void onLoadSettings() {}
62 61
   void onStoreSettings() {}

+ 27
- 38
Marlin/src/lcd/extensible_ui/ui_api.cpp Прегледај датотеку

@@ -94,6 +94,7 @@ static struct {
94 94
 } flags;
95 95
 
96 96
 namespace ExtUI {
97
+
97 98
   #ifdef __SAM3X8E__
98 99
     /**
99 100
      * Implement a special millis() to allow time measurement
@@ -134,12 +135,7 @@ namespace ExtUI {
134 135
       return (uint32_t)(currTime / (F_CPU / 8000));
135 136
     }
136 137
 
137
-  #else
138
-
139
-    // TODO: Implement for AVR
140
-    FORCE_INLINE uint32_t safe_millis() { return millis(); }
141
-
142
-  #endif
138
+  #endif // __SAM3X8E__
143 139
 
144 140
   void delay_us(unsigned long us) {
145 141
     DELAY_US(us);
@@ -287,12 +283,14 @@ namespace ExtUI {
287 283
   }
288 284
 
289 285
   void setActiveTool(const extruder_t extruder, bool no_move) {
290
-    const uint8_t e = extruder - E0;
291
-    #if DO_SWITCH_EXTRUDER || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)
292
-      if (e != active_extruder)
293
-        tool_change(e, 0, no_move);
286
+    #if EXTRUDERS > 1
287
+      const uint8_t e = extruder - E0;
288
+      #if DO_SWITCH_EXTRUDER || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)
289
+        if (e != active_extruder)
290
+          tool_change(e, 0, no_move);
291
+      #endif
292
+      active_extruder = e;
294 293
     #endif
295
-    active_extruder = e;
296 294
   }
297 295
 
298 296
   extruder_t getActiveTool() {
@@ -533,24 +531,26 @@ namespace ExtUI {
533 531
 
534 532
   float getFeedrate_percent() { return feedrate_percentage; }
535 533
 
536
-  void enqueueCommands(progmem_str gcode) {
537
-    enqueue_and_echo_commands_P((PGM_P)gcode);
534
+  void enqueueCommands_P(PGM_P const gcode) {
535
+    enqueue_and_echo_commands_P(gcode);
538 536
   }
539 537
 
540 538
   bool isAxisPositionKnown(const axis_t axis) {
541 539
     return TEST(axis_known_position, axis);
542 540
   }
543 541
 
544
-  progmem_str getFirmwareName_str() {
545
-    return F("Marlin " SHORT_BUILD_VERSION);
542
+  PGM_P getFirmwareName_str() {
543
+    static const char firmware_name[] PROGMEM = "Marlin " SHORT_BUILD_VERSION;
544
+    return firmware_name;
546 545
   }
547 546
 
548 547
   void setTargetTemp_celsius(float value, const heater_t heater) {
549 548
     #if HAS_HEATED_BED
550
-    if (heater == BED)
551
-      thermalManager.setTargetBed(clamp(value,0,200));
549
+      if (heater == BED)
550
+        thermalManager.setTargetBed(clamp(value,0,200));
551
+      else
552 552
     #endif
553
-      thermalManager.setTargetHotend(clamp(value,0,500), heater - H0);
553
+        thermalManager.setTargetHotend(clamp(value,0,500), heater - H0);
554 554
   }
555 555
 
556 556
   void setTargetTemp_celsius(float value, const extruder_t extruder) {
@@ -579,7 +579,7 @@ namespace ExtUI {
579 579
   }
580 580
 
581 581
   bool isPrinting() {
582
-    return (planner.movesplanned() || IS_SD_PRINTING() || isPrintingFromMedia());
582
+    return (planner.movesplanned() || isPrintingFromMedia() || IFSD(IS_SD_PRINTING(), false));
583 583
   }
584 584
 
585 585
   bool isMediaInserted() {
@@ -593,19 +593,20 @@ namespace ExtUI {
593 593
       #if ENABLED(PARK_HEAD_ON_PAUSE)
594 594
         enqueue_and_echo_commands_P(PSTR("M125"));
595 595
       #endif
596
-      ExtUI::onStatusChanged(PSTR(MSG_PRINT_PAUSED));
596
+      ui.set_status_P(PSTR(MSG_PRINT_PAUSED));
597 597
     #endif
598 598
   }
599 599
 
600 600
   void resumePrint() {
601 601
     #if ENABLED(SDSUPPORT)
602
+      ui.set_status_P(PSTR(MSG_FILAMENT_CHANGE_RESUME_1));
602 603
       #if ENABLED(PARK_HEAD_ON_PAUSE)
604
+        wait_for_heatup = wait_for_user = false;
603 605
         enqueue_and_echo_commands_P(PSTR("M24"));
604 606
       #else
605 607
         card.startFileprint();
606 608
         print_job_timer.start();
607 609
       #endif
608
-      ExtUI::onStatusChanged(PSTR(MSG_PRINTING));
609 610
     #endif
610 611
   }
611 612
 
@@ -613,7 +614,7 @@ namespace ExtUI {
613 614
     #if ENABLED(SDSUPPORT)
614 615
       wait_for_heatup = wait_for_user = false;
615 616
       card.flag.abort_sd_printing = true;
616
-      ExtUI::onStatusChanged(PSTR(MSG_PRINT_ABORTED));
617
+      ui.set_status_P(PSTR(MSG_PRINT_ABORTED));
617 618
     #endif
618 619
   }
619 620
 
@@ -621,7 +622,7 @@ namespace ExtUI {
621 622
 
622 623
   void FileList::refresh() { num_files = 0xFFFF; }
623 624
 
624
-  bool FileList::seek(uint16_t pos, bool skip_range_check) {
625
+  bool FileList::seek(const uint16_t pos, const bool skip_range_check) {
625 626
     #if ENABLED(SDSUPPORT)
626 627
       if (!skip_range_check && pos > (count() - 1)) return false;
627 628
       const uint16_t nr =
@@ -632,6 +633,8 @@ namespace ExtUI {
632 633
 
633 634
       card.getfilename_sorted(nr);
634 635
       return card.filename && card.filename[0] != '\0';
636
+    #else
637
+      return false;
635 638
     #endif
636 639
   }
637 640
 
@@ -671,7 +674,7 @@ namespace ExtUI {
671 674
     #endif
672 675
   }
673 676
 
674
-  void FileList::changeDir(const char *dirname) {
677
+  void FileList::changeDir(const char * const dirname) {
675 678
     #if ENABLED(SDSUPPORT)
676 679
       card.chdir(dirname);
677 680
       num_files = 0xFFFF;
@@ -713,20 +716,6 @@ void MarlinUI::update() {
713 716
   ExtUI::onIdle();
714 717
 }
715 718
 
716
-void MarlinUI::setstatus(const char * const message, const bool persist/*=false*/)  { ExtUI::onStatusChanged(message); }
717
-void MarlinUI::setstatusPGM(PGM_P const message, int8_t level/*=0*/)                { ExtUI::onStatusChanged((progmem_str)message); }
718
-void MarlinUI::setalertstatusPGM(PGM_P const message)                               { setstatusPGM(message, 0); }
719
-
720
-void MarlinUI::status_printf_P(const uint8_t level, const char * const fmt, ...) {
721
-  char buff[64];
722
-  va_list args;
723
-  va_start(args, fmt);
724
-  vsnprintf_P(buff, sizeof(buff), fmt, args);
725
-  va_end(args);
726
-  buff[63] = '\0';
727
-  ExtUI::onStatusChanged(buff);
728
-}
729
-
730 719
 void MarlinUI::kill_screen(PGM_P const msg) {
731 720
   if (!flags.printer_killed) {
732 721
     flags.printer_killed = true;

+ 11
- 9
Marlin/src/lcd/extensible_ui/ui_api.h Прегледај датотеку

@@ -45,8 +45,6 @@
45 45
 
46 46
 #include "../../inc/MarlinConfig.h"
47 47
 
48
-typedef const __FlashStringHelper *progmem_str;
49
-
50 48
 namespace ExtUI {
51 49
 
52 50
   enum axis_t     : uint8_t { X, Y, Z };
@@ -62,13 +60,13 @@ namespace ExtUI {
62 60
   bool isAxisPositionKnown(const axis_t);
63 61
   bool canMove(const axis_t);
64 62
   bool canMove(const extruder_t);
65
-  void enqueueCommands(progmem_str);
63
+  void enqueueCommands_P(PGM_P const);
66 64
 
67 65
   /**
68 66
    * Getters and setters
69 67
    * Should be used by the EXTENSIBLE_UI to query or change Marlin's state.
70 68
    */
71
-  progmem_str getFirmwareName_str();
69
+  PGM_P getFirmwareName_str();
72 70
 
73 71
   float getActualTemp_celsius(const heater_t);
74 72
   float getActualTemp_celsius(const extruder_t);
@@ -178,7 +176,12 @@ namespace ExtUI {
178 176
    * safe_millis must be called at least every 1 sec to guarantee time
179 177
    * yield should be called within lengthy loops
180 178
    */
181
-  uint32_t safe_millis();
179
+  #ifdef __SAM3X8E__
180
+    uint32_t safe_millis();
181
+  #else
182
+    #define safe_millis() millis() // TODO: Implement for AVR
183
+  #endif
184
+
182 185
   void delay_us(unsigned long us);
183 186
   void delay_ms(unsigned long ms);
184 187
   void yield();
@@ -205,14 +208,14 @@ namespace ExtUI {
205 208
     public:
206 209
       FileList();
207 210
       void refresh();
208
-      bool seek(uint16_t, bool skip_range_check = false);
211
+      bool seek(const uint16_t, const bool skip_range_check = false);
209 212
 
210 213
       const char *longFilename();
211 214
       const char *shortFilename();
212 215
       const char *filename();
213 216
       bool isDir();
214 217
 
215
-      void changeDir(const char *dirname);
218
+      void changeDir(const char * const dirname);
216 219
       void upDir();
217 220
       bool isAtRootDir();
218 221
       uint16_t    count();
@@ -234,8 +237,7 @@ namespace ExtUI {
234 237
   void onPrintTimerPaused();
235 238
   void onPrintTimerStopped();
236 239
   void onFilamentRunout();
237
-  void onStatusChanged(const char* msg);
238
-  void onStatusChanged(progmem_str msg);
240
+  void onStatusChanged(const char * const msg);
239 241
   void onFactoryReset();
240 242
   void onStoreSettings();
241 243
   void onLoadSettings();

+ 1
- 1
Marlin/src/lcd/malyanlcd.cpp Прегледај датотеку

@@ -480,7 +480,7 @@ void MarlinUI::init() {
480 480
 /**
481 481
  * Set an alert.
482 482
  */
483
-void MarlinUI::setalertstatusPGM(PGM_P const message) {
483
+void MarlinUI::set_alert_status_P(PGM_P const message) {
484 484
   write_to_lcd_P(PSTR("{E:"));
485 485
   write_to_lcd_P(message);
486 486
   write_to_lcd_P("}");

+ 1
- 1
Marlin/src/lcd/menu/menu_main.cpp Прегледај датотеку

@@ -59,7 +59,7 @@
59 59
   void lcd_sdcard_stop() {
60 60
     wait_for_heatup = wait_for_user = false;
61 61
     card.flag.abort_sd_printing = true;
62
-    ui.setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
62
+    ui.set_status_P(PSTR(MSG_PRINT_ABORTED), -1);
63 63
     ui.return_to_status();
64 64
   }
65 65
 

+ 101
- 85
Marlin/src/lcd/ultralcd.cpp Прегледај датотеку

@@ -29,6 +29,16 @@
29 29
     #include "../sd/cardreader.h"
30 30
   #endif
31 31
   MarlinUI ui;
32
+  #if ENABLED(SDSUPPORT)
33
+    #include "../sd/cardreader.h"
34
+  #endif
35
+  #if ENABLED(EXTENSIBLE_UI)
36
+    #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80u)
37
+  #endif
38
+
39
+  #define MAX_MESSAGE_LENGTH 63
40
+  uint8_t MarlinUI::status_message_level; // = 0
41
+  char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
32 42
 #endif
33 43
 
34 44
 #if HAS_SPI_LCD
@@ -86,9 +96,7 @@
86 96
   bool MarlinUI::defer_return_to_status;
87 97
 #endif
88 98
 
89
-char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
90 99
 uint8_t MarlinUI::lcd_status_update_delay = 1; // First update one loop delayed
91
-uint8_t MarlinUI::status_message_level; // = 0
92 100
 
93 101
 #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
94 102
   millis_t MarlinUI::next_filament_display; // = 0
@@ -475,7 +483,7 @@ void MarlinUI::status_screen() {
475 483
 
476 484
 void MarlinUI::kill_screen(PGM_P lcd_msg) {
477 485
   init();
478
-  setalertstatusPGM(lcd_msg);
486
+  set_alert_status_P(lcd_msg);
479 487
   draw_kill_screen();
480 488
 }
481 489
 
@@ -674,11 +682,11 @@ void MarlinUI::update() {
674 682
         if (old_sd_status == 2)
675 683
           card.beginautostart();  // Initial boot
676 684
         else
677
-          setstatusPGM(PSTR(MSG_SD_INSERTED));
685
+          set_status_P(PSTR(MSG_SD_INSERTED));
678 686
       }
679 687
       else {
680 688
         card.release();
681
-        if (old_sd_status != 2) setstatusPGM(PSTR(MSG_SD_REMOVED));
689
+        if (old_sd_status != 2) set_status_P(PSTR(MSG_SD_REMOVED));
682 690
       }
683 691
 
684 692
       refresh();
@@ -1083,110 +1091,118 @@ void MarlinUI::update() {
1083 1091
 
1084 1092
 #endif // HAS_ENCODER_ACTION
1085 1093
 
1086
-////////////////////////////////////////////
1087
-/////////////// Status Line ////////////////
1088
-////////////////////////////////////////////
1094
+#endif // HAS_SPI_LCD
1089 1095
 
1090
-void MarlinUI::finishstatus(const bool persist) {
1096
+#if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)
1091 1097
 
1092
-  #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
1093
-    UNUSED(persist);
1098
+  #if ENABLED(EXTENSIBLE_UI)
1099
+    #include "extensible_ui/ui_api.h"
1094 1100
   #endif
1095 1101
 
1096
-  #if ENABLED(LCD_PROGRESS_BAR)
1097
-    progress_bar_ms = millis();
1098
-    #if PROGRESS_MSG_EXPIRE > 0
1099
-      expire_status_ms = persist ? 0 : progress_bar_ms + PROGRESS_MSG_EXPIRE;
1102
+  ////////////////////////////////////////////
1103
+  /////////////// Status Line ////////////////
1104
+  ////////////////////////////////////////////
1105
+
1106
+  void MarlinUI::finishstatus(const bool persist) {
1107
+
1108
+    #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
1109
+      UNUSED(persist);
1100 1110
     #endif
1101
-  #endif
1102 1111
 
1103
-  #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
1104
-    next_filament_display = millis() + 5000UL; // Show status message for 5s
1105
-  #endif
1112
+    #if ENABLED(LCD_PROGRESS_BAR)
1113
+      progress_bar_ms = millis();
1114
+      #if PROGRESS_MSG_EXPIRE > 0
1115
+        expire_status_ms = persist ? 0 : progress_bar_ms + PROGRESS_MSG_EXPIRE;
1116
+      #endif
1117
+    #endif
1106 1118
 
1107
-  #if ENABLED(STATUS_MESSAGE_SCROLLING)
1108
-    status_scroll_offset = 0;
1109
-  #endif
1119
+    #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
1120
+      next_filament_display = millis() + 5000UL; // Show status message for 5s
1121
+    #endif
1110 1122
 
1111
-  refresh();
1112
-}
1123
+    #if ENABLED(STATUS_MESSAGE_SCROLLING)
1124
+      status_scroll_offset = 0;
1125
+    #endif
1113 1126
 
1114
-bool MarlinUI::has_status() { return (status_message[0] != '\0'); }
1127
+    #if ENABLED(EXTENSIBLE_UI)
1128
+      ExtUI::onStatusChanged(status_message);
1129
+    #endif
1115 1130
 
1116
-void MarlinUI::setstatus(const char * const message, const bool persist) {
1117
-  if (status_message_level > 0) return;
1131
+    refresh();
1132
+  }
1118 1133
 
1119
-  // Here we have a problem. The message is encoded in UTF8, so
1120
-  // arbitrarily cutting it will be a problem. We MUST be sure
1121
-  // that there is no cutting in the middle of a multibyte character!
1134
+  bool MarlinUI::has_status() { return (status_message[0] != '\0'); }
1122 1135
 
1123
-  // Get a pointer to the null terminator
1124
-  const char* pend = message + strlen(message);
1136
+  void MarlinUI::set_status(const char * const message, const bool persist) {
1137
+    if (status_message_level > 0) return;
1125 1138
 
1126
-  //  If length of supplied UTF8 string is greater than
1127
-  // our buffer size, start cutting whole UTF8 chars
1128
-  while ((pend - message) > MAX_MESSAGE_LENGTH) {
1129
-    --pend;
1130
-    while (!START_OF_UTF8_CHAR(*pend)) --pend;
1131
-  };
1139
+    // Here we have a problem. The message is encoded in UTF8, so
1140
+    // arbitrarily cutting it will be a problem. We MUST be sure
1141
+    // that there is no cutting in the middle of a multibyte character!
1132 1142
 
1133
-  // At this point, we have the proper cut point. Use it
1134
-  uint8_t maxLen = pend - message;
1135
-  strncpy(status_message, message, maxLen);
1136
-  status_message[maxLen] = '\0';
1143
+    // Get a pointer to the null terminator
1144
+    const char* pend = message + strlen(message);
1137 1145
 
1138
-  finishstatus(persist);
1139
-}
1146
+    //  If length of supplied UTF8 string is greater than
1147
+    // our buffer size, start cutting whole UTF8 chars
1148
+    while ((pend - message) > MAX_MESSAGE_LENGTH) {
1149
+      --pend;
1150
+      while (!START_OF_UTF8_CHAR(*pend)) --pend;
1151
+    };
1140 1152
 
1141
-#include <stdarg.h>
1153
+    // At this point, we have the proper cut point. Use it
1154
+    uint8_t maxLen = pend - message;
1155
+    strncpy(status_message, message, maxLen);
1156
+    status_message[maxLen] = '\0';
1142 1157
 
1143
-void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
1144
-  if (level < status_message_level) return;
1145
-  status_message_level = level;
1146
-  va_list args;
1147
-  va_start(args, fmt);
1148
-  vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
1149
-  va_end(args);
1150
-  finishstatus(level > 0);
1151
-}
1158
+    finishstatus(persist);
1159
+  }
1152 1160
 
1153
-void MarlinUI::setstatusPGM(PGM_P const message, int8_t level) {
1154
-  if (level < 0) level = status_message_level = 0;
1155
-  if (level < status_message_level) return;
1156
-  status_message_level = level;
1161
+  #include <stdarg.h>
1157 1162
 
1158
-  // Here we have a problem. The message is encoded in UTF8, so
1159
-  // arbitrarily cutting it will be a problem. We MUST be sure
1160
-  // that there is no cutting in the middle of a multibyte character!
1163
+  void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
1164
+    if (level < status_message_level) return;
1165
+    status_message_level = level;
1166
+    va_list args;
1167
+    va_start(args, fmt);
1168
+    vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
1169
+    va_end(args);
1170
+    finishstatus(level > 0);
1171
+  }
1161 1172
 
1162
-  // Get a pointer to the null terminator
1163
-  PGM_P pend = message + strlen_P(message);
1173
+  void MarlinUI::set_status_P(PGM_P const message, int8_t level) {
1174
+    if (level < 0) level = status_message_level = 0;
1175
+    if (level < status_message_level) return;
1176
+    status_message_level = level;
1164 1177
 
1165
-  //  If length of supplied UTF8 string is greater than
1166
-  // our buffer size, start cutting whole UTF8 chars
1167
-  while ((pend - message) > MAX_MESSAGE_LENGTH) {
1168
-    --pend;
1169
-    while (!START_OF_UTF8_CHAR(pgm_read_byte(pend))) --pend;
1170
-  };
1178
+    // Here we have a problem. The message is encoded in UTF8, so
1179
+    // arbitrarily cutting it will be a problem. We MUST be sure
1180
+    // that there is no cutting in the middle of a multibyte character!
1171 1181
 
1172
-  // At this point, we have the proper cut point. Use it
1173
-  uint8_t maxLen = pend - message;
1174
-  strncpy_P(status_message, message, maxLen);
1175
-  status_message[maxLen] = '\0';
1182
+    // Get a pointer to the null terminator
1183
+    PGM_P pend = message + strlen_P(message);
1176 1184
 
1177
-  finishstatus(level > 0);
1178
-}
1185
+    //  If length of supplied UTF8 string is greater than
1186
+    // our buffer size, start cutting whole UTF8 chars
1187
+    while ((pend - message) > MAX_MESSAGE_LENGTH) {
1188
+      --pend;
1189
+      while (!START_OF_UTF8_CHAR(pgm_read_byte(pend))) --pend;
1190
+    };
1179 1191
 
1180
-void MarlinUI::setalertstatusPGM(PGM_P const message) {
1181
-  setstatusPGM(message, 1);
1182
-  #if HAS_LCD_MENU
1183
-    return_to_status();
1184
-  #endif
1185
-}
1192
+    // At this point, we have the proper cut point. Use it
1193
+    uint8_t maxLen = pend - message;
1194
+    strncpy_P(status_message, message, maxLen);
1195
+    status_message[maxLen] = '\0';
1186 1196
 
1187
-#endif // HAS_SPI_LCD
1197
+    finishstatus(level > 0);
1198
+  }
1188 1199
 
1189
-#if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)
1200
+  void MarlinUI::set_alert_status_P(PGM_P const message) {
1201
+    set_status_P(message, 1);
1202
+    #if HAS_LCD_MENU
1203
+      return_to_status();
1204
+    #endif
1205
+  }
1190 1206
 
1191 1207
   #include "../module/printcounter.h"
1192 1208
 
@@ -1202,14 +1218,14 @@ void MarlinUI::setalertstatusPGM(PGM_P const message) {
1202 1218
       msg = paused;
1203 1219
     #if ENABLED(SDSUPPORT)
1204 1220
       else if (IS_SD_PRINTING())
1205
-        return setstatus(card.longest_filename(), true);
1221
+        return set_status(card.longest_filename(), true);
1206 1222
     #endif
1207 1223
     else if (print_job_timer.isRunning())
1208 1224
       msg = printing;
1209 1225
     else
1210 1226
       msg = welcome;
1211 1227
 
1212
-    setstatusPGM(msg, -1);
1228
+    set_status_P(msg, -1);
1213 1229
   }
1214 1230
 
1215 1231
 #endif

+ 19
- 21
Marlin/src/lcd/ultralcd.h Прегледај датотеку

@@ -243,15 +243,22 @@ public:
243 243
   #if HAS_SPI_LCD || ENABLED(MALYAN_LCD) || ENABLED(EXTENSIBLE_UI)
244 244
     static void init();
245 245
     static void update();
246
-    static void setalertstatusPGM(PGM_P message);
246
+    static void set_alert_status_P(PGM_P message);
247 247
   #else // NO LCD
248 248
     static inline void init() {}
249 249
     static inline void update() {}
250
-    static inline void setalertstatusPGM(PGM_P message) { UNUSED(message); }
250
+    static inline void set_alert_status_P(PGM_P message) { UNUSED(message); }
251 251
   #endif
252 252
 
253 253
   #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)
254 254
 
255
+    static char status_message[];
256
+    static bool has_status();
257
+
258
+
259
+    static uint8_t status_message_level;      // Higher levels block lower levels
260
+    static inline void reset_alert_level() { status_message_level = 0; }
261
+
255 262
     #if HAS_SPI_LCD
256 263
 
257 264
       static bool detected();
@@ -296,16 +303,10 @@ public:
296 303
 
297 304
       #endif
298 305
 
299
-      // Status message
300
-      static char status_message[];
301 306
       #if ENABLED(STATUS_MESSAGE_SCROLLING)
302 307
         static uint8_t status_scroll_offset;
303 308
       #endif
304
-      static bool has_status();
305
-
306 309
       static uint8_t lcd_status_update_delay;
307
-      static uint8_t status_message_level;      // Higher levels block lower levels
308
-      static inline void reset_alert_level() { status_message_level = 0; }
309 310
 
310 311
       #if HAS_PRINT_PROGRESS
311 312
         #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
@@ -341,26 +342,22 @@ public:
341 342
       static void status_screen();
342 343
 
343 344
     #else
344
-
345 345
       static void refresh() {}
346
-      static inline void reset_alert_level() {}
347
-      static constexpr bool has_status() { return true; }
348
-
349 346
     #endif
350 347
 
351 348
     static bool get_blink();
352 349
     static void kill_screen(PGM_P const lcd_msg);
353 350
     static void draw_kill_screen();
354
-    static void setstatus(const char* const message, const bool persist=false);
355
-    static void setstatusPGM(PGM_P const message, const int8_t level=0);
351
+    static void set_status(const char* const message, const bool persist=false);
352
+    static void set_status_P(PGM_P const message, const int8_t level=0);
356 353
     static void status_printf_P(const uint8_t level, PGM_P const fmt, ...);
357 354
     static void reset_status();
358 355
 
359 356
   #else // MALYAN_LCD or NO LCD
360 357
 
361 358
     static inline void refresh() {}
362
-    static inline void setstatus(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
363
-    static inline void setstatusPGM(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
359
+    static inline void set_status(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
360
+    static inline void set_status_P(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
364 361
     static inline void status_printf_P(const uint8_t level, PGM_P const fmt, ...) { UNUSED(level); UNUSED(fmt); }
365 362
     static inline void reset_status() {}
366 363
     static inline void reset_alert_level() {}
@@ -508,6 +505,10 @@ private:
508 505
 
509 506
   static void _synchronize();
510 507
 
508
+  #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)
509
+    static void finishstatus(const bool persist);
510
+  #endif
511
+
511 512
   #if HAS_SPI_LCD
512 513
     #if HAS_LCD_MENU
513 514
       #if LCD_TIMEOUT_TO_STATUS
@@ -517,13 +518,10 @@ private:
517 518
       #endif
518 519
     #endif
519 520
     static void draw_status_screen();
520
-    static void finishstatus(const bool persist);
521
-  #else
522
-    static inline void finishstatus(const bool persist) { UNUSED(persist); refresh(); }
523 521
   #endif
524 522
 };
525 523
 
526 524
 extern MarlinUI ui;
527 525
 
528
-#define LCD_MESSAGEPGM(x)      ui.setstatusPGM(PSTR(x))
529
-#define LCD_ALERTMESSAGEPGM(x) ui.setalertstatusPGM(PSTR(x))
526
+#define LCD_MESSAGEPGM(x)      ui.set_status_P(PSTR(x))
527
+#define LCD_ALERTMESSAGEPGM(x) ui.set_alert_status_P(PSTR(x))

+ 1
- 1
Marlin/src/module/probe.cpp Прегледај датотеку

@@ -371,7 +371,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
371 371
 
372 372
     PGM_P const ds_str = deploy ? PSTR(MSG_MANUAL_DEPLOY) : PSTR(MSG_MANUAL_STOW);
373 373
     ui.return_to_status();       // To display the new status message
374
-    ui.setstatusPGM(ds_str, 99);
374
+    ui.set_status_P(ds_str, 99);
375 375
     serialprintPGM(ds_str);
376 376
     SERIAL_EOL();
377 377
 

+ 1
- 1
Marlin/src/module/temperature.cpp Прегледај датотеку

@@ -2464,7 +2464,7 @@ void Temperature::isr() {
2464 2464
       #if HOTENDS > 1
2465 2465
         ui.status_printf_P(0, heating ? PSTR("E%i " MSG_HEATING) : PSTR("E%i " MSG_COOLING), int(e + 1));
2466 2466
       #else
2467
-        ui.setstatusPGM(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
2467
+        ui.set_status_P(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
2468 2468
       #endif
2469 2469
     }
2470 2470
   #endif

+ 2
- 2
Marlin/src/sd/cardreader.cpp Прегледај датотеку

@@ -521,7 +521,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall
521 521
       SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
522 522
 
523 523
       getfilename(0, fname);
524
-      ui.setstatus(longFilename[0] ? longFilename : fname);
524
+      ui.set_status(longFilename[0] ? longFilename : fname);
525 525
       //if (longFilename[0]) {
526 526
       //  SERIAL_PROTOCOLPAIR(MSG_SD_FILE_LONG_NAME, longFilename);
527 527
       //}
@@ -545,7 +545,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall
545 545
         emergency_parser.disable();
546 546
       #endif
547 547
       SERIAL_PROTOCOLLNPAIR(MSG_SD_WRITE_TO_FILE, fname);
548
-      ui.setstatus(fname);
548
+      ui.set_status(fname);
549 549
     }
550 550
   }
551 551
 }

Loading…
Откажи
Сачувај