My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

status_screen_DOGM.cpp 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. //
  23. // status_screen_DOGM.cpp
  24. // Standard Status Screen for Graphical Display
  25. //
  26. #include "../../inc/MarlinConfigPre.h"
  27. #if HAS_GRAPHICAL_LCD && DISABLED(LIGHTWEIGHT_UI)
  28. #include "dogm_Statusscreen.h"
  29. #include "ultralcd_DOGM.h"
  30. #include "../ultralcd.h"
  31. #include "../lcdprint.h"
  32. #include "../../libs/numtostr.h"
  33. #include "../../module/motion.h"
  34. #include "../../module/temperature.h"
  35. #if ENABLED(FILAMENT_LCD_DISPLAY)
  36. #include "../../feature/filwidth.h"
  37. #include "../../module/planner.h"
  38. #include "../../gcode/parser.h"
  39. #endif
  40. #if ENABLED(SDSUPPORT)
  41. #include "../../sd/cardreader.h"
  42. #endif
  43. #if HAS_PRINT_PROGRESS
  44. #include "../../module/printcounter.h"
  45. #endif
  46. #if DUAL_MIXING_EXTRUDER
  47. #include "../../feature/mixing.h"
  48. #endif
  49. FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
  50. const char *str = i16tostr3(temp);
  51. const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
  52. lcd_moveto(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty);
  53. lcd_put_u8str(&str[3-len]);
  54. lcd_put_wchar(LCD_STR_DEGREE[0]);
  55. }
  56. #define X_LABEL_POS 3
  57. #define X_VALUE_POS 11
  58. #define XYZ_SPACING 37
  59. #define XYZ_BASELINE (30 + INFO_FONT_ASCENT)
  60. #define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
  61. #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
  62. #define DO_DRAW_BED (HAS_HEATED_BED && STATUS_BED_WIDTH && HOTENDS <= 3 && DISABLED(STATUS_COMBINE_HEATERS))
  63. #define DO_DRAW_FAN (HAS_FAN0 && STATUS_FAN_WIDTH && STATUS_FAN_FRAMES)
  64. #define ANIM_HOTEND (HOTENDS && ENABLED(STATUS_HOTEND_ANIM))
  65. #define ANIM_BED (DO_DRAW_BED && ENABLED(STATUS_BED_ANIM))
  66. #define ANIM_CHAMBER (HAS_HEATED_CHAMBER && ENABLED(STATUS_CHAMBER_ANIM))
  67. #if ANIM_HOTEND || ANIM_BED
  68. uint8_t heat_bits;
  69. #endif
  70. #if ANIM_HOTEND
  71. #define HOTEND_ALT(N) TEST(heat_bits, N)
  72. #else
  73. #define HOTEND_ALT(N) false
  74. #endif
  75. #if ANIM_BED
  76. #define BED_ALT() TEST(heat_bits, 7)
  77. #else
  78. #define BED_ALT() false
  79. #endif
  80. #if ANIM_CHAMBER
  81. #define CHAMBER_ALT() TEST(heat_bits, 6)
  82. #else
  83. #define CHAMBER_ALT() false
  84. #endif
  85. #define MAX_HOTEND_DRAW MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
  86. #define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
  87. #if ENABLED(MARLIN_DEV_MODE)
  88. #define SHOW_ON_STATE READ(X_MIN_PIN)
  89. #else
  90. #define SHOW_ON_STATE false
  91. #endif
  92. FORCE_INLINE void _draw_heater_status(const heater_ind_t heater, const bool blink) {
  93. #if !HEATER_IDLE_HANDLER
  94. UNUSED(blink);
  95. #endif
  96. #if HAS_HEATED_BED
  97. const bool isBed = heater < 0;
  98. #define IFBED(A,B) (isBed ? (A) : (B))
  99. #else
  100. #define IFBED(A,B) (B)
  101. #endif
  102. #if ENABLED(MARLIN_DEV_MODE)
  103. constexpr bool isHeat = true;
  104. #else
  105. const bool isHeat = IFBED(BED_ALT(), HOTEND_ALT(heater));
  106. #endif
  107. const uint8_t tx = IFBED(STATUS_BED_TEXT_X, STATUS_HOTEND_TEXT_X(heater));
  108. #if ENABLED(MARLIN_DEV_MODE)
  109. const float temp = 20 + (millis() >> 8) % IFBED(100, 200);
  110. const float target = IFBED(100, 200);
  111. #else
  112. const float temp = IFBED(thermalManager.degBed(), thermalManager.degHotend(heater)),
  113. target = IFBED(thermalManager.degTargetBed(), thermalManager.degTargetHotend(heater));
  114. #endif
  115. #if HAS_HEATED_CHAMBER
  116. FORCE_INLINE void _draw_chamber_status(const bool blink) {
  117. const float temp = thermalManager.degChamber(),
  118. target = thermalManager.degTargetChamber();
  119. #if !HEATER_IDLE_HANDLER
  120. UNUSED(blink);
  121. #endif
  122. if (PAGE_UNDER(7)) {
  123. #if HEATER_IDLE_HANDLER
  124. const bool is_idle = false, // thermalManager.chamber_idle.timed_out,
  125. dodraw = (blink || !is_idle);
  126. #else
  127. constexpr bool dodraw = true;
  128. #endif
  129. if (dodraw) _draw_centered_temp(target + 0.5, STATUS_CHAMBER_TEXT_X, 7);
  130. }
  131. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  132. _draw_centered_temp(temp + 0.5f, STATUS_CHAMBER_TEXT_X, 28);
  133. }
  134. #endif
  135. #if DISABLED(STATUS_HOTEND_ANIM)
  136. #define STATIC_HOTEND true
  137. #define HOTEND_DOT isHeat
  138. #else
  139. #define STATIC_HOTEND false
  140. #define HOTEND_DOT false
  141. #endif
  142. #if HAS_HEATED_BED && DISABLED(STATUS_BED_ANIM)
  143. #define STATIC_BED true
  144. #define BED_DOT isHeat
  145. #else
  146. #define STATIC_BED false
  147. #define BED_DOT false
  148. #endif
  149. #if ANIM_HOTEND && ENABLED(STATUS_HOTEND_INVERTED)
  150. #define OFF_BMP(N) status_hotend##N##_b_bmp
  151. #define ON_BMP(N) status_hotend##N##_a_bmp
  152. #else
  153. #define OFF_BMP(N) status_hotend##N##_a_bmp
  154. #define ON_BMP(N) status_hotend##N##_b_bmp
  155. #endif
  156. #if STATUS_HOTEND_BITMAPS > 1
  157. static const unsigned char* const status_hotend_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = ARRAY_N(STATUS_HOTEND_BITMAPS, OFF_BMP(1), OFF_BMP(2), OFF_BMP(3), OFF_BMP(4), OFF_BMP(5), OFF_BMP(6));
  158. #if ANIM_HOTEND
  159. static const unsigned char* const status_hotend_on_gfx[STATUS_HOTEND_BITMAPS] PROGMEM = ARRAY_N(STATUS_HOTEND_BITMAPS, ON_BMP(1), ON_BMP(2), ON_BMP(3), ON_BMP(4), ON_BMP(5), ON_BMP(6));
  160. #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr((S) ? &status_hotend_on_gfx[(N) % (STATUS_HOTEND_BITMAPS)] : &status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])
  161. #else
  162. #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr(&status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])
  163. #endif
  164. #elif ANIM_HOTEND
  165. #define HOTEND_BITMAP(N,S) ((S) ? ON_BMP() : OFF_BMP())
  166. #else
  167. #define HOTEND_BITMAP(N,S) status_hotend_a_bmp
  168. #endif
  169. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) {
  170. #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2)
  171. const float prop = target - 20,
  172. perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0;
  173. uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f);
  174. NOMORE(tall, BAR_TALL);
  175. #ifdef STATUS_HOTEND_ANIM
  176. // Draw hotend bitmap, either whole or split by the heating percent
  177. if (IFBED(0, 1)) {
  178. const uint8_t hx = STATUS_HOTEND_X(heater), bw = STATUS_HOTEND_BYTEWIDTH(heater);
  179. #if ENABLED(STATUS_HEAT_PERCENT)
  180. if (isHeat && tall <= BAR_TALL) {
  181. const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
  182. u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(heater, false));
  183. u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(heater, true) + ph * bw);
  184. }
  185. else
  186. #endif
  187. u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater, isHeat));
  188. }
  189. #endif
  190. // Draw a heating progress bar, if specified
  191. #if ENABLED(STATUS_HEAT_PERCENT)
  192. if (IFBED(true, STATIC_HOTEND) && isHeat) {
  193. const uint8_t bx = IFBED(STATUS_BED_X + STATUS_BED_WIDTH, STATUS_HOTEND_X(heater) + STATUS_HOTEND_WIDTH(heater)) + 1;
  194. u8g.drawFrame(bx, STATUS_HEATERS_Y, 3, STATUS_HEATERS_HEIGHT);
  195. if (tall) {
  196. const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
  197. if (PAGE_OVER(STATUS_HEATERS_Y + ph))
  198. u8g.drawVLine(bx + 1, STATUS_HEATERS_Y + ph, tall);
  199. }
  200. }
  201. #endif
  202. } // PAGE_CONTAINS
  203. if (PAGE_UNDER(7)) {
  204. #if HEATER_IDLE_HANDLER
  205. const bool is_idle = IFBED(thermalManager.bed_idle.timed_out, thermalManager.hotend_idle[heater].timed_out),
  206. dodraw = (blink || !is_idle);
  207. #else
  208. constexpr bool dodraw = true;
  209. #endif
  210. if (dodraw) _draw_centered_temp(target + 0.5, tx, 7);
  211. }
  212. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  213. _draw_centered_temp(temp + 0.5f, tx, 28);
  214. if (IFBED(STATIC_BED && BED_DOT, STATIC_HOTEND && HOTEND_DOT) && PAGE_CONTAINS(17, 19)) {
  215. u8g.setColorIndex(0); // set to white on black
  216. u8g.drawBox(tx, IFBED(20-2, 20-3), 2, 2);
  217. u8g.setColorIndex(1); // restore black on white
  218. }
  219. }
  220. //
  221. // Before homing, blink '123' <-> '???'.
  222. // Homed but unknown... '123' <-> ' '.
  223. // Homed and known, display constantly.
  224. //
  225. FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
  226. const uint8_t offs = (XYZ_SPACING) * axis;
  227. lcd_moveto(X_LABEL_POS + offs, XYZ_BASELINE);
  228. lcd_put_wchar('X' + axis);
  229. lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
  230. if (blink)
  231. lcd_put_u8str(value);
  232. else {
  233. if (!TEST(axis_homed, axis))
  234. while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
  235. else {
  236. #if DISABLED(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
  237. if (!TEST(axis_known_position, axis))
  238. lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
  239. else
  240. #endif
  241. lcd_put_u8str(value);
  242. }
  243. }
  244. }
  245. #if ENABLED(MARLIN_DEV_MODE)
  246. uint16_t count_renders = 0;
  247. uint32_t total_cycles = 0;
  248. #endif
  249. void MarlinUI::draw_status_screen() {
  250. #if ENABLED(MARLIN_DEV_MODE)
  251. if (first_page) count_renders++;
  252. #endif
  253. static char xstring[5], ystring[5], zstring[8];
  254. #if ENABLED(FILAMENT_LCD_DISPLAY)
  255. static char wstring[5], mstring[4];
  256. #endif
  257. // At the first page, generate new display values
  258. if (first_page) {
  259. #if ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER
  260. uint8_t new_bits = 0;
  261. #if ANIM_HOTEND
  262. HOTEND_LOOP() if (thermalManager.isHeatingHotend(e) ^ SHOW_ON_STATE) SBI(new_bits, e);
  263. #endif
  264. #if ANIM_BED
  265. if (thermalManager.isHeatingBed() ^ SHOW_ON_STATE) SBI(new_bits, 7);
  266. #endif
  267. #if ANIM_CHAMBER
  268. if (thermalManager.isHeatingChamber() ^ SHOW_ON_STATE) SBI(new_bits, 6);
  269. #endif
  270. heat_bits = new_bits;
  271. #endif
  272. strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
  273. strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
  274. strcpy(zstring, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])));
  275. #if ENABLED(FILAMENT_LCD_DISPLAY)
  276. strcpy(wstring, ftostr12ns(filament_width_meas));
  277. strcpy(mstring, i16tostr3(100.0 * (
  278. parser.volumetric_enabled
  279. ? planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  280. : planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  281. )
  282. ));
  283. #endif
  284. }
  285. const bool blink = get_blink();
  286. // Status Menu Font
  287. set_font(FONT_STATUSMENU);
  288. #if ENABLED(MARLIN_DEV_MODE)
  289. TCNT5 = 0;
  290. #endif
  291. #if STATUS_LOGO_WIDTH
  292. if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1))
  293. u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp);
  294. #endif
  295. #if STATUS_HEATERS_WIDTH
  296. // Draw all heaters (and maybe the bed) in one go
  297. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1))
  298. u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
  299. #endif
  300. #if DO_DRAW_BED
  301. #if ANIM_BED
  302. #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
  303. #else
  304. #define BED_BITMAP(S) status_bed_bmp
  305. #endif
  306. const uint8_t bedy = STATUS_BED_Y(BED_ALT()), bedh = STATUS_BED_HEIGHT(BED_ALT());
  307. if (PAGE_CONTAINS(bedy, bedy + bedh - 1))
  308. u8g.drawBitmapP(STATUS_BED_X, bedy, STATUS_BED_BYTEWIDTH, bedh, BED_BITMAP(BED_ALT()));
  309. #endif
  310. #if DO_DRAW_CHAMBER
  311. #if ANIM_HAMBER
  312. #define CHAMBER_BITMAP(S) ((S) ? status_chamber_on_bmp : status_chamber_bmp)
  313. #else
  314. #define CHAMBER_BITMAP(S) status_chamber_bmp
  315. #endif
  316. if (PAGE_CONTAINS(STATUS_CHAMBER_Y, STATUS_CHAMBER_Y + STATUS_CHAMBER_HEIGHT - 1))
  317. u8g.drawBitmapP(
  318. STATUS_CHAMBER_X, STATUS_CHAMBER_Y,
  319. STATUS_CHAMBER_BYTEWIDTH, STATUS_CHAMBER_HEIGHT,
  320. CHAMBER_BITMAP(CHAMBER_ALT())
  321. );
  322. #endif
  323. #if DO_DRAW_FAN
  324. #if STATUS_FAN_FRAMES > 2
  325. static bool old_blink;
  326. static uint8_t fan_frame;
  327. if (old_blink != blink) {
  328. old_blink = blink;
  329. if (!thermalManager.fan_speed[0] || ++fan_frame >= STATUS_FAN_FRAMES) fan_frame = 0;
  330. }
  331. #endif
  332. if (PAGE_CONTAINS(STATUS_FAN_Y, STATUS_FAN_Y + STATUS_FAN_HEIGHT - 1))
  333. u8g.drawBitmapP(
  334. STATUS_FAN_X, STATUS_FAN_Y,
  335. STATUS_FAN_BYTEWIDTH, STATUS_FAN_HEIGHT,
  336. #if STATUS_FAN_FRAMES > 2
  337. fan_frame == 1 ? status_fan1_bmp :
  338. fan_frame == 2 ? status_fan2_bmp :
  339. #if STATUS_FAN_FRAMES > 3
  340. fan_frame == 3 ? status_fan3_bmp :
  341. #endif
  342. #elif STATUS_FAN_FRAMES > 1
  343. blink && thermalManager.fan_speed[0] ? status_fan1_bmp :
  344. #endif
  345. status_fan0_bmp
  346. );
  347. #endif
  348. //
  349. // Temperature Graphics and Info
  350. //
  351. if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
  352. // Extruders
  353. for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e)
  354. _draw_heater_status((heater_ind_t)e, blink);
  355. // Heated bed
  356. #if HAS_HEATED_BED && HOTENDS < 4
  357. _draw_heater_status(H_BED, blink);
  358. #endif
  359. #if HAS_HEATED_CHAMBER
  360. _draw_chamber_status(blink);
  361. #endif
  362. // Fan, if a bitmap was provided
  363. #if DO_DRAW_FAN
  364. if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {
  365. char c = '%';
  366. uint16_t spd = thermalManager.fan_speed[0];
  367. if (spd) {
  368. #if ENABLED(ADAPTIVE_FAN_SLOWING)
  369. if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
  370. spd = thermalManager.scaledFanSpeed(0, spd);
  371. c = '*';
  372. }
  373. #endif
  374. lcd_moveto(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y);
  375. lcd_put_u8str(i16tostr3(thermalManager.fanPercent(spd)));
  376. lcd_put_wchar(c);
  377. }
  378. }
  379. #endif
  380. }
  381. #if ENABLED(MARLIN_DEV_MODE)
  382. total_cycles += TCNT5;
  383. #endif
  384. #if ENABLED(SDSUPPORT)
  385. //
  386. // SD Card Symbol
  387. //
  388. if (card.isFileOpen() && PAGE_CONTAINS(42, 51)) {
  389. // Upper box
  390. u8g.drawBox(42, 42, 8, 7); // 42-48 (or 41-47)
  391. // Right edge
  392. u8g.drawBox(50, 44, 2, 5); // 44-48 (or 43-47)
  393. // Bottom hollow box
  394. u8g.drawFrame(42, 49, 10, 4); // 49-52 (or 48-51)
  395. // Corner pixel
  396. u8g.drawPixel(50, 43); // 43 (or 42)
  397. }
  398. #endif // SDSUPPORT
  399. #if HAS_PRINT_PROGRESS
  400. //
  401. // Progress bar frame
  402. //
  403. #define PROGRESS_BAR_X 54
  404. #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
  405. if (PAGE_CONTAINS(49, 52))
  406. u8g.drawFrame(PROGRESS_BAR_X, 49, PROGRESS_BAR_WIDTH, 4);
  407. const uint8_t progress = get_progress();
  408. if (progress > 1) {
  409. //
  410. // Progress bar solid part
  411. //
  412. if (PAGE_CONTAINS(50, 51)) // 50-51 (or just 50)
  413. u8g.drawBox(
  414. PROGRESS_BAR_X + 1, 50,
  415. (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress * 0.01), 2
  416. );
  417. //
  418. // SD Percent Complete
  419. //
  420. #if ENABLED(DOGM_SD_PERCENT)
  421. if (PAGE_CONTAINS(41, 48)) {
  422. // Percent complete
  423. lcd_moveto(55, 48);
  424. lcd_put_u8str(ui8tostr3(progress));
  425. lcd_put_wchar('%');
  426. }
  427. #endif
  428. }
  429. //
  430. // Elapsed Time
  431. //
  432. #if DISABLED(DOGM_SD_PERCENT)
  433. #define SD_DURATION_X (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH / 2) - len * (MENU_FONT_WIDTH / 2))
  434. #else
  435. #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * MENU_FONT_WIDTH)
  436. #endif
  437. if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
  438. char buffer[13];
  439. duration_t elapsed = print_job_timer.duration();
  440. bool has_days = (elapsed.value >= 60*60*24L);
  441. uint8_t len = elapsed.toDigital(buffer, has_days);
  442. lcd_moveto(SD_DURATION_X, EXTRAS_BASELINE);
  443. lcd_put_u8str(buffer);
  444. }
  445. #endif // HAS_PRINT_PROGRESS
  446. //
  447. // XYZ Coordinates
  448. //
  449. #define X_LABEL_POS 3
  450. #define X_VALUE_POS 11
  451. #define XYZ_SPACING 37
  452. #if ENABLED(XYZ_HOLLOW_FRAME)
  453. #define XYZ_FRAME_TOP 29
  454. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 3
  455. #else
  456. #define XYZ_FRAME_TOP 30
  457. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 1
  458. #endif
  459. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  460. #if ENABLED(XYZ_HOLLOW_FRAME)
  461. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  462. #else
  463. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  464. #endif
  465. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_ASCENT - 1), XYZ_BASELINE)) {
  466. #if DISABLED(XYZ_HOLLOW_FRAME)
  467. u8g.setColorIndex(0); // white on black
  468. #endif
  469. #if DUAL_MIXING_EXTRUDER
  470. // Two-component mix / gradient instead of XY
  471. lcd_moveto(X_LABEL_POS, XYZ_BASELINE);
  472. char mixer_messages[12];
  473. const char *mix_label;
  474. #if ENABLED(GRADIENT_MIX)
  475. if (mixer.gradient.enabled) {
  476. mixer.update_mix_from_gradient();
  477. mix_label = "Gr";
  478. }
  479. else
  480. #endif
  481. {
  482. mixer.update_mix_from_vtool();
  483. mix_label = "Mx";
  484. }
  485. sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
  486. lcd_put_u8str(mixer_messages);
  487. #else
  488. _draw_axis_value(X_AXIS, xstring, blink);
  489. _draw_axis_value(Y_AXIS, ystring, blink);
  490. #endif
  491. _draw_axis_value(Z_AXIS, zstring, blink);
  492. #if DISABLED(XYZ_HOLLOW_FRAME)
  493. u8g.setColorIndex(1); // black on white
  494. #endif
  495. }
  496. }
  497. //
  498. // Feedrate
  499. //
  500. #define EXTRAS_2_BASELINE (EXTRAS_BASELINE + 3)
  501. if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
  502. set_font(FONT_MENU);
  503. lcd_moveto(3, EXTRAS_2_BASELINE);
  504. lcd_put_wchar(LCD_STR_FEEDRATE[0]);
  505. set_font(FONT_STATUSMENU);
  506. lcd_moveto(12, EXTRAS_2_BASELINE);
  507. lcd_put_u8str(i16tostr3(feedrate_percentage));
  508. lcd_put_wchar('%');
  509. //
  510. // Filament sensor display if SD is disabled
  511. //
  512. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  513. lcd_moveto(56, EXTRAS_2_BASELINE);
  514. lcd_put_u8str(wstring);
  515. lcd_moveto(102, EXTRAS_2_BASELINE);
  516. lcd_put_u8str(mstring);
  517. lcd_put_wchar('%');
  518. set_font(FONT_MENU);
  519. lcd_moveto(47, EXTRAS_2_BASELINE);
  520. lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  521. lcd_moveto(93, EXTRAS_2_BASELINE);
  522. lcd_put_wchar(LCD_STR_FILAM_MUL[0]);
  523. #endif
  524. }
  525. //
  526. // Status line
  527. //
  528. if (PAGE_CONTAINS(STATUS_BASELINE - INFO_FONT_ASCENT, STATUS_BASELINE + INFO_FONT_DESCENT)) {
  529. lcd_moveto(0, STATUS_BASELINE);
  530. #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
  531. // Alternate Status message and Filament display
  532. if (ELAPSED(millis(), next_filament_display)) {
  533. lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  534. lcd_put_wchar(':');
  535. lcd_put_u8str(wstring);
  536. lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL));
  537. lcd_put_wchar(':');
  538. lcd_put_u8str(mstring);
  539. lcd_put_wchar('%');
  540. }
  541. else
  542. #endif
  543. draw_status_message(blink);
  544. }
  545. }
  546. void MarlinUI::draw_status_message(const bool blink) {
  547. #if ENABLED(MARLIN_DEV_MODE)
  548. if (PAGE_CONTAINS(64-8, 64-1)) {
  549. lcd_put_int(total_cycles);
  550. lcd_put_wchar('/');
  551. lcd_put_int(count_renders);
  552. lcd_put_wchar('=');
  553. lcd_put_int(int(total_cycles / count_renders));
  554. return;
  555. }
  556. #endif
  557. // Get the UTF8 character count of the string
  558. uint8_t slen = utf8_strlen(status_message);
  559. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  560. static bool last_blink = false;
  561. if (slen <= LCD_WIDTH) {
  562. // The string fits within the line. Print with no scrolling
  563. lcd_put_u8str(status_message);
  564. while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; }
  565. }
  566. else {
  567. // String is longer than the available space
  568. // Get a pointer to the next valid UTF8 character
  569. // and the string remaining length
  570. uint8_t rlen;
  571. const char *stat = status_and_len(rlen);
  572. lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
  573. // If the remaining string doesn't completely fill the screen
  574. if (rlen < LCD_WIDTH) {
  575. lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
  576. uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
  577. if (--chars) { // Draw a second dot if there's space
  578. lcd_put_wchar('.');
  579. if (--chars) { // Print a second copy of the message
  580. lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH));
  581. lcd_put_wchar(' ');
  582. }
  583. }
  584. }
  585. if (last_blink != blink) {
  586. last_blink = blink;
  587. advance_status_scroll();
  588. }
  589. }
  590. #else // !STATUS_MESSAGE_SCROLLING
  591. UNUSED(blink);
  592. // Just print the string to the LCD
  593. lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH);
  594. // Fill the rest with spaces
  595. for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' ');
  596. #endif // !STATUS_MESSAGE_SCROLLING
  597. }
  598. #endif // HAS_GRAPHICAL_LCD && !LIGHTWEIGHT_UI