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.

Marlin.h 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #ifndef __MARLINH
  2. #define __MARLINH
  3. // Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
  4. // Licence: GPL
  5. #define HardwareSerial_h // trick to disable the standard HWserial
  6. #include <math.h>
  7. #if ARDUINO >= 100
  8. #include "Arduino.h"
  9. #else
  10. #include "WProgram.h"
  11. #endif
  12. #include "fastio.h"
  13. #include <avr/pgmspace.h>
  14. #include "Configuration.h"
  15. #include "MarlinSerial.h"
  16. #define FORCE_INLINE __attribute__((always_inline)) inline
  17. //#define SERIAL_ECHO(x) Serial << "echo: " << x;
  18. //#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
  19. //#define SERIAL_ERROR(x) Serial << "Error: " << x;
  20. //#define SERIAL_ERRORLN(x) Serial << "Error: " << x<<endl;
  21. //#define SERIAL_PROTOCOL(x) Serial << x;
  22. //#define SERIAL_PROTOCOLLN(x) Serial << x<<endl;
  23. //this is a unfinsihed attemp to removes a lot of warning messages, see:
  24. // http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
  25. //typedef char prog_char PROGMEM;
  26. // //#define PSTR (s ) ((const PROGMEM char *)(s))
  27. // //# define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];}))
  28. // //#define MYPGM(s) ((const prog_char *g PROGMEM=s))
  29. // //#define MYPGM(s) PSTR(s)
  30. #define MYPGM(s) (__extension__({static char __c[] __attribute__((__progmem__)) = (s); &__c[0];})) //This is the normal behaviour
  31. //#define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];})) //this does not work but hides the warnings
  32. #define SERIAL_PROTOCOL(x) MSerial.print(x);
  33. #define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
  34. #define SERIAL_PROTOCOLLN(x) {MSerial.print(x);MSerial.write('\n');}
  35. #define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MSerial.write('\n');}
  36. const prog_char errormagic[] PROGMEM ="Error:";
  37. const prog_char echomagic[] PROGMEM ="echo:";
  38. #define SERIAL_ERROR_START serialprintPGM(errormagic);
  39. #define SERIAL_ERROR(x) SERIAL_PROTOCOL(x)
  40. #define SERIAL_ERRORPGM(x) SERIAL_PROTOCOLPGM(x)
  41. #define SERIAL_ERRORLN(x) SERIAL_PROTOCOLLN(x)
  42. #define SERIAL_ERRORLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
  43. #define SERIAL_ECHO_START serialprintPGM(echomagic);
  44. #define SERIAL_ECHO(x) SERIAL_PROTOCOL(x)
  45. #define SERIAL_ECHOPGM(x) SERIAL_PROTOCOLPGM(x)
  46. #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
  47. #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
  48. #define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
  49. // Macro for getting current active extruder
  50. #define ACTIVE_EXTRUDER (active_extruder)
  51. //things to write to serial from Programmemory. saves 400 to 2k of RAM.
  52. #define SerialprintPGM(x) serialprintPGM(MYPGM(x))
  53. FORCE_INLINE void serialprintPGM(const char *str)
  54. {
  55. char ch=pgm_read_byte(str);
  56. while(ch)
  57. {
  58. MSerial.write(ch);
  59. ch=pgm_read_byte(++str);
  60. }
  61. }
  62. void get_command();
  63. void process_commands();
  64. void manage_inactivity(byte debug);
  65. #if X_ENABLE_PIN > -1
  66. #define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
  67. #define disable_x() WRITE(X_ENABLE_PIN,!X_ENABLE_ON)
  68. #else
  69. #define enable_x() ;
  70. #define disable_x() ;
  71. #endif
  72. #if Y_ENABLE_PIN > -1
  73. #define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
  74. #define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
  75. #else
  76. #define enable_y() ;
  77. #define disable_y() ;
  78. #endif
  79. #if Z_ENABLE_PIN > -1
  80. #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
  81. #define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON)
  82. #else
  83. #define enable_z() ;
  84. #define disable_z() ;
  85. #endif
  86. #if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
  87. #define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON)
  88. #define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON)
  89. #else
  90. #define enable_e0() /* nothing */
  91. #define disable_e0() /* nothing */
  92. #endif
  93. #if (EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
  94. #define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
  95. #define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
  96. #else
  97. #define enable_e1() /* nothing */
  98. #define disable_e1() /* nothing */
  99. #endif
  100. #if (EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
  101. #define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
  102. #define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
  103. #else
  104. #define enable_e2() /* nothing */
  105. #define disable_e2() /* nothing */
  106. #endif
  107. enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};
  108. void FlushSerialRequestResend();
  109. void ClearToSend();
  110. void get_coordinates();
  111. void prepare_move();
  112. void kill();
  113. void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
  114. void prepare_arc_move(char isclockwise);
  115. #ifndef CRITICAL_SECTION_START
  116. #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
  117. #define CRITICAL_SECTION_END SREG = _sreg;
  118. #endif //CRITICAL_SECTION_START
  119. extern float homing_feedrate[];
  120. extern bool axis_relative_modes[];
  121. extern float current_position[NUM_AXIS] ;
  122. extern float add_homeing[3];
  123. // Handling multiple extruders pins
  124. extern uint8_t active_extruder;
  125. #endif