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.

Marlin.h 4.7KB

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