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.

Marlin.h 4.8KB

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