My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

status_screen_DOGM.h 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * status_screen_DOGM.h
  24. *
  25. * Standard Status Screen for Graphical Display
  26. */
  27. #ifndef _STATUS_SCREEN_DOGM_H_
  28. #define _STATUS_SCREEN_DOGM_H_
  29. FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t x, const uint8_t y) {
  30. const char * const str = itostr3(temp);
  31. lcd_moveto(x - (str[0] != ' ' ? 0 : str[1] != ' ' ? 1 : 2) * DOG_CHAR_WIDTH / 2, y);
  32. lcd_put_u8str(str);
  33. lcd_put_u8str_P(PSTR(LCD_STR_DEGREE " "));
  34. }
  35. #ifndef HEAT_INDICATOR_X
  36. #define HEAT_INDICATOR_X 8
  37. #endif
  38. FORCE_INLINE void _draw_heater_status(const uint8_t x, const int8_t heater, const bool blink) {
  39. #if !HEATER_IDLE_HANDLER
  40. UNUSED(blink);
  41. #endif
  42. #if HAS_HEATED_BED
  43. const bool isBed = heater < 0;
  44. #else
  45. constexpr bool isBed = false;
  46. #endif
  47. if (PAGE_UNDER(7)) {
  48. #if HEATER_IDLE_HANDLER
  49. const bool is_idle = (
  50. #if HAS_HEATED_BED
  51. isBed ? thermalManager.is_bed_idle() :
  52. #endif
  53. thermalManager.is_heater_idle(heater)
  54. );
  55. if (blink || !is_idle)
  56. #endif
  57. _draw_centered_temp(0.5 + (
  58. #if HAS_HEATED_BED
  59. isBed ? thermalManager.degTargetBed() :
  60. #endif
  61. thermalManager.degTargetHotend(heater)
  62. ), x, 7
  63. );
  64. }
  65. if (PAGE_CONTAINS(21, 28)) {
  66. _draw_centered_temp(0.5 + (
  67. #if HAS_HEATED_BED
  68. isBed ? thermalManager.degBed() :
  69. #endif
  70. thermalManager.degHotend(heater)
  71. ), x, 28
  72. );
  73. if (PAGE_CONTAINS(17, 20)) {
  74. const uint8_t h = isBed ? 7 : HEAT_INDICATOR_X,
  75. y = isBed ? 18 : 17;
  76. if (
  77. #if HAS_HEATED_BED
  78. isBed ? thermalManager.isHeatingBed() :
  79. #endif
  80. thermalManager.isHeatingHotend(heater)
  81. ) {
  82. u8g.setColorIndex(0); // white on black
  83. u8g.drawBox(x + h, y, 2, 2);
  84. u8g.setColorIndex(1); // black on white
  85. }
  86. else
  87. u8g.drawBox(x + h, y, 2, 2);
  88. }
  89. }
  90. }
  91. //
  92. // Before homing, blink '123' <-> '???'.
  93. // Homed but unknown... '123' <-> ' '.
  94. // Homed and known, display constantly.
  95. //
  96. FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
  97. if (blink)
  98. lcd_put_u8str(value);
  99. else {
  100. if (!axis_homed[axis])
  101. while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?');
  102. else {
  103. #if DISABLED(HOME_AFTER_DEACTIVATE) && DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
  104. if (!axis_known_position[axis])
  105. lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
  106. else
  107. #endif
  108. lcd_put_u8str(value);
  109. }
  110. }
  111. }
  112. inline void lcd_implementation_status_message(const bool blink) {
  113. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  114. static bool last_blink = false;
  115. // Get the UTF8 character count of the string
  116. uint8_t slen = utf8_strlen(lcd_status_message);
  117. // If the string fits into the LCD, just print it and do not scroll it
  118. if (slen <= LCD_WIDTH) {
  119. // The string isn't scrolling and may not fill the screen
  120. lcd_put_u8str(lcd_status_message);
  121. // Fill the rest with spaces
  122. while (slen < LCD_WIDTH) {
  123. lcd_put_wchar(' ');
  124. ++slen;
  125. }
  126. }
  127. else {
  128. // String is larger than the available space in screen.
  129. // Get a pointer to the next valid UTF8 character
  130. const char *stat = lcd_status_message + status_scroll_offset;
  131. // Get the string remaining length
  132. const uint8_t rlen = utf8_strlen(stat);
  133. // If we have enough characters to display
  134. if (rlen >= LCD_WIDTH) {
  135. // The remaining string fills the screen - Print it
  136. lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
  137. }
  138. else {
  139. // The remaining string does not completely fill the screen
  140. lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH); // The string leaves space
  141. uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
  142. lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
  143. if (--chars) { // Draw a second dot if there's space
  144. lcd_put_wchar('.');
  145. if (--chars) {
  146. // Print a second copy of the message
  147. lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH - ((rlen+2) * DOG_CHAR_WIDTH));
  148. }
  149. }
  150. }
  151. if (last_blink != blink) {
  152. last_blink = blink;
  153. // Adjust by complete UTF8 characters
  154. if (status_scroll_offset < slen) {
  155. status_scroll_offset++;
  156. while (!START_OF_UTF8_CHAR(lcd_status_message[status_scroll_offset]))
  157. status_scroll_offset++;
  158. }
  159. else
  160. status_scroll_offset = 0;
  161. }
  162. }
  163. #else
  164. UNUSED(blink);
  165. // Get the UTF8 character count of the string
  166. uint8_t slen = utf8_strlen(lcd_status_message);
  167. // Just print the string to the LCD
  168. lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH);
  169. // Fill the rest with spaces if there are missing spaces
  170. while (slen < LCD_WIDTH) {
  171. lcd_put_wchar(' ');
  172. ++slen;
  173. }
  174. #endif
  175. }
  176. static void lcd_implementation_status_screen() {
  177. const bool blink = lcd_blink();
  178. #if FAN_ANIM_FRAMES > 2
  179. static bool old_blink;
  180. static uint8_t fan_frame;
  181. if (old_blink != blink) {
  182. old_blink = blink;
  183. if (!fanSpeeds[0] || ++fan_frame >= FAN_ANIM_FRAMES) fan_frame = 0;
  184. }
  185. #endif
  186. // Status Menu Font
  187. lcd_setFont(FONT_STATUSMENU);
  188. //
  189. // Fan Animation
  190. //
  191. // Draws the whole heading image as a B/W bitmap rather than
  192. // drawing the elements separately.
  193. // This was done as an optimization, as it was slower to draw
  194. // multiple parts compared to a single bitmap.
  195. //
  196. // The bitmap:
  197. // - May be offset in X
  198. // - Includes all nozzle(s), bed(s), and the fan.
  199. //
  200. // TODO:
  201. //
  202. // - Only draw the whole header on the first
  203. // entry to the status screen. Nozzle, bed, and
  204. // fan outline bits don't change.
  205. //
  206. if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1)) {
  207. u8g.drawBitmapP(
  208. STATUS_SCREEN_X, STATUS_SCREEN_Y,
  209. (STATUS_SCREENWIDTH + 7) / 8, STATUS_SCREENHEIGHT,
  210. #if HAS_FAN0
  211. #if FAN_ANIM_FRAMES > 2
  212. fan_frame == 1 ? status_screen1_bmp :
  213. fan_frame == 2 ? status_screen2_bmp :
  214. #if FAN_ANIM_FRAMES > 3
  215. fan_frame == 3 ? status_screen3_bmp :
  216. #endif
  217. #else
  218. blink && fanSpeeds[0] ? status_screen1_bmp :
  219. #endif
  220. #endif
  221. status_screen0_bmp
  222. );
  223. }
  224. //
  225. // Temperature Graphics and Info
  226. //
  227. if (PAGE_UNDER(28)) {
  228. // Extruders
  229. HOTEND_LOOP() _draw_heater_status(STATUS_SCREEN_HOTEND_TEXT_X(e), e, blink);
  230. // Heated bed
  231. #if HOTENDS < 4 && HAS_HEATED_BED
  232. _draw_heater_status(STATUS_SCREEN_BED_TEXT_X, -1, blink);
  233. #endif
  234. #if HAS_FAN0
  235. if (PAGE_CONTAINS(STATUS_SCREEN_FAN_TEXT_Y - 7, STATUS_SCREEN_FAN_TEXT_Y)) {
  236. // Fan
  237. const int16_t per = ((fanSpeeds[0] + 1) * 100) / 256;
  238. if (per) {
  239. lcd_moveto(STATUS_SCREEN_FAN_TEXT_X, STATUS_SCREEN_FAN_TEXT_Y);
  240. lcd_put_u8str(itostr3(per));
  241. lcd_put_wchar('%');
  242. }
  243. }
  244. #endif
  245. }
  246. #if ENABLED(SDSUPPORT)
  247. //
  248. // SD Card Symbol
  249. //
  250. if (card.isFileOpen() && PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) {
  251. // Upper box
  252. u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7); // 42-48 (or 41-47)
  253. // Right edge
  254. u8g.drawBox(50, 44 - (TALL_FONT_CORRECTION), 2, 5); // 44-48 (or 43-47)
  255. // Bottom hollow box
  256. u8g.drawFrame(42, 49 - (TALL_FONT_CORRECTION), 10, 4); // 49-52 (or 48-51)
  257. // Corner pixel
  258. u8g.drawPixel(50, 43 - (TALL_FONT_CORRECTION)); // 43 (or 42)
  259. }
  260. #endif // SDSUPPORT
  261. #if ENABLED(SDSUPPORT) || ENABLED(LCD_SET_PROGRESS_MANUALLY)
  262. //
  263. // Progress bar frame
  264. //
  265. #define PROGRESS_BAR_X 54
  266. #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
  267. if (PAGE_CONTAINS(49, 52 - (TALL_FONT_CORRECTION))) // 49-52 (or 49-51)
  268. u8g.drawFrame(
  269. PROGRESS_BAR_X, 49,
  270. PROGRESS_BAR_WIDTH, 4 - (TALL_FONT_CORRECTION)
  271. );
  272. #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
  273. const uint8_t progress_bar_percent = card.percentDone();
  274. #endif
  275. if (progress_bar_percent > 1) {
  276. //
  277. // Progress bar solid part
  278. //
  279. if (PAGE_CONTAINS(50, 51 - (TALL_FONT_CORRECTION))) // 50-51 (or just 50)
  280. u8g.drawBox(
  281. PROGRESS_BAR_X + 1, 50,
  282. (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress_bar_percent * 0.01), 2 - (TALL_FONT_CORRECTION)
  283. );
  284. //
  285. // SD Percent Complete
  286. //
  287. #if ENABLED(DOGM_SD_PERCENT)
  288. if (PAGE_CONTAINS(41, 48)) {
  289. // Percent complete
  290. lcd_moveto(55, 48);
  291. lcd_put_u8str(itostr3(progress_bar_percent));
  292. lcd_put_wchar('%');
  293. }
  294. #endif
  295. }
  296. //
  297. // Elapsed Time
  298. //
  299. #if DISABLED(DOGM_SD_PERCENT)
  300. #define SD_DURATION_X (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH / 2) - len * (DOG_CHAR_WIDTH / 2))
  301. #else
  302. #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * DOG_CHAR_WIDTH)
  303. #endif
  304. if (PAGE_CONTAINS(41, 48)) {
  305. char buffer[10];
  306. duration_t elapsed = print_job_timer.duration();
  307. bool has_days = (elapsed.value >= 60*60*24L);
  308. uint8_t len = elapsed.toDigital(buffer, has_days);
  309. lcd_moveto(SD_DURATION_X, 48);
  310. lcd_put_u8str(buffer);
  311. }
  312. #endif // SDSUPPORT || LCD_SET_PROGRESS_MANUALLY
  313. //
  314. // XYZ Coordinates
  315. //
  316. #define XYZ_BASELINE (30 + INFO_FONT_HEIGHT)
  317. #define X_LABEL_POS 3
  318. #define X_VALUE_POS 11
  319. #define XYZ_SPACING 40
  320. #if ENABLED(XYZ_HOLLOW_FRAME)
  321. #define XYZ_FRAME_TOP 29
  322. #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
  323. #else
  324. #define XYZ_FRAME_TOP 30
  325. #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 1
  326. #endif
  327. static char xstring[5], ystring[5], zstring[7];
  328. #if ENABLED(FILAMENT_LCD_DISPLAY)
  329. static char wstring[5], mstring[4];
  330. #endif
  331. // At the first page, regenerate the XYZ strings
  332. if (page.page == 0) {
  333. strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
  334. strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
  335. strcpy(zstring, ftostr52sp(LOGICAL_Z_POSITION(current_position[Z_AXIS])));
  336. #if ENABLED(FILAMENT_LCD_DISPLAY)
  337. strcpy(wstring, ftostr12ns(filament_width_meas));
  338. strcpy(mstring, itostr3(100.0 * (
  339. parser.volumetric_enabled
  340. ? planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  341. : planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  342. )
  343. ));
  344. #endif
  345. }
  346. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  347. #if ENABLED(XYZ_HOLLOW_FRAME)
  348. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  349. #else
  350. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  351. #endif
  352. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_HEIGHT - 1), XYZ_BASELINE)) {
  353. #if DISABLED(XYZ_HOLLOW_FRAME)
  354. u8g.setColorIndex(0); // white on black
  355. #endif
  356. lcd_moveto(0 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
  357. lcd_put_wchar('X');
  358. lcd_moveto(0 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
  359. _draw_axis_value(X_AXIS, xstring, blink);
  360. lcd_moveto(1 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
  361. lcd_put_wchar('Y');
  362. lcd_moveto(1 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
  363. _draw_axis_value(Y_AXIS, ystring, blink);
  364. lcd_moveto(2 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
  365. lcd_put_wchar('Z');
  366. lcd_moveto(2 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
  367. _draw_axis_value(Z_AXIS, zstring, blink);
  368. #if DISABLED(XYZ_HOLLOW_FRAME)
  369. u8g.setColorIndex(1); // black on white
  370. #endif
  371. }
  372. }
  373. //
  374. // Feedrate
  375. //
  376. if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
  377. lcd_setFont(FONT_MENU);
  378. lcd_moveto(3, 50);
  379. lcd_put_wchar(LCD_STR_FEEDRATE[0]);
  380. lcd_setFont(FONT_STATUSMENU);
  381. lcd_moveto(12, 50);
  382. lcd_put_u8str(itostr3(feedrate_percentage));
  383. lcd_put_wchar('%');
  384. //
  385. // Filament sensor display if SD is disabled
  386. //
  387. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  388. lcd_moveto(56, 50);
  389. lcd_put_u8str(wstring);
  390. lcd_moveto(102, 50);
  391. lcd_put_u8str(mstring);
  392. lcd_put_wchar('%');
  393. lcd_setFont(FONT_MENU);
  394. lcd_moveto(47, 50);
  395. lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  396. lcd_moveto(93, 50);
  397. lcd_put_wchar(LCD_STR_FILAM_MUL[0]);
  398. #endif
  399. }
  400. //
  401. // Status line
  402. //
  403. #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
  404. if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) {
  405. lcd_moveto(0, STATUS_BASELINE);
  406. #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
  407. if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line
  408. lcd_implementation_status_message(blink);
  409. }
  410. else {
  411. lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
  412. lcd_put_wchar(':');
  413. lcd_put_u8str(wstring);
  414. lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL));
  415. lcd_put_wchar(':');
  416. lcd_put_u8str(mstring);
  417. lcd_put_wchar('%');
  418. }
  419. #else
  420. lcd_implementation_status_message(blink);
  421. #endif
  422. }
  423. }
  424. #endif // _STATUS_SCREEN_DOGM_H_