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

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