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.

host_actions.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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. #pragma once
  23. #include "../inc/MarlinConfigPre.h"
  24. #include "../HAL/shared/Marduino.h"
  25. #if ENABLED(HOST_PROMPT_SUPPORT)
  26. enum PromptReason : uint8_t {
  27. PROMPT_NOT_DEFINED,
  28. PROMPT_FILAMENT_RUNOUT,
  29. PROMPT_USER_CONTINUE,
  30. PROMPT_FILAMENT_RUNOUT_REHEAT,
  31. PROMPT_PAUSE_RESUME,
  32. PROMPT_INFO
  33. };
  34. #endif
  35. class HostUI {
  36. public:
  37. static void action(FSTR_P const fstr, const bool eol=true);
  38. #ifdef ACTION_ON_KILL
  39. static void kill();
  40. #endif
  41. #ifdef ACTION_ON_PAUSE
  42. static void pause(const bool eol=true);
  43. #endif
  44. #ifdef ACTION_ON_PAUSED
  45. static void paused(const bool eol=true);
  46. #endif
  47. #ifdef ACTION_ON_RESUME
  48. static void resume();
  49. #endif
  50. #ifdef ACTION_ON_RESUMED
  51. static void resumed();
  52. #endif
  53. #ifdef ACTION_ON_CANCEL
  54. static void cancel();
  55. #endif
  56. #ifdef ACTION_ON_START
  57. static void start();
  58. #endif
  59. #ifdef SHUTDOWN_ACTION
  60. static void shutdown();
  61. #endif
  62. #if ENABLED(G29_RETRY_AND_RECOVER)
  63. #ifdef ACTION_ON_G29_RECOVER
  64. static void g29_recover();
  65. #endif
  66. #ifdef ACTION_ON_G29_FAILURE
  67. static void g29_failure();
  68. #endif
  69. #endif
  70. #if ENABLED(HOST_PROMPT_SUPPORT)
  71. private:
  72. static void prompt(FSTR_P const ptype, const bool eol=true);
  73. static void prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char='\0');
  74. static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0') {
  75. prompt_plus(true, ptype, FTOP(fstr), extra_char);
  76. }
  77. static void prompt_plus(FSTR_P const ptype, const char * const cstr, const char extra_char='\0') {
  78. prompt_plus(false, ptype, cstr, extra_char);
  79. }
  80. static void prompt_show();
  81. static void _prompt_show(FSTR_P const btn1, FSTR_P const btn2);
  82. public:
  83. static PromptReason host_prompt_reason;
  84. static void handle_response(const uint8_t response);
  85. static void notify_P(PGM_P const message);
  86. static void notify(FSTR_P const fmsg) { notify_P(FTOP(fmsg)); }
  87. static void notify(const char * const message);
  88. static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0');
  89. static void prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char='\0');
  90. static void prompt_end();
  91. static void prompt_button(FSTR_P const fstr);
  92. static void prompt_button(const char * const cstr);
  93. static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
  94. static void prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
  95. static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
  96. static void prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
  97. static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) {
  98. if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2);
  99. }
  100. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  101. static void filament_load_prompt();
  102. #endif
  103. #endif
  104. };
  105. extern HostUI hostui;
  106. extern const char CONTINUE_STR[], DISMISS_STR[];