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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  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(TERN0(HAS_Z_AXIS, 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)];
  424. #if HAS_Y_AXIS
  425. static char ystring[xystorage];
  426. #endif
  427. #if HAS_Z_AXIS
  428. static char zstring[8];
  429. #endif
  430. #if ENABLED(FILAMENT_LCD_DISPLAY)
  431. static char wstring[5], mstring[4];
  432. #endif
  433. const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive());
  434. // At the first page, generate new display values
  435. if (first_page) {
  436. #if ANIM_HBCC
  437. uint8_t new_bits = 0;
  438. #if ANIM_HOTEND
  439. HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, DRAWBIT_HOTEND + e);
  440. #endif
  441. if (TERN0(ANIM_BED, thermalManager.isHeatingBed())) SBI(new_bits, DRAWBIT_BED);
  442. #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
  443. if (thermalManager.isHeatingChamber()) SBI(new_bits, DRAWBIT_CHAMBER);
  444. #endif
  445. if (TERN0(ANIM_CUTTER, cutter.enabled())) SBI(new_bits, DRAWBIT_CUTTER);
  446. draw_bits = new_bits;
  447. #endif
  448. const xyz_pos_t lpos = current_position.asLogical();
  449. const bool is_inch = parser.using_inch_units();
  450. #if HAS_Z_AXIS
  451. strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z));
  452. #endif
  453. if (show_e_total) {
  454. #if ENABLED(LCD_SHOW_E_TOTAL)
  455. const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm
  456. sprintf_P(xstring, PSTR("%ld%cm"), uint32_t(_MAX(e_move_accumulator, 0.0f)) / escale, escale == 10 ? 'c' : 'm'); // 1234567mm
  457. #endif
  458. }
  459. else {
  460. strcpy(xstring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.x)) : ftostr4sign(lpos.x));
  461. TERN_(HAS_Y_AXIS, strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y)));
  462. }
  463. #if ENABLED(FILAMENT_LCD_DISPLAY)
  464. strcpy(wstring, ftostr12ns(filwidth.measured_mm));
  465. strcpy(mstring, i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled)));
  466. #endif
  467. // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw
  468. #if HAS_PRINT_PROGRESS
  469. const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
  470. duration_t elapsedt = print_job_timer.duration();
  471. const uint8_t p = progress & 0xFF, ev = elapsedt.value & 0xFF;
  472. if (p != lastProgress) {
  473. lastProgress = p;
  474. progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f);
  475. #if ENABLED(SHOW_PROGRESS_PERCENT)
  476. if (progress == 0)
  477. progress_string[0] = '\0';
  478. else
  479. strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
  480. progress_x_pos = TERN(PCENTERED, 77, _PRGR_INFO_X(strlen(progress_string) + 1));
  481. #endif
  482. }
  483. #if ENABLED(SHOW_INTERACTION_TIME)
  484. if (!(interaction_time)) {
  485. interaction_string[0] = '\0';
  486. interaction_x_pos = _PRGR_INFO_X(0);
  487. }
  488. else {
  489. const duration_t interactt = ui.interaction_time;
  490. interactt.toDigital(interaction_string, interactt.value >= 60*60*24L);
  491. interaction_x_pos = _PRGR_INFO_X(strlen(interaction_string));
  492. }
  493. #endif
  494. #if ENABLED(SHOW_ELAPSED_TIME)
  495. if (ev != lastElapsed) {
  496. lastElapsed = ev;
  497. const uint8_t len = elapsedt.toDigital(elapsed_string, elapsedt.value >= 60*60*24L);
  498. elapsed_x_pos = _PRGR_INFO_X(len);
  499. }
  500. #endif
  501. #if ENABLED(SHOW_REMAINING_TIME)
  502. if (!(ev & 0x3)) {
  503. uint32_t timeval = get_remaining_time();
  504. if (!timeval) {
  505. remaining_string[0] = '\0';
  506. remaining_x_pos = _PRGR_INFO_X(0);
  507. }
  508. else {
  509. const duration_t remaint = timeval;
  510. const uint8_t len = remaint.toDigital(remaining_string, remaint.value >= 60*60*24L);
  511. remaining_x_pos = _PRGR_INFO_X(len);
  512. }
  513. }
  514. #endif
  515. #endif
  516. }
  517. // Status Menu Font
  518. set_font(FONT_STATUSMENU);
  519. #if DO_DRAW_LOGO
  520. if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1))
  521. u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp);
  522. #endif
  523. #if STATUS_HEATERS_WIDTH
  524. // Draw all heaters (and maybe the bed) in one go
  525. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1))
  526. u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
  527. #endif
  528. #if DO_DRAW_CUTTER && DISABLED(STATUS_COMBINE_HEATERS)
  529. #if ANIM_CUTTER
  530. #define CUTTER_BITMAP(S) ((S) ? status_cutter_on_bmp : status_cutter_bmp)
  531. #else
  532. #define CUTTER_BITMAP(S) status_cutter_bmp
  533. #endif
  534. const uint8_t cuttery = STATUS_CUTTER_Y(CUTTER_ALT()),
  535. cutterh = STATUS_CUTTER_HEIGHT(CUTTER_ALT());
  536. if (PAGE_CONTAINS(cuttery, cuttery + cutterh - 1))
  537. u8g.drawBitmapP(STATUS_CUTTER_X, cuttery, STATUS_CUTTER_BYTEWIDTH, cutterh, CUTTER_BITMAP(CUTTER_ALT()));
  538. #endif
  539. #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS)
  540. #if ANIM_BED
  541. #if BOTH(HAS_LEVELING, STATUS_ALT_BED_BITMAP)
  542. #define BED_BITMAP(S) ((S) \
  543. ? (planner.leveling_active ? status_bed_leveled_on_bmp : status_bed_on_bmp) \
  544. : (planner.leveling_active ? status_bed_leveled_bmp : status_bed_bmp))
  545. #else
  546. #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
  547. #endif
  548. #else
  549. #define BED_BITMAP(S) status_bed_bmp
  550. #endif
  551. const uint8_t bedy = STATUS_BED_Y(BED_ALT()),
  552. bedh = STATUS_BED_HEIGHT(BED_ALT());
  553. if (PAGE_CONTAINS(bedy, bedy + bedh - 1))
  554. u8g.drawBitmapP(STATUS_BED_X, bedy, STATUS_BED_BYTEWIDTH, bedh, BED_BITMAP(BED_ALT()));
  555. #endif
  556. #if DO_DRAW_CHAMBER && DISABLED(STATUS_COMBINE_HEATERS)
  557. #if ANIM_CHAMBER
  558. #define CHAMBER_BITMAP(S) ((S) ? status_chamber_on_bmp : status_chamber_bmp)
  559. #else
  560. #define CHAMBER_BITMAP(S) status_chamber_bmp
  561. #endif
  562. const uint8_t chambery = STATUS_CHAMBER_Y(CHAMBER_ALT()),
  563. chamberh = STATUS_CHAMBER_HEIGHT(CHAMBER_ALT());
  564. if (PAGE_CONTAINS(chambery, chambery + chamberh - 1))
  565. u8g.drawBitmapP(STATUS_CHAMBER_X, chambery, STATUS_CHAMBER_BYTEWIDTH, chamberh, CHAMBER_BITMAP(CHAMBER_ALT()));
  566. #endif
  567. const bool blink = ui.get_blink();
  568. #if DO_DRAW_FAN
  569. #if STATUS_FAN_FRAMES > 2
  570. static bool old_blink;
  571. static uint8_t fan_frame;
  572. if (old_blink != blink) {
  573. old_blink = blink;
  574. if (!thermalManager.fan_speed[0] || ++fan_frame >= STATUS_FAN_FRAMES) fan_frame = 0;
  575. }
  576. #endif
  577. if (PAGE_CONTAINS(STATUS_FAN_Y, STATUS_FAN_Y + STATUS_FAN_HEIGHT - 1))
  578. u8g.drawBitmapP(STATUS_FAN_X, STATUS_FAN_Y, STATUS_FAN_BYTEWIDTH, STATUS_FAN_HEIGHT,
  579. #if STATUS_FAN_FRAMES > 2
  580. fan_frame == 1 ? status_fan1_bmp :
  581. fan_frame == 2 ? status_fan2_bmp :
  582. #if STATUS_FAN_FRAMES > 3
  583. fan_frame == 3 ? status_fan3_bmp :
  584. #endif
  585. #elif STATUS_FAN_FRAMES > 1
  586. blink && thermalManager.fan_speed[0] ? status_fan1_bmp :
  587. #endif
  588. status_fan0_bmp
  589. );
  590. #endif
  591. //
  592. // Temperature Graphics and Info
  593. //
  594. if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
  595. // Extruders
  596. #if DO_DRAW_HOTENDS
  597. LOOP_L_N(e, MAX_HOTEND_DRAW) _draw_hotend_status((heater_id_t)e, blink);
  598. #endif
  599. // Laser / Spindle
  600. #if DO_DRAW_CUTTER
  601. if (cutter.isReadyForUI && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
  602. #if CUTTER_UNIT_IS(PERCENT)
  603. lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
  604. #elif CUTTER_UNIT_IS(RPM)
  605. lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000));
  606. lcd_put_lchar('K');
  607. #else
  608. lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
  609. #endif
  610. }
  611. #endif
  612. // Laser Cooler
  613. #if DO_DRAW_COOLER
  614. const uint8_t coolery = STATUS_COOLER_Y(status_cooler_bmp1),
  615. coolerh = STATUS_COOLER_HEIGHT(status_cooler_bmp1);
  616. if (PAGE_CONTAINS(coolery, coolery + coolerh - 1))
  617. u8g.drawBitmapP(STATUS_COOLER_X, coolery, STATUS_COOLER_BYTEWIDTH, coolerh, blink && cooler.enabled ? status_cooler_bmp2 : status_cooler_bmp1);
  618. #endif
  619. // Laser Cooler Flow Meter
  620. #if DO_DRAW_FLOWMETER
  621. const uint8_t flowmetery = STATUS_FLOWMETER_Y(status_flowmeter_bmp1),
  622. flowmeterh = STATUS_FLOWMETER_HEIGHT(status_flowmeter_bmp1);
  623. if (PAGE_CONTAINS(flowmetery, flowmetery + flowmeterh - 1))
  624. u8g.drawBitmapP(STATUS_FLOWMETER_X, flowmetery, STATUS_FLOWMETER_BYTEWIDTH, flowmeterh, blink && cooler.flowpulses ? status_flowmeter_bmp2 : status_flowmeter_bmp1);
  625. #endif
  626. // Laser Ammeter
  627. #if DO_DRAW_AMMETER
  628. const uint8_t ammetery = STATUS_AMMETER_Y(status_ammeter_bmp_mA),
  629. ammeterh = STATUS_AMMETER_HEIGHT(status_ammeter_bmp_mA);
  630. if (PAGE_CONTAINS(ammetery, ammetery + ammeterh - 1))
  631. u8g.drawBitmapP(STATUS_AMMETER_X, ammetery, STATUS_AMMETER_BYTEWIDTH, ammeterh, (ammeter.current < 0.1f) ? status_ammeter_bmp_mA : status_ammeter_bmp_A);
  632. #endif
  633. // Heated Bed
  634. TERN_(DO_DRAW_BED, _draw_bed_status(blink));
  635. // Heated Chamber
  636. TERN_(DO_DRAW_CHAMBER, _draw_chamber_status());
  637. // Cooler
  638. TERN_(DO_DRAW_COOLER, _draw_cooler_status());
  639. // Flowmeter
  640. TERN_(DO_DRAW_FLOWMETER, _draw_flowmeter_status());
  641. // Flowmeter
  642. TERN_(DO_DRAW_AMMETER, _draw_ammeter_status());
  643. // Fan, if a bitmap was provided
  644. #if DO_DRAW_FAN
  645. if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {
  646. char c = '%';
  647. uint16_t spd = thermalManager.fan_speed[0];
  648. if (spd) {
  649. #if ENABLED(ADAPTIVE_FAN_SLOWING)
  650. if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
  651. spd = thermalManager.scaledFanSpeed(0, spd);
  652. c = '*';
  653. }
  654. #endif
  655. lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.pwmToPercent(spd)));
  656. lcd_put_lchar(c);
  657. }
  658. }
  659. #endif
  660. }
  661. #if ENABLED(SDSUPPORT)
  662. //
  663. // SD Card Symbol
  664. //
  665. if (card.isFileOpen() && PAGE_CONTAINS(42, 51)) {
  666. // Upper box
  667. u8g.drawBox(42, 42, 8, 7); // 42-48 (or 41-47)
  668. // Right edge
  669. u8g.drawBox(50, 44, 2, 5); // 44-48 (or 43-47)
  670. // Bottom hollow box
  671. u8g.drawFrame(42, 49, 10, 4); // 49-52 (or 48-51)
  672. // Corner pixel
  673. u8g.drawPixel(50, 43); // 43 (or 42)
  674. }
  675. #endif // SDSUPPORT
  676. #if HAS_PRINT_PROGRESS
  677. // Progress bar frame
  678. if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3))
  679. u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4);
  680. // Progress bar solid part
  681. if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2))
  682. u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2);
  683. // Progress strings
  684. if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1))
  685. ui.rotate_progress();
  686. #endif
  687. //
  688. // XYZ Coordinates
  689. //
  690. #if EITHER(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME)
  691. #define XYZ_FRAME_TOP 29
  692. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 3
  693. #else
  694. #define XYZ_FRAME_TOP 30
  695. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 1
  696. #endif
  697. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  698. #if DISABLED(XYZ_NO_FRAME)
  699. #if ENABLED(XYZ_HOLLOW_FRAME)
  700. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  701. #else
  702. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  703. #endif
  704. #endif
  705. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_ASCENT - 1), XYZ_BASELINE)) {
  706. #if NONE(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME)
  707. u8g.setColorIndex(0); // white on black
  708. #endif
  709. #if HAS_DUAL_MIXING
  710. // Two-component mix / gradient instead of XY
  711. char mixer_messages[15];
  712. PGM_P mix_label;
  713. #if ENABLED(GRADIENT_MIX)
  714. if (mixer.gradient.enabled) {
  715. mixer.update_mix_from_gradient();
  716. mix_label = PSTR("Gr");
  717. }
  718. else
  719. #endif
  720. {
  721. mixer.update_mix_from_vtool();
  722. mix_label = PSTR("Mx");
  723. }
  724. #pragma GCC diagnostic push
  725. #if GCC_VERSION <= 50000
  726. #pragma GCC diagnostic ignored "-Wformat-overflow"
  727. #endif
  728. sprintf_P(mixer_messages, PSTR(S_FMT " %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
  729. lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
  730. #pragma GCC diagnostic pop
  731. #else
  732. if (show_e_total) {
  733. #if ENABLED(LCD_SHOW_E_TOTAL)
  734. _draw_axis_value(E_AXIS, xstring, true);
  735. lcd_put_u8str(F(" "));
  736. #endif
  737. }
  738. else {
  739. _draw_axis_value(X_AXIS, xstring, blink);
  740. TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ystring, blink));
  741. }
  742. #endif
  743. #if HAS_Z_AXIS
  744. _draw_axis_value(Z_AXIS, zstring, blink);
  745. #endif
  746. #if NONE(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME)
  747. u8g.setColorIndex(1); // black on white
  748. #endif
  749. }
  750. }
  751. //
  752. // Feedrate
  753. //
  754. #define EXTRAS_2_BASELINE (EXTRAS_BASELINE + 3)
  755. if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
  756. set_font(FONT_MENU);
  757. lcd_put_lchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]);
  758. set_font(FONT_STATUSMENU);
  759. lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage));
  760. lcd_put_lchar('%');
  761. //
  762. // Filament sensor display if SD is disabled
  763. //
  764. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  765. lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring);
  766. lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring);
  767. lcd_put_lchar('%');
  768. set_font(FONT_MENU);
  769. lcd_put_lchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA));
  770. lcd_put_lchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]);
  771. #endif
  772. }
  773. //
  774. // Status line
  775. //
  776. if (PAGE_CONTAINS(STATUS_BASELINE - INFO_FONT_ASCENT, STATUS_BASELINE + INFO_FONT_DESCENT)) {
  777. lcd_moveto(0, STATUS_BASELINE);
  778. #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
  779. // Alternate Status message and Filament display
  780. if (ELAPSED(millis(), next_filament_display)) {
  781. lcd_put_u8str(F(LCD_STR_FILAM_DIA));
  782. lcd_put_lchar(':');
  783. lcd_put_u8str(wstring);
  784. lcd_put_u8str(F(" " LCD_STR_FILAM_MUL));
  785. lcd_put_lchar(':');
  786. lcd_put_u8str(mstring);
  787. lcd_put_lchar('%');
  788. return;
  789. }
  790. #endif
  791. draw_status_message(blink);
  792. }
  793. }
  794. /**
  795. * Draw the Status Message area
  796. */
  797. void MarlinUI::draw_status_message(const bool blink) {
  798. // Get the UTF8 character count of the string
  799. uint8_t lcd_width = LCD_WIDTH, pixel_width = LCD_PIXEL_WIDTH,
  800. slen = utf8_strlen(status_message);
  801. #if HAS_POWER_MONITOR
  802. if (power_monitor.display_enabled()) {
  803. // make room at the end of the status line for the power monitor reading
  804. lcd_width -= 6;
  805. pixel_width -= (MENU_FONT_WIDTH) * 6;
  806. }
  807. #endif
  808. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  809. static bool last_blink = false;
  810. if (slen <= lcd_width) {
  811. // The string fits within the line. Print with no scrolling
  812. lcd_put_u8str(status_message);
  813. while (slen < lcd_width) { lcd_put_lchar(' '); ++slen; }
  814. }
  815. else {
  816. // String is longer than the available space
  817. if (blink != last_blink) {
  818. last_blink = blink;
  819. advance_status_scroll();
  820. }
  821. // Get a pointer to the next valid UTF8 character
  822. // and the string remaining length
  823. uint8_t rlen;
  824. const char *stat = status_and_len(rlen);
  825. lcd_put_u8str_max(stat, pixel_width);
  826. // If the remaining string doesn't completely fill the screen
  827. if (rlen < lcd_width) {
  828. uint8_t chars = lcd_width - rlen; // Amount of space left in characters
  829. lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space
  830. if (--chars) { // Draw a second space if there's room
  831. lcd_put_lchar(' ');
  832. if (--chars) { // Draw a third space if there's room
  833. lcd_put_lchar(' ');
  834. if (--chars) { // Print a second copy of the message
  835. lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH));
  836. lcd_put_lchar(' ');
  837. }
  838. }
  839. }
  840. }
  841. }
  842. #else // !STATUS_MESSAGE_SCROLLING
  843. UNUSED(blink);
  844. // Just print the string to the LCD
  845. lcd_put_u8str_max(status_message, pixel_width);
  846. // Fill the rest with spaces
  847. for (; slen < lcd_width; ++slen) lcd_put_lchar(' ');
  848. #endif // !STATUS_MESSAGE_SCROLLING
  849. #if HAS_POWER_MONITOR
  850. display_power_monitor(pixel_width + MENU_FONT_WIDTH, STATUS_BASELINE);
  851. #endif
  852. }
  853. #endif // HAS_MARLINUI_U8GLIB && !LIGHTWEIGHT_UI