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.

bio_printing_dialog_box.cpp 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*******************************
  2. * bio_printing_dialog_box.cpp *
  3. *******************************/
  4. /****************************************************************************
  5. * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
  6. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  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. * To view a copy of the GNU General Public License, go to the following *
  19. * location: <https://www.gnu.org/licenses/>. *
  20. ****************************************************************************/
  21. #include "../config.h"
  22. #if ENABLED(TOUCH_UI_FTDI_EVE) && defined(TOUCH_UI_LULZBOT_BIO)
  23. #include "screens.h"
  24. #include "../ftdi_eve_lib/extras/circular_progress.h"
  25. using namespace FTDI;
  26. using namespace ExtUI;
  27. using namespace Theme;
  28. #define GRID_COLS 2
  29. #define GRID_ROWS 9
  30. void BioPrintingDialogBox::draw_status_message(draw_mode_t what, const char* message) {
  31. if (what & BACKGROUND) {
  32. CommandProcessor cmd;
  33. cmd.cmd(COLOR_RGB(bg_text_enabled))
  34. .tag(0);
  35. draw_text_box(cmd, BTN_POS(1,2), BTN_SIZE(2,2), message, OPT_CENTER, font_large);
  36. }
  37. }
  38. void BioPrintingDialogBox::draw_progress(draw_mode_t what) {
  39. if (what & FOREGROUND) {
  40. CommandProcessor cmd;
  41. cmd.font(font_large)
  42. .text(BTN_POS(1,1), BTN_SIZE(2,2), isPrinting() ? F("Printing...") : F("Finished."))
  43. .tag(1)
  44. .font(font_xlarge);
  45. draw_circular_progress(cmd, BTN_POS(1,4), BTN_SIZE(2,3), getProgress_percent(), theme_dark, theme_darkest);
  46. }
  47. }
  48. void BioPrintingDialogBox::draw_time_remaining(draw_mode_t what) {
  49. if (what & FOREGROUND) {
  50. const uint32_t elapsed = getProgress_seconds_elapsed();
  51. const uint8_t hrs = elapsed/3600;
  52. const uint8_t min = (elapsed/60)%60;
  53. char time_str[10];
  54. sprintf_P(time_str, PSTR("%02dh %02dm"), hrs, min);
  55. CommandProcessor cmd;
  56. cmd.font(font_large)
  57. .text(BTN_POS(1,7), BTN_SIZE(2,2), time_str);
  58. }
  59. }
  60. void BioPrintingDialogBox::draw_interaction_buttons(draw_mode_t what) {
  61. if (what & FOREGROUND) {
  62. CommandProcessor cmd;
  63. cmd.colors(normal_btn)
  64. .font(font_medium)
  65. .colors(isPrinting() ? action_btn : normal_btn)
  66. .tag(2).button(BTN_POS(1,9), BTN_SIZE(1,1), F("Menu"))
  67. #if ENABLED(SDSUPPORT)
  68. .enabled(isPrinting() ? isPrintingFromMedia() : 1)
  69. #else
  70. .enabled(isPrinting() ? 0 : 1)
  71. #endif
  72. .tag(3)
  73. .colors(isPrinting() ? normal_btn : action_btn)
  74. .button( BTN_POS(2,9), BTN_SIZE(1,1), isPrinting() ? F("Cancel") : F("Back"));
  75. }
  76. }
  77. void BioPrintingDialogBox::onRedraw(draw_mode_t what) {
  78. if (what & FOREGROUND) {
  79. draw_progress(FOREGROUND);
  80. draw_time_remaining(FOREGROUND);
  81. draw_interaction_buttons(FOREGROUND);
  82. }
  83. }
  84. bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) {
  85. switch (tag) {
  86. case 1: GOTO_SCREEN(FeedratePercentScreen); break;
  87. case 2: GOTO_SCREEN(TuneMenu); break;
  88. case 3:
  89. if (isPrinting())
  90. GOTO_SCREEN(ConfirmAbortPrintDialogBox);
  91. else
  92. GOTO_SCREEN(StatusScreen);
  93. break;
  94. default: return false;
  95. }
  96. return true;
  97. }
  98. void BioPrintingDialogBox::setStatusMessage(progmem_str message) {
  99. char buff[strlen_P((const char*)message)+1];
  100. strcpy_P(buff, (const char*) message);
  101. setStatusMessage(buff);
  102. }
  103. void BioPrintingDialogBox::setStatusMessage(const char* message) {
  104. CommandProcessor cmd;
  105. cmd.cmd(CMD_DLSTART)
  106. .cmd(CLEAR_COLOR_RGB(bg_color))
  107. .cmd(CLEAR(true,true,true));
  108. draw_status_message(BACKGROUND, message);
  109. draw_progress(BACKGROUND);
  110. draw_time_remaining(BACKGROUND);
  111. draw_interaction_buttons(BACKGROUND);
  112. storeBackground();
  113. #if ENABLED(TOUCH_UI_DEBUG)
  114. SERIAL_ECHO_START();
  115. SERIAL_ECHOLNPAIR("New status message: ", message);
  116. #endif
  117. if (AT_SCREEN(BioPrintingDialogBox))
  118. current_screen.onRefresh();
  119. }
  120. void BioPrintingDialogBox::onIdle() {
  121. reset_menu_timeout();
  122. if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
  123. onRefresh();
  124. refresh_timer.start();
  125. }
  126. BaseScreen::onIdle();
  127. }
  128. void BioPrintingDialogBox::show() {
  129. GOTO_SCREEN(BioPrintingDialogBox);
  130. }
  131. #endif // TOUCH_UI_FTDI_EVE