Przeglądaj źródła

Add Laser / Spindle bitmap for LCD (#16068)

Luu Lac 5 lat temu
rodzic
commit
01e4b0c067

+ 1
- 0
Marlin/src/feature/spindle_laser.h Wyświetl plik

@@ -46,6 +46,7 @@
46 46
 class SpindleLaser {
47 47
 public:
48 48
   static cutter_power_t power;
49
+  static inline uint8_t powerPercent(const uint8_t pp) { return ui8_to_percent(pp); } // for display
49 50
 
50 51
   static void init();
51 52
 

+ 144
- 0
Marlin/src/lcd/dogm/dogm_Statusscreen.h Wyświetl plik

@@ -598,6 +598,105 @@
598 598
 
599 599
 #endif // !STATUS_HEATERS_WIDTH && !STATUS_HOTEND1_WIDTH
600 600
 
601
+// LASER / SPINDLE
602
+#if !STATUS_CUTTER_WIDTH && HAS_CUTTER
603
+  #define STATUS_CUTTER_WIDTH 24
604
+  #define STATUS_CUTTER_X 80
605
+  #if ENABLED(LASER_FEATURE)
606
+    #ifdef STATUS_CUTTER_ANIM
607
+      const unsigned char status_cutter_on_bmp[] PROGMEM = {
608
+        B00000000,B00100100,B00000000,
609
+        B00000000,B01100110,B00000000,
610
+        B00000000,B11000011,B00000000,
611
+        B00000001,B10011001,B10000000,
612
+        B00000011,B00100100,B11000000,
613
+        B00000000,B01000010,B00000000,
614
+        B00000000,B01000010,B00000000,
615
+        B00000011,B00100100,B11000000,
616
+        B00000001,B10011001,B10000000,
617
+        B00000000,B11000011,B00000000,
618
+        B00000000,B01100110,B00000000,
619
+        B00000000,B00100100,B00000000
620
+      };
621
+      const unsigned char status_cutter_bmp[] PROGMEM = {
622
+        B00000000,B00100100,B00000000,
623
+        B00000000,B01100110,B00000000,
624
+        B00000000,B00000000,B00000000,
625
+        B00000001,B00000000,B10000000,
626
+        B00000011,B00000000,B11000000,
627
+        B00000000,B00011000,B00000000,
628
+        B00000000,B00011000,B00000000,
629
+        B00000011,B00000000,B11000000,
630
+        B00000001,B00000000,B10000000,
631
+        B00000000,B00000000,B00000000,
632
+        B00000000,B01100110,B00000000,
633
+        B00000000,B00100100,B00000000
634
+      };
635
+    #else
636
+      const unsigned char status_cutter_bmp[] PROGMEM = {
637
+        B00000000,B00100100,B00000000,
638
+        B00000000,B01100110,B00000000,
639
+        B00000000,B11000011,B00000000,
640
+        B00000001,B10000001,B10000000,
641
+        B00000011,B00000000,B11000000,
642
+        B00000000,B00000000,B00000000,
643
+        B00000000,B00000000,B00000000,
644
+        B00000011,B00000000,B11000000,
645
+        B00000001,B10000001,B10000000,
646
+        B00000000,B11000011,B00000000,
647
+        B00000000,B01100110,B00000000,
648
+        B00000000,B00100100,B00000000
649
+      };
650
+    #endif
651
+  #else
652
+    #ifdef STATUS_CUTTER_ANIM
653
+      const unsigned char status_cutter_on_bmp[] PROGMEM = {
654
+        B00000001,B11111110,B10000000,
655
+        B00000000,B11000000,B00000000,
656
+        B00000001,B10000000,B10000000,
657
+        B00000001,B00000000,B10000000,
658
+        B00000001,B11111100,B10000000,
659
+        B00000000,B11100000,B00000000,
660
+        B00000001,B11000000,B10000000,
661
+        B00000000,B10000001,B00000000,
662
+        B00000000,B01111010,B00000000,
663
+        B00000000,B00110100,B00000000,
664
+        B00000000,B00011000,B00000000,
665
+        B00000000,B00000000,B00000000
666
+      };
667
+      const unsigned char status_cutter_bmp[] PROGMEM = {
668
+        B00000001,B11111110,B10000000,
669
+        B00000000,B11000000,B00000000,
670
+        B00000001,B10000000,B10000000,
671
+        B00000001,B00000000,B10000000,
672
+        B00000001,B11111100,B10000000,
673
+        B00000000,B11100000,B00000000,
674
+        B00000001,B11000000,B10000000,
675
+        B00000000,B10000001,B00000000,
676
+        B00000000,B01111010,B00000000,
677
+        B00000000,B00110100,B00000000,
678
+        B00000000,B00011000,B00000000,
679
+        B00000000,B00000000,B00000000
680
+      };
681
+    #else
682
+      const unsigned char status_cutter_bmp[] PROGMEM = {
683
+        B00000001,B11000010,B10000000,
684
+        B00000001,B00011100,B10000000,
685
+        B00000000,B11100001,B00000000,
686
+        B00000001,B00001110,B10000000,
687
+        B00000001,B01110000,B10000000,
688
+        B00000000,B10000111,B10000000,
689
+        B00000001,B00111111,B10000000,
690
+        B00000000,B11111111,B00000000,
691
+        B00000000,B01111110,B00000000,
692
+        B00000000,B00111100,B00000000,
693
+        B00000000,B00011000,B00000000,
694
+        B00000000,B00000000,B00000000
695
+      };
696
+    #endif
697
+  #endif
698
+#endif // LASER / SPINDLE
699
+
601 700
 //
602 701
 // Default Status Screen Bed bitmaps
603 702
 //
@@ -1468,6 +1567,51 @@
1468 1567
 #endif
1469 1568
 
1470 1569
 //
1570
+// Cutter Bitmap Properties
1571
+//
1572
+#ifndef STATUS_CUTTER_BYTEWIDTH
1573
+  #define STATUS_CUTTER_BYTEWIDTH BW(STATUS_CUTTER_WIDTH)
1574
+#endif
1575
+#if STATUS_CUTTER_WIDTH
1576
+
1577
+  #ifndef STATUS_CUTTER_X
1578
+    #define STATUS_CUTTER_X (LCD_PIXEL_WIDTH - (STATUS_CUTTER_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8)
1579
+  #endif
1580
+
1581
+  #ifndef STATUS_CUTTER_HEIGHT
1582
+    #ifdef STATUS_CUTTER_ANIM
1583
+      #define STATUS_CUTTER_HEIGHT(S) ((S) ? sizeof(status_cutter_on_bmp) / (STATUS_CUTTER_BYTEWIDTH) : sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH))
1584
+    #else
1585
+      #define STATUS_CUTTER_HEIGHT(S) (sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH))
1586
+    #endif
1587
+  #endif
1588
+
1589
+  #ifndef STATUS_CUTTER_Y
1590
+    #define STATUS_CUTTER_Y(S) 4
1591
+  #endif
1592
+
1593
+  #ifndef STATUS_CUTTER_TEXT_X
1594
+    #define STATUS_CUTTER_TEXT_X (STATUS_CUTTER_X -1)
1595
+  #endif
1596
+
1597
+  #ifndef STATUS_CUTTER_TEXT_Y
1598
+    #define STATUS_CUTTER_TEXT_Y 28
1599
+  #endif
1600
+
1601
+  static_assert(
1602
+    sizeof(status_cutter_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(0)),
1603
+    "Status cutter bitmap (status_cutter_bmp) dimensions don't match data."
1604
+  );
1605
+  #ifdef STATUS_CUTTER_ANIM
1606
+    static_assert(
1607
+      sizeof(status_cutter_on_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(1)),
1608
+      "Status cutter bitmap (status_cutter_on_bmp) dimensions don't match data."
1609
+    );
1610
+  #endif
1611
+
1612
+#endif
1613
+
1614
+//
1471 1615
 // Chamber Bitmap Properties
1472 1616
 //
1473 1617
 #ifndef STATUS_CHAMBER_BYTEWIDTH

+ 63
- 23
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Wyświetl plik

@@ -44,6 +44,10 @@
44 44
   #include "../../gcode/parser.h"
45 45
 #endif
46 46
 
47
+#if HAS_CUTTER
48
+  #include "../../feature/spindle_laser.h"
49
+#endif
50
+
47 51
 #if ENABLED(SDSUPPORT)
48 52
   #include "../../sd/cardreader.h"
49 53
 #endif
@@ -65,6 +69,7 @@
65 69
 
66 70
 #define DO_DRAW_LOGO (STATUS_LOGO_WIDTH && ENABLED(CUSTOM_STATUS_SCREEN_IMAGE))
67 71
 #define DO_DRAW_HOTENDS (HOTENDS > 0)
72
+#define DO_DRAW_CUTTER (HAS_CUTTER)
68 73
 #define DO_DRAW_BED (HAS_HEATED_BED && STATUS_BED_WIDTH && HOTENDS <= 4)
69 74
 #define DO_DRAW_CHAMBER (HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4)
70 75
 #define DO_DRAW_FAN (HAS_FAN0 && STATUS_FAN_WIDTH && HOTENDS <= 4 && defined(STATUS_FAN_FRAMES))
@@ -72,34 +77,45 @@
72 77
 #define ANIM_HOTEND (HOTENDS && ENABLED(STATUS_HOTEND_ANIM))
73 78
 #define ANIM_BED (DO_DRAW_BED && ENABLED(STATUS_BED_ANIM))
74 79
 #define ANIM_CHAMBER (DO_DRAW_CHAMBER && ENABLED(STATUS_CHAMBER_ANIM))
75
-
76
-#define ANIM_HBC (ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER)
77
-
78
-#if ANIM_HBC
79
-  uint8_t heat_bits;
80
+#define ANIM_CUTTER (DO_DRAW_CUTTER && ENABLED(STATUS_CUTTER_ANIM))
81
+
82
+#define ANIM_HBCC (ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER || ANIM_CUTTER)
83
+
84
+#if ANIM_HBCC
85
+  enum HeatBits : uint8_t {
86
+    HEATBIT_HOTEND,
87
+    HEATBIT_BED = HOTENDS,
88
+    HEATBIT_CHAMBER,
89
+    HEATBIT_CUTTER
90
+  };
91
+  IF<(HEATBIT_CUTTER > 7), uint16_t, uint8_t>::type heat_bits;
80 92
 #endif
81 93
 #if ANIM_HOTEND
82
-  #define HOTEND_ALT(N) TEST(heat_bits, N)
94
+  #define HOTEND_ALT(N) TEST(heat_bits, HEATBIT_HOTEND + N)
83 95
 #else
84 96
   #define HOTEND_ALT(N) false
85 97
 #endif
86 98
 #if ANIM_BED
87
-  #define BED_ALT() TEST(heat_bits, 7)
99
+  #define BED_ALT() TEST(heat_bits, HEATBIT_BED)
88 100
 #else
89 101
   #define BED_ALT() false
90 102
 #endif
91 103
 #if ANIM_CHAMBER
92
-  #define CHAMBER_ALT() TEST(heat_bits, 6)
104
+  #define CHAMBER_ALT() TEST(heat_bits, HEATBIT_CHAMBER)
93 105
 #else
94 106
   #define CHAMBER_ALT() false
95 107
 #endif
108
+#if ANIM_CUTTER
109
+  #define CUTTER_ALT(N) TEST(heat_bits, HEATBIT_CUTTER)
110
+#else
111
+  #define CUTTER_ALT() false
112
+#endif
96 113
 
97
-#if HOTENDS
114
+#if DO_DRAW_HOTENDS
98 115
   #define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
116
+  #define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
99 117
 #endif
100 118
 
101
-#define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
102
-
103 119
 #define PROGRESS_BAR_X 54
104 120
 #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
105 121
 
@@ -112,6 +128,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
112 128
 
113 129
 #if DO_DRAW_HOTENDS
114 130
 
131
+  // Draw hotend bitmap with current and target temperatures
115 132
   FORCE_INLINE void _draw_hotend_status(const heater_ind_t heater, const bool blink) {
116 133
     #if !HEATER_IDLE_HANDLER
117 134
       UNUSED(blink);
@@ -203,8 +220,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
203 220
 
204 221
     if (PAGE_UNDER(7)) {
205 222
       #if HEATER_IDLE_HANDLER
206
-        const bool is_idle = thermalManager.hotend_idle[heater].timed_out,
207
-                   dodraw = (blink || !is_idle);
223
+        const bool dodraw = (blink || !thermalManager.hotend_idle[heater].timed_out);
208 224
       #else
209 225
         constexpr bool dodraw = true;
210 226
       #endif
@@ -222,10 +238,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
222 238
 
223 239
   }
224 240
 
225
-#endif // HOTENDS
241
+#endif // DO_DRAW_HOTENDS
226 242
 
227 243
 #if DO_DRAW_BED
228 244
 
245
+  // Draw bed bitmap with current and target temperatures
229 246
   FORCE_INLINE void _draw_bed_status(const bool blink) {
230 247
     #if !HEATER_IDLE_HANDLER
231 248
       UNUSED(blink);
@@ -274,8 +291,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
274 291
 
275 292
     if (PAGE_UNDER(7)) {
276 293
       #if HEATER_IDLE_HANDLER
277
-        const bool is_idle = thermalManager.bed_idle.timed_out,
278
-                   dodraw = (blink || !is_idle);
294
+        const bool dodraw = (blink || !thermalManager.bed_idle.timed_out);
279 295
       #else
280 296
         constexpr bool dodraw = true;
281 297
       #endif
@@ -383,16 +399,19 @@ void MarlinUI::draw_status_screen() {
383 399
 
384 400
   // At the first page, generate new display values
385 401
   if (first_page) {
386
-    #if ANIM_HBC
402
+    #if ANIM_HBCC
387 403
       uint8_t new_bits = 0;
388 404
       #if ANIM_HOTEND
389
-        HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, e);
405
+        HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, HEATBIT_HOTEND + e);
390 406
       #endif
391 407
       #if ANIM_BED
392
-        if (thermalManager.isHeatingBed()) SBI(new_bits, 7);
408
+        if (thermalManager.isHeatingBed()) SBI(new_bits, HEATBIT_BED);
393 409
       #endif
394 410
       #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
395
-        if (thermalManager.isHeatingChamber()) SBI(new_bits, 6);
411
+        if (thermalManager.isHeatingChamber()) SBI(new_bits, HEATBIT_CHAMBER);
412
+      #endif
413
+      #if ANIM_CUTTER
414
+        if (cutter.enabled()) SBI(new_bits, HEATBIT_CUTTER);
396 415
       #endif
397 416
       heat_bits = new_bits;
398 417
     #endif
@@ -505,6 +524,18 @@ void MarlinUI::draw_status_screen() {
505 524
       u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
506 525
   #endif
507 526
 
527
+  #if DO_DRAW_CUTTER
528
+    #if ANIM_CUTTER
529
+      #define CUTTER_BITMAP(S) ((S) ? status_cutter_on_bmp : status_cutter_bmp)
530
+    #else
531
+      #define CUTTER_BITMAP(S) status_cutter_bmp
532
+    #endif
533
+    const uint8_t cuttery = STATUS_CUTTER_Y(CUTTER_ALT()),
534
+                  cutterh = STATUS_CUTTER_HEIGHT(CUTTER_ALT());
535
+    if (PAGE_CONTAINS(cuttery, cuttery + cutterh - 1))
536
+      u8g.drawBitmapP(STATUS_CUTTER_X, cuttery, STATUS_CUTTER_BYTEWIDTH, cutterh, CUTTER_BITMAP(CUTTER_ALT()));
537
+  #endif
538
+
508 539
   #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS)
509 540
     #if ANIM_BED
510 541
       #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
@@ -558,16 +589,25 @@ void MarlinUI::draw_status_screen() {
558 589
   //
559 590
   if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
560 591
     // Extruders
561
-    #if HOTENDS
592
+    #if DO_DRAW_HOTENDS
562 593
       for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e)
563 594
         _draw_hotend_status((heater_ind_t)e, blink);
564 595
     #endif
565 596
 
566
-    // Heated bed
567
-    #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) || (HAS_HEATED_BED && ENABLED(STATUS_COMBINE_HEATERS) && HOTENDS <= 4)
597
+    // Laser / Spindle
598
+    #if DO_DRAW_CUTTER
599
+      if (cutter.power && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
600
+        lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, i16tostr3(cutter.powerPercent(cutter.power)));
601
+        lcd_put_wchar('%');
602
+      }
603
+    #endif
604
+
605
+    // Heated Bed
606
+    #if DO_DRAW_BED
568 607
       _draw_bed_status(blink);
569 608
     #endif
570 609
 
610
+    // Heated Chamber
571 611
     #if DO_DRAW_CHAMBER
572 612
       _draw_chamber_status();
573 613
     #endif

Ładowanie…
Anuluj
Zapisz