My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cancel_object.cpp 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../inc/MarlinConfig.h"
  23. #if ENABLED(CANCEL_OBJECTS)
  24. #include "cancel_object.h"
  25. #include "../gcode/gcode.h"
  26. #include "../lcd/ultralcd.h"
  27. CancelObject cancelable;
  28. int8_t CancelObject::object_count, // = 0
  29. CancelObject::active_object = -1;
  30. uint32_t CancelObject::canceled; // = 0x0000
  31. bool CancelObject::skipping; // = false
  32. void CancelObject::set_active_object(const int8_t obj) {
  33. active_object = obj;
  34. if (WITHIN(obj, 0, 31)) {
  35. if (obj >= object_count) object_count = obj + 1;
  36. skipping = TEST(canceled, obj);
  37. }
  38. else
  39. skipping = false;
  40. #if HAS_DISPLAY
  41. if (active_object >= 0)
  42. ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object + 1));
  43. else
  44. ui.reset_status();
  45. #endif
  46. }
  47. void CancelObject::cancel_object(const int8_t obj) {
  48. if (WITHIN(obj, 0, 31)) {
  49. SBI(canceled, obj);
  50. if (obj == active_object) skipping = true;
  51. }
  52. }
  53. void CancelObject::uncancel_object(const int8_t obj) {
  54. if (WITHIN(obj, 0, 31)) {
  55. CBI(canceled, obj);
  56. if (obj == active_object) skipping = false;
  57. }
  58. }
  59. void CancelObject::report() {
  60. if (active_object >= 0) {
  61. SERIAL_ECHO_START();
  62. SERIAL_ECHOLNPAIR("Active Object: ", int(active_object));
  63. }
  64. if (canceled) {
  65. SERIAL_ECHO_START();
  66. SERIAL_ECHOPGM("Canceled:");
  67. for (int i = 0; i < object_count; i++)
  68. if (TEST(canceled, i)) { SERIAL_CHAR(' '); SERIAL_ECHO(i); }
  69. SERIAL_EOL();
  70. }
  71. }
  72. #endif // CANCEL_OBJECTS