Просмотр исходного кода

Improved Ender 3 V2 display status area (#20983)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Jyers 4 лет назад
Родитель
Сommit
3c41f108df
Аккаунт пользователя с таким Email не найден
1 измененных файлов: 111 добавлений и 34 удалений
  1. 111
    34
      Marlin/src/lcd/dwin/e3v2/dwin.cpp

+ 111
- 34
Marlin/src/lcd/dwin/e3v2/dwin.cpp Просмотреть файл

@@ -138,6 +138,7 @@
138 138
 #define MINUNITMULT pow(10, UNITFDIGITS)
139 139
 
140 140
 #define ENCODER_WAIT_MS                  20
141
+#define DWIN_VAR_UPDATE_INTERVAL         1024
141 142
 #define DWIN_SCROLL_UPDATE_INTERVAL      SEC_TO_MS(2)
142 143
 #define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20)
143 144
 
@@ -1581,6 +1582,41 @@ void HMI_StepXYZE() {
1581 1582
   }
1582 1583
 }
1583 1584
 
1585
+// Draw X, Y, Z and blink if in an un-homed or un-trusted state
1586
+void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink, const bool force) {
1587
+  const bool draw_qmark = axis_should_home(axis),
1588
+             draw_empty = NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !draw_qmark && !axis_is_trusted(axis);
1589
+
1590
+  // Check for a position change
1591
+  static xyz_pos_t oldpos = { -1, -1, -1 };
1592
+  const float p = current_position[axis];
1593
+  const bool changed = oldpos[axis] != p;
1594
+  if (changed) oldpos[axis] = p;
1595
+
1596
+  if (force || changed || draw_qmark || draw_empty) {
1597
+    if (blink && draw_qmark)
1598
+      DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F("???.?"));
1599
+    else if (blink && draw_empty)
1600
+      DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, x, y, F("     "));
1601
+    else
1602
+      DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, x, y, p * 10);
1603
+  }
1604
+}
1605
+
1606
+void _draw_xyz_position(const bool force) {
1607
+  //SERIAL_ECHOPGM("Draw XYZ:");
1608
+  static bool _blink = false;
1609
+  const bool blink = !!(millis() & 0x400UL);
1610
+  if (force || blink != _blink) {
1611
+    _blink = blink;
1612
+    //SERIAL_ECHOPGM(" (blink)");
1613
+    _update_axis_value(X_AXIS,  35, 459, blink, true);
1614
+    _update_axis_value(Y_AXIS, 120, 459, blink, true);
1615
+    _update_axis_value(Z_AXIS, 205, 459, blink, true);
1616
+  }
1617
+  //SERIAL_EOL();
1618
+}
1619
+
1584 1620
 void update_variable() {
1585 1621
   #if HAS_HOTEND
1586 1622
     static float _hotendtemp = 0;
@@ -1639,29 +1675,51 @@ void update_variable() {
1639 1675
 
1640 1676
   #if HAS_HOTEND
1641 1677
     if (_new_hotend_temp)
1642
-      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, _hotendtemp);
1678
+      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, _hotendtemp);
1643 1679
     if (_new_hotend_target)
1644
-      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, _hotendtarget);
1680
+      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, _hotendtarget);
1681
+
1682
+    static int16_t _flow = planner.flow_percentage[0];
1683
+    if (_flow != planner.flow_percentage[0]) {
1684
+      _flow = planner.flow_percentage[0];
1685
+      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, _flow);
1686
+    }
1645 1687
   #endif
1646 1688
 
1647 1689
   #if HAS_HEATED_BED
1648 1690
     if (_new_bed_temp)
1649
-      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, _bedtemp);
1691
+      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, _bedtemp);
1650 1692
     if (_new_bed_target)
1651
-      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, _bedtarget);
1693
+      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, _bedtarget);
1652 1694
   #endif
1653 1695
 
1654 1696
   static int16_t _feedrate = 100;
1655 1697
   if (_feedrate != feedrate_percentage) {
1656 1698
     _feedrate = feedrate_percentage;
1657
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, _feedrate);
1699
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, _feedrate);
1658 1700
   }
1659
-  #if HAS_ZOFFSET_ITEM
1660
-    if (last_zoffset != BABY_Z_VAR) {
1661
-      last_zoffset = BABY_Z_VAR;
1662
-      DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178 + STAT_CHR_W, 429, last_zoffset * 100);
1701
+
1702
+  #if HAS_FAN
1703
+    if (_fanspeed != thermalManager.fan_speed[0]) {
1704
+      _fanspeed = thermalManager.fan_speed[0];
1705
+      DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, _fanspeed);
1663 1706
     }
1664 1707
   #endif
