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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. //
  23. // status_screen_DOGM.cpp
  24. // Standard Status Screen for Graphical Display
  25. //
  26. #include "../../inc/MarlinConfigPre.h"
  27. #if HAS_GRAPHICAL_LCD && DISABLED(LIGHTWEIGHT_UI)
  28. #include "dogm_Statusscreen.h"
  29. #include "ultralcd_DOGM.h"
  30. #include "../ultralcd.h"
  31. #include "../lcdprint.h"
  32. #include "../../libs/numtostr.h"
  33. #include "../../module/motion.h"
  34. #include "../../module/temperature.h"
  35. #if ENABLED(FILAMENT_LCD_DISPLAY)
  36. #include "../../feature/filwidth.h"
  37. #include "../../module/planner.h"
  38. #include "../../gcode/parser.h"
  39. #endif
  40. #if HAS_CUTTER
  41. #include "../../feature/spindle_laser.h"
  42. #endif
  43. #if ENABLED(SDSUPPORT)
  44. #include "../../sd/cardreader.h"
  45. #endif
  46. #if HAS_PRINT_PROGRESS
  47. #include "../../module/printcounter.h"
  48. #endif
  49. #if DUAL_MIXING_EXTRUDER
  50. #include "../../feature/mixing.h"
  51. #endif
  52. #define X_LABEL_POS 3
  53. #define X_VALUE_POS 11
  54. #define XYZ_SPACING 37
  55. #define XYZ_BASELINE (30 + INFO_FONT_ASCENT)
  56. #define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
  57. #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
  58. #if ANIM_HBCC
  59. enum HeatBits : uint8_t {
  60. HEATBIT_HOTEND,
  61. HEATBIT_BED = HOTENDS,
  62. HEATBIT_CHAMBER,
  63. HEATBIT_CUTTER
  64. };
  65. IF<(HEATBIT_CUTTER > 7), uint16_t, uint8_t>::type heat_bits;
  66. #endif
  67. #if ANIM_HOTEND
  68. #define HOTEND_ALT(N) TEST(heat_bits, HEATBIT_HOTEND + N)
  69. #else
  70. #define HOTEND_ALT(N) false
  71. #endif
  72. #if ANIM_BED
  73. #define BED_ALT() TEST(heat_bits, HEATBIT_BED)
  74. #else
  75. #define BED_ALT() false
  76. #endif
  77. #if ANIM_CHAMBER
  78. #define CHAMBER_ALT() TEST(heat_bits, HEATBIT_CHAMBER)
  79. #else
  80. #define CHAMBER_ALT() false
  81. #endif
  82. #if ANIM_CUTTER
  83. #define CUTTER_ALT(N) TEST(heat_bits, HEATBIT_CUTTER)
  84. #else
  85. #define CUTTER_ALT() false
  86. #endif
  87. #if DO_DRAW_HOTENDS
  88. #define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
  89. #define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
  90. #endif
  91. #define PROGRESS_BAR_X 54
  92. #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
  93. FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
  94. const char *str = i16tostr3rj(temp);
  95. const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
  96. lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
  97. lcd_put_wchar(LCD_STR_DEGREE[0]);
  98. }
  99. #if DO_DRAW_HOTENDS
  100. // Draw hotend bitmap with current and target temperatures
  101. FORCE_INLINE void _draw_hotend_status(const heater_ind_t heater, const bool blink) {
  102. #if !HEATER_IDLE_HANDLER
  103. UNUSED(blink);
  104. #endif
  105. const bool isHeat = HOTEND_ALT(heater);
  106. const uint8_t tx = STATUS_HOTEND_TEXT_X(heater);
  107. const float temp = thermalManager.degHotend(heater),
  108. target = thermalManager.degTargetHotend(heater);
  109. #if DISABLED(STATUS_HOTEND_ANIM)
  110. #define STATIC_HOTEND true
  111. #define HOTEND_DOT isHeat
  112. #else
  113. #define STATIC_HOTEND false
  114. #define HOTEND_DOT false
  115. #endif
  116. #if ANIM_HOTEND && BOTH(STATUS_HOTEND_INVERTED, STATUS_HOTEND_NUMBERLESS)
  117. #define OFF_BMP(N) status_hotend_b_bmp
  118. #define ON_BMP(N) status_hotend_a_bmp
  119. #elif ANIM_HOTEND && DISABLED(STATUS_HOTEND_INVERTED) && ENABLED(STATUS_HOTEND_NUMBERLESS)
  120. #define OFF_BMP(N) status_hotend_a_bmp
  121. #define ON_BMP(N) status_hotend_b_bmp
  122. #elif ANIM_HOTEND && ENABLED(STATUS_HOTEND_INVERTED)
  123. #define OFF_BMP(N) status_hotend##N##_b_bmp
  124. #define ON_BMP(N) status_hotend##N##_a_bmp
  125. #else
  126. #define OFF_BMP(N) status_hotend##N##_a_bmp
  127. #define ON_BMP(N) status_hotend##N##_b_bmp
  128. #endif
  129. #if STATUS_HOTEND_BITMAPS > 1
  130. 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));
  131. #if ANIM_HOTEND
  132. 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));
  133. #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)])
  134. #else
  135. #define HOTEND_BITMAP(N,S) (unsigned char*)pgm_read_ptr(&status_hotend_gfx[(N) % (STATUS_HOTEND_BITMAPS)])
  136. #endif
  137. #elif ANIM_HOTEND
  138. #define HOTEND_BITMAP(N,S) ((S) ? ON_BMP() : OFF_BMP())
  139. #else
  140. #define HOTEND_BITMAP(N,S) status_hotend_a_bmp
  141. #endif
  142. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) {
  143. #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2)
  144. const float prop = target - 20,
  145. perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0;
  146. uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f);
  147. NOMORE(tall, BAR_TALL);
  148. #if ANIM_HOTEND
  149. // Draw hotend bitmap, either whole or split by the heating percent
  150. const uint8_t hx = STATUS_HOTEND_X(heater),
  151. bw = STATUS_HOTEND_BYTEWIDTH(heater);
  152. #if ENABLED(STATUS_HEAT_PERCENT)
  153. if (isHeat && tall <= BAR_TALL) {
  154. const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
  155. u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(heater, false));
  156. u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(heater, true) + ph * bw);
  157. }
  158. else
  159. #endif
  160. u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(heater, isHeat));
  161. #endif
  162. } // PAGE_CONTAINS
  163. if (PAGE_UNDER(7)) {
  164. #if HEATER_IDLE_HANDLER
  165. const bool dodraw = (blink || !thermalManager.hotend_idle[heater].timed_out);
  166. #else
  167. constexpr bool dodraw = true;
  168. #endif
  169. if (dodraw) _draw_centered_temp(target + 0.5, tx, 7);
  170. }
  171. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  172. _draw_centered_temp(temp + 0.5f, tx, 28);
  173. if (STATIC_HOTEND && HOTEND_DOT && PAGE_CONTAINS(17, 19)) {
  174. u8g.setColorIndex(0); // set to white on black
  175. u8g.drawBox(tx, 20 - 3, 2, 2);
  176. u8g.setColorIndex(1); // restore black on white
  177. }
  178. }
  179. #endif // DO_DRAW_HOTENDS
  180. #if DO_DRAW_BED
  181. // Draw bed bitmap with current and target temperatures
  182. FORCE_INLINE void _draw_bed_status(const bool blink) {
  183. #if !HEATER_IDLE_HANDLER
  184. UNUSED(blink);
  185. #endif
  186. const uint8_t tx = STATUS_BED_TEXT_X;
  187. const float temp = thermalManager.degBed(),
  188. target = thermalManager.degTargetBed();
  189. #if ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM)
  190. const bool isHeat = BED_ALT();
  191. #endif
  192. #if DISABLED(STATUS_BED_ANIM)
  193. #define STATIC_BED true
  194. #define BED_DOT isHeat
  195. #else
  196. #define STATIC_BED false
  197. #define BED_DOT false
  198. #endif
  199. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) {
  200. #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2)
  201. const float prop = target - 20,
  202. perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0;
  203. uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f);
  204. NOMORE(tall, BAR_TALL);
  205. // Draw a heating progress bar, if specified
  206. #if ENABLED(STATUS_HEAT_PERCENT)
  207. if (isHeat) {
  208. const uint8_t bx = STATUS_BED_X + STATUS_BED_WIDTH;
  209. u8g.drawFrame(bx, STATUS_HEATERS_Y, 3, STATUS_HEATERS_HEIGHT);
  210. if (tall) {
  211. const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
  212. if (PAGE_OVER(STATUS_HEATERS_Y + ph))
  213. u8g.drawVLine(bx + 1, STATUS_HEATERS_Y + ph, tall);
  214. }
  215. }
  216. #endif
  217. } // PAGE_CONTAINS
  218. if (PAGE_UNDER(7)) {
  219. #if HEATER_IDLE_HANDLER
  220. const bool dodraw = (blink || !thermalManager.bed_idle.timed_out);
  221. #else
  222. constexpr bool dodraw = true;
  223. #endif
  224. if (dodraw) _draw_centered_temp(target + 0.5, tx, 7);
  225. }
  226. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  227. _draw_centered_temp(temp + 0.5f, tx, 28);
  228. if (STATIC_BED && BED_DOT && PAGE_CONTAINS(17, 19)) {
  229. u8g.setColorIndex(0); // set to white on black
  230. u8g.drawBox(tx, 20 - 2, 2, 2);
  231. u8g.setColorIndex(1); // restore black on white
  232. }
  233. }
  234. #endif // DO_DRAW_BED
  235. #if DO_DRAW_CHAMBER
  236. FORCE_INLINE void _draw_chamber_status() {
  237. #if HAS_HEATED_CHAMBER
  238. if (PAGE_UNDER(7))
  239. _draw_centered_temp(thermalManager.degTargetChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 7);
  240. #endif
  241. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  242. _draw_centered_temp(thermalManager.degChamber() + 0.5f, STATUS_CHAMBER_TEXT_X, 28);
  243. }
  244. #endif // DO_DRAW_CHAMBER
  245. //
  246. // Before homing, blink '123' <-> '???'.
  247. // Homed but unknown... '123' <-> ' '.
  248. // Homed and known, display constantly.
  249. //
  250. FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
  251. const AxisEnum a = (
  252. #if ENABLED(LCD_SHOW_E_TOTAL)
  253. axis == E_AXIS ? X_AXIS :
  254. #endif
  255. axis
  256. );
  257. const uint8_t offs = (XYZ_SPACING) * a;
  258. lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, axis_codes[axis]);
  259. lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
  260. if (blink)
  261. lcd_put_u8str(value);
  262. else {
  263. if (!TEST(axis_homed, axis))
  264. while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
  265. else {
  266. #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
  267. if (!TEST(axis_known_position, axis))
  268. lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
  269. else
  270. #endif
  271. lcd_put_u8str(value);
  272. }
  273. }
  274. }
  275. void MarlinUI::draw_status_screen() {
  276. static char xstring[5
  277. #if ENABLED(LCD_SHOW_E_TOTAL)
  278. + 7
  279. #endif
  280. ], ystring[5], zstring[8];
  281. #if ENABLED(FILAMENT_LCD_DISPLAY)
  282. static char wstring[5], mstring[4];
  283. #endif
  284. #if HAS_PRINT_PROGRESS
  285. #if DISABLED(DOGM_SD_PERCENT)
  286. #define _SD_INFO_X(len) (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH) / 2 - (len) * (MENU_FONT_WIDTH) / 2)
  287. #else
  288. #define _SD_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH))
  289. #endif
  290. #if ENABLED(DOGM_SD_PERCENT)
  291. static char progress_string[5];
  292. #endif
  293. static uint8_t lastElapsed = 0xFF, lastProgress = 0xFF;
  294. static u8g_uint_t elapsed_x_pos = 0, progress_bar_solid_width = 0;
  295. static char elapsed_string[16];
  296. #if ENABLED(SHOW_REMAINING_TIME)
  297. static u8g_uint_t estimation_x_pos = 0;
  298. static char estimation_string[10];
  299. #if BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
  300. static u8g_uint_t progress_x_pos = 0;
  301. static uint8_t progress_state = 0;
  302. static bool prev_blink = 0;
  303. #endif
  304. #endif
  305. #endif
  306. const bool showxy = (true
  307. #if ENABLED(LCD_SHOW_E_TOTAL)
  308. && !printingIsActive()
  309. #endif
  310. );
  311. // At the first page, generate new display values
  312. if (first_page) {
  313. #if ANIM_HBCC
  314. uint8_t new_bits = 0;
  315. #if ANIM_HOTEND
  316. HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, HEATBIT_HOTEND + e);
  317. #endif
  318. #if ANIM_BED
  319. if (thermalManager.isHeatingBed()) SBI(new_bits, HEATBIT_BED);
  320. #endif
  321. #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
  322. if (thermalManager.isHeatingChamber()) SBI(new_bits, HEATBIT_CHAMBER);
  323. #endif
  324. #if ANIM_CUTTER
  325. if (cutter.enabled()) SBI(new_bits, HEATBIT_CUTTER);
  326. #endif
  327. heat_bits = new_bits;
  328. #endif
  329. const xyz_pos_t lpos = current_position.asLogical();
  330. strcpy(zstring, ftostr52sp(lpos.z));
  331. if (showxy) {
  332. strcpy(xstring, ftostr4sign(lpos.x));
  333. strcpy(ystring, ftostr4sign(lpos.y));
  334. }
  335. else {
  336. #if ENABLED(LCD_SHOW_E_TOTAL)
  337. const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm
  338. sprintf_P(xstring, PSTR("%ld%cm"), uint32_t(_MAX(e_move_accumulator, 0.0f)) / escale, escale == 10 ? 'c' : 'm'); // 1234567mm
  339. #endif
  340. }
  341. #if ENABLED(FILAMENT_LCD_DISPLAY)
  342. strcpy(wstring, ftostr12ns(filwidth.measured_mm));
  343. strcpy(mstring, i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled)));
  344. #endif
  345. // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw
  346. #if HAS_PRINT_PROGRESS
  347. const progress_t progress =
  348. #if HAS_PRINT_PROGRESS_PERMYRIAD
  349. get_progress_permyriad()
  350. #else
  351. get_progress_percent()
  352. #endif
  353. ;
  354. duration_t elapsed = print_job_timer.duration();
  355. const uint8_t p = progress & 0xFF, ev = elapsed.value & 0xFF;
  356. if (p != lastProgress) {
  357. lastProgress = p;
  358. progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f);
  359. #if ENABLED(DOGM_SD_PERCENT)
  360. if (progress == 0) {
  361. progress_string[0] = '\0';
  362. #if ENABLED(SHOW_REMAINING_TIME)
  363. estimation_string[0] = '\0';
  364. estimation_x_pos = _SD_INFO_X(0);
  365. #endif
  366. }
  367. else {
  368. strcpy(progress_string, (
  369. #if ENABLED(PRINT_PROGRESS_SHOW_DECIMALS)
  370. permyriadtostr4(progress)
  371. #else
  372. ui8tostr3rj(progress / (PROGRESS_SCALE))
  373. #endif
  374. ));
  375. }
  376. #if BOTH(SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) // Tri-state progress display mode
  377. progress_x_pos = _SD_INFO_X(strlen(progress_string) + 1);
  378. #endif
  379. #endif
  380. }
  381. if (ev != lastElapsed) {
  382. lastElapsed = ev;
  383. const bool has_days = (elapsed.value >= 60*60*24L);
  384. const uint8_t len = elapsed.toDigital(elapsed_string, has_days);
  385. elapsed_x_pos = _SD_INFO_X(len);
  386. #if ENABLED(SHOW_REMAINING_TIME)
  387. if (!(ev & 0x3)) {
  388. uint32_t timeval = (0
  389. #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
  390. + get_remaining_time()
  391. #endif
  392. );
  393. if (!timeval && progress > 0) timeval = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress;
  394. if (!timeval) {
  395. estimation_string[0] = '\0';
  396. estimation_x_pos = _SD_INFO_X(0);
  397. }
  398. else {
  399. duration_t estimation = timeval;
  400. const bool has_days = (estimation.value >= 60*60*24L);
  401. const uint8_t len = estimation.toDigital(estimation_string, has_days);
  402. estimation_x_pos = _SD_INFO_X(len
  403. #if !BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
  404. + 1
  405. #endif
  406. );
  407. }
  408. }
  409. #endif
  410. }
  411. #endif
  412. }
  413. const bool blink = get_blink();
  414. // Status Menu Font
  415. set_font(FONT_STATUSMENU);
  416. #if DO_DRAW_LOGO
  417. if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1))
  418. u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp);
  419. #endif
  420. #if STATUS_HEATERS_WIDTH
  421. // Draw all heaters (and maybe the bed) in one go
  422. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1))
  423. u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
  424. #endif
  425. #if DO_DRAW_CUTTER && DISABLED(STATUS_COMBINE_HEATERS)
  426. #if ANIM_CUTTER
  427. #define CUTTER_BITMAP(S) ((S) ? status_cutter_on_bmp : status_cutter_bmp)
  428. #else
  429. #define CUTTER_BITMAP(S) status_cutter_bmp
  430. #endif
  431. const uint8_t cuttery = STATUS_CUTTER_Y(CUTTER_ALT()),
  432. cutterh = STATUS_CUTTER_HEIGHT(CUTTER_ALT());
  433. if (PAGE_CONTAINS(cuttery, cuttery + cutterh - 1))
  434. u8g.drawBitmapP(STATUS_CUTTER_X, cuttery, STATUS_CUTTER_BYTEWIDTH, cutterh, CUTTER_BITMAP(CUTTER_ALT()));
  435. #endif
  436. #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS)
  437. #if ANIM_BED
  438. #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
  439. #else
  440. #define BED_BITMAP(S) status_bed_bmp
  441. #endif
  442. const uint8_t bedy = STATUS_BED_Y(BED_ALT()),
  443. bedh = STATUS_BED_HEIGHT(BED_ALT());
  444. if (PAGE_CONTAINS(bedy, bedy + bedh - 1))
  445. u8g.drawBitmapP(STATUS_BED_X, bedy, STATUS_BED_BYTEWIDTH, bedh, BED_BITMAP(BED_ALT()));
  446. #endif
  447. #if DO_DRAW_CHAMBER && DISABLED(STATUS_COMBINE_HEATERS)
  448. #if ANIM_CHAMBER
  449. #define CHAMBER_BITMAP(S) ((S) ? status_chamber_on_bmp : status_chamber_bmp)
  450. #else
  451. #define CHAMBER_BITMAP(S) status_chamber_bmp
  452. #endif
  453. const uint8_t chambery = STATUS_CHAMBER_Y(CHAMBER_ALT()),
  454. chamberh = STATUS_CHAMBER_HEIGHT(CHAMBER_ALT());
  455. if (PAGE_CONTAINS(chambery, chambery + chamberh - 1))
  456. u8g.drawBitmapP(STATUS_CHAMBER_X, chambery, STATUS_CHAMBER_BYTEWIDTH, chamberh, CHAMBER_BITMAP(CHAMBER_ALT()));
  457. #endif
  458. #if DO_DRAW_FAN
  459. #if STATUS_FAN_FRAMES > 2
  460. static bool old_blink;
  461. static uint8_t fan_frame;
  462. if (old_blink != blink) {
  463. old_blink = blink;
  464. if (!thermalManager.fan_speed[0] || ++fan_frame >= STATUS_FAN_FRAMES) fan_frame = 0;
  465. }
  466. #endif
  467. if (PAGE_CONTAINS(STATUS_FAN_Y, STATUS_FAN_Y + STATUS_FAN_HEIGHT - 1))
  468. u8g.drawBitmapP(STATUS_FAN_X, STATUS_FAN_Y, STATUS_FAN_BYTEWIDTH, STATUS_FAN_HEIGHT,
  469. #if STATUS_FAN_FRAMES > 2
  470. fan_frame == 1 ? status_fan1_bmp :
  471. fan_frame == 2 ? status_fan2_bmp :
  472. #if STATUS_FAN_FRAMES > 3
  473. fan_frame == 3 ? status_fan3_bmp :
  474. #endif
  475. #elif STATUS_FAN_FRAMES > 1
  476. blink && thermalManager.fan_speed[0] ? status_fan1_bmp :
  477. #endif
  478. status_fan0_bmp
  479. );
  480. #endif
  481. //
  482. // Temperature Graphics and Info
  483. //
  484. if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
  485. // Extruders
  486. #if DO_DRAW_HOTENDS
  487. LOOP_L_N(e, MAX_HOTEND_DRAW)
  488. _draw_hotend_status((heater_ind_t)e, blink);
  489. #endif
  490. // Laser / Spindle
  491. #if DO_DRAW_CUTTER
  492. if (cutter.power && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
  493. lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, i16tostr3rj(cutter.powerPercent(cutter.power)));
  494. lcd_put_wchar('%');
  495. }
  496. #endif
  497. // Heated Bed
  498. #if DO_DRAW_BED
  499. _draw_bed_status(blink);
  500. #endif
  501. // Heated Chamber
  502. #if DO_DRAW_CHAMBER
  503. _draw_chamber_status();
  504. #endif
  505. // Fan, if a bitmap was provided
  506. #if DO_DRAW_FAN
  507. if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {
  508. char c = '%';
  509. uint16_t spd = thermalManager.fan_speed[0];
  510. if (spd) {
  511. #if ENABLED(ADAPTIVE_FAN_SLOWING)
  512. if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
  513. spd = thermalManager.scaledFanSpeed(0, spd);
  514. c = '*';
  515. }
  516. #endif
  517. lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.fanPercent(spd)));
  518. lcd_put_wchar(c);
  519. }
  520. }
  521. #endif
  522. }
  523. #if ENABLED(SDSUPPORT)
  524. //
  525. // SD Card Symbol
  526. //
  527. if (card.isFileOpen() && PAGE_CONTAINS(42, 51)) {
  528. // Upper box
  529. u8g.drawBox(42, 42, 8, 7); // 42-48 (or 41-47)
  530. // Right edge
  531. u8g.drawBox(50, 44, 2, 5); // 44-48 (or 43-47)
  532. // Bottom hollow box
  533. u8g.drawFrame(42, 49, 10, 4); // 49-52 (or 48-51)
  534. // Corner pixel
  535. u8g.drawPixel(50, 43); // 43 (or 42)
  536. }
  537. #endif // SDSUPPORT
  538. #if HAS_PRINT_PROGRESS
  539. //
  540. // Progress bar frame
  541. //
  542. if (PAGE_CONTAINS(49, 52))
  543. u8g.drawFrame(PROGRESS_BAR_X, 49, PROGRESS_BAR_WIDTH, 4);
  544. //
  545. // Progress bar solid part
  546. //
  547. if (PAGE_CONTAINS(50, 51)) // 50-51 (or just 50)
  548. u8g.drawBox(PROGRESS_BAR_X + 1, 50, progress_bar_solid_width, 2);
  549. if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
  550. #if ALL(DOGM_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY)
  551. if (prev_blink != blink) {
  552. prev_blink = blink;
  553. if (++progress_state >= 3) progress_state = 0;
  554. }
  555. if (progress_state == 0) {
  556. if (progress_string[0]) {
  557. lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string);
  558. lcd_put_wchar('%');
  559. }
  560. }
  561. else if (progress_state == 2 && estimation_string[0]) {
  562. lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, PSTR("R:"));
  563. lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string);
  564. }
  565. else if (elapsed_string[0]) {
  566. lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, E_LBL);
  567. lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
  568. }
  569. #else // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
  570. //
  571. // SD Percent Complete
  572. //
  573. #if ENABLED(DOGM_SD_PERCENT)
  574. if (progress_string[0]) {
  575. lcd_put_u8str(55, 48, progress_string); // Percent complete
  576. lcd_put_wchar('%');
  577. }
  578. #endif
  579. //
  580. // Elapsed Time
  581. //
  582. #if ENABLED(SHOW_REMAINING_TIME)
  583. if (blink && estimation_string[0]) {
  584. lcd_put_wchar(estimation_x_pos, EXTRAS_BASELINE, 'R');
  585. lcd_put_u8str(estimation_string);
  586. }
  587. else
  588. #endif
  589. lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
  590. #endif // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
  591. }
  592. #endif // HAS_PRINT_PROGRESS
  593. //
  594. // XYZ Coordinates
  595. //
  596. #if ENABLED(XYZ_HOLLOW_FRAME)
  597. #define XYZ_FRAME_TOP 29
  598. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 3
  599. #else
  600. #define XYZ_FRAME_TOP 30
  601. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 1
  602. #endif
  603. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  604. #if ENABLED(XYZ_HOLLOW_FRAME)
  605. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  606. #else
  607. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  608. #endif
  609. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_ASCENT - 1), XYZ_BASELINE)) {
  610. #if DISABLED(XYZ_HOLLOW_FRAME)
  611. u8g.setColorIndex(0); // white on black
  612. #endif
  613. #if DUAL_MIXING_EXTRUDER
  614. // Two-component mix / gradient instead of XY
  615. char mixer_messages[12];
  616. const char *mix_label;
  617. #if ENABLED(GRADIENT_MIX)
  618. if (mixer.gradient.enabled) {
  619. mixer.update_mix_from_gradient();
  620. mix_label = "Gr";
  621. }
  622. else
  623. #endif
  624. {
  625. mixer.update_mix_from_vtool();
  626. mix_label = "Mx";
  627. }
  628. sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
  629. lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
  630. #else
  631. if (showxy) {
  632. _draw_axis_value(X_AXIS, xstring, blink);
  633. _draw_axis_value(Y_AXIS, ystring, blink);
  634. }
  635. else {
  636. _draw_axis_value(E_AXIS, xstring, true);
  637. lcd_put_u8str_P(PSTR(" "));
  638. }
  639. #endif
  640. _draw_axis_value(Z_AXIS, zstring, blink);
  641. #if DISABLED(XYZ_HOLLOW_FRAME)
  642. u8g.setColorIndex(1); // black on white
  643. #endif
  644. }
  645. }
  646. //
  647. // Feedrate
  648. //
  649. #define EXTRAS_2_BASELINE (EXTRAS_BASELINE + 3)
  650. if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
  651. set_font(FONT_MENU);
  652. lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]);
  653. set_font(FONT_STATUSMENU);
  654. lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage));
  655. lcd_put_wchar('%');
  656. //
  657. // Filament sensor display if SD is disabled
  658. //
  659. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  660. lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring);
  661. lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring);
  662. lcd_put_wchar('%');
  663. set_font(FONT_MENU);
  664. lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  665. lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]);
  666. #endif
  667. }
  668. //
  669. // Status line
  670. //
  671. if (PAGE_CONTAINS(STATUS_BASELINE - INFO_FONT_ASCENT, STATUS_BASELINE + INFO_FONT_DESCENT)) {
  672. lcd_moveto(0, STATUS_BASELINE);
  673. #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
  674. // Alternate Status message and Filament display
  675. if (ELAPSED(millis(), next_filament_display)) {
  676. lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  677. lcd_put_wchar(':');
  678. lcd_put_u8str(wstring);
  679. lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL));
  680. lcd_put_wchar(':');
  681. lcd_put_u8str(mstring);
  682. lcd_put_wchar('%');
  683. }
  684. else
  685. #endif
  686. draw_status_message(blink);
  687. }
  688. }
  689. void MarlinUI::draw_status_message(const bool blink) {
  690. // Get the UTF8 character count of the string
  691. uint8_t slen = utf8_strlen(status_message);
  692. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  693. static bool last_blink = false;
  694. if (slen <= LCD_WIDTH) {
  695. // The string fits within the line. Print with no scrolling
  696. lcd_put_u8str(status_message);
  697. while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; }
  698. }
  699. else {
  700. // String is longer than the available space
  701. // Get a pointer to the next valid UTF8 character
  702. // and the string remaining length
  703. uint8_t rlen;
  704. const char *stat = status_and_len(rlen);
  705. lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
  706. // If the remaining string doesn't completely fill the screen
  707. if (rlen < LCD_WIDTH) {
  708. lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
  709. uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
  710. if (--chars) { // Draw a second dot if there's space
  711. lcd_put_wchar('.');
  712. if (--chars) { // Print a second copy of the message
  713. lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH));
  714. lcd_put_wchar(' ');
  715. }
  716. }
  717. }
  718. if (last_blink != blink) {
  719. last_blink = blink;
  720. advance_status_scroll();
  721. }
  722. }
  723. #else // !STATUS_MESSAGE_SCROLLING
  724. UNUSED(blink);
  725. // Just print the string to the LCD
  726. lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH);
  727. // Fill the rest with spaces
  728. for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' ');
  729. #endif // !STATUS_MESSAGE_SCROLLING
  730. }
  731. #endif // HAS_GRAPHICAL_LCD && !LIGHTWEIGHT_UI