My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

bltouch.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. // BLTouch commands are sent as servo angles
  25. typedef unsigned char BLTCommand;
  26. #define STOW_ALARM true
  27. #define BLTOUCH_DEPLOY 10
  28. #define BLTOUCH_STOW 90
  29. #define BLTOUCH_SW_MODE 60
  30. #define BLTOUCH_SELFTEST 120
  31. #define BLTOUCH_MODE_STORE 130
  32. #define BLTOUCH_5V_MODE 140
  33. #define BLTOUCH_OD_MODE 150
  34. #define BLTOUCH_RESET 160
  35. /**
  36. * The following commands require different minimum delays.
  37. *
  38. * 500ms required for a reliable Reset.
  39. *
  40. * 750ms required for Deploy/Stow, otherwise the alarm state
  41. * will not be seen until the following move command.
  42. */
  43. #ifndef BLTOUCH_SET5V_DELAY
  44. #define BLTOUCH_SET5V_DELAY 150
  45. #endif
  46. #ifndef BLTOUCH_SETOD_DELAY
  47. #define BLTOUCH_SETOD_DELAY 150
  48. #endif
  49. #ifndef BLTOUCH_MODE_STORE_DELAY
  50. #define BLTOUCH_MODE_STORE_DELAY 150
  51. #endif
  52. #ifndef BLTOUCH_DEPLOY_DELAY
  53. #define BLTOUCH_DEPLOY_DELAY 750
  54. #endif
  55. #ifndef BLTOUCH_STOW_DELAY
  56. #define BLTOUCH_STOW_DELAY 750
  57. #endif
  58. #ifndef BLTOUCH_RESET_DELAY
  59. #define BLTOUCH_RESET_DELAY 500
  60. #endif
  61. class BLTouch {
  62. public:
  63. static void init(const bool set_voltage=false);
  64. static bool od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
  65. #ifdef BLTOUCH_HS_MODE
  66. static bool high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
  67. #else
  68. static constexpr bool high_speed_mode = false;
  69. #endif
  70. static float z_extra_clearance() { return high_speed_mode ? 7 : 0; }
  71. // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing
  72. static bool deploy() { return deploy_proc(); }
  73. static bool stow() { return stow_proc(); }
  74. static bool status() { return status_proc(); }
  75. // Native BLTouch commands ("Underscore"...), used in lcd menus and internally
  76. static void _reset() { command(BLTOUCH_RESET, BLTOUCH_RESET_DELAY); }
  77. static void _selftest() { command(BLTOUCH_SELFTEST, BLTOUCH_DELAY); }
  78. static void _set_SW_mode() { command(BLTOUCH_SW_MODE, BLTOUCH_DELAY); }
  79. static void _reset_SW_mode() { if (triggered()) _stow(); else _deploy(); }
  80. static void _set_5V_mode() { command(BLTOUCH_5V_MODE, BLTOUCH_SET5V_DELAY); }
  81. static void _set_OD_mode() { command(BLTOUCH_OD_MODE, BLTOUCH_SETOD_DELAY); }
  82. static void _mode_store() { command(BLTOUCH_MODE_STORE, BLTOUCH_MODE_STORE_DELAY); }
  83. static void _deploy() { command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); }
  84. static void _stow() { command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY); }
  85. static void mode_conv_5V() { mode_conv_proc(true); }
  86. static void mode_conv_OD() { mode_conv_proc(false); }
  87. static bool triggered();
  88. private:
  89. static bool _deploy_query_alarm() { return command(BLTOUCH_DEPLOY, BLTOUCH_DEPLOY_DELAY); }
  90. static bool _stow_query_alarm() { return command(BLTOUCH_STOW, BLTOUCH_STOW_DELAY) == STOW_ALARM; }
  91. static void clear();
  92. static bool command(const BLTCommand cmd, const millis_t &ms);
  93. static bool deploy_proc();
  94. static bool stow_proc();
  95. static bool status_proc();
  96. static void mode_conv_proc(const bool M5V);
  97. };
  98. extern BLTouch bltouch;