My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

status_screen_DOGM.cpp 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  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 HAS_DUAL_MIXING
  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 BOTH(ANIM_HOTEND, 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 = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
  252. const uint8_t offs = (XYZ_SPACING) * a;
  253. lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, axis_codes[axis]);
  254. lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
  255. if (blink)
  256. lcd_put_u8str(value);
  257. else {
  258. if (!TEST(axis_homed, axis))
  259. while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
  260. else {
  261. #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
  262. if (!TEST(axis_known_position, axis))
  263. lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
  264. else
  265. #endif
  266. lcd_put_u8str(value);
  267. }
  268. }
  269. }
  270. void MarlinUI::draw_status_screen() {
  271. static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, 5)], ystring[5], zstring[8];
  272. #if ENABLED(FILAMENT_LCD_DISPLAY)
  273. static char wstring[5], mstring[4];
  274. #endif
  275. #if HAS_PRINT_PROGRESS
  276. #if DISABLED(DOGM_SD_PERCENT)
  277. #define _SD_INFO_X(len) (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH) / 2 - (len) * (MENU_FONT_WIDTH) / 2)
  278. #else
  279. #define _SD_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH))
  280. #endif
  281. #if ENABLED(DOGM_SD_PERCENT)
  282. static char progress_string[5];
  283. #endif
  284. static uint8_t lastElapsed = 0xFF, lastProgress = 0xFF;
  285. static u8g_uint_t elapsed_x_pos = 0, progress_bar_solid_width = 0;
  286. static char elapsed_string[16];
  287. #if ENABLED(SHOW_REMAINING_TIME)
  288. static u8g_uint_t estimation_x_pos = 0;
  289. static char estimation_string[10];
  290. #if BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
  291. static u8g_uint_t progress_x_pos = 0;
  292. static uint8_t progress_state = 0;
  293. static bool prev_blink = 0;
  294. #endif
  295. #endif
  296. #endif
  297. const bool showxy = TERN1(LCD_SHOW_E_TOTAL, !printingIsActive());
  298. // At the first page, generate new display values
  299. if (first_page) {
  300. #if ANIM_HBCC
  301. uint8_t new_bits = 0;
  302. #if ANIM_HOTEND
  303. HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, HEATBIT_HOTEND + e);
  304. #endif
  305. if (TERN0(ANIM_BED, thermalManager.isHeatingBed())) SBI(new_bits, HEATBIT_BED);
  306. #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
  307. if (thermalManager.isHeatingChamber()) SBI(new_bits, HEATBIT_CHAMBER);
  308. #endif
  309. if (TERN0(ANIM_CUTTER, cutter.enabled())) SBI(new_bits, HEATBIT_CUTTER);
  310. heat_bits = new_bits;
  311. #endif
  312. const xyz_pos_t lpos = current_position.asLogical();
  313. strcpy(zstring, ftostr52sp(lpos.z));
  314. if (showxy) {
  315. strcpy(xstring, ftostr4sign(lpos.x));
  316. strcpy(ystring, ftostr4sign(lpos.y));
  317. }
  318. else {
  319. #if ENABLED(LCD_SHOW_E_TOTAL)
  320. const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm
  321. sprintf_P(xstring, PSTR("%ld%cm"), uint32_t(_MAX(e_move_accumulator, 0.0f)) / escale, escale == 10 ? 'c' : 'm'); // 1234567mm
  322. #endif
  323. }
  324. #if ENABLED(FILAMENT_LCD_DISPLAY)
  325. strcpy(wstring, ftostr12ns(filwidth.measured_mm));
  326. strcpy(mstring, i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled)));
  327. #endif
  328. // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw
  329. #if HAS_PRINT_PROGRESS
  330. const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
  331. duration_t elapsed = print_job_timer.duration();
  332. const uint8_t p = progress & 0xFF, ev = elapsed.value & 0xFF;
  333. if (p != lastProgress) {
  334. lastProgress = p;
  335. progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f);
  336. #if ENABLED(DOGM_SD_PERCENT)
  337. if (progress == 0) {
  338. progress_string[0] = '\0';
  339. #if ENABLED(SHOW_REMAINING_TIME)
  340. estimation_string[0] = '\0';
  341. estimation_x_pos = _SD_INFO_X(0);
  342. #endif
  343. }
  344. else
  345. strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
  346. #if BOTH(SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) // Tri-state progress display mode
  347. progress_x_pos = _SD_INFO_X(strlen(progress_string) + 1);
  348. #endif
  349. #endif
  350. }
  351. constexpr bool can_show_days = DISABLED(DOGM_SD_PERCENT) || ENABLED(ROTATE_PROGRESS_DISPLAY);
  352. if (ev != lastElapsed) {
  353. lastElapsed = ev;
  354. const uint8_t len = elapsed.toDigital(elapsed_string, can_show_days && elapsed.value >= 60*60*24L);
  355. elapsed_x_pos = _SD_INFO_X(len);
  356. #if ENABLED(SHOW_REMAINING_TIME)
  357. if (!(ev & 0x3)) {
  358. uint32_t timeval = (0
  359. #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
  360. + get_remaining_time()
  361. #endif
  362. );
  363. if (!timeval && progress > 0) timeval = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress;
  364. if (!timeval) {
  365. estimation_string[0] = '\0';
  366. estimation_x_pos = _SD_INFO_X(0);
  367. }
  368. else {
  369. duration_t estimation = timeval;
  370. const uint8_t len = estimation.toDigital(estimation_string, can_show_days && estimation.value >= 60*60*24L);
  371. estimation_x_pos = _SD_INFO_X(len
  372. #if !BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
  373. + 1
  374. #endif
  375. );
  376. }
  377. }
  378. #endif
  379. }
  380. #endif
  381. }
  382. const bool blink = get_blink();
  383. // Status Menu Font
  384. set_font(FONT_STATUSMENU);
  385. #if DO_DRAW_LOGO
  386. if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1))
  387. u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp);
  388. #endif
  389. #if STATUS_HEATERS_WIDTH
  390. // Draw all heaters (and maybe the bed) in one go
  391. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1))
  392. u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
  393. #endif
  394. #if DO_DRAW_CUTTER && DISABLED(STATUS_COMBINE_HEATERS)
  395. #if ANIM_CUTTER
  396. #define CUTTER_BITMAP(S) ((S) ? status_cutter_on_bmp : status_cutter_bmp)
  397. #else
  398. #define CUTTER_BITMAP(S) status_cutter_bmp
  399. #endif
  400. const uint8_t cuttery = STATUS_CUTTER_Y(CUTTER_ALT()),
  401. cutterh = STATUS_CUTTER_HEIGHT(CUTTER_ALT());
  402. if (PAGE_CONTAINS(cuttery, cuttery + cutterh - 1))
  403. u8g.drawBitmapP(STATUS_CUTTER_X, cuttery, STATUS_CUTTER_BYTEWIDTH, cutterh, CUTTER_BITMAP(CUTTER_ALT()));
  404. #endif
  405. #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS)
  406. #if ANIM_BED
  407. #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
  408. #else
  409. #define BED_BITMAP(S) status_bed_bmp
  410. #endif
  411. const uint8_t bedy = STATUS_BED_Y(BED_ALT()),
  412. bedh = STATUS_BED_HEIGHT(BED_ALT());
  413. if (PAGE_CONTAINS(bedy, bedy + bedh - 1))
  414. u8g.drawBitmapP(STATUS_BED_X, bedy, STATUS_BED_BYTEWIDTH, bedh, BED_BITMAP(BED_ALT()));
  415. #endif
  416. #if DO_DRAW_CHAMBER && DISABLED(STATUS_COMBINE_HEATERS)
  417. #if ANIM_CHAMBER
  418. #define CHAMBER_BITMAP(S) ((S) ? status_chamber_on_bmp : status_chamber_bmp)
  419. #else
  420. #define CHAMBER_BITMAP(S) status_chamber_bmp
  421. #endif
  422. const uint8_t chambery = STATUS_CHAMBER_Y(CHAMBER_ALT()),
  423. chamberh = STATUS_CHAMBER_HEIGHT(CHAMBER_ALT());
  424. if (PAGE_CONTAINS(chambery, chambery + chamberh - 1))
  425. u8g.drawBitmapP(STATUS_CHAMBER_X, chambery, STATUS_CHAMBER_BYTEWIDTH, chamberh, CHAMBER_BITMAP(CHAMBER_ALT()));
  426. #endif
  427. #if DO_DRAW_FAN
  428. #if STATUS_FAN_FRAMES > 2
  429. static bool old_blink;
  430. static uint8_t fan_frame;
  431. if (old_blink != blink) {
  432. old_blink = blink;
  433. if (!thermalManager.fan_speed[0] || ++fan_frame >= STATUS_FAN_FRAMES) fan_frame = 0;
  434. }
  435. #endif
  436. if (PAGE_CONTAINS(STATUS_FAN_Y, STATUS_FAN_Y + STATUS_FAN_HEIGHT - 1))
  437. u8g.drawBitmapP(STATUS_FAN_X, STATUS_FAN_Y, STATUS_FAN_BYTEWIDTH, STATUS_FAN_HEIGHT,
  438. #if STATUS_FAN_FRAMES > 2
  439. fan_frame == 1 ? status_fan1_bmp :
  440. fan_frame == 2 ? status_fan2_bmp :
  441. #if STATUS_FAN_FRAMES > 3
  442. fan_frame == 3 ? status_fan3_bmp :
  443. #endif
  444. #elif STATUS_FAN_FRAMES > 1
  445. blink && thermalManager.fan_speed[0] ? status_fan1_bmp :
  446. #endif
  447. status_fan0_bmp
  448. );
  449. #endif
  450. //
  451. // Temperature Graphics and Info
  452. //
  453. if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
  454. // Extruders
  455. #if DO_DRAW_HOTENDS
  456. LOOP_L_N(e, MAX_HOTEND_DRAW)
  457. _draw_hotend_status((heater_ind_t)e, blink);
  458. #endif
  459. // Laser / Spindle
  460. #if DO_DRAW_CUTTER
  461. if (cutter.power && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
  462. lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, i16tostr3rj(cutter.power));
  463. #if CUTTER_DISPLAY_IS(PERCENT)
  464. lcd_put_wchar('%');
  465. #elif CUTTER_DISPLAY_IS(RPM)
  466. lcd_put_wchar('K');
  467. #endif
  468. }
  469. #endif
  470. // Heated Bed
  471. TERN_(DO_DRAW_BED, _draw_bed_status(blink));
  472. // Heated Chamber
  473. TERN_(DO_DRAW_CHAMBER, _draw_chamber_status());
  474. // Fan, if a bitmap was provided
  475. #if DO_DRAW_FAN
  476. if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {
  477. char c = '%';
  478. uint16_t spd = thermalManager.fan_speed[0];
  479. if (spd) {
  480. #if ENABLED(ADAPTIVE_FAN_SLOWING)
  481. if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
  482. spd = thermalManager.scaledFanSpeed(0, spd);
  483. c = '*';
  484. }
  485. #endif
  486. lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.fanPercent(spd)));
  487. lcd_put_wchar(c);
  488. }
  489. }
  490. #endif
  491. }
  492. #if ENABLED(SDSUPPORT)
  493. //
  494. // SD Card Symbol
  495. //
  496. if (card.isFileOpen() && PAGE_CONTAINS(42, 51)) {
  497. // Upper box
  498. u8g.drawBox(42, 42, 8, 7); // 42-48 (or 41-47)
  499. // Right edge
  500. u8g.drawBox(50, 44, 2, 5); // 44-48 (or 43-47)
  501. // Bottom hollow box
  502. u8g.drawFrame(42, 49, 10, 4); // 49-52 (or 48-51)
  503. // Corner pixel
  504. u8g.drawPixel(50, 43); // 43 (or 42)
  505. }
  506. #endif // SDSUPPORT
  507. #if HAS_PRINT_PROGRESS
  508. //
  509. // Progress bar frame
  510. //
  511. if (PAGE_CONTAINS(49, 52))
  512. u8g.drawFrame(PROGRESS_BAR_X, 49, PROGRESS_BAR_WIDTH, 4);
  513. //
  514. // Progress bar solid part
  515. //
  516. if (PAGE_CONTAINS(50, 51)) // 50-51 (or just 50)
  517. u8g.drawBox(PROGRESS_BAR_X + 1, 50, progress_bar_solid_width, 2);
  518. if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
  519. #if ALL(DOGM_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY)
  520. if (prev_blink != blink) {
  521. prev_blink = blink;
  522. if (++progress_state >= 3) progress_state = 0;
  523. }
  524. if (progress_state == 0) {
  525. if (progress_string[0]) {
  526. lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string);
  527. lcd_put_wchar('%');
  528. }
  529. }
  530. else if (progress_state == 2 && estimation_string[0]) {
  531. lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, PSTR("R:"));
  532. lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string);
  533. }
  534. else if (elapsed_string[0]) {
  535. lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, E_LBL);
  536. lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
  537. }
  538. #else // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
  539. //
  540. // SD Percent Complete
  541. //
  542. #if ENABLED(DOGM_SD_PERCENT)
  543. if (progress_string[0]) {
  544. lcd_put_u8str(55, 48, progress_string); // Percent complete
  545. lcd_put_wchar('%');
  546. }
  547. #endif
  548. //
  549. // Elapsed Time
  550. //
  551. #if ENABLED(SHOW_REMAINING_TIME)
  552. if (blink && estimation_string[0]) {
  553. lcd_put_wchar(estimation_x_pos, EXTRAS_BASELINE, 'R');
  554. lcd_put_u8str(estimation_string);
  555. }
  556. else
  557. #endif
  558. lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
  559. #endif // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
  560. }
  561. #endif // HAS_PRINT_PROGRESS
  562. //
  563. // XYZ Coordinates
  564. //
  565. #if ENABLED(XYZ_HOLLOW_FRAME)
  566. #define XYZ_FRAME_TOP 29
  567. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 3
  568. #else
  569. #define XYZ_FRAME_TOP 30
  570. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 1
  571. #endif
  572. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  573. #if ENABLED(XYZ_HOLLOW_FRAME)
  574. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  575. #else
  576. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  577. #endif
  578. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_ASCENT - 1), XYZ_BASELINE)) {
  579. #if DISABLED(XYZ_HOLLOW_FRAME)
  580. u8g.setColorIndex(0); // white on black
  581. #endif
  582. #if HAS_DUAL_MIXING
  583. // Two-component mix / gradient instead of XY
  584. char mixer_messages[12];
  585. const char *mix_label;
  586. #if ENABLED(GRADIENT_MIX)
  587. if (mixer.gradient.enabled) {
  588. mixer.update_mix_from_gradient();
  589. mix_label = "Gr";
  590. }
  591. else
  592. #endif
  593. {
  594. mixer.update_mix_from_vtool();
  595. mix_label = "Mx";
  596. }
  597. sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
  598. lcd_put_u8str(X_LABEL_POS, XYZ_BASELINE, mixer_messages);
  599. #else
  600. if (showxy) {
  601. _draw_axis_value(X_AXIS, xstring, blink);
  602. _draw_axis_value(Y_AXIS, ystring, blink);
  603. }
  604. else {
  605. _draw_axis_value(E_AXIS, xstring, true);
  606. lcd_put_u8str_P(PSTR(" "));
  607. }
  608. #endif
  609. _draw_axis_value(Z_AXIS, zstring, blink);
  610. #if DISABLED(XYZ_HOLLOW_FRAME)
  611. u8g.setColorIndex(1); // black on white
  612. #endif
  613. }
  614. }
  615. //
  616. // Feedrate
  617. //
  618. #define EXTRAS_2_BASELINE (EXTRAS_BASELINE + 3)
  619. if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
  620. set_font(FONT_MENU);
  621. lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]);
  622. set_font(FONT_STATUSMENU);
  623. lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage));
  624. lcd_put_wchar('%');
  625. //
  626. // Filament sensor display if SD is disabled
  627. //
  628. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  629. lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring);
  630. lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring);
  631. lcd_put_wchar('%');
  632. set_font(FONT_MENU);
  633. lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  634. lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]);
  635. #endif
  636. }
  637. //
  638. // Status line
  639. //
  640. if (PAGE_CONTAINS(STATUS_BASELINE - INFO_FONT_ASCENT, STATUS_BASELINE + INFO_FONT_DESCENT)) {
  641. lcd_moveto(0, STATUS_BASELINE);
  642. #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT)
  643. // Alternate Status message and Filament display
  644. if (ELAPSED(millis(), next_filament_display)) {
  645. lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  646. lcd_put_wchar(':');
  647. lcd_put_u8str(wstring);
  648. lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL));
  649. lcd_put_wchar(':');
  650. lcd_put_u8str(mstring);
  651. lcd_put_wchar('%');
  652. }
  653. else
  654. #endif
  655. draw_status_message(blink);
  656. }
  657. }
  658. void MarlinUI::draw_status_message(const bool blink) {
  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