1708
+
1709
+  static float _offset = 0;
1710
+  if (BABY_Z_VAR != _offset) {
1711
+    _offset = BABY_Z_VAR;
1712
+    if (BABY_Z_VAR < 0) {
1713
+      DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -_offset * 100);
1714
+      DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-"));
1715
+    }
1716
+    else {
1717
+      DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, _offset * 100);
1718
+      DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" "));
1719
+    }
1720
+  }
1721
+
1722
+  _draw_xyz_position(false);
1665 1723
 }
1666 1724
 
1667 1725
 /**
@@ -1853,39 +1911,55 @@ void HMI_SDCardUpdate() {
1853 1911
 //
1854 1912
 void Draw_Status_Area(const bool with_update) {
1855 1913
 
1856
-  // Clear the bottom area of the screen
1857 1914
   DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1);
1858 1915
 
1859
-  //
1860
-  // Status Area
1861
-  //
1862 1916
   #if HAS_HOTEND
1863
-    DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381);
1864
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius);
1865
-    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 3 * STAT_CHR_W + 5, 383, F("/"));
1866
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target);
1867
-  #endif
1868
-  #if HOTENDS > 1
1869
-    // DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381);
1917
+    DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
1918
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius);
1919
+    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
1920
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target);
1921
+
1922
+    DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
1923
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]);
1924
+    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%"));
1870 1925
   #endif
1871 1926
 
1872 1927
   #if HAS_HEATED_BED
1873
-    DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381);
1874
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius);
1875
-    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 178 + 3 * STAT_CHR_W + 5, 383, F("/"));
1876
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target);
1928
+    DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
1929
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius);
1930
+    DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
1931
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target);
1877 1932
   #endif
1878 1933
 
1879
-  DWIN_ICON_Show(ICON, ICON_Speed, 13, 429);
1880
-  DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage);
1881
-  DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 33 + 5 * STAT_CHR_W + 2, 429, F("%"));
1934
+  DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
1935
+  DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage);
1936
+  DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%"));
1937
+
1938
+  #if HAS_FAN
1939
+    DWIN_ICON_Show(ICON, ICON_FanSpeed, 187, 383);
1940
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]);
1941
+  #endif
1882 1942
 
1883 1943
   #if HAS_ZOFFSET_ITEM
1884
-    DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428);
1885
-    dwin_zoffset = BABY_Z_VAR;
1886
-    DWIN_Draw_Signed_Float(DWIN_FONT_STAT, Color_Bg_Black, 2, 2, 178, 429, dwin_zoffset * 100);
1944
+    DWIN_ICON_Show(ICON, ICON_Zoffset, 187, 416);
1887 1945
   #endif
1888 1946
 
1947
+  if (BABY_Z_VAR < 0) {
1948
+    DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, -BABY_Z_VAR * 100);
1949
+    DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F("-"));
1950
+  }
1951
+  else {
1952
+    DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 2, 2, 207, 417, BABY_Z_VAR * 100);
1953
+    DWIN_Draw_String(false, true, font8x16, Color_White, Color_Bg_Black, 205, 419, F(" "));
1954
+  }
1955
+
1956
+  DWIN_Draw_Rectangle(1, Line_Color, 0, 449, DWIN_WIDTH, 451);
1957
+
1958
+  DWIN_ICON_Show(ICON, ICON_MaxSpeedX,  10, 456);
1959
+  DWIN_ICON_Show(ICON, ICON_MaxSpeedY,  95, 456);
1960
+  DWIN_ICON_Show(ICON, ICON_MaxSpeedZ, 180, 456);
1961
+  _draw_xyz_position(true);
1962
+
1889 1963
   if (with_update) {
1890 1964
     DWIN_UpdateLCD();
1891 1965
     delay(5);
@@ -3546,14 +3620,17 @@ void DWIN_Update() {
3546 3620
 }
3547 3621
 
3548 3622
 void EachMomentUpdate() {
3549
-  static millis_t next_rts_update_ms = 0;
3623
+  static millis_t next_var_update_ms = 0, next_rts_update_ms = 0;
3624
+
3550 3625
   const millis_t ms = millis();
3626
+  if (ELAPSED(ms, next_var_update_ms)) {
3627
+    next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL;
3628
+    update_variable();
3629
+  }
3630
+
3551 3631
   if (PENDING(ms, next_rts_update_ms)) return;
3552 3632
   next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL;
3553 3633
 
3554
-  // variable update
3555
-  update_variable();
3556
-
3557 3634
   if (checkkey == PrintProcess) {
3558 3635
     // if print done
3559 3636
     if (HMI_flag.print_finish && !HMI_flag.done_confirm_flag) {

Загрузка…
Отмена
Сохранить