My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

status_screen_DOGM.cpp 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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 "../../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. #if DUAL_MIXING_EXTRUDER
  46. #include "../../feature/mixing.h"
  47. #endif
  48. FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, const uint8_t ty) {
  49. const char *str = i16tostr3(temp);
  50. const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
  51. lcd_moveto(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty);
  52. lcd_put_u8str(&str[3-len]);
  53. lcd_put_wchar(LCD_STR_DEGREE[0]);
  54. }
  55. #define X_LABEL_POS 3
  56. #define X_VALUE_POS 11
  57. #define XYZ_SPACING 37
  58. #define XYZ_BASELINE (30 + INFO_FONT_ASCENT)
  59. #define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
  60. #define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
  61. #define DO_DRAW_BED (HAS_HEATED_BED && STATUS_BED_WIDTH && HOTENDS <= 3 && DISABLED(STATUS_COMBINE_HEATERS))
  62. #define DO_DRAW_FAN (HAS_FAN0 && STATUS_FAN_WIDTH && STATUS_FAN_FRAMES)
  63. #define ANIM_HOTEND (HOTENDS && ENABLED(STATUS_HOTEND_ANIM))
  64. #define ANIM_BED (DO_DRAW_BED && ENABLED(STATUS_BED_ANIM))
  65. #if ANIM_HOTEND || ANIM_BED
  66. uint8_t heat_bits;
  67. #endif
  68. #if ANIM_HOTEND
  69. #define HOTEND_ALT(N) TEST(heat_bits, N)
  70. #else
  71. #define HOTEND_ALT(N) false
  72. #endif
  73. #if ANIM_BED
  74. #define BED_ALT() TEST(heat_bits, 7)
  75. #else
  76. #define BED_ALT() false
  77. #endif
  78. #define MAX_HOTEND_DRAW MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
  79. #define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
  80. #if ENABLED(MARLIN_DEV_MODE)
  81. #define SHOW_ON_STATE READ(X_MIN_PIN)
  82. #else
  83. #define SHOW_ON_STATE false
  84. #endif
  85. FORCE_INLINE void _draw_heater_status(const int8_t heater, const bool blink) {
  86. #if !HEATER_IDLE_HANDLER
  87. UNUSED(blink);
  88. #endif
  89. #if HAS_HEATED_BED
  90. const bool isBed = heater < 0;
  91. #define IFBED(A,B) (isBed ? (A) : (B))
  92. #else
  93. #define IFBED(A,B) (B)
  94. #endif
  95. #if ENABLED(MARLIN_DEV_MODE)
  96. constexpr bool isHeat = true;
  97. #else
  98. const bool isHeat = IFBED(BED_ALT(), HOTEND_ALT(heater));
  99. #endif
  100. const uint8_t tx = IFBED(STATUS_BED_TEXT_X, STATUS_HOTEND_TEXT_X(heater));
  101. #if ENABLED(MARLIN_DEV_MODE)
  102. const float temp = 20 + (millis() >> 8) % IFBED(100, 200);
  103. const float target = IFBED(100, 200);
  104. #else
  105. const float temp = IFBED(thermalManager.degBed(), thermalManager.degHotend(heater)),
  106. target = IFBED(thermalManager.degTargetBed(), thermalManager.degTargetHotend(heater));
  107. #endif
  108. #if DISABLED(STATUS_HOTEND_ANIM)
  109. #define STATIC_HOTEND true
  110. #define HOTEND_DOT isHeat
  111. #else
  112. #define STATIC_HOTEND false
  113. #define HOTEND_DOT false
  114. #endif
  115. #if HAS_HEATED_BED && DISABLED(STATUS_BED_ANIM)
  116. #define STATIC_BED true
  117. #define BED_DOT isHeat
  118. #else
  119. #define STATIC_BED false
  120. #define BED_DOT false
  121. #endif
  122. #if 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. #ifdef STATUS_HOTEND_ANIM
  149. // Draw hotend bitmap, either whole or split by the heating percent
  150. if (IFBED(0, 1)) {
  151. const uint8_t hx = STATUS_HOTEND_X(heater), 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. }
  162. #endif
  163. // Draw a heating progress bar, if specified
  164. #if ENABLED(STATUS_HEAT_PERCENT)
  165. if (IFBED(true, STATIC_HOTEND) && isHeat) {
  166. const uint8_t bx = IFBED(STATUS_BED_X + STATUS_BED_WIDTH, STATUS_HOTEND_X(heater) + STATUS_HOTEND_WIDTH(heater)) + 1;
  167. u8g.drawFrame(bx, STATUS_HEATERS_Y, 3, STATUS_HEATERS_HEIGHT);
  168. if (tall) {
  169. const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall;
  170. if (PAGE_OVER(STATUS_HEATERS_Y + ph))
  171. u8g.drawVLine(bx + 1, STATUS_HEATERS_Y + ph, tall);
  172. }
  173. }
  174. #endif
  175. } // PAGE_CONTAINS
  176. if (PAGE_UNDER(7)) {
  177. #if HEATER_IDLE_HANDLER
  178. const bool is_idle = IFBED(thermalManager.is_bed_idle(), thermalManager.is_heater_idle(heater)),
  179. dodraw = (blink || !is_idle);
  180. #else
  181. constexpr bool dodraw = true;
  182. #endif
  183. if (dodraw) _draw_centered_temp(target + 0.5, tx, 7);
  184. }
  185. if (PAGE_CONTAINS(28 - INFO_FONT_ASCENT, 28 - 1))
  186. _draw_centered_temp(temp + 0.5f, tx, 28);
  187. if (IFBED(STATIC_BED && BED_DOT, STATIC_HOTEND && HOTEND_DOT) && PAGE_CONTAINS(17, 19)) {
  188. u8g.setColorIndex(0); // set to white on black
  189. u8g.drawBox(tx, IFBED(20-2, 20-3), 2, 2);
  190. u8g.setColorIndex(1); // restore black on white
  191. }
  192. }
  193. //
  194. // Before homing, blink '123' <-> '???'.
  195. // Homed but unknown... '123' <-> ' '.
  196. // Homed and known, display constantly.
  197. //
  198. FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
  199. const uint8_t offs = (XYZ_SPACING) * axis;
  200. lcd_moveto(X_LABEL_POS + offs, XYZ_BASELINE);
  201. lcd_put_wchar('X' + axis);
  202. lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
  203. if (blink)
  204. lcd_put_u8str(value);
  205. else {
  206. if (!TEST(axis_homed, axis))
  207. while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
  208. else {
  209. #if DISABLED(HOME_AFTER_DEACTIVATE) && DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
  210. if (!TEST(axis_known_position, axis))
  211. lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
  212. else
  213. #endif
  214. lcd_put_u8str(value);
  215. }
  216. }
  217. }
  218. #if ENABLED(MARLIN_DEV_MODE)
  219. uint16_t count_renders = 0;
  220. uint32_t total_cycles = 0;
  221. #endif
  222. void MarlinUI::draw_status_screen() {
  223. #if ENABLED(MARLIN_DEV_MODE)
  224. if (first_page) count_renders++;
  225. #endif
  226. static char xstring[5], ystring[5], zstring[8];
  227. #if ENABLED(FILAMENT_LCD_DISPLAY)
  228. static char wstring[5], mstring[4];
  229. #endif
  230. // At the first page, generate new display values
  231. if (first_page) {
  232. #if ANIM_HOTEND || ANIM_BED
  233. uint8_t new_bits = 0;
  234. #if ANIM_HOTEND
  235. HOTEND_LOOP() if (thermalManager.isHeatingHotend(e) ^ SHOW_ON_STATE) SBI(new_bits, e);
  236. #endif
  237. #if ANIM_BED
  238. if (thermalManager.isHeatingBed() ^ SHOW_ON_STATE) SBI(new_bits, 7);
  239. #endif
  240. heat_bits = new_bits;
  241. #endif
  242. strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
  243. strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
  244. strcpy(zstring, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])));
  245. #if ENABLED(FILAMENT_LCD_DISPLAY)
  246. strcpy(wstring, ftostr12ns(filament_width_meas));
  247. strcpy(mstring, i16tostr3(100.0 * (
  248. parser.volumetric_enabled
  249. ? planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  250. : planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  251. )
  252. ));
  253. #endif
  254. }
  255. const bool blink = get_blink();
  256. // Status Menu Font
  257. set_font(FONT_STATUSMENU);
  258. #if ENABLED(MARLIN_DEV_MODE)
  259. TCNT5 = 0;
  260. #endif
  261. #if STATUS_LOGO_WIDTH
  262. if (PAGE_CONTAINS(STATUS_LOGO_Y, STATUS_LOGO_Y + STATUS_LOGO_HEIGHT - 1))
  263. u8g.drawBitmapP(STATUS_LOGO_X, STATUS_LOGO_Y, STATUS_LOGO_BYTEWIDTH, STATUS_LOGO_HEIGHT, status_logo_bmp);
  264. #endif
  265. #if STATUS_HEATERS_WIDTH
  266. // Draw all heaters (and maybe the bed) in one go
  267. if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1))
  268. u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
  269. #endif
  270. #if DO_DRAW_BED
  271. #if ANIM_BED
  272. #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
  273. #else
  274. #define BED_BITMAP(S) status_bed_bmp
  275. #endif
  276. const uint8_t bedy = STATUS_BED_Y(BED_ALT()), bedh = STATUS_BED_HEIGHT(BED_ALT());
  277. if (PAGE_CONTAINS(bedy, bedy + bedh - 1))
  278. u8g.drawBitmapP(STATUS_BED_X, bedy, STATUS_BED_BYTEWIDTH, bedh, BED_BITMAP(BED_ALT()));
  279. #endif
  280. #if DO_DRAW_FAN
  281. #if STATUS_FAN_FRAMES > 2
  282. static bool old_blink;
  283. static uint8_t fan_frame;
  284. if (old_blink != blink) {
  285. old_blink = blink;
  286. if (!thermalManager.fan_speed[0] || ++fan_frame >= STATUS_FAN_FRAMES) fan_frame = 0;
  287. }
  288. #endif
  289. if (PAGE_CONTAINS(STATUS_FAN_Y, STATUS_FAN_Y + STATUS_FAN_HEIGHT - 1))
  290. u8g.drawBitmapP(
  291. STATUS_FAN_X, STATUS_FAN_Y,
  292. STATUS_FAN_BYTEWIDTH, STATUS_FAN_HEIGHT,
  293. #if STATUS_FAN_FRAMES > 2
  294. fan_frame == 1 ? status_fan1_bmp :
  295. fan_frame == 2 ? status_fan2_bmp :
  296. #if STATUS_FAN_FRAMES > 3
  297. fan_frame == 3 ? status_fan3_bmp :
  298. #endif
  299. #elif STATUS_FAN_FRAMES > 1
  300. blink && thermalManager.fan_speed[0] ? status_fan1_bmp :
  301. #endif
  302. status_fan0_bmp
  303. );
  304. #endif
  305. //
  306. // Temperature Graphics and Info
  307. //
  308. if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
  309. // Extruders
  310. for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e)
  311. _draw_heater_status(e, blink);
  312. // Heated bed
  313. #if HAS_HEATED_BED && HOTENDS < 4
  314. _draw_heater_status(-1, blink);
  315. #endif
  316. // Fan, if a bitmap was provided
  317. #if DO_DRAW_FAN
  318. if (PAGE_CONTAINS(STATUS_FAN_TEXT_Y - INFO_FONT_ASCENT, STATUS_FAN_TEXT_Y - 1)) {
  319. char c = '%';
  320. uint16_t spd = thermalManager.fan_speed[0];
  321. if (spd) {
  322. #if ENABLED(ADAPTIVE_FAN_SLOWING)
  323. if (!blink && thermalManager.fan_speed_scaler[0] < 128) {
  324. spd = (spd * thermalManager.fan_speed_scaler[0]) >> 7;
  325. c = '*';
  326. }
  327. #endif
  328. lcd_moveto(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y);
  329. lcd_put_u8str(i16tostr3(thermalManager.fanPercent(spd)));
  330. lcd_put_wchar(c);
  331. }
  332. }
  333. #endif
  334. }
  335. #if ENABLED(MARLIN_DEV_MODE)
  336. total_cycles += TCNT5;
  337. #endif
  338. #if ENABLED(SDSUPPORT)
  339. //
  340. // SD Card Symbol
  341. //
  342. if (card.isFileOpen() && PAGE_CONTAINS(42, 51)) {
  343. // Upper box
  344. u8g.drawBox(42, 42, 8, 7); // 42-48 (or 41-47)
  345. // Right edge
  346. u8g.drawBox(50, 44, 2, 5); // 44-48 (or 43-47)
  347. // Bottom hollow box
  348. u8g.drawFrame(42, 49, 10, 4); // 49-52 (or 48-51)
  349. // Corner pixel
  350. u8g.drawPixel(50, 43); // 43 (or 42)
  351. }
  352. #endif // SDSUPPORT
  353. #if HAS_PRINT_PROGRESS
  354. //
  355. // Progress bar frame
  356. //
  357. #define PROGRESS_BAR_X 54
  358. #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
  359. if (PAGE_CONTAINS(49, 52))
  360. u8g.drawFrame(PROGRESS_BAR_X, 49, PROGRESS_BAR_WIDTH, 4);
  361. const uint8_t progress = get_progress();
  362. if (progress > 1) {
  363. //
  364. // Progress bar solid part
  365. //
  366. if (PAGE_CONTAINS(50, 51)) // 50-51 (or just 50)
  367. u8g.drawBox(
  368. PROGRESS_BAR_X + 1, 50,
  369. (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress * 0.01), 2
  370. );
  371. //
  372. // SD Percent Complete
  373. //
  374. #if ENABLED(DOGM_SD_PERCENT)
  375. if (PAGE_CONTAINS(41, 48)) {
  376. // Percent complete
  377. lcd_moveto(55, 48);
  378. lcd_put_u8str(ui8tostr3(progress));
  379. lcd_put_wchar('%');
  380. }
  381. #endif
  382. }
  383. //
  384. // Elapsed Time
  385. //
  386. #if DISABLED(DOGM_SD_PERCENT)
  387. #define SD_DURATION_X (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH / 2) - len * (MENU_FONT_WIDTH / 2))
  388. #else
  389. #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * MENU_FONT_WIDTH)
  390. #endif
  391. if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
  392. char buffer[13];
  393. duration_t elapsed = print_job_timer.duration();
  394. bool has_days = (elapsed.value >= 60*60*24L);
  395. uint8_t len = elapsed.toDigital(buffer, has_days);
  396. lcd_moveto(SD_DURATION_X, EXTRAS_BASELINE);
  397. lcd_put_u8str(buffer);
  398. }
  399. #endif // HAS_PRINT_PROGRESS
  400. //
  401. // XYZ Coordinates
  402. //
  403. #define X_LABEL_POS 3
  404. #define X_VALUE_POS 11
  405. #define XYZ_SPACING 37
  406. #if ENABLED(XYZ_HOLLOW_FRAME)
  407. #define XYZ_FRAME_TOP 29
  408. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 3
  409. #else
  410. #define XYZ_FRAME_TOP 30
  411. #define XYZ_FRAME_HEIGHT INFO_FONT_ASCENT + 1
  412. #endif
  413. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  414. #if ENABLED(XYZ_HOLLOW_FRAME)
  415. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  416. #else
  417. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  418. #endif
  419. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_ASCENT - 1), XYZ_BASELINE)) {
  420. #if DISABLED(XYZ_HOLLOW_FRAME)
  421. u8g.setColorIndex(0); // white on black
  422. #endif
  423. #if DUAL_MIXING_EXTRUDER
  424. // Two-component mix / gradient instead of XY
  425. lcd_moveto(X_LABEL_POS, XYZ_BASELINE);
  426. char mixer_messages[12];
  427. const char *mix_label;
  428. #if ENABLED(GRADIENT_MIX)
  429. if (mixer.gradient.enabled) {
  430. mixer.update_mix_from_gradient();
  431. mix_label = "Gr";
  432. }
  433. else
  434. #endif
  435. {
  436. mixer.update_mix_from_vtool();
  437. mix_label = "Mx";
  438. }
  439. sprintf_P(mixer_messages, PSTR("%s %d;%d%% "), mix_label, int(mixer.mix[0]), int(mixer.mix[1]));
  440. lcd_put_u8str(mixer_messages);
  441. #else
  442. _draw_axis_value(X_AXIS, xstring, blink);
  443. _draw_axis_value(Y_AXIS, ystring, blink);
  444. #endif
  445. _draw_axis_value(Z_AXIS, zstring, blink);
  446. #if DISABLED(XYZ_HOLLOW_FRAME)
  447. u8g.setColorIndex(1); // black on white
  448. #endif
  449. }
  450. }
  451. //
  452. // Feedrate
  453. //
  454. #define EXTRAS_2_BASELINE (EXTRAS_BASELINE + 3)
  455. if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) {
  456. set_font(FONT_MENU);
  457. lcd_moveto(3, EXTRAS_2_BASELINE);
  458. lcd_put_wchar(LCD_STR_FEEDRATE[0]);
  459. set_font(FONT_STATUSMENU);
  460. lcd_moveto(12, EXTRAS_2_BASELINE);
  461. lcd_put_u8str(i16tostr3(feedrate_percentage));
  462. lcd_put_wchar('%');
  463. //
  464. // Filament sensor display if SD is disabled
  465. //
  466. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  467. lcd_moveto(56, EXTRAS_2_BASELINE);
  468. lcd_put_u8str(wstring);
  469. lcd_moveto(102, EXTRAS_2_BASELINE);
  470. lcd_put_u8str(mstring);
  471. lcd_put_wchar('%');
  472. set_font(FONT_MENU);
  473. lcd_moveto(47, EXTRAS_2_BASELINE);
  474. lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  475. lcd_moveto(93, EXTRAS_2_BASELINE);
  476. lcd_put_wchar(LCD_STR_FILAM_MUL[0]);
  477. #endif
  478. }
  479. //
  480. // Status line
  481. //
  482. if (PAGE_CONTAINS(STATUS_BASELINE - INFO_FONT_ASCENT, STATUS_BASELINE + INFO_FONT_DESCENT)) {
  483. lcd_moveto(0, STATUS_BASELINE);
  484. #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
  485. // Alternate Status message and Filament display
  486. if (ELAPSED(millis(), next_filament_display)) {
  487. lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  488. lcd_put_wchar(':');
  489. lcd_put_u8str(wstring);
  490. lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL));
  491. lcd_put_wchar(':');
  492. lcd_put_u8str(mstring);
  493. lcd_put_wchar('%');
  494. }
  495. else
  496. #endif
  497. draw_status_message(blink);
  498. }
  499. }
  500. void MarlinUI::draw_status_message(const bool blink) {
  501. #if ENABLED(MARLIN_DEV_MODE)
  502. if (PAGE_CONTAINS(64-8, 64-1)) {
  503. lcd_put_int(total_cycles);
  504. lcd_put_wchar('/');
  505. lcd_put_int(count_renders);
  506. lcd_put_wchar('=');
  507. lcd_put_int(int(total_cycles / count_renders));
  508. return;
  509. }
  510. #endif
  511. // Get the UTF8 character count of the string
  512. uint8_t slen = utf8_strlen(status_message);
  513. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  514. static bool last_blink = false;
  515. if (slen <= LCD_WIDTH) {
  516. // The string fits within the line. Print with no scrolling
  517. lcd_put_u8str(status_message);
  518. for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' ');
  519. }
  520. else {
  521. // String is longer than the available space
  522. // Get a pointer to the next valid UTF8 character
  523. const char *stat = status_message + status_scroll_offset;
  524. // Get the string remaining length
  525. const uint8_t rlen = utf8_strlen(stat);
  526. if (rlen >= LCD_WIDTH) {
  527. // The remaining string fills the screen - Print it
  528. lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
  529. }
  530. else {
  531. // The remaining string does not completely fill the screen
  532. lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH); // The string leaves space
  533. uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
  534. lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
  535. if (--chars) { // Draw a second dot if there's space
  536. lcd_put_wchar('.');
  537. if (--chars) {
  538. // Print a second copy of the message
  539. lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH));
  540. lcd_put_wchar(' ');
  541. }
  542. }
  543. }
  544. if (last_blink != blink) {
  545. last_blink = blink;
  546. // Adjust by complete UTF8 characters
  547. if (status_scroll_offset < slen) {
  548. status_scroll_offset++;
  549. while (!START_OF_UTF8_CHAR(status_message[status_scroll_offset]))
  550. status_scroll_offset++;
  551. }
  552. else
  553. status_scroll_offset = 0;
  554. }
  555. }
  556. #else // !STATUS_MESSAGE_SCROLLING
  557. UNUSED(blink);
  558. // Just print the string to the LCD
  559. lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH);
  560. // Fill the rest with spaces
  561. for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' ');
  562. #endif // !STATUS_MESSAGE_SCROLLING
  563. }
  564. #endif // HAS_GRAPHICAL_LCD && !LIGHTWEIGHT_UI