如果我想在 Marlin 中添加我自己的自定义 M 代码 - 我会在哪个源代码文件中这样做?
为 Marlin 添加自定义 M 代码
3D打印
马林鱼
2021-04-24 20:06:35
1个回答
在第Marlin_main.cpp
7131 行的文件中有一个 switch case:
(要打开行号,请转到File>Preferences
并单击显示行号。)
case 'M': switch (codenum) {
#if ENABLED(ULTIPANEL)
case 0: // M0 - Unconditional stop - Wait for user button press on LCD
case 1: // M1 - Conditional stop - Wait for user button press on LCD
gcode_M0_M1();
break;
#endif // ULTIPANEL
case 17:
gcode_M17();
break;
etc.....
添加另一个带有未使用的数字(例如 5)的案例,然后添加您想要的代码后跟一个中断应该可以解决问题。前任:
case 5:
doABunchofCoolStuff();
myservo.write(thebestposition);
break;
-AC