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

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