power_loss_recovery.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. /**
  23. * power_loss_recovery.h - Resume an SD print after power-loss
  24. */
  25. #ifndef _POWER_LOSS_RECOVERY_H_
  26. #define _POWER_LOSS_RECOVERY_H_
  27. #include "cardreader.h"
  28. #include "types.h"
  29. #include "MarlinConfig.h"
  30. #define SAVE_INFO_INTERVAL_MS 0
  31. //#define SAVE_EACH_CMD_MODE
  32. //#define DEBUG_POWER_LOSS_RECOVERY
  33. typedef struct {
  34. uint8_t valid_head;
  35. // Machine state
  36. float current_position[NUM_AXIS], feedrate;
  37. #if HOTENDS > 1
  38. uint8_t active_hotend;
  39. #endif
  40. int16_t target_temperature[HOTENDS];
  41. #if HAS_HEATED_BED
  42. int16_t target_temperature_bed;
  43. #endif
  44. #if FAN_COUNT
  45. int16_t fanSpeeds[FAN_COUNT];
  46. #endif
  47. #if HAS_LEVELING
  48. bool leveling;
  49. float fade;
  50. #endif
  51. // Command queue
  52. uint8_t cmd_queue_index_r, commands_in_queue;
  53. char command_queue[BUFSIZE][MAX_CMD_SIZE];
  54. // SD Filename and position
  55. char sd_filename[MAXPATHNAMELENGTH];
  56. uint32_t sdpos;
  57. // Job elapsed time
  58. millis_t print_job_elapsed;
  59. uint8_t valid_foot;
  60. } job_recovery_info_t;
  61. extern job_recovery_info_t job_recovery_info;
  62. enum JobRecoveryPhase : unsigned char {
  63. JOB_RECOVERY_IDLE,
  64. JOB_RECOVERY_MAYBE,
  65. JOB_RECOVERY_YES,
  66. JOB_RECOVERY_DONE
  67. };
  68. extern JobRecoveryPhase job_recovery_phase;
  69. #if HAS_LEVELING
  70. #define APPEND_CMD_COUNT 9
  71. #else
  72. #define APPEND_CMD_COUNT 7
  73. #endif
  74. extern char job_recovery_commands[BUFSIZE + APPEND_CMD_COUNT][MAX_CMD_SIZE];
  75. extern uint8_t job_recovery_commands_count;
  76. void check_print_job_recovery();
  77. void save_job_recovery_info();
  78. #endif // _POWER_LOSS_RECOVERY_H_