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.

bio_printing_dialog_box.cpp 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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: <http://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. }
  94. break;
  95. default: return false;
  96. }
  97. return true;
  98. }
  99. void BioPrintingDialogBox::setStatusMessage(progmem_str message) {
  100. char buff[strlen_P((const char*)message)+1];
  101. strcpy_P(buff, (const char*) message);
  102. setStatusMessage(buff);
  103. }
  104. void BioPrintingDialogBox::setStatusMessage(const char* message) {
  105. CommandProcessor cmd;
  106. cmd.cmd(CMD_DLSTART)
  107. .cmd(CLEAR_COLOR_RGB(bg_color))
  108. .cmd(CLEAR(true,true,true));
  109. draw_status_message(BACKGROUND, message);
  110. draw_progress(BACKGROUND);
  111. draw_time_remaining(BACKGROUND);
  112. draw_interaction_buttons(BACKGROUND);
  113. storeBackground();
  114. #if ENABLED(TOUCH_UI_DEBUG)
  115. SERIAL_ECHO_START();
  116. SERIAL_ECHOLNPAIR("New status message: ", message);
  117. #endif
  118. if (AT_SCREEN(BioPrintingDialogBox)) {
  119. current_screen.onRefresh();
  120. }
  121. }
  122. void BioPrintingDialogBox::onIdle() {
  123. reset_menu_timeout();
  124. if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
  125. onRefresh();
  126. refresh_timer.start();
  127. }
  128. BaseScreen::onIdle();
  129. }
  130. void BioPrintingDialogBox::show() {
  131. GOTO_SCREEN(BioPrintingDialogBox);
  132. }
  133. #endif // TOUCH_UI_FTDI_EVE