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.

printstats.cpp 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Print Stats page for PRO UI
  24. * Author: Miguel A. Risco-Castillo (MRISCOC)
  25. * Version: 1.3.0
  26. * Date: 2022/02/24
  27. */
  28. #include "../../../inc/MarlinConfigPre.h"
  29. #if BOTH(DWIN_LCD_PROUI, PRINTCOUNTER)
  30. #include "printstats.h"
  31. #include "../../../core/types.h"
  32. #include "../../../MarlinCore.h"
  33. #include "../../marlinui.h"
  34. #include "../../../module/printcounter.h"
  35. #include "dwin_lcd.h"
  36. #include "dwinui.h"
  37. #include "dwin_popup.h"
  38. #include "dwin.h"
  39. PrintStatsClass PrintStats;
  40. void PrintStatsClass::Draw() {
  41. char buf[50] = "";
  42. char str[30] = "";
  43. constexpr int8_t MRG = 30;
  44. Title.ShowCaption(GET_TEXT_F(MSG_INFO_STATS_MENU));
  45. DWINUI::ClearMainArea();
  46. Draw_Popup_Bkgd();
  47. DWINUI::Draw_Button(BTN_Continue, 86, 250);
  48. printStatistics ps = print_job_timer.getStats();
  49. sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_PRINT_COUNT), ps.totalPrints);
  50. DWINUI::Draw_String(MRG, 80, buf);
  51. sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_COMPLETED_PRINTS), ps.finishedPrints);
  52. DWINUI::Draw_String(MRG, 100, buf);
  53. duration_t(print_job_timer.getStats().printTime).toDigital(str, true);
  54. sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_TIME), str);
  55. DWINUI::Draw_String(MRG, 120, buf);
  56. duration_t(print_job_timer.getStats().longestPrint).toDigital(str, true);
  57. sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_LONGEST), str);
  58. DWINUI::Draw_String(MRG, 140, buf);
  59. sprintf_P(buf, PSTR(S_FMT ": %s m"), GET_TEXT(MSG_INFO_PRINT_FILAMENT), dtostrf(ps.filamentUsed / 1000, 1, 2, str));
  60. DWINUI::Draw_String(MRG, 160, buf);
  61. }
  62. void PrintStatsClass::Reset() {
  63. print_job_timer.initStats();
  64. DONE_BUZZ(true);
  65. }
  66. void Goto_PrintStats() {
  67. PrintStats.Draw();
  68. HMI_SaveProcessID(WaitResponse);
  69. }
  70. #endif // DWIN_LCD_PROUI && PRINTCOUNTER