My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

status_screen_DOGM.h 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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. u8g.setPrintPos(x - (str[0] != ' ' ? 0 : str[1] != ' ' ? 1 : 2) * DOG_CHAR_WIDTH / 2, y);
  32. lcd_print(str);
  33. lcd_printPGM(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_TEMP_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 = (!isBed ? thermalManager.is_heater_idle(heater) :
  50. #if HAS_TEMP_BED
  51. thermalManager.is_bed_idle()
  52. #else
  53. false
  54. #endif
  55. );
  56. if (blink || !is_idle)
  57. #endif
  58. _draw_centered_temp((isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater)) + 0.5, x, 7); }
  59. if (PAGE_CONTAINS(21, 28))
  60. _draw_centered_temp((isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)) + 0.5, x, 28);
  61. if (PAGE_CONTAINS(17, 20)) {
  62. const uint8_t h = isBed ? 7 : HEAT_INDICATOR_X,
  63. y = isBed ? 18 : 17;
  64. if (isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater)) {
  65. u8g.setColorIndex(0); // white on black
  66. u8g.drawBox(x + h, y, 2, 2);
  67. u8g.setColorIndex(1); // black on white
  68. }
  69. else {
  70. u8g.drawBox(x + h, y, 2, 2);
  71. }
  72. }
  73. }
  74. FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr, const bool blink) {
  75. if (blink)
  76. lcd_printPGM(pstr);
  77. else {
  78. if (!axis_homed[axis])
  79. u8g.print('?');
  80. else {
  81. #if DISABLED(HOME_AFTER_DEACTIVATE) && DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
  82. if (!axis_known_position[axis])
  83. u8g.print(' ');
  84. else
  85. #endif
  86. lcd_printPGM(pstr);
  87. }
  88. }
  89. }
  90. inline void lcd_implementation_status_message(const bool blink) {
  91. #if ENABLED(STATUS_MESSAGE_SCROLLING)
  92. static bool last_blink = false;
  93. const uint8_t slen = lcd_strlen(lcd_status_message);
  94. const char *stat = lcd_status_message + status_scroll_pos;
  95. if (slen <= LCD_WIDTH)
  96. lcd_print_utf(stat); // The string isn't scrolling
  97. else {
  98. if (status_scroll_pos <= slen - LCD_WIDTH)
  99. lcd_print_utf(stat); // The string fills the screen
  100. else {
  101. uint8_t chars = LCD_WIDTH;
  102. if (status_scroll_pos < slen) { // First string still visible
  103. lcd_print_utf(stat); // The string leaves space
  104. chars -= slen - status_scroll_pos; // Amount of space left
  105. }
  106. u8g.print('.'); // Always at 1+ spaces left, draw a dot
  107. if (--chars) {
  108. if (status_scroll_pos < slen + 1) // Draw a second dot if there's space
  109. --chars, u8g.print('.');
  110. if (chars) lcd_print_utf(lcd_status_message, chars); // Print a second copy of the message
  111. }
  112. }
  113. if (last_blink != blink) {
  114. last_blink = blink;
  115. // Skip any non-printing bytes
  116. if (status_scroll_pos < slen) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
  117. if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;
  118. }
  119. }
  120. #else
  121. UNUSED(blink);
  122. lcd_print_utf(lcd_status_message);
  123. #endif
  124. }
  125. static void lcd_implementation_status_screen() {
  126. const bool blink = lcd_blink();
  127. #if FAN_ANIM_FRAMES > 2
  128. static bool old_blink;
  129. static uint8_t fan_frame;
  130. if (old_blink != blink) {
  131. old_blink = blink;
  132. if (!fanSpeeds[0] || ++fan_frame >= FAN_ANIM_FRAMES) fan_frame = 0;
  133. }
  134. #endif
  135. // Status Menu Font
  136. lcd_setFont(FONT_STATUSMENU);
  137. //
  138. // Fan Animation
  139. //
  140. // Draws the whole heading image as a B/W bitmap rather than
  141. // drawing the elements separately.
  142. // This was done as an optimization, as it was slower to draw
  143. // multiple parts compared to a single bitmap.
  144. //
  145. // The bitmap:
  146. // - May be offset in X
  147. // - Includes all nozzle(s), bed(s), and the fan.
  148. //
  149. // TODO:
  150. //
  151. // - Only draw the whole header on the first
  152. // entry to the status screen. Nozzle, bed, and
  153. // fan outline bits don't change.
  154. //
  155. if (PAGE_UNDER(STATUS_SCREENHEIGHT + 1)) {
  156. u8g.drawBitmapP(
  157. STATUS_SCREEN_X, STATUS_SCREEN_Y,
  158. (STATUS_SCREENWIDTH + 7) / 8, STATUS_SCREENHEIGHT,
  159. #if HAS_FAN0
  160. #if FAN_ANIM_FRAMES > 2
  161. fan_frame == 1 ? status_screen1_bmp :
  162. fan_frame == 2 ? status_screen2_bmp :
  163. #if FAN_ANIM_FRAMES > 3
  164. fan_frame == 3 ? status_screen3_bmp :
  165. #endif
  166. #else
  167. blink && fanSpeeds[0] ? status_screen1_bmp :
  168. #endif
  169. #endif
  170. status_screen0_bmp
  171. );
  172. }
  173. //
  174. // Temperature Graphics and Info
  175. //
  176. if (PAGE_UNDER(28)) {
  177. // Extruders
  178. HOTEND_LOOP() _draw_heater_status(STATUS_SCREEN_HOTEND_TEXT_X(e), e, blink);
  179. // Heated bed
  180. #if HOTENDS < 4 && HAS_TEMP_BED
  181. _draw_heater_status(STATUS_SCREEN_BED_TEXT_X, -1, blink);
  182. #endif
  183. #if HAS_FAN0
  184. if (PAGE_CONTAINS(20, 27)) {
  185. // Fan
  186. const int16_t per = ((fanSpeeds[0] + 1) * 100) / 256;
  187. if (per) {
  188. u8g.setPrintPos(STATUS_SCREEN_FAN_TEXT_X, STATUS_SCREEN_FAN_TEXT_Y);
  189. lcd_print(itostr3(per));
  190. u8g.print('%');
  191. }
  192. }
  193. #endif
  194. }
  195. #if ENABLED(SDSUPPORT)
  196. //
  197. // SD Card Symbol
  198. //
  199. if (card.isFileOpen() && PAGE_CONTAINS(42 - (TALL_FONT_CORRECTION), 51 - (TALL_FONT_CORRECTION))) {
  200. // Upper box
  201. u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7); // 42-48 (or 41-47)
  202. // Right edge
  203. u8g.drawBox(50, 44 - (TALL_FONT_CORRECTION), 2, 5); // 44-48 (or 43-47)
  204. // Bottom hollow box
  205. u8g.drawFrame(42, 49 - (TALL_FONT_CORRECTION), 10, 4); // 49-52 (or 48-51)
  206. // Corner pixel
  207. u8g.drawPixel(50, 43 - (TALL_FONT_CORRECTION)); // 43 (or 42)
  208. }
  209. #endif // SDSUPPORT
  210. #if ENABLED(SDSUPPORT) || ENABLED(LCD_SET_PROGRESS_MANUALLY)
  211. //
  212. // Progress bar frame
  213. //
  214. #define PROGRESS_BAR_X 54
  215. #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
  216. if (PAGE_CONTAINS(49, 52 - (TALL_FONT_CORRECTION))) // 49-52 (or 49-51)
  217. u8g.drawFrame(
  218. PROGRESS_BAR_X, 49,
  219. PROGRESS_BAR_WIDTH, 4 - (TALL_FONT_CORRECTION)
  220. );
  221. #if DISABLED(LCD_SET_PROGRESS_MANUALLY)
  222. const uint8_t progress_bar_percent = card.percentDone();
  223. #endif
  224. if (progress_bar_percent > 1) {
  225. //
  226. // Progress bar solid part
  227. //
  228. if (PAGE_CONTAINS(50, 51 - (TALL_FONT_CORRECTION))) // 50-51 (or just 50)
  229. u8g.drawBox(
  230. PROGRESS_BAR_X + 1, 50,
  231. (uint16_t)((PROGRESS_BAR_WIDTH - 2) * progress_bar_percent * 0.01), 2 - (TALL_FONT_CORRECTION)
  232. );
  233. //
  234. // SD Percent Complete
  235. //
  236. #if ENABLED(DOGM_SD_PERCENT)
  237. if (PAGE_CONTAINS(41, 48)) {
  238. // Percent complete
  239. u8g.setPrintPos(55, 48);
  240. u8g.print(itostr3(progress_bar_percent));
  241. u8g.print('%');
  242. }
  243. #endif
  244. }
  245. //
  246. // Elapsed Time
  247. //
  248. #if DISABLED(DOGM_SD_PERCENT)
  249. #define SD_DURATION_X (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH / 2) - len * (DOG_CHAR_WIDTH / 2))
  250. #else
  251. #define SD_DURATION_X (LCD_PIXEL_WIDTH - len * DOG_CHAR_WIDTH)
  252. #endif
  253. if (PAGE_CONTAINS(41, 48)) {
  254. char buffer[10];
  255. duration_t elapsed = print_job_timer.duration();
  256. bool has_days = (elapsed.value >= 60*60*24L);
  257. uint8_t len = elapsed.toDigital(buffer, has_days);
  258. u8g.setPrintPos(SD_DURATION_X, 48);
  259. lcd_print(buffer);
  260. }
  261. #endif // SDSUPPORT || LCD_SET_PROGRESS_MANUALLY
  262. //
  263. // XYZ Coordinates
  264. //
  265. #if ENABLED(USE_SMALL_INFOFONT)
  266. #define INFO_FONT_HEIGHT 7
  267. #else
  268. #define INFO_FONT_HEIGHT 8
  269. #endif
  270. #define XYZ_BASELINE (30 + INFO_FONT_HEIGHT)
  271. #define X_LABEL_POS 3
  272. #define X_VALUE_POS 11
  273. #define XYZ_SPACING 40
  274. #if ENABLED(XYZ_HOLLOW_FRAME)
  275. #define XYZ_FRAME_TOP 29
  276. #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 3
  277. #else
  278. #define XYZ_FRAME_TOP 30
  279. #define XYZ_FRAME_HEIGHT INFO_FONT_HEIGHT + 1
  280. #endif
  281. // Before homing the axis letters are blinking 'X' <-> '?'.
  282. // When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
  283. // When everything is ok you see a constant 'X'.
  284. static char xstring[5], ystring[5], zstring[7];
  285. #if ENABLED(FILAMENT_LCD_DISPLAY)
  286. static char wstring[5], mstring[4];
  287. #endif
  288. // At the first page, regenerate the XYZ strings
  289. if (page.page == 0) {
  290. strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
  291. strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
  292. strcpy(zstring, ftostr52sp(FIXFLOAT(LOGICAL_Z_POSITION(current_position[Z_AXIS]))));
  293. #if ENABLED(FILAMENT_LCD_DISPLAY)
  294. strcpy(wstring, ftostr12ns(filament_width_meas));
  295. strcpy(mstring, itostr3(100.0 * (
  296. parser.volumetric_enabled
  297. ? planner.volumetric_area_nominal / planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  298. : planner.volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]
  299. )
  300. ));
  301. #endif
  302. }
  303. if (PAGE_CONTAINS(XYZ_FRAME_TOP, XYZ_FRAME_TOP + XYZ_FRAME_HEIGHT - 1)) {
  304. #if ENABLED(XYZ_HOLLOW_FRAME)
  305. u8g.drawFrame(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 29-40 7: 29-39
  306. #else
  307. u8g.drawBox(0, XYZ_FRAME_TOP, LCD_PIXEL_WIDTH, XYZ_FRAME_HEIGHT); // 8: 30-39 7: 30-37
  308. #endif
  309. if (PAGE_CONTAINS(XYZ_BASELINE - (INFO_FONT_HEIGHT - 1), XYZ_BASELINE)) {
  310. #if DISABLED(XYZ_HOLLOW_FRAME)
  311. u8g.setColorIndex(0); // white on black
  312. #endif
  313. u8g.setPrintPos(0 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
  314. _draw_axis_label(X_AXIS, PSTR(MSG_X), blink);
  315. u8g.setPrintPos(0 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
  316. lcd_print(xstring);
  317. u8g.setPrintPos(1 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
  318. _draw_axis_label(Y_AXIS, PSTR(MSG_Y), blink);
  319. u8g.setPrintPos(1 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
  320. lcd_print(ystring);
  321. u8g.setPrintPos(2 * XYZ_SPACING + X_LABEL_POS, XYZ_BASELINE);
  322. _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink);
  323. u8g.setPrintPos(2 * XYZ_SPACING + X_VALUE_POS, XYZ_BASELINE);
  324. lcd_print(zstring);
  325. #if DISABLED(XYZ_HOLLOW_FRAME)
  326. u8g.setColorIndex(1); // black on white
  327. #endif
  328. }
  329. }
  330. //
  331. // Feedrate
  332. //
  333. if (PAGE_CONTAINS(51 - INFO_FONT_HEIGHT, 49)) {
  334. lcd_setFont(FONT_MENU);
  335. u8g.setPrintPos(3, 50);
  336. lcd_print(LCD_STR_FEEDRATE[0]);
  337. lcd_setFont(FONT_STATUSMENU);
  338. u8g.setPrintPos(12, 50);
  339. lcd_print(itostr3(feedrate_percentage));
  340. u8g.print('%');
  341. //
  342. // Filament sensor display if SD is disabled
  343. //
  344. #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT)
  345. u8g.setPrintPos(56, 50);
  346. lcd_print(wstring);
  347. u8g.setPrintPos(102, 50);
  348. lcd_print(mstring);
  349. u8g.print('%');
  350. lcd_setFont(FONT_MENU);
  351. u8g.setPrintPos(47, 50);
  352. lcd_print(LCD_STR_FILAM_DIA);
  353. u8g.setPrintPos(93, 50);
  354. lcd_print(LCD_STR_FILAM_MUL);
  355. #endif
  356. }
  357. //
  358. // Status line
  359. //
  360. #define STATUS_BASELINE (55 + INFO_FONT_HEIGHT)
  361. if (PAGE_CONTAINS(STATUS_BASELINE - (INFO_FONT_HEIGHT - 1), STATUS_BASELINE)) {
  362. u8g.setPrintPos(0, STATUS_BASELINE);
  363. #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
  364. if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line
  365. lcd_implementation_status_message(blink);
  366. }
  367. else {
  368. lcd_printPGM(PSTR(LCD_STR_FILAM_DIA));
  369. u8g.print(':');
  370. lcd_print(wstring);
  371. lcd_printPGM(PSTR(" " LCD_STR_FILAM_MUL));
  372. u8g.print(':');
  373. lcd_print(mstring);
  374. u8g.print('%');
  375. }
  376. #else
  377. lcd_implementation_status_message(blink);
  378. #endif
  379. }
  380. }
  381. #endif // _STATUS_SCREEN_DOGM_H_