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 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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 <https://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_MARLINUI_U8GLIB && DISABLED(LIGHTWEIGHT_UI)
  28. #include "dogm_Statusscreen.h"
  29. #include "marlinui_DOGM.h"
  30. #include "../marlinui.h"
  31. #include "../lcdprint.h"
  32. #include "../../libs/numtostr.h"
  33. #include "../../module/motion.h"
  34. #include "../../module/temperature.h"
  35. #include "../../gcode/parser.h" // for units (and volumetric)
  36. #if ENABLED(LCD_SHOW_E_TOTAL)
  37. #include "../../MarlinCore.h" // for printingIsActive(), marlin_state and MF_SD_COMPLETE
  38. #endif
  39. #if ENABLED(FILAMENT_LCD_DISPLAY)
  40. #include "../../feature/filwidth.h"
  41. #include "../../module/planner.h"
  42. #endif
  43. #if HAS_CUTTER
  44. #include "../../feature/spindle_laser.h"
  45. #endif
  46. #if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER)
  47. #include "../../feature/cooler.h"
  48. #endif
  49. #if HAS_POWER_MONITOR
  50. #include "../../feature/power_monitor.h"
  51. #endif
  52. #if ENABLED(SDSUPPORT)
  53. #include "../../sd/cardreader.h"
  54. #endif
  55. #if HAS_PRINT_PROGRESS
  56. #include "../../module/printcounter.h"
  57. #endif
  58. #if HAS_DUAL_MIXING
  59. #include "../../feature/mixing.h"
  60. #endif
  61. #define X_LABEL_POS 3
  62. #define X_VALUE_POS 11
  63. #define XYZ_SPACING 37
  64. #define X_LABEL_POS_IN (X_LABEL_POS - 2)
  65. #define X_VALUE_POS_IN (X_VALUE_POS - 5)
  66. #define XYZ_SPACING_IN (XYZ_SPACING + 9)
  67. #define XYZ_BASELINE (30 + INFO_FONT_ASCENT)
  68. #define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
  69. #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
  70. #if ANIM_HBCC
  71. enum HeatBits : uint8_t {
  72. DRAWBIT_HOTEND,
  73. DRAWBIT_BED = HOTENDS,
  74. DRAWBIT_CHAMBER,
  75. DRAWBIT_CUTTER
  76. };
  77. IF<(DRAWBIT_CUTTER > 7), uint16_t, uint8_t>::type draw_bits;
  78. #endif
  79. #if ANIM_HOTEND
  80. #define HOTEND_ALT(N) TEST(draw_bits, DRAWBIT_HOTEND + N)
  81. #else
  82. #define HOTEND_ALT(N) false
  83. #endif
  84. #if ANIM_BED
  85. #define BED_ALT() TEST(draw_bits, DRAWBIT_BED)
  86. #else
  87. #define BED_ALT() false
  88. #endif
  89. #if ANIM_CHAMBER
  90. #define CHAMBER_ALT() TEST(draw_bits, DRAWBIT_CHAMBER)
  91. #else
  92. #define CHAMBER_ALT() false
  93. #endif
  94. #if ANIM_CUTTER
  95. #define CUTTER_ALT(N) TEST(draw_bits, DRAWBIT_CUTTER)
  96. #else
  97. #define CUTTER_ALT() false
  98. #endif
  99. #if DO_DRAW_HOTENDS
  100. #define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
  101. #endif
  102. #if EITHER(DO_DRAW_BED, DO_DRAW_HOTENDS)
  103. #define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
  104. #endif
  105. #if HAS_POWER_MONITOR
  106. void display_power_monitor(const uint8_t x, const uint8_t y) {
  107. lcd_moveto(x, y);
  108. #if HAS_POWER_MONITOR_WATTS
  109. const bool wflag = power_monitor.power_display_enabled();
  110. #endif
  111. #if ENABLED(POWER_MONITOR_CURRENT)
  112. const bool iflag = power_monitor.current_display_enabled();
  113. #endif
  114. #if ENABLED(POWER_MONITOR_VOLTAGE)
  115. const bool vflag = power_monitor.voltage_display_enabled();
  116. #endif
  117. #if HAS_POWER_MONITOR_WATTS
  118. // Cycle between current, voltage, and power
  119. if (ELAPSED(millis(), power_monitor.display_item_ms)) {
  120. power_monitor.display_item_ms = millis() + 1000UL;
  121. ++power_monitor.display_item;
  122. }
  123. #elif ENABLED(POWER_MONITOR_CURRENT)
  124. power_monitor.display_item = 0;
  125. #elif ENABLED(POWER_MONITOR_VOLTAGE)
  126. power_monitor.display_item = 1;
  127. #endif
  128. // ensure we have the right one selected for display
  129. for (uint8_t i = 0; i < 3; i++) {
  130. #if ENABLED(POWER_MONITOR_CURRENT)
  131. if (power_monitor.display_item == 0 && !iflag) ++power_monitor.display_item;
  132. #endif
  133. #if ENABLED(POWER_MONITOR_VOLTAGE)
  134. if (power_monitor.display_item == 1 && !vflag) ++power_monitor.display_item;
  135. #endif
  136. #if HAS_POWER_MONITOR_WATTS
  137. if (power_monitor.display_item == 2 && !wflag) ++power_monitor.display_item;
  138. #endif
  139. if (power_monitor.display_item >= 3) power_monitor.display_item = 0;
  140. }
  141. switch (power_monitor.display_item) {
  142. #if ENABLED(POWER_MONITOR_CURRENT) // Current
  143. case 0: if (iflag) power_monitor.draw_current(); break;
  144. #endif
  145. #if ENABLED(POWER_MONITOR_VOLTAGE) // Voltage
  146. case 1: if (vflag) power_monitor.draw_voltage(); break;
  147. #endif
  148. #if HAS_POWER_MONITOR_WATTS // Power
  149. case 2: if (wflag) power_monitor.draw_power(); break;
  150. #endif
  151. default: break;
  152. }
  153. }
  154. #endif
  155. #define PROGRESS_BAR_X 54
  156. #define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1)
  157. #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
  158. FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
  159. if (temp < 0)
  160. lcd_put_u8str(tx - 3 * (INFO_FONT_WIDTH) / 2 + 1, ty, "err");
  161. else {
  162. const char *str = i16tostr3rj(temp);
  163. const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
  164. lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
  165. lcd_put_wchar(LCD_STR_DEGREE[0]);
  166. }
  167. }
  168. #if DO_DRAW_FLOWMETER
  169. FORCE_INLINE void _draw_centered_flowrate(const float flow, const uint8_t tx, const uint8_t ty) {
  170. const char *str = ftostr11ns(flow);
  171. const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
  172. lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
  173. lcd_put_u8str("L");
  174. }
  175. #endif
  176. #if DO_DRAW_HOTENDS
  177. // Draw hotend bitmap with current and target temperatures
  178. FORCE_INLINE void _draw_hotend_status(const heater_id_t heater_id, const bool blink) {
  179. #if !HEATER_IDLE_HANDLER
  180. UNUSED(blink);
  181. #endif
  182. const bool isHeat = HOTEND_ALT(heater_id);
  183. const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id);
  184. const celsius_t temp = thermalManager.wholeDegHotend(heater_id),
  185. target = thermalManager.degTargetHotend(heater_id);
  186. #if DISABLED(STATUS_HOTEND_ANIM)
  187. #define STATIC_HOTEND true
  188. #define HOTEND_DOT isHeat
  189. #else
  190. #define STATIC_HOTEND false
  191. #define HOTEND_DOT false
  192. #endif
  193. #if ANIM_HOTEND && BOTH(STATUS_HOTEND_INVERTED, STATUS_HOTEND_NUMBERLESS)
  194. #define OFF_BMP(N) status_hotend_b_bmp
  195. #define ON_BMP(N) status_hotend_a_bmp
  196. #elif ANIM_HOTEND && DISABLED(STATUS_HOTEND_INVERTED) && ENABLED(STATUS_HOTEND_NUMBERLESS)
  197. #define OFF_BMP(N) status_hotend_a_bmp
  198. #define ON_BMP(N) status_hotend_b_bmp
  199. #elif BOTH(ANIM_HOTEND, STATUS_HOTEND_INVERTED)
  200. #define OFF_BMP(N) status_hotend##N##_b_bmp
  201. #define ON_BMP(N) status_hotend##N##_a_bmp
  202. #else
  203. #define OFF_BMP(N) status_hotend##N##_a_bmp
  204. #define ON_BMP(N) status_hotend##N##_b_bmp
  205. #endif
  206. #if STATUS_HOTEND_BITMAPS > 1
  207. 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));
  208. #if ANIM_HOTEND
  209. 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));
  210. #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)])
  211. #else
  212. #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr(&status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])
  213. #endif
  214. #elif ANIM_HOTEND
  215. #define HOTEND_BITMAP(N,S) ((S) ? ON_BMP() : OFF_BMP())
  216. #else
  217. #define HOTEND_BITMAP(N,S) status_hotend_a_bmp
  218. #endif
  219. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) {
  220. #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2)
  221. const float prop = target - 20,
  222. perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0;
  223. uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f);
  224. NOMORE(tall, BAR_TALL);
  225. #if ANIM_HOTEND
  226. // Draw hotend bitmap, either whole or split by the heating percent
  227. const uint8_t hx = STATUS_HOTEND_X(heater_id),
  228. bw = STATUS_HOTEND_BYTEWIDTH(heater_id);
  229. #if ENABLED(STATUS_HEAT_PERCENT)
  230. if (isHeat && tall <= BAR_TALL) {
  231. const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
  232. u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(heater_id, false));
  233. u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(heater_id, true) + ph * bw);
  234. }
  235. else
  236. #endif
  237. u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater_id, isHeat));
  238. #endif
  239. } // PAGE_CONTAINS
  240. if (PAGE_UNDER(7)) {
  241. #if HEATER_IDLE_HANDLER
  242. const bool dodraw = (blink || !thermalManager.heater_idle[heater_id].timed_out);
  243. #else
  244. constexpr bool dodraw = true;
  245. #endif
  246. if (dodraw) _draw_centered_temp(target, tx, 7);
  247. }
  248. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  249. _draw_centered_temp(temp, tx, 28);
  250. if (STATIC_HOTEND && HOTEND_DOT && PAGE_CONTAINS(17, 19)) {
  251. u8g.setColorIndex(0); // set to white on black
  252. u8g.drawBox(tx, 20 - 3, 2, 2);
  253. u8g.setColorIndex(1); // restore black on white
  254. }
  255. }
  256. #endif // DO_DRAW_HOTENDS
  257. #if DO_DRAW_BED
  258. // Draw bed bitmap with current and target temperatures
  259. FORCE_INLINE void _draw_bed_status(const bool blink) {
  260. #if !HEATER_IDLE_HANDLER
  261. UNUSED(blink);
  262. #endif
  263. const uint8_t tx = STATUS_BED_TEXT_X;
  264. const celsius_t temp = thermalManager.wholeDegBed(),
  265. target = thermalManager.degTargetBed();
  266. #if ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM)
  267. const bool isHeat = BED_ALT();
  268. #endif
  269. #if DISABLED(STATUS_BED_ANIM)
  270. #define STATIC_BED true
  271. #define BED_DOT isHeat
  272. #else
  273. #define STATIC_BED false
  274. #define BED_DOT false
  275. #endif
  276. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) {
  277. #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2)
  278. const float prop = target - 20,
  279. perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0;
  280. uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f);
  281. NOMORE(tall, BAR_TALL);
  282. // Draw a heating progress bar, if specified
  283. #if ENABLED(STATUS_HEAT_PERCENT)
  284. if (isHeat) {
  285. const uint8_t bx = STATUS_BED_X + STATUS_BED_WIDTH;
  286. u8g.drawFrame(bx, STATUS_HEATERS_Y, 3, STATUS_HEATERS_HEIGHT);
  287. if (tall) {
  288. const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
  289. if (PAGE_OVER(STATUS_HEATERS_Y + ph))
  290. u8g.drawVLine(bx + 1, STATUS_HEATERS_Y + ph, tall);
  291. }
  292. }
  293. #endif
  294. } // PAGE_CONTAINS
  295. if (PAGE_UNDER(7)) {
  296. #if HEATER_IDLE_HANDLER
  297. const bool dodraw = (blink || !thermalManager.heater_idle[thermalManager.IDLE_INDEX_BED].timed_out);
  298. #else
  299. constexpr bool dodraw = true;
  300. #endif
  301. if (dodraw) _draw_centered_temp(target, tx, 7);
  302. }
  303. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  304. _draw_centered_temp(temp, tx, 28);
  305. if (STATIC_BED && BED_DOT && PAGE_CONTAINS(17, 19)) {
  306. u8g.setColorIndex(0); // set to white on black
  307. u8g.drawBox(tx, 20 - 2, 2, 2);
  308. u8g.setColorIndex(1); // restore black on white
  309. }
  310. }
  311. #endif // DO_DRAW_BED
  312. #if DO_DRAW_CHAMBER
  313. FORCE_INLINE void _draw_chamber_status() {
  314. #if HAS_HEATED_CHAMBER
  315. if (PAGE_UNDER(7))
  316. _draw_centered_temp(thermalManager.degTargetChamber(), STATUS_CHAMBER_TEXT_X, 7);
  317. #endif
  318. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  319. _draw_centered_temp(thermalManager.wholeDegChamber(), STATUS_CHAMBER_TEXT_X, 28);
  320. }
  321. #endif
  322. #if DO_DRAW_COOLER
  323. FORCE_INLINE void _draw_cooler_status() {
  324. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  325. _draw_centered_temp(thermalManager.wholeDegCooler(), STATUS_COOLER_TEXT_X, 28);
  326. }
  327. #endif
  328. #if DO_DRAW_FLOWMETER
  329. FORCE_INLINE void _draw_flowmeter_status() {
  330. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  331. _draw_centered_flowrate(cooler.flowrate, STATUS_FLOWMETER_TEXT_X, 28);
  332. }
  333. #endif
  334. //
  335. // Before homing, blink '123' <-> '???'.
  336. // Homed but unknown... '123' <-> ' '.
  337. // Homed and known, display constantly.
  338. //
  339. FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
  340. const bool is_inch = parser.using_inch_units();
  341. const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
  342. const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING);
  343. lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, axis_codes[axis]);
  344. lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE);
  345. if (blink)
  346. lcd_put_u8str(value);
  347. else if (axis_should_home(axis))
  348. while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
  349. else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis))
  350. lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
  351. else
  352. lcd_put_u8str(value);
  353. }
  354. /**
  355. * Draw the Status Screen for a 128x64 DOGM (U8glib) display.
  356. *
  357. * Called as needed to update the current display stripe.
  358. * Use the PAGE_CONTAINS macros to avoid pointless draw calls.
  359. */
  360. void MarlinUI::draw_status_screen() {
  361. constexpr int xystorage = TERN(INCH_MODE_SUPPORT, 8, 5);
  362. static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, xystorage)], ystring[xystorage], zstring[8];
  363. #if ENABLED(FILAMENT_LCD_DISPLAY)
  364. static char wstring[5], mstring[4];
  365. #endif
  366. #if HAS_PRINT_PROGRESS
  367. #if DISABLED(DOGM_SD_PERCENT)
  368. #define _SD_INFO_X(len) (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH) / 2 - (len) * (MENU_FONT_WIDTH) / 2)
  369. #else
  370. #define _SD_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH))
  371. #endif
  372. #if ENABLED(DOGM_SD_PERCENT)
  373. static char progress_string[5];
  374. #endif
  375. static uint8_t lastElapsed = 0xFF, lastProgress = 0xFF;
  376. static u8g_uint_t elapsed_x_pos = 0, progress_bar_solid_width = 0;
  377. static char elapsed_string[16];
  378. #if ENABLED(SHOW_REMAINING_TIME)
  379. static u8g_uint_t estimation_x_pos = 0;
  380. static char estimation_string[10];
  381. #if BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
  382. static u8g_uint_t progress_x_pos = 0;
  383. static uint8_t progress_state = 0;
  384. static bool prev_blink = 0;
  385. #endif
  386. #endif
  387. #endif
  388. const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive() || marlin_state == MF_SD_COMPLETE);
  389. // At the first page, generate new display values
  390. if (first_page) {
  391. #if ANIM_HBCC
  392. uint8_t new_bits = 0;
  393. #if ANIM_HOTEND
  394. HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, DRAWBIT_HOTEND + e);
  395. #endif
  396. if (TERN0(ANIM_BED, thermalManager.isHeatingBed())) SBI(new_bits, DRAWBIT_BED);
  397. #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
  398. if (thermalManager.isHeatingChamber()) SBI(new_bits, DRAWBIT_CHAMBER);
  399. #endif
  400. if (TERN0(ANIM_CUTTER, cutter.enabled())) SBI(new_bits, DRAWBIT_CUTTER);
  401. draw_bits = new_bits;
  402. #endif
  403. const xyz_pos_t lpos = current_position.asLogical();
  404. const bool is_inch = parser.using_inch_units();
  405. strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z));
  406. if (show_e_total) {
  407. #if ENABLED(LCD_SHOW_E_TOTAL)
  408. const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm
  409. sprintf_P(xstring, PSTR("%ld%cm"), uint32_t(_MAX(e_move_accumulator, 0.0f)) / escale, escale == 10 ? 'c' : 'm'); // 1234567mm
  410. #endif
  411. }
  412. else {
  413. strcpy(xstring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.x)) : ftostr4sign(lpos.x));
  414. strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y));
  415. }
  416. #if ENABLED(FILAMENT_LCD_DISPLAY)
  417. strcpy(wstring, ftostr12ns(filwidth.measured_mm));
  418. strcpy(mstring, i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled)));
  419. #endif
  420. // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw
  421. #if HAS_PRINT_PROGRESS
  422. const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
  423. duration_t elapsed = print_job_timer.duration();
  424. const uint8_t p = progress & 0xFF, ev = elapsed.value & 0xFF;
  425. if (p != lastProgress) {
  426. lastProgress = p;
  427. progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f);
  428. #if ENABLED(DOGM_SD_PERCENT)
  429. if (progress == 0) {
  430. progress_string[0] = '\0';
  431. #if ENABLED(SHOW_REMAINING_TIME)
  432. estimation_string[0] = '\0';
  433. estimation_x_pos = _SD_INFO_X(0);
  434. #endif
  435. }
  436. else
  437. strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
  438. #if BOTH(SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) // Tri-state progress display mode
  439. progress_x_pos = _SD_INFO_X(strlen(progress_string) + 1);
  440. #endif
  441. #endif
  442. }
  443. constexpr bool can_show_days = DISABLED(DOGM_SD_PERCENT) || ENABLED(ROTATE_PROGRESS_DISPLAY);
  444. if (ev != lastElapsed) {
  445. lastElapsed = ev;
  446. const uint8_t len = elapsed.toDigital(elapsed_string, can_show_days && elapsed.value >= 60*60*24L);
  447. elapsed_x_pos = _SD_INFO_X(len);
  448. #if ENABLED(SHOW_REMAINING_TIME)
  449. if (!(ev & 0x3)) {
  450. uint32_t timeval = (0
  451. #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
  452. + get_remaining_time()
  453. #endif
  454. );
  455. if (!timeval && progress > 0) timeval = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress;
  456. if (!timeval) {
  457. estimation_string[0] = '\0';
  458. estimation_x_pos = _SD_INFO_X(0);
  459. }
  460. else {
  461. duration_t estimation = timeval;
  462. const uint8_t len = estimation.toDigital(estimation_string, can_show_days && estimation.value >= 60*60*24L);
  463. estimation_x_pos = _SD_INFO_X(len
  464. #if !BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
  465. + 1
  466. #endif
  467. );
  468. }
  469. }
  470. #endif
  471. }
  472. #endif
  473. }
  474. const bool blink = get_blink();
  475. // Status Menu Font
  476. set_font(FONT_STATUSMENU);
  477. #if DO_DRAW_LOGO
  478. if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1))
  479. u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp);
  480. #endif
  481. #if STATUS_HEATERS_WIDTH
  482. // Draw all heaters (and maybe the bed) in one go
  483. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1))
  484. u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
  485. #endif
  486. #if DO_DRAW_CUTTER && DISABLED(STATUS_COMBINE_HEATERS)
  487. #if ANIM_CUTTER
  488. #define CUTTER_BITMAP(S) ((S) ? status_cutter_on_bmp : status_cutter_bmp)
  489. #else
  490. #define CUTTER_BITMAP(S) status_cutter_bmp
  491. #endif
  492. const uint8_t cuttery = STATUS_CUTTER_Y(CUTTER_ALT()),
  493. cutterh = STATUS_CUTTER_HEIGHT(CUTTER_ALT());
  494. if (PAGE_CONTAINS(cuttery, cuttery + cutterh - 1))
  495. u8g.drawBitmapP(STATUS_CUTTER_X, cuttery, STATUS_CUTTER_BYTEWIDTH, cutterh, CUTTER_BITMAP(CUTTER_ALT()));
  496. #endif
  497. #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS)
  498. #if ANIM_BED
  499. #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
  500. #else
  501. #define BED_BITMAP(S) status_bed_bmp
  502. #endif
  503. const uint8_t bedy = STATUS_BED_Y(BED_ALT()),
  504. bedh = STATUS_BED_HEIGHT(BED_ALT());
  505. if (PAGE_CONTAINS(bedy, bedy + bedh - 1))
  506. u8g.drawBitmapP(STATUS_BED_X, bedy, STATUS_BED_BYTEWIDTH, bedh, BED_BITMAP(BED_ALT()));
  507. #endif
  508. #if DO_DRAW_CHAMBER && DISABLED(STATUS_COMBINE_HEATERS)
  509. #if ANIM_CHAMBER
  510. #define CHAMBER_BITMAP(S) ((S) ? status_chamber_on_bmp : status_chamber_bmp)
  511. #else
  512. #define CHAMBER_BITMAP(S) status_chamber_bmp
  513. #endif
  514. const uint8_t chambery = STATUS_CHAMBER_Y(CHAMBER_ALT()),
  515. chamberh = STATUS_CHAMBER_HEIGHT(CHAMBER_ALT());
  516. if (PAGE_CONTAINS(chambery, chambery + chamberh - 1))
  517. u8g.drawBitmapP(STATUS_CHAMBER_X, chambery, STATUS_CHAMBER_BYTEWIDTH, chamberh, CHAMBER_BITMAP(CHAMBER_ALT()));
  518. #endif
  519. #if DO_DRAW_FAN
  520. #if STATUS_FAN_FRAMES > 2
  521. static bool old_blink;
  522. static uint8_t fan_frame;
  523. if (old_blink != blink) {
  524. old_blink = blink;
  525. if (!thermalManager.fan_speed[0] || ++fan_frame >= STATUS_FAN_FRAMES) fan_frame = 0;
  526. }
  527. #endif
  528. if (PAGE_CONTAINS(STATUS_FAN_Y, STATUS_FAN_Y + STATUS_FAN_HEIGHT - 1))
  529. u8g.drawBitmapP(STATUS_FAN_X, STATUS_FAN_Y, STATUS_FAN_BYTEWIDTH, STATUS_FAN_HEIGHT,
  530. #if STATUS_FAN_FRAMES > 2
  531. fan_frame == 1 ? status_fan1_bmp :
  532. fan_frame == 2 ? status_fan2_bmp :
  533. #if STATUS_FAN_FRAMES > 3
  534. fan_frame == 3 ? status_fan3_bmp :
  535. #endif
  536. #elif STATUS_FAN_FRAMES > 1
  537. blink && thermalManager.fan_speed[0] ? status_fan1_bmp :
  538. #endif
  539. status_fan0_bmp
  540. );
  541. #endif
  542. //
  543. // Temperature Graphics and Info
  544. //
  545. if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
  546. // Extruders
  547. #if DO_DRAW_HOTENDS
  548. LOOP_L_N(e, MAX_HOTEND_DRAW)
  549. _draw_hotend_status((heater_id_t)e, blink);
  550. #endif
  551. // Laser / Spindle
  552. #if DO_DRAW_CUTTER
  553. if (cutter.isReady && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
  554. #if CUTTER_UNIT_IS(PERCENT)
  555. lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
  556. #elif CUTTER_UNIT_IS(RPM)
  557. lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr51rj(float(cutter.unitPower) / 1000));
  558. lcd_put_wchar('K');
  559. #else
  560. lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
  561. #endif
  562. }
  563. #endif
  564. // Laser Cooler
  565. #if DO_DRAW_COOLER
  566. const uint8_t coolery = STATUS_COOLER_Y(status_cooler_bmp1),
  567. coolerh = STATUS_COOLER_HEIGHT(status_cooler_bmp1);
  568. if (PAGE_CONTAINS(coolery, coolery + coolerh - 1))
  569. u8g.drawBitmapP(STATUS_COOLER_X, coolery, STATUS_COOLER_BYTEWIDTH, coolerh, blink && cooler.enabled ? status_cooler_bmp2 : status_cooler_bmp1);
  570. #endif
  571. // Laser Cooler Flow Meter
  572. #if DO_DRAW_FLOWMETER
  573. const uint8_t flowmetery = STATUS_FLOWMETER_Y(status_flowmeter_bmp1),
  574. flowmeterh = STATUS_FLOWMETER_HEIGHT(status_flowmeter_bmp1);
  575. if (PAGE_CONTAINS(flowmetery, flowmetery + flowmeterh - 1))
  576. u8g.drawBitmapP(STATUS_FLOWMETER_X, flowmetery, STATUS_FLOWMETER_BYTEWIDTH, flowmeterh, blink && cooler.flowpulses ? status_flowmeter_bmp2 : status_flowmeter_bmp1);
  577. #endif
  578. // Heated Bed
  579. TERN_(DO_DRAW_BED, _draw_bed_status(blink));
  580. // Heated Chamber
  581. TERN_(DO_DRAW_CHAMBER, _draw_chamber_status());
  582. // Cooler
  583. TERN_(DO_DRAW_COOLER, _draw_cooler_status());
  584. // Flowmeter
  585. TERN_(DO_DRAW_FLOWMETER, _draw_flowmeter_status());
  586. // Fan, if a bitmap was provided
  587. #if DO_DRAW_FAN
  588. if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {
  589. char c = '%';
  590. uint16_t spd = thermalManager.fan_speed[0];
  591. if (spd) {
  592. #if ENABLED(ADAPTIVE_FAN_SLOWING)
  593. if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
  594. spd = thermalManager.scaledFanSpeed(0, spd);
  595. c = '*';
  596. }
  597. #endif
  598. lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.pwmToPercent(spd)));
  599. lcd_put_wchar(c);
  600. }
  601. }
  602. #endif
  603. }
  604. #if ENABLED(SDSUPPORT)
  605. //
  606. // SD Card Symbol
  607. //
  608. if (card.isFileOpen() && PAGE_CONTAINS(42, 51)) {
  609. // Upper box
  610. u8g.drawBox(42, 42, 8, 7); // 42-48 (or 41-47)
  611. // Right edge
  612. u8g.drawBox(50, 44, 2, 5); // 44-48 (or 43-47)
  613. // Bottom hollow box
  614. u8g.drawFrame(42, 49, 10, 4); // 49-52 (or 48-51)
  615. // Corner pixel
  616. u8g.drawPixel(50, 43); // 43 (or 42)
  617. }
  618. #endif // SDSUPPORT
  619. #if HAS_PRINT_PROGRESS
  620. //
  621. // Progress bar frame
  622. //
  623. if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3))
  624. u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4);
  625. //
  626. // Progress bar solid part
  627. //
  628. if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2))
  629. u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2);
  630. if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
  631. #if ALL(DOGM_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY)
  632. if (prev_blink != blink) {
  633. prev_blink = blink;
  634. if (++progress_state >= 3) progress_state = 0;
  635. }
  636. if (progress_state == 0) {
  637. if (progress_string[0]) {
  638. lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string);
  639. lcd_put_wchar('%');
  640. }
  641. }
  642. else if (progress_state == 2 && estimation_string[0]) {
  643. lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, PSTR("R:"));
  644. lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string);
  645. }
  646. else if (elapsed_string[0]) {
  647. lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, E_LBL);
  648. lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
  649. }
  650. #else // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
  651. //
  652. // SD Percent Complete
  653. //
  654. #if ENABLED(DOGM_SD_PERCENT)
  655. if (progress_string[0]) {
  656. lcd_put_u8str(55, EXTRAS_BASELINE, progress_string); // Percent complete
  657. lcd_put_wchar('%');
  658. }
  659. #endif
  660. //
  661. // Elapsed Time
  662. //
  663. #if ENABLED(SHOW_REMAINING_TIME)
  664. if (blink && estimation_string[0]) {
  665. lcd_put_wchar(estimation_x_pos, EXTRAS_BASELINE, 'R');
  666. lcd_put_u8str(estimation_string);
  667. }
  668. else
  669. #endif
  670. lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
  671. #endif // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
  672. }
  673. #endif // HAS_PRINT_PROGRESS
  674. //
  675. // XYZ Coordinates
  676. //
  677. #if EITHER(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME)
  678. #define XYZ_FRAME_TOP 29
  679. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 3
  680. #else
  681. #define XYZ_FRAME_TOP 30
  682. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 1
  683. #endif
  684. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  685. #if DISABLED(XYZ_NO_FRAME)
  686. #if ENABLED(XYZ_HOLLOW_FRAME)
  687. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  688. #else
  689. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  690. #endif
  691. #endif
  692. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_ASCENT - 1), XYZ_BASELINE)) {
  693. #if NONE(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME)
  694. u8g.setColorIndex(0); // white on black
  695. #endif
  696. #if HAS_DUAL_MIXING
  697. // Two-component mix / gradient instead of XY
  698. char mixer_messages[15];
  699. PGM_P mix_label;
  700. #if ENABLED(GRADIENT_MIX)
  701. if (mixer.gradient.enabled) {
  702. mixer.update_mix_from_gradient();
  703. mix_label = PSTR("Gr");
  704. }
  705. else
  706. #endif
  707. {
  708. mixer.update_mix_from_vtool();
  709. mix_label = PSTR("Mx");
  710. }
  711. #if GCC_VERSION <= 50000
  712. #pragma GCC diagnostic push
  713. #pragma GCC diagnostic ignored "-Wformat-overflow"
  714. #endif
  715. sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
  716. lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
  717. #if GCC_VERSION <= 50000
  718. #pragma GCC diagnostic pop
  719. #endif
  720. #else
  721. if (show_e_total) {
  722. _draw_axis_value(E_AXIS, xstring, true);
  723. lcd_put_u8str_P(PSTR(" "));
  724. }
  725. else {
  726. _draw_axis_value(X_AXIS, xstring, blink);
  727. _draw_axis_value(Y_AXIS, ystring, blink);
  728. }
  729. #endif
  730. _draw_axis_value(Z_AXIS, zstring, blink);
  731. #if NONE(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME)
  732. u8g.setColorIndex(1); // black on white
  733. #endif
  734. }
  735. }
  736. //
  737. // Feedrate
  738. //
  739. #define EXTRAS_2_BASELINE (EXTRAS_BASELINE + 3)
  740. if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
  741. set_font(FONT_MENU);
  742. lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]);
  743. set_font(FONT_STATUSMENU);
  744. lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage));
  745. lcd_put_wchar('%');
  746. //
  747. // Filament sensor display if SD is disabled
  748. //
  749. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  750. lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring);
  751. lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring);
  752. lcd_put_wchar('%');
  753. set_font(FONT_MENU);
  754. lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  755. lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]);
  756. #endif
  757. }
  758. //
  759. // Status line
  760. //
  761. if (PAGE_CONTAINS(STATUS_BASELINE - INFO_FONT_ASCENT, STATUS_BASELINE + INFO_FONT_DESCENT)) {
  762. lcd_moveto(0, STATUS_BASELINE);
  763. #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
  764. // Alternate Status message and Filament display
  765. if (ELAPSED(millis(), next_filament_display)) {
  766. lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  767. lcd_put_wchar(':');
  768. lcd_put_u8str(wstring);
  769. lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL));
  770. lcd_put_wchar(':');
  771. lcd_put_u8str(mstring);
  772. lcd_put_wchar('%');
  773. return;
  774. }
  775. #endif
  776. draw_status_message(blink);
  777. }
  778. }
  779. /**
  780. * Draw the Status Message area
  781. */
  782. void MarlinUI::draw_status_message(const bool blink) {
  783. // Get the UTF8 character count of the string
  784. uint8_t lcd_width = LCD_WIDTH, pixel_width = LCD_PIXEL_WIDTH,
  785. slen = utf8_strlen(status_message);
  786. #if HAS_POWER_MONITOR
  787. if (power_monitor.display_enabled()) {
  788. // make room at the end of the status line for the power monitor reading
  789. lcd_width -= 6;
  790. pixel_width -= (MENU_FONT_WIDTH) * 6;
  791. }
  792. #endif
  793. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  794. static bool last_blink = false;
  795. if (slen <= lcd_width) {
  796. // The string fits within the line. Print with no scrolling
  797. lcd_put_u8str(status_message);
  798. while (slen < lcd_width) { lcd_put_wchar(' '); ++slen; }
  799. }
  800. else {
  801. // String is longer than the available space
  802. if (blink != last_blink) {
  803. last_blink = blink;
  804. advance_status_scroll();
  805. }
  806. // Get a pointer to the next valid UTF8 character
  807. // and the string remaining length
  808. uint8_t rlen;
  809. const char *stat = status_and_len(rlen);
  810. lcd_put_u8str_max(stat, pixel_width);
  811. // If the remaining string doesn't completely fill the screen
  812. if (rlen < lcd_width) {
  813. uint8_t chars = lcd_width - rlen; // Amount of space left in characters
  814. lcd_put_wchar(' '); // Always at 1+ spaces left, draw a space
  815. if (--chars) { // Draw a second space if there's room
  816. lcd_put_wchar(' ');
  817. if (--chars) { // Draw a third space if there's room
  818. lcd_put_wchar(' ');
  819. if (--chars) { // Print a second copy of the message
  820. lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH));
  821. lcd_put_wchar(' ');
  822. }
  823. }
  824. }
  825. }
  826. }
  827. #else // !STATUS_MESSAGE_SCROLLING
  828. UNUSED(blink);
  829. // Just print the string to the LCD
  830. lcd_put_u8str_max(status_message, pixel_width);
  831. // Fill the rest with spaces
  832. for (; slen < lcd_width; ++slen) lcd_put_wchar(' ');
  833. #endif // !STATUS_MESSAGE_SCROLLING
  834. #if HAS_POWER_MONITOR
  835. display_power_monitor(pixel_width + MENU_FONT_WIDTH, STATUS_BASELINE);
  836. #endif
  837. }
  838. #endif // HAS_MARLINUI_U8GLIB && !LIGHTWEIGHT_UI