My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ui_api.h 9.0KB

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