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.

preheat_timer_screen.cpp 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /****************************
  2. * preheat_timer_screen.cpp *
  3. ****************************/
  4. /****************************************************************************
  5. * Written By Marcio Teixeira 2019 - Cocoa Press *
  6. * *
  7. * This program is free software: you can redistribute it and/or modify *
  8. * it under the terms of the GNU General Public License as published by *
  9. * the Free Software Foundation, either version 3 of the License, or *
  10. * (at your option) any later version. *
  11. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * To view a copy of the GNU General Public License, go to the following *
  18. * location: <https://www.gnu.org/licenses/>. *
  19. ****************************************************************************/
  20. #include "../config.h"
  21. #if ENABLED(TOUCH_UI_FTDI_EVE) && defined(TOUCH_UI_COCOA_PRESS)
  22. #include "screens.h"
  23. #include "screen_data.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 5
  30. void PreheatTimerScreen::draw_message(draw_mode_t what) {
  31. if (what & BACKGROUND) {
  32. CommandProcessor cmd;
  33. cmd.cmd(CLEAR_COLOR_RGB(bg_color))
  34. .cmd(CLEAR(true,true,true))
  35. .cmd(COLOR_RGB(bg_text_enabled))
  36. .tag(0);
  37. draw_text_box(cmd, BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_HEATING), OPT_CENTER, font_large);
  38. }
  39. }
  40. uint16_t PreheatTimerScreen::secondsRemaining() {
  41. const uint32_t elapsed_sec = (millis() - screen_data.PreheatTimerScreen.start_ms) / 1000;
  42. return (COCOA_PRESS_PREHEAT_SECONDS > elapsed_sec) ? COCOA_PRESS_PREHEAT_SECONDS - elapsed_sec : 0;
  43. }
  44. void PreheatTimerScreen::draw_time_remaining(draw_mode_t what) {
  45. if (what & FOREGROUND) {
  46. const uint16_t elapsed_sec = secondsRemaining();
  47. const uint8_t min = elapsed_sec / 60,
  48. sec = elapsed_sec % 60;
  49. char str[10];
  50. sprintf_P(str, PSTR("%02d:%02d"), min, sec);
  51. CommandProcessor cmd;
  52. cmd.font(font_xlarge);
  53. draw_circular_progress(cmd, BTN_POS(1,1), BTN_SIZE(1,5), float(secondsRemaining()) * 100 / COCOA_PRESS_PREHEAT_SECONDS, str, theme_dark, theme_darkest);
  54. }
  55. }
  56. void PreheatTimerScreen::draw_interaction_buttons(draw_mode_t what) {
  57. if (what & FOREGROUND) {
  58. CommandProcessor cmd;
  59. cmd.colors(normal_btn)
  60. .font(font_medium)
  61. .tag(1).button( BTN_POS(2,5), BTN_SIZE(1,1), F("Cancel"));
  62. }
  63. }
  64. void PreheatTimerScreen::onEntry() {
  65. screen_data.PreheatTimerScreen.start_ms = millis();
  66. }
  67. void PreheatTimerScreen::onRedraw(draw_mode_t what) {
  68. draw_message(what);
  69. draw_time_remaining(what);
  70. draw_interaction_buttons(what);
  71. }
  72. bool PreheatTimerScreen::onTouchEnd(uint8_t tag) {
  73. switch (tag) {
  74. case 1: GOTO_PREVIOUS(); return true;
  75. default: break;
  76. }
  77. return false;
  78. }
  79. void PreheatTimerScreen::onIdle() {
  80. if (secondsRemaining() == 0) {
  81. AlertDialogBox::show(GET_TEXT_F(MSG_PREHEAT_FINISHED));
  82. // Remove SaveSettingsDialogBox from the stack
  83. // so the alert box doesn't return to me.
  84. current_screen.forget();
  85. }
  86. reset_menu_timeout();
  87. if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
  88. onRefresh();
  89. refresh_timer.start();
  90. }
  91. BaseScreen::onIdle();
  92. }
  93. #endif // TOUCH_UI_FTDI_EVE