My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ui_api.h 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2019 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. * ui_api.h *
  24. ************/
  25. /****************************************************************************
  26. * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
  27. * *
  28. * This program is free software: you can redistribute it and/or modify *
  29. * it under the terms of the GNU General Public License as published by *
  30. * the Free Software Foundation, either version 3 of the License, or *
  31. * (at your option) any later version. *
  32. * *
  33. * This program is distributed in the hope that it will be useful, *
  34. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  35. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  36. * GNU General Public License for more details. *
  37. * *
  38. * To view a copy of the GNU General Public License, go to the following *
  39. * location: <http://www.gnu.org/licenses/>. *
  40. ****************************************************************************/
  41. #pragma once
  42. #include "../../inc/MarlinConfig.h"
  43. namespace ExtUI {
  44. enum axis_t : uint8_t { X, Y, Z };
  45. enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5 };
  46. enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED };
  47. enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5 };
  48. constexpr uint8_t extruderCount = EXTRUDERS;
  49. constexpr uint8_t hotendCount = HOTENDS;
  50. constexpr uint8_t fanCount = FAN_COUNT;
  51. bool isMoving();
  52. bool isAxisPositionKnown(const axis_t);
  53. bool canMove(const axis_t);
  54. bool canMove(const extruder_t);
  55. void enqueueCommands_P(PGM_P const);
  56. /**
  57. * Getters and setters
  58. * Should be used by the EXTENSIBLE_UI to query or change Marlin's state.
  59. */
  60. PGM_P getFirmwareName_str();
  61. #if HAS_SOFTWARE_ENDSTOPS
  62. bool getSoftEndstopState();
  63. void setSoftEndstopState(const bool);
  64. #endif
  65. #if HAS_TRINAMIC
  66. float getAxisCurrent_mA(const axis_t);
  67. float getAxisCurrent_mA(const extruder_t);
  68. void setAxisCurrent_mA(const float, const axis_t);
  69. void setAxisCurrent_mA(const float, const extruder_t);
  70. int getTMCBumpSensitivity(const axis_t);
  71. void setTMCBumpSensitivity(const float, const axis_t);
  72. #endif
  73. float getActualTemp_celsius(const heater_t);
  74. float getActualTemp_celsius(const extruder_t);
  75. float getTargetTemp_celsius(const heater_t);
  76. float getTargetTemp_celsius(const extruder_t);
  77. float getTargetFan_percent(const fan_t);
  78. float getActualFan_percent(const fan_t);
  79. float getAxisPosition_mm(const axis_t);
  80. float getAxisPosition_mm(const extruder_t);
  81. float getAxisSteps_per_mm(const axis_t);
  82. float getAxisSteps_per_mm(const extruder_t);
  83. float getAxisMaxFeedrate_mm_s(const axis_t);
  84. float getAxisMaxFeedrate_mm_s(const extruder_t);
  85. float getAxisMaxAcceleration_mm_s2(const axis_t);
  86. float getAxisMaxAcceleration_mm_s2(const extruder_t);
  87. float getMinFeedrate_mm_s();
  88. float getMinTravelFeedrate_mm_s();
  89. float getPrintingAcceleration_mm_s2();
  90. float getRetractAcceleration_mm_s2();
  91. float getTravelAcceleration_mm_s2();
  92. float getFeedrate_percent();
  93. uint8_t getProgress_percent();
  94. uint32_t getProgress_seconds_elapsed();
  95. #if HAS_LEVELING
  96. bool getLevelingActive();
  97. void setLevelingActive(const bool);
  98. #if HAS_MESH
  99. bool getMeshValid();
  100. bed_mesh_t getMeshArray();
  101. void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval);
  102. void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval);
  103. #endif
  104. #endif
  105. #if ENABLED(HOST_PROMPT_SUPPORT)
  106. void setHostResponse(const uint8_t);
  107. #endif
  108. #if ENABLED(PRINTCOUNTER)
  109. char* getTotalPrints_str(char buffer[21]);
  110. char* getFinishedPrints_str(char buffer[21]);
  111. char* getTotalPrintTime_str(char buffer[21]);
  112. char* getLongestPrint_str(char buffer[21]);
  113. char* getFilamentUsed_str(char buffer[21]);
  114. #endif
  115. void setTargetTemp_celsius(const float, const heater_t);
  116. void setTargetTemp_celsius(const float, const extruder_t);
  117. void setTargetFan_percent(const float, const fan_t);
  118. void setAxisPosition_mm(const float, const axis_t);
  119. void setAxisPosition_mm(const float, const extruder_t);
  120. void setAxisSteps_per_mm(const float, const axis_t);
  121. void setAxisSteps_per_mm(const float, const extruder_t);
  122. void setAxisMaxFeedrate_mm_s(const float, const axis_t);
  123. void setAxisMaxFeedrate_mm_s(const float, const extruder_t);
  124. void setAxisMaxAcceleration_mm_s2(const float, const axis_t);
  125. void setAxisMaxAcceleration_mm_s2(const float, const extruder_t);
  126. void setFeedrate_mm_s(const float);
  127. void setMinFeedrate_mm_s(const float);
  128. void setMinTravelFeedrate_mm_s(const float);
  129. void setPrintingAcceleration_mm_s2(const float);
  130. void setRetractAcceleration_mm_s2(const float);
  131. void setTravelAcceleration_mm_s2(const float);
  132. void setFeedrate_percent(const float);
  133. void setUserConfirmed(void);
  134. #if ENABLED(LIN_ADVANCE)
  135. float getLinearAdvance_mm_mm_s(const extruder_t);
  136. void setLinearAdvance_mm_mm_s(const float, const extruder_t);
  137. #endif
  138. #if ENABLED(JUNCTION_DEVIATION)
  139. float getJunctionDeviation_mm();
  140. void setJunctionDeviation_mm(const float);
  141. #else
  142. float getAxisMaxJerk_mm_s(const axis_t);
  143. float getAxisMaxJerk_mm_s(const extruder_t);
  144. void setAxisMaxJerk_mm_s(const float, const axis_t);
  145. void setAxisMaxJerk_mm_s(const float, const extruder_t);
  146. #endif
  147. extruder_t getActiveTool();
  148. void setActiveTool(const extruder_t, bool no_move);
  149. #if ENABLED(BABYSTEPPING)
  150. int16_t mmToWholeSteps(const float mm, const axis_t axis);
  151. bool babystepAxis_steps(const int16_t steps, const axis_t axis);
  152. void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles);
  153. #endif
  154. #if HAS_HOTEND_OFFSET
  155. float getNozzleOffset_mm(const axis_t, const extruder_t);
  156. void setNozzleOffset_mm(const float, const axis_t, const extruder_t);
  157. void normalizeNozzleOffset(const axis_t axis);
  158. #endif
  159. #if HAS_BED_PROBE
  160. float getZOffset_mm();
  161. void setZOffset_mm(const float);
  162. #endif
  163. #if ENABLED(BACKLASH_GCODE)
  164. float getAxisBacklash_mm(const axis_t);
  165. void setAxisBacklash_mm(const float, const axis_t);
  166. float getBacklashCorrection_percent();
  167. void setBacklashCorrection_percent(const float);
  168. #ifdef BACKLASH_SMOOTHING_MM
  169. float getBacklashSmoothing_mm();
  170. void setBacklashSmoothing_mm(const float);
  171. #endif
  172. #endif
  173. #if HAS_FILAMENT_SENSOR
  174. bool getFilamentRunoutEnabled();
  175. void setFilamentRunoutEnabled(const bool);
  176. #if FILAMENT_RUNOUT_DISTANCE_MM > 0
  177. float getFilamentRunoutDistance_mm();
  178. void setFilamentRunoutDistance_mm(const float);
  179. #endif
  180. #endif
  181. /**
  182. * Delay and timing routines
  183. * Should be used by the EXTENSIBLE_UI to safely pause or measure time
  184. * safe_millis must be called at least every 1 sec to guarantee time
  185. * yield should be called within lengthy loops
  186. */
  187. #ifdef __SAM3X8E__
  188. uint32_t safe_millis();
  189. #else
  190. FORCE_INLINE uint32_t safe_millis() { return millis(); } // TODO: Implement for AVR
  191. #endif
  192. void delay_us(unsigned long us);
  193. void delay_ms(unsigned long ms);
  194. void yield();
  195. /**
  196. * Media access routines
  197. *
  198. * Should be used by the EXTENSIBLE_UI to operate on files
  199. */
  200. bool isMediaInserted();
  201. bool isPrintingFromMediaPaused();
  202. bool isPrintingFromMedia();
  203. bool isPrinting();
  204. void printFile(const char *filename);
  205. void stopPrint();
  206. void pausePrint();
  207. void resumePrint();
  208. class FileList {
  209. private:
  210. uint16_t num_files;
  211. public:
  212. FileList();
  213. void refresh();
  214. bool seek(const uint16_t, const bool skip_range_check = false);
  215. const char *longFilename();
  216. const char *shortFilename();
  217. const char *filename();
  218. bool isDir();
  219. void changeDir(const char * const dirname);
  220. void upDir();
  221. bool isAtRootDir();
  222. uint16_t count();
  223. };
  224. /**
  225. * Event callback routines
  226. *
  227. * Should be declared by EXTENSIBLE_UI and will be called by Marlin
  228. */
  229. void onStartup();
  230. void onIdle();
  231. void onMediaInserted();
  232. void onMediaError();
  233. void onMediaRemoved();
  234. void onPlayTone(const uint16_t frequency, const uint16_t duration);
  235. void onPrinterKilled(PGM_P const msg);
  236. void onPrintTimerStarted();
  237. void onPrintTimerPaused();
  238. void onPrintTimerStopped();
  239. void onFilamentRunout(const extruder_t extruder);
  240. void onUserConfirmRequired(const char * const msg);
  241. void onStatusChanged(const char * const msg);
  242. void onFactoryReset();
  243. void onStoreSettings();
  244. void onLoadSettings();
  245. };
  246. /**
  247. * Helper macros to increment or decrement a value. For example:
  248. *
  249. * UI_INCREMENT_BY(TargetTemp_celsius, 10, E0)
  250. *
  251. * Expands to:
  252. *
  253. * setTargetTemp_celsius(getTargetTemp_celsius(E0) + 10, E0);
  254. *
  255. * Or, in the case where a constant increment is desired:
  256. *
  257. * constexpr float increment = 10;
  258. *
  259. * UI_INCREMENT(TargetTemp_celsius, E0)
  260. *
  261. */
  262. #define UI_INCREMENT_BY(method, inc, ...) ExtUI::set ## method(ExtUI::get ## method (__VA_ARGS__) + inc, ##__VA_ARGS__)
  263. #define UI_DECREMENT_BY(method, inc, ...) ExtUI::set ## method(ExtUI::get ## method (__VA_ARGS__) - inc, ##__VA_ARGS__)
  264. #define UI_INCREMENT(method, ...) UI_INCREMENT_BY(method, increment, ##__VA_ARGS__)
  265. #define UI_DECREMENT(method, ...) UI_DECREMENT_BY(method, increment, ##__VA_ARGS__)