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

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