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.

ui_api.h 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. float getActualTemp_celsius(const heater_t);
  62. float getActualTemp_celsius(const extruder_t);
  63. float getTargetTemp_celsius(const heater_t);
  64. float getTargetTemp_celsius(const extruder_t);
  65. float getTargetFan_percent(const fan_t);
  66. float getActualFan_percent(const fan_t);
  67. float getAxisPosition_mm(const axis_t);
  68. float getAxisPosition_mm(const extruder_t);
  69. float getAxisSteps_per_mm(const axis_t);
  70. float getAxisSteps_per_mm(const extruder_t);
  71. float getAxisMaxFeedrate_mm_s(const axis_t);
  72. float getAxisMaxFeedrate_mm_s(const extruder_t);
  73. float getAxisMaxAcceleration_mm_s2(const axis_t);
  74. float getAxisMaxAcceleration_mm_s2(const extruder_t);
  75. float getMinFeedrate_mm_s();
  76. float getMinTravelFeedrate_mm_s();
  77. float getPrintingAcceleration_mm_s2();
  78. float getRetractAcceleration_mm_s2();
  79. float getTravelAcceleration_mm_s2();
  80. float getFeedrate_percent();
  81. uint8_t getProgress_percent();
  82. uint32_t getProgress_seconds_elapsed();
  83. #if HAS_LEVELING
  84. bool getLevelingActive();
  85. void setLevelingActive(const bool);
  86. #if HAS_MESH
  87. typedef float (&bed_mesh_t)[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
  88. bool getMeshValid();
  89. bed_mesh_t getMeshArray();
  90. void setMeshPoint(const uint8_t xpos, const uint8_t ypos, const float zval);
  91. void onMeshUpdate(const uint8_t xpos, const uint8_t ypos, const float zval);
  92. #endif
  93. #endif
  94. #if ENABLED(HOST_PROMPT_SUPPORT)
  95. void setHostResponse(const uint8_t);
  96. #endif
  97. #if ENABLED(PRINTCOUNTER)
  98. char* getTotalPrints_str(char buffer[21]);
  99. char* getFinishedPrints_str(char buffer[21]);
  100. char* getTotalPrintTime_str(char buffer[21]);
  101. char* getLongestPrint_str(char buffer[21]);
  102. char* getFilamentUsed_str(char buffer[21]);
  103. #endif
  104. void setTargetTemp_celsius(const float, const heater_t);
  105. void setTargetTemp_celsius(const float, const extruder_t);
  106. void setTargetFan_percent(const float, const fan_t);
  107. void setAxisPosition_mm(const float, const axis_t);
  108. void setAxisPosition_mm(const float, const extruder_t);
  109. void setAxisSteps_per_mm(const float, const axis_t);
  110. void setAxisSteps_per_mm(const float, const extruder_t);
  111. void setAxisMaxFeedrate_mm_s(const float, const axis_t);
  112. void setAxisMaxFeedrate_mm_s(const float, const extruder_t);
  113. void setAxisMaxAcceleration_mm_s2(const float, const axis_t);
  114. void setAxisMaxAcceleration_mm_s2(const float, const extruder_t);
  115. void setFeedrate_mm_s(const float);
  116. void setMinFeedrate_mm_s(const float);
  117. void setMinTravelFeedrate_mm_s(const float);
  118. void setPrintingAcceleration_mm_s2(const float);
  119. void setRetractAcceleration_mm_s2(const float);
  120. void setTravelAcceleration_mm_s2(const float);
  121. void setFeedrate_percent(const float);
  122. void setUserConfirmed(void);
  123. #if ENABLED(LIN_ADVANCE)
  124. float getLinearAdvance_mm_mm_s(const extruder_t);
  125. void setLinearAdvance_mm_mm_s(const float, const extruder_t);
  126. #endif
  127. #if ENABLED(JUNCTION_DEVIATION)
  128. float getJunctionDeviation_mm();
  129. void setJunctionDeviation_mm(const float);
  130. #else
  131. float getAxisMaxJerk_mm_s(const axis_t);
  132. float getAxisMaxJerk_mm_s(const extruder_t);
  133. void setAxisMaxJerk_mm_s(const float, const axis_t);
  134. void setAxisMaxJerk_mm_s(const float, const extruder_t);
  135. #endif
  136. extruder_t getActiveTool();
  137. void setActiveTool(const extruder_t, bool no_move);
  138. #if ENABLED(BABYSTEPPING)
  139. int16_t mmToWholeSteps(const float mm, const axis_t axis);
  140. bool babystepAxis_steps(const int16_t steps, const axis_t axis);
  141. void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles);
  142. #endif
  143. #if HAS_HOTEND_OFFSET
  144. float getNozzleOffset_mm(const axis_t, const extruder_t);
  145. void setNozzleOffset_mm(const float, const axis_t, const extruder_t);
  146. void normalizeNozzleOffset(const axis_t axis);
  147. #endif
  148. #if HAS_BED_PROBE
  149. float getZOffset_mm();
  150. void setZOffset_mm(const float);
  151. #endif
  152. #if ENABLED(BACKLASH_GCODE)
  153. float getAxisBacklash_mm(const axis_t);
  154. void setAxisBacklash_mm(const float, const axis_t);
  155. float getBacklashCorrection_percent();
  156. void setBacklashCorrection_percent(const float);
  157. #ifdef BACKLASH_SMOOTHING_MM
  158. float getBacklashSmoothing_mm();
  159. void setBacklashSmoothing_mm(const float);
  160. #endif
  161. #endif
  162. #if HAS_FILAMENT_SENSOR
  163. bool getFilamentRunoutEnabled();
  164. void setFilamentRunoutEnabled(const bool);
  165. #if FILAMENT_RUNOUT_DISTANCE_MM > 0
  166. float getFilamentRunoutDistance_mm();
  167. void setFilamentRunoutDistance_mm(const float);
  168. #endif
  169. #endif
  170. /**
  171. * Delay and timing routines
  172. * Should be used by the EXTENSIBLE_UI to safely pause or measure time
  173. * safe_millis must be called at least every 1 sec to guarantee time
  174. * yield should be called within lengthy loops
  175. */
  176. #ifdef __SAM3X8E__
  177. uint32_t safe_millis();
  178. #else
  179. FORCE_INLINE uint32_t safe_millis() { return millis(); } // TODO: Implement for AVR
  180. #endif
  181. void delay_us(unsigned long us);
  182. void delay_ms(unsigned long ms);
  183. void yield();
  184. /**
  185. * Media access routines
  186. *
  187. * Should be used by the EXTENSIBLE_UI to operate on files
  188. */
  189. bool isMediaInserted();
  190. bool isPrintingFromMediaPaused();
  191. bool isPrintingFromMedia();
  192. bool isPrinting();
  193. void printFile(const char *filename);
  194. void stopPrint();
  195. void pausePrint();
  196. void resumePrint();
  197. class FileList {
  198. private:
  199. uint16_t num_files;
  200. public:
  201. FileList();
  202. void refresh();
  203. bool seek(const uint16_t, const bool skip_range_check = false);
  204. const char *longFilename();
  205. const char *shortFilename();
  206. const char *filename();
  207. bool isDir();
  208. void changeDir(const char * const dirname);
  209. void upDir();
  210. bool isAtRootDir();
  211. uint16_t count();
  212. };
  213. /**
  214. * Event callback routines
  215. *
  216. * Should be declared by EXTENSIBLE_UI and will be called by Marlin
  217. */
  218. void onStartup();
  219. void onIdle();
  220. void onMediaInserted();
  221. void onMediaError();
  222. void onMediaRemoved();
  223. void onPlayTone(const uint16_t frequency, const uint16_t duration);
  224. void onPrinterKilled(PGM_P const msg);
  225. void onPrintTimerStarted();
  226. void onPrintTimerPaused();
  227. void onPrintTimerStopped();
  228. void onFilamentRunout(const extruder_t extruder);
  229. void onUserConfirmRequired(const char * const msg);
  230. void onStatusChanged(const char * const msg);
  231. void onFactoryReset();
  232. void onStoreSettings();
  233. void onLoadSettings();
  234. };
  235. /**
  236. * Helper macros to increment or decrement a value. For example:
  237. *
  238. * UI_INCREMENT_BY(TargetTemp_celsius, 10, E0)
  239. *
  240. * Expands to:
  241. *
  242. * setTargetTemp_celsius(getTargetTemp_celsius(E0) + 10, E0);
  243. *
  244. * Or, in the case where a constant increment is desired:
  245. *
  246. * constexpr float increment = 10;
  247. *
  248. * UI_INCREMENT(TargetTemp_celsius, E0)
  249. *
  250. */
  251. #define UI_INCREMENT_BY(method, inc, ...) ExtUI::set ## method(ExtUI::get ## method (__VA_ARGS__) + inc, ##__VA_ARGS__)
  252. #define UI_DECREMENT_BY(method, inc, ...) ExtUI::set ## method(ExtUI::get ## method (__VA_ARGS__) - inc, ##__VA_ARGS__)
  253. #define UI_INCREMENT(method, ...) UI_INCREMENT_BY(method, increment, ##__VA_ARGS__)
  254. #define UI_DECREMENT(method, ...) UI_DECREMENT_BY(method, increment, ##__VA_ARGS__)