|
@@ -57,14 +57,24 @@
|
|
|
|
|
|
#include <avr/wdt.h>
|
|
|
|
|
|
-#ifdef HAVE_PAT9125_SENSOR
|
|
|
+#include "Dcodes.h"
|
|
|
+
|
|
|
+
|
|
|
+#ifdef SWSPI
|
|
|
#include "swspi.h"
|
|
|
+#endif //SWSPI
|
|
|
+
|
|
|
+#ifdef SWI2C
|
|
|
+#include "swi2c.h"
|
|
|
+#endif //SWI2C
|
|
|
+
|
|
|
+#ifdef PAT9125
|
|
|
#include "pat9125.h"
|
|
|
-#endif //HAVE_PAT9125_SENSOR
|
|
|
+#endif //PAT9125
|
|
|
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
+#ifdef TMC2130
|
|
|
#include "tmc2130.h"
|
|
|
-#endif //HAVE_TMC2130_DRIVERS
|
|
|
+#endif //TMC2130
|
|
|
|
|
|
|
|
|
#ifdef BLINKM
|
|
@@ -89,6 +99,8 @@
|
|
|
|
|
|
#include "ultralcd.h"
|
|
|
|
|
|
+#include "cmdqueue.h"
|
|
|
+
|
|
|
// Macros for bit masks
|
|
|
#define BIT(b) (1<<(b))
|
|
|
#define TEST(n,b) (((n)&BIT(b))!=0)
|
|
@@ -233,8 +245,6 @@
|
|
|
CardReader card;
|
|
|
#endif
|
|
|
|
|
|
-unsigned long TimeSent = millis();
|
|
|
-unsigned long TimeNow = millis();
|
|
|
unsigned long PingTime = millis();
|
|
|
union Data
|
|
|
{
|
|
@@ -410,58 +420,11 @@ static float delta[3] = {0.0, 0.0, 0.0};
|
|
|
static float offset[3] = {0.0, 0.0, 0.0};
|
|
|
static bool home_all_axis = true;
|
|
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
|
|
-static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
|
|
|
|
|
|
// Determines Absolute or Relative Coordinates.
|
|
|
// Also there is bool axis_relative_modes[] per axis flag.
|
|
|
static bool relative_mode = false;
|
|
|
|
|
|
-// String circular buffer. Commands may be pushed to the buffer from both sides:
|
|
|
-// Chained commands will be pushed to the front, interactive (from LCD menu)
|
|
|
-// and printing commands (from serial line or from SD card) are pushed to the tail.
|
|
|
-// First character of each entry indicates the type of the entry:
|
|
|
-#define CMDBUFFER_CURRENT_TYPE_UNKNOWN 0
|
|
|
-// Command in cmdbuffer was sent over USB.
|
|
|
-#define CMDBUFFER_CURRENT_TYPE_USB 1
|
|
|
-// Command in cmdbuffer was read from SDCARD.
|
|
|
-#define CMDBUFFER_CURRENT_TYPE_SDCARD 2
|
|
|
-// Command in cmdbuffer was generated by the UI.
|
|
|
-#define CMDBUFFER_CURRENT_TYPE_UI 3
|
|
|
-// Command in cmdbuffer was generated by another G-code.
|
|
|
-#define CMDBUFFER_CURRENT_TYPE_CHAINED 4
|
|
|
-
|
|
|
-// How much space to reserve for the chained commands
|
|
|
-// of type CMDBUFFER_CURRENT_TYPE_CHAINED,
|
|
|
-// which are pushed to the front of the queue?
|
|
|
-// Maximum 5 commands of max length 20 + null terminator.
|
|
|
-#define CMDBUFFER_RESERVE_FRONT (5*21)
|
|
|
-// Reserve BUFSIZE lines of length MAX_CMD_SIZE plus CMDBUFFER_RESERVE_FRONT.
|
|
|
-static char cmdbuffer[BUFSIZE * (MAX_CMD_SIZE + 1) + CMDBUFFER_RESERVE_FRONT];
|
|
|
-// Head of the circular buffer, where to read.
|
|
|
-static int bufindr = 0;
|
|
|
-// Tail of the buffer, where to write.
|
|
|
-static int bufindw = 0;
|
|
|
-// Number of lines in cmdbuffer.
|
|
|
-static int buflen = 0;
|
|
|
-// Flag for processing the current command inside the main Arduino loop().
|
|
|
-// If a new command was pushed to the front of a command buffer while
|
|
|
-// processing another command, this replaces the command on the top.
|
|
|
-// Therefore don't remove the command from the queue in the loop() function.
|
|
|
-static bool cmdbuffer_front_already_processed = false;
|
|
|
-
|
|
|
-// Type of a command, which is to be executed right now.
|
|
|
-#define CMDBUFFER_CURRENT_TYPE (cmdbuffer[bufindr])
|
|
|
-// String of a command, which is to be executed right now.
|
|
|
-#define CMDBUFFER_CURRENT_STRING (cmdbuffer+bufindr+1)
|
|
|
-
|
|
|
-// Enable debugging of the command buffer.
|
|
|
-// Debugging information will be sent to serial line.
|
|
|
-//#define CMDBUFFER_DEBUG
|
|
|
-
|
|
|
-static int serial_count = 0; //index of character read from serial line
|
|
|
-static boolean comment_mode = false;
|
|
|
-static char *strchr_pointer; // just a pointer to find chars in the command string like X, Y, Z, E, etc
|
|
|
-
|
|
|
const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42
|
|
|
|
|
|
//static float tt = 0;
|
|
@@ -530,314 +493,6 @@ void serial_echopair_P(const char *s_P, unsigned long v)
|
|
|
}
|
|
|
#endif //!SDSUPPORT
|
|
|
|
|
|
-// Pop the currently processed command from the queue.
|
|
|
-// It is expected, that there is at least one command in the queue.
|
|
|
-bool cmdqueue_pop_front()
|
|
|
-{
|
|
|
- if (buflen > 0) {
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- SERIAL_ECHOPGM("Dequeing ");
|
|
|
- SERIAL_ECHO(cmdbuffer+bufindr+1);
|
|
|
- SERIAL_ECHOLNPGM("");
|
|
|
- SERIAL_ECHOPGM("Old indices: buflen ");
|
|
|
- SERIAL_ECHO(buflen);
|
|
|
- SERIAL_ECHOPGM(", bufindr ");
|
|
|
- SERIAL_ECHO(bufindr);
|
|
|
- SERIAL_ECHOPGM(", bufindw ");
|
|
|
- SERIAL_ECHO(bufindw);
|
|
|
- SERIAL_ECHOPGM(", serial_count ");
|
|
|
- SERIAL_ECHO(serial_count);
|
|
|
- SERIAL_ECHOPGM(", bufsize ");
|
|
|
- SERIAL_ECHO(sizeof(cmdbuffer));
|
|
|
- SERIAL_ECHOLNPGM("");
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- if (-- buflen == 0) {
|
|
|
- // Empty buffer.
|
|
|
- if (serial_count == 0)
|
|
|
- // No serial communication is pending. Reset both pointers to zero.
|
|
|
- bufindw = 0;
|
|
|
- bufindr = bufindw;
|
|
|
- } else {
|
|
|
- // There is at least one ready line in the buffer.
|
|
|
- // First skip the current command ID and iterate up to the end of the string.
|
|
|
- for (++ bufindr; cmdbuffer[bufindr] != 0; ++ bufindr) ;
|
|
|
- // Second, skip the end of string null character and iterate until a nonzero command ID is found.
|
|
|
- for (++ bufindr; bufindr < sizeof(cmdbuffer) && cmdbuffer[bufindr] == 0; ++ bufindr) ;
|
|
|
- // If the end of the buffer was empty,
|
|
|
- if (bufindr == sizeof(cmdbuffer)) {
|
|
|
- // skip to the start and find the nonzero command.
|
|
|
- for (bufindr = 0; cmdbuffer[bufindr] == 0; ++ bufindr) ;
|
|
|
- }
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- SERIAL_ECHOPGM("New indices: buflen ");
|
|
|
- SERIAL_ECHO(buflen);
|
|
|
- SERIAL_ECHOPGM(", bufindr ");
|
|
|
- SERIAL_ECHO(bufindr);
|
|
|
- SERIAL_ECHOPGM(", bufindw ");
|
|
|
- SERIAL_ECHO(bufindw);
|
|
|
- SERIAL_ECHOPGM(", serial_count ");
|
|
|
- SERIAL_ECHO(serial_count);
|
|
|
- SERIAL_ECHOPGM(" new command on the top: ");
|
|
|
- SERIAL_ECHO(cmdbuffer+bufindr+1);
|
|
|
- SERIAL_ECHOLNPGM("");
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-void cmdqueue_reset()
|
|
|
-{
|
|
|
- while (cmdqueue_pop_front()) ;
|
|
|
-}
|
|
|
-
|
|
|
-// How long a string could be pushed to the front of the command queue?
|
|
|
-// If yes, adjust bufindr to the new position, where the new command could be enqued.
|
|
|
-// len_asked does not contain the zero terminator size.
|
|
|
-bool cmdqueue_could_enqueue_front(int len_asked)
|
|
|
-{
|
|
|
- // MAX_CMD_SIZE has to accommodate the zero terminator.
|
|
|
- if (len_asked >= MAX_CMD_SIZE)
|
|
|
- return false;
|
|
|
- // Remove the currently processed command from the queue.
|
|
|
- if (! cmdbuffer_front_already_processed) {
|
|
|
- cmdqueue_pop_front();
|
|
|
- cmdbuffer_front_already_processed = true;
|
|
|
- }
|
|
|
- if (bufindr == bufindw && buflen > 0)
|
|
|
- // Full buffer.
|
|
|
- return false;
|
|
|
- // Adjust the end of the write buffer based on whether a partial line is in the receive buffer.
|
|
|
- int endw = (serial_count > 0) ? (bufindw + MAX_CMD_SIZE + 1) : bufindw;
|
|
|
- if (bufindw < bufindr) {
|
|
|
- int bufindr_new = bufindr - len_asked - 2;
|
|
|
- // Simple case. There is a contiguous space between the write buffer and the read buffer.
|
|
|
- if (endw <= bufindr_new) {
|
|
|
- bufindr = bufindr_new;
|
|
|
- return true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // Otherwise the free space is split between the start and end.
|
|
|
- if (len_asked + 2 <= bufindr) {
|
|
|
- // Could fit at the start.
|
|
|
- bufindr -= len_asked + 2;
|
|
|
- return true;
|
|
|
- }
|
|
|
- int bufindr_new = sizeof(cmdbuffer) - len_asked - 2;
|
|
|
- if (endw <= bufindr_new) {
|
|
|
- memset(cmdbuffer, 0, bufindr);
|
|
|
- bufindr = bufindr_new;
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-// Could one enqueue a command of lenthg len_asked into the buffer,
|
|
|
-// while leaving CMDBUFFER_RESERVE_FRONT at the start?
|
|
|
-// If yes, adjust bufindw to the new position, where the new command could be enqued.
|
|
|
-// len_asked does not contain the zero terminator size.
|
|
|
-bool cmdqueue_could_enqueue_back(int len_asked)
|
|
|
-{
|
|
|
- // MAX_CMD_SIZE has to accommodate the zero terminator.
|
|
|
- if (len_asked >= MAX_CMD_SIZE)
|
|
|
- return false;
|
|
|
-
|
|
|
- if (bufindr == bufindw && buflen > 0)
|
|
|
- // Full buffer.
|
|
|
- return false;
|
|
|
-
|
|
|
- if (serial_count > 0) {
|
|
|
- // If there is some data stored starting at bufindw, len_asked is certainly smaller than
|
|
|
- // the allocated data buffer. Try to reserve a new buffer and to move the already received
|
|
|
- // serial data.
|
|
|
- // How much memory to reserve for the commands pushed to the front?
|
|
|
- // End of the queue, when pushing to the end.
|
|
|
- int endw = bufindw + len_asked + 2;
|
|
|
- if (bufindw < bufindr)
|
|
|
- // Simple case. There is a contiguous space between the write buffer and the read buffer.
|
|
|
- return endw + CMDBUFFER_RESERVE_FRONT <= bufindr;
|
|
|
- // Otherwise the free space is split between the start and end.
|
|
|
- if (// Could one fit to the end, including the reserve?
|
|
|
- endw + CMDBUFFER_RESERVE_FRONT <= sizeof(cmdbuffer) ||
|
|
|
- // Could one fit to the end, and the reserve to the start?
|
|
|
- (endw <= sizeof(cmdbuffer) && CMDBUFFER_RESERVE_FRONT <= bufindr))
|
|
|
- return true;
|
|
|
- // Could one fit both to the start?
|
|
|
- if (len_asked + 2 + CMDBUFFER_RESERVE_FRONT <= bufindr) {
|
|
|
- // Mark the rest of the buffer as used.
|
|
|
- memset(cmdbuffer+bufindw, 0, sizeof(cmdbuffer)-bufindw);
|
|
|
- // and point to the start.
|
|
|
- bufindw = 0;
|
|
|
- return true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // How much memory to reserve for the commands pushed to the front?
|
|
|
- // End of the queue, when pushing to the end.
|
|
|
- int endw = bufindw + len_asked + 2;
|
|
|
- if (bufindw < bufindr)
|
|
|
- // Simple case. There is a contiguous space between the write buffer and the read buffer.
|
|
|
- return endw + CMDBUFFER_RESERVE_FRONT <= bufindr;
|
|
|
- // Otherwise the free space is split between the start and end.
|
|
|
- if (// Could one fit to the end, including the reserve?
|
|
|
- endw + CMDBUFFER_RESERVE_FRONT <= sizeof(cmdbuffer) ||
|
|
|
- // Could one fit to the end, and the reserve to the start?
|
|
|
- (endw <= sizeof(cmdbuffer) && CMDBUFFER_RESERVE_FRONT <= bufindr))
|
|
|
- return true;
|
|
|
- // Could one fit both to the start?
|
|
|
- if (len_asked + 2 + CMDBUFFER_RESERVE_FRONT <= bufindr) {
|
|
|
- // Mark the rest of the buffer as used.
|
|
|
- memset(cmdbuffer+bufindw, 0, sizeof(cmdbuffer)-bufindw);
|
|
|
- // and point to the start.
|
|
|
- bufindw = 0;
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
-static void cmdqueue_dump_to_serial_single_line(int nr, const char *p)
|
|
|
-{
|
|
|
- SERIAL_ECHOPGM("Entry nr: ");
|
|
|
- SERIAL_ECHO(nr);
|
|
|
- SERIAL_ECHOPGM(", type: ");
|
|
|
- SERIAL_ECHO(int(*p));
|
|
|
- SERIAL_ECHOPGM(", cmd: ");
|
|
|
- SERIAL_ECHO(p+1);
|
|
|
- SERIAL_ECHOLNPGM("");
|
|
|
-}
|
|
|
-
|
|
|
-static void cmdqueue_dump_to_serial()
|
|
|
-{
|
|
|
- if (buflen == 0) {
|
|
|
- SERIAL_ECHOLNPGM("The command buffer is empty.");
|
|
|
- } else {
|
|
|
- SERIAL_ECHOPGM("Content of the buffer: entries ");
|
|
|
- SERIAL_ECHO(buflen);
|
|
|
- SERIAL_ECHOPGM(", indr ");
|
|
|
- SERIAL_ECHO(bufindr);
|
|
|
- SERIAL_ECHOPGM(", indw ");
|
|
|
- SERIAL_ECHO(bufindw);
|
|
|
- SERIAL_ECHOLNPGM("");
|
|
|
- int nr = 0;
|
|
|
- if (bufindr < bufindw) {
|
|
|
- for (const char *p = cmdbuffer + bufindr; p < cmdbuffer + bufindw; ++ nr) {
|
|
|
- cmdqueue_dump_to_serial_single_line(nr, p);
|
|
|
- // Skip the command.
|
|
|
- for (++p; *p != 0; ++ p);
|
|
|
- // Skip the gaps.
|
|
|
- for (++p; p < cmdbuffer + bufindw && *p == 0; ++ p);
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (const char *p = cmdbuffer + bufindr; p < cmdbuffer + sizeof(cmdbuffer); ++ nr) {
|
|
|
- cmdqueue_dump_to_serial_single_line(nr, p);
|
|
|
- // Skip the command.
|
|
|
- for (++p; *p != 0; ++ p);
|
|
|
- // Skip the gaps.
|
|
|
- for (++p; p < cmdbuffer + sizeof(cmdbuffer) && *p == 0; ++ p);
|
|
|
- }
|
|
|
- for (const char *p = cmdbuffer; p < cmdbuffer + bufindw; ++ nr) {
|
|
|
- cmdqueue_dump_to_serial_single_line(nr, p);
|
|
|
- // Skip the command.
|
|
|
- for (++p; *p != 0; ++ p);
|
|
|
- // Skip the gaps.
|
|
|
- for (++p; p < cmdbuffer + bufindw && *p == 0; ++ p);
|
|
|
- }
|
|
|
- }
|
|
|
- SERIAL_ECHOLNPGM("End of the buffer.");
|
|
|
- }
|
|
|
-}
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
-
|
|
|
-//adds an command to the main command buffer
|
|
|
-//thats really done in a non-safe way.
|
|
|
-//needs overworking someday
|
|
|
-// Currently the maximum length of a command piped through this function is around 20 characters
|
|
|
-void enquecommand(const char *cmd, bool from_progmem)
|
|
|
-{
|
|
|
- int len = from_progmem ? strlen_P(cmd) : strlen(cmd);
|
|
|
- // Does cmd fit the queue while leaving sufficient space at the front for the chained commands?
|
|
|
- // If it fits, it may move bufindw, so it points to a contiguous buffer, which fits cmd.
|
|
|
- if (cmdqueue_could_enqueue_back(len)) {
|
|
|
- // This is dangerous if a mixing of serial and this happens
|
|
|
- // This may easily be tested: If serial_count > 0, we have a problem.
|
|
|
- cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_UI;
|
|
|
- if (from_progmem)
|
|
|
- strcpy_P(cmdbuffer + bufindw + 1, cmd);
|
|
|
- else
|
|
|
- strcpy(cmdbuffer + bufindw + 1, cmd);
|
|
|
- SERIAL_ECHO_START;
|
|
|
- SERIAL_ECHORPGM(MSG_Enqueing);
|
|
|
- SERIAL_ECHO(cmdbuffer + bufindw + 1);
|
|
|
- SERIAL_ECHOLNPGM("\"");
|
|
|
- bufindw += len + 2;
|
|
|
- if (bufindw == sizeof(cmdbuffer))
|
|
|
- bufindw = 0;
|
|
|
- ++ buflen;
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- cmdqueue_dump_to_serial();
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- } else {
|
|
|
- SERIAL_ERROR_START;
|
|
|
- SERIAL_ECHORPGM(MSG_Enqueing);
|
|
|
- if (from_progmem)
|
|
|
- SERIAL_PROTOCOLRPGM(cmd);
|
|
|
- else
|
|
|
- SERIAL_ECHO(cmd);
|
|
|
- SERIAL_ECHOLNPGM("\" failed: Buffer full!");
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- cmdqueue_dump_to_serial();
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void enquecommand_front(const char *cmd, bool from_progmem)
|
|
|
-{
|
|
|
- int len = from_progmem ? strlen_P(cmd) : strlen(cmd);
|
|
|
- // Does cmd fit the queue? This call shall move bufindr, so the command may be copied.
|
|
|
- if (cmdqueue_could_enqueue_front(len)) {
|
|
|
- cmdbuffer[bufindr] = CMDBUFFER_CURRENT_TYPE_UI;
|
|
|
- if (from_progmem)
|
|
|
- strcpy_P(cmdbuffer + bufindr + 1, cmd);
|
|
|
- else
|
|
|
- strcpy(cmdbuffer + bufindr + 1, cmd);
|
|
|
- ++ buflen;
|
|
|
- SERIAL_ECHO_START;
|
|
|
- SERIAL_ECHOPGM("Enqueing to the front: \"");
|
|
|
- SERIAL_ECHO(cmdbuffer + bufindr + 1);
|
|
|
- SERIAL_ECHOLNPGM("\"");
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- cmdqueue_dump_to_serial();
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- } else {
|
|
|
- SERIAL_ERROR_START;
|
|
|
- SERIAL_ECHOPGM("Enqueing to the front: \"");
|
|
|
- if (from_progmem)
|
|
|
- SERIAL_PROTOCOLRPGM(cmd);
|
|
|
- else
|
|
|
- SERIAL_ECHO(cmd);
|
|
|
- SERIAL_ECHOLNPGM("\" failed: Buffer full!");
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- cmdqueue_dump_to_serial();
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// Mark the command at the top of the command queue as new.
|
|
|
-// Therefore it will not be removed from the queue.
|
|
|
-void repeatcommand_front()
|
|
|
-{
|
|
|
- cmdbuffer_front_already_processed = true;
|
|
|
-}
|
|
|
-
|
|
|
-bool is_buffer_empty()
|
|
|
-{
|
|
|
- if (buflen == 0) return true;
|
|
|
- else return false;
|
|
|
-}
|
|
|
-
|
|
|
void setup_killpin()
|
|
|
{
|
|
|
#if defined(KILL_PIN) && KILL_PIN > -1
|
|
@@ -909,7 +564,7 @@ void servo_init()
|
|
|
static void lcd_language_menu();
|
|
|
|
|
|
|
|
|
-#ifdef HAVE_PAT9125_SENSOR
|
|
|
+#ifdef PAT9125
|
|
|
|
|
|
bool fsensor_enabled = false;
|
|
|
bool fsensor_ignore_error = true;
|
|
@@ -993,7 +648,7 @@ void fsensor_update()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#endif //HAVE_PAT9125_SENSOR
|
|
|
+#endif //PAT9125
|
|
|
|
|
|
|
|
|
#ifdef MESH_BED_LEVELING
|
|
@@ -1103,6 +758,17 @@ void setup()
|
|
|
lcd_print_at_PGM(0, 2, PSTR(" 3D Printers "));
|
|
|
setup_killpin();
|
|
|
setup_powerhold();
|
|
|
+ farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
|
|
|
+ EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no);
|
|
|
+ if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode
|
|
|
+ if (farm_no == 0xFFFF) farm_no = 0;
|
|
|
+ if (farm_mode)
|
|
|
+ {
|
|
|
+ prusa_statistics(8);
|
|
|
+ selectedSerialPort = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ selectedSerialPort = 0;
|
|
|
MYSERIAL.begin(BAUDRATE);
|
|
|
SERIAL_PROTOCOLLNPGM("start");
|
|
|
SERIAL_ECHO_START;
|
|
@@ -1158,15 +824,15 @@ void setup()
|
|
|
plan_init(); // Initialize planner;
|
|
|
watchdog_init();
|
|
|
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
+#ifdef TMC2130
|
|
|
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
|
|
tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
|
|
|
-#endif //HAVE_TMC2130_DRIVERS
|
|
|
+#endif //TMC2130
|
|
|
|
|
|
-#ifdef HAVE_PAT9125_SENSOR
|
|
|
+#ifdef PAT9125
|
|
|
MYSERIAL.print("PAT9125_init:");
|
|
|
MYSERIAL.println(pat9125_init(200, 200));
|
|
|
-#endif //HAVE_PAT9125_SENSOR
|
|
|
+#endif //PAT9125
|
|
|
|
|
|
st_init(); // Initialize stepper, this enables interrupts!
|
|
|
|
|
@@ -1249,10 +915,14 @@ void setup()
|
|
|
|
|
|
|
|
|
|
|
|
-#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
|
|
|
+#if defined(CONTROLLERFAN_PIN) && (CONTROLLERFAN_PIN > -1)
|
|
|
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
|
|
|
#endif
|
|
|
|
|
|
+#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
|
|
|
+ SET_OUTPUT(LCD_PWM_PIN); //Set pin used for driver cooling fan
|
|
|
+#endif
|
|
|
+
|
|
|
#ifdef DIGIPOT_I2C
|
|
|
digipot_i2c_init();
|
|
|
#endif
|
|
@@ -1489,281 +1159,12 @@ void loop()
|
|
|
isPrintPaused ? manage_inactivity(true) : manage_inactivity(false);
|
|
|
checkHitEndstops();
|
|
|
lcd_update();
|
|
|
-#ifdef HAVE_PAT9125_SENSOR
|
|
|
+#ifdef PAT9125
|
|
|
fsensor_update();
|
|
|
-#endif //HAVE_PAT9125_SENSOR
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
+#endif //PAT9125
|
|
|
+#ifdef TMC2130
|
|
|
tmc2130_check_overtemp();
|
|
|
-#endif //HAVE_TMC2130_DRIVERS
|
|
|
-}
|
|
|
-
|
|
|
-void get_command()
|
|
|
-{
|
|
|
- // Test and reserve space for the new command string.
|
|
|
- if (!cmdqueue_could_enqueue_back(MAX_CMD_SIZE - 1))
|
|
|
- return;
|
|
|
-
|
|
|
- bool rx_buffer_full = false; //flag that serial rx buffer is full
|
|
|
-
|
|
|
- while (MYSERIAL.available() > 0) {
|
|
|
- if (MYSERIAL.available() == RX_BUFFER_SIZE - 1) { //compare number of chars buffered in rx buffer with rx buffer size
|
|
|
- SERIAL_ECHOLNPGM("Full RX Buffer"); //if buffer was full, there is danger that reading of last gcode will not be completed
|
|
|
- rx_buffer_full = true; //sets flag that buffer was full
|
|
|
- }
|
|
|
- char serial_char = MYSERIAL.read();
|
|
|
- TimeSent = millis();
|
|
|
- TimeNow = millis();
|
|
|
-
|
|
|
- if (serial_char < 0)
|
|
|
- // Ignore extended ASCII characters. These characters have no meaning in the G-code apart from the file names
|
|
|
- // and Marlin does not support such file names anyway.
|
|
|
- // Serial characters with a highest bit set to 1 are generated when the USB cable is unplugged, leading
|
|
|
- // to a hang-up of the print process from an SD card.
|
|
|
- continue;
|
|
|
- if(serial_char == '\n' ||
|
|
|
- serial_char == '\r' ||
|
|
|
- (serial_char == ':' && comment_mode == false) ||
|
|
|
- serial_count >= (MAX_CMD_SIZE - 1) )
|
|
|
- {
|
|
|
- if(!serial_count) { //if empty line
|
|
|
- comment_mode = false; //for new command
|
|
|
- return;
|
|
|
- }
|
|
|
- cmdbuffer[bufindw+serial_count+1] = 0; //terminate string
|
|
|
- if(!comment_mode){
|
|
|
- comment_mode = false; //for new command
|
|
|
- if ((strchr_pointer = strstr(cmdbuffer+bufindw+1, "PRUSA")) == NULL && (strchr_pointer = strchr(cmdbuffer+bufindw+1, 'N')) != NULL) {
|
|
|
- if ((strchr_pointer = strchr(cmdbuffer+bufindw+1, 'N')) != NULL)
|
|
|
- {
|
|
|
- // Line number met. When sending a G-code over a serial line, each line may be stamped with its index,
|
|
|
- // and Marlin tests, whether the successive lines are stamped with an increasing line number ID.
|
|
|
- gcode_N = (strtol(strchr_pointer+1, NULL, 10));
|
|
|
- if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer+bufindw+1, PSTR("M110")) == NULL) ) {
|
|
|
- // M110 - set current line number.
|
|
|
- // Line numbers not sent in succession.
|
|
|
- SERIAL_ERROR_START;
|
|
|
- SERIAL_ERRORRPGM(MSG_ERR_LINE_NO);
|
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
|
|
- //Serial.println(gcode_N);
|
|
|
- FlushSerialRequestResend();
|
|
|
- serial_count = 0;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if((strchr_pointer = strchr(cmdbuffer+bufindw+1, '*')) != NULL)
|
|
|
- {
|
|
|
- byte checksum = 0;
|
|
|
- char *p = cmdbuffer+bufindw+1;
|
|
|
- while (p != strchr_pointer)
|
|
|
- checksum = checksum^(*p++);
|
|
|
- if (int(strtol(strchr_pointer+1, NULL, 10)) != int(checksum)) {
|
|
|
- SERIAL_ERROR_START;
|
|
|
- SERIAL_ERRORRPGM(MSG_ERR_CHECKSUM_MISMATCH);
|
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
|
|
- FlushSerialRequestResend();
|
|
|
- serial_count = 0;
|
|
|
- return;
|
|
|
- }
|
|
|
- // If no errors, remove the checksum and continue parsing.
|
|
|
- *strchr_pointer = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SERIAL_ERROR_START;
|
|
|
- SERIAL_ERRORRPGM(MSG_ERR_NO_CHECKSUM);
|
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
|
|
- FlushSerialRequestResend();
|
|
|
- serial_count = 0;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- gcode_LastN = gcode_N;
|
|
|
- //if no errors, continue parsing
|
|
|
- } // end of 'N' command
|
|
|
- }
|
|
|
- else // if we don't receive 'N' but still see '*'
|
|
|
- {
|
|
|
- if((strchr(cmdbuffer+bufindw+1, '*') != NULL))
|
|
|
- {
|
|
|
- SERIAL_ERROR_START;
|
|
|
- SERIAL_ERRORRPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
|
|
|
- SERIAL_ERRORLN(gcode_LastN);
|
|
|
- serial_count = 0;
|
|
|
- return;
|
|
|
- }
|
|
|
- } // end of '*' command
|
|
|
- if ((strchr_pointer = strchr(cmdbuffer+bufindw+1, 'G')) != NULL) {
|
|
|
- if (! IS_SD_PRINTING) {
|
|
|
- usb_printing_counter = 10;
|
|
|
- is_usb_printing = true;
|
|
|
- }
|
|
|
- if (Stopped == true) {
|
|
|
- int gcode = strtol(strchr_pointer+1, NULL, 10);
|
|
|
- if (gcode >= 0 && gcode <= 3) {
|
|
|
- SERIAL_ERRORLNRPGM(MSG_ERR_STOPPED);
|
|
|
- LCD_MESSAGERPGM(MSG_STOPPED);
|
|
|
- }
|
|
|
- }
|
|
|
- } // end of 'G' command
|
|
|
-
|
|
|
- //If command was e-stop process now
|
|
|
- if(strcmp(cmdbuffer+bufindw+1, "M112") == 0)
|
|
|
- kill("", 2);
|
|
|
-
|
|
|
- // Store the current line into buffer, move to the next line.
|
|
|
- cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_USB;
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- SERIAL_ECHO_START;
|
|
|
- SERIAL_ECHOPGM("Storing a command line to buffer: ");
|
|
|
- SERIAL_ECHO(cmdbuffer+bufindw+1);
|
|
|
- SERIAL_ECHOLNPGM("");
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- bufindw += strlen(cmdbuffer+bufindw+1) + 2;
|
|
|
- if (bufindw == sizeof(cmdbuffer))
|
|
|
- bufindw = 0;
|
|
|
- ++ buflen;
|
|
|
-#ifdef CMDBUFFER_DEBUG
|
|
|
- SERIAL_ECHOPGM("Number of commands in the buffer: ");
|
|
|
- SERIAL_ECHO(buflen);
|
|
|
- SERIAL_ECHOLNPGM("");
|
|
|
-#endif /* CMDBUFFER_DEBUG */
|
|
|
- } // end of 'not comment mode'
|
|
|
- serial_count = 0; //clear buffer
|
|
|
- // Don't call cmdqueue_could_enqueue_back if there are no characters waiting
|
|
|
- // in the queue, as this function will reserve the memory.
|
|
|
- if (MYSERIAL.available() == 0 || ! cmdqueue_could_enqueue_back(MAX_CMD_SIZE-1))
|
|
|
- return;
|
|
|
- } // end of "end of line" processing
|
|
|
- else {
|
|
|
- // Not an "end of line" symbol. Store the new character into a buffer.
|
|
|
- if(serial_char == ';') comment_mode = true;
|
|
|
- if(!comment_mode) cmdbuffer[bufindw+1+serial_count++] = serial_char;
|
|
|
- }
|
|
|
- } // end of serial line processing loop
|
|
|
-
|
|
|
- if(farm_mode){
|
|
|
- TimeNow = millis();
|
|
|
- if ( ((TimeNow - TimeSent) > 800) && (serial_count > 0) ) {
|
|
|
- cmdbuffer[bufindw+serial_count+1] = 0;
|
|
|
-
|
|
|
- bufindw += strlen(cmdbuffer+bufindw+1) + 2;
|
|
|
- if (bufindw == sizeof(cmdbuffer))
|
|
|
- bufindw = 0;
|
|
|
- ++ buflen;
|
|
|
-
|
|
|
- serial_count = 0;
|
|
|
-
|
|
|
- SERIAL_ECHOPGM("TIMEOUT:");
|
|
|
- //memset(cmdbuffer, 0 , sizeof(cmdbuffer));
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //add comment
|
|
|
- if (rx_buffer_full == true && serial_count > 0) { //if rx buffer was full and string was not properly terminated
|
|
|
- rx_buffer_full = false;
|
|
|
- bufindw = bufindw - serial_count; //adjust tail of the buffer to prepare buffer for writing new command
|
|
|
- serial_count = 0;
|
|
|
- }
|
|
|
-
|
|
|
- #ifdef SDSUPPORT
|
|
|
- if(!card.sdprinting || serial_count!=0){
|
|
|
- // If there is a half filled buffer from serial line, wait until return before
|
|
|
- // continuing with the serial line.
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //'#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
|
|
|
- // if it occurs, stop_buffering is triggered and the buffer is ran dry.
|
|
|
- // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
|
|
-
|
|
|
- static bool stop_buffering=false;
|
|
|
- if(buflen==0) stop_buffering=false;
|
|
|
-
|
|
|
- // Reads whole lines from the SD card. Never leaves a half-filled line in the cmdbuffer.
|
|
|
- while( !card.eof() && !stop_buffering) {
|
|
|
- int16_t n=card.get();
|
|
|
- char serial_char = (char)n;
|
|
|
- if(serial_char == '\n' ||
|
|
|
- serial_char == '\r' ||
|
|
|
- (serial_char == '#' && comment_mode == false) ||
|
|
|
- (serial_char == ':' && comment_mode == false) ||
|
|
|
- serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
|
|
|
- {
|
|
|
- if(card.eof()){
|
|
|
- SERIAL_PROTOCOLLNRPGM(MSG_FILE_PRINTED);
|
|
|
- stoptime=millis();
|
|
|
- char time[30];
|
|
|
- unsigned long t=(stoptime-starttime-pause_time)/1000;
|
|
|
- pause_time = 0;
|
|
|
- int hours, minutes;
|
|
|
- minutes=(t/60)%60;
|
|
|
- hours=t/60/60;
|
|
|
- save_statistics(total_filament_used, t);
|
|
|
- sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes);
|
|
|
- SERIAL_ECHO_START;
|
|
|
- SERIAL_ECHOLN(time);
|
|
|
- lcd_setstatus(time);
|
|
|
- card.printingHasFinished();
|
|
|
- card.checkautostart(true);
|
|
|
-
|
|
|
- if (farm_mode)
|
|
|
- {
|
|
|
- prusa_statistics(6);
|
|
|
- lcd_commands_type = LCD_COMMAND_FARM_MODE_CONFIRM;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if(serial_char=='#')
|
|
|
- stop_buffering=true;
|
|
|
-
|
|
|
- if(!serial_count)
|
|
|
- {
|
|
|
- comment_mode = false; //for new command
|
|
|
- return; //if empty line
|
|
|
- }
|
|
|
- cmdbuffer[bufindw+serial_count+1] = 0; //terminate string
|
|
|
- cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_SDCARD;
|
|
|
- SERIAL_ECHOPGM("cmdbuffer:");
|
|
|
- MYSERIAL.print(cmdbuffer);
|
|
|
- ++ buflen;
|
|
|
- SERIAL_ECHOPGM("buflen:");
|
|
|
- MYSERIAL.print(buflen);
|
|
|
- bufindw += strlen(cmdbuffer+bufindw+1) + 2;
|
|
|
- if (bufindw == sizeof(cmdbuffer))
|
|
|
- bufindw = 0;
|
|
|
- comment_mode = false; //for new command
|
|
|
- serial_count = 0; //clear buffer
|
|
|
- // The following line will reserve buffer space if available.
|
|
|
- if (! cmdqueue_could_enqueue_back(MAX_CMD_SIZE-1))
|
|
|
- return;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(serial_char == ';') comment_mode = true;
|
|
|
- if(!comment_mode) cmdbuffer[bufindw+1+serial_count++] = serial_char;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #endif //SDSUPPORT
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// Return True if a character was found
|
|
|
-static inline bool code_seen(char code) { return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL; }
|
|
|
-static inline bool code_seen(const char *code) { return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL; }
|
|
|
-static inline float code_value() { return strtod(strchr_pointer+1, NULL);}
|
|
|
-static inline long code_value_long() { return strtol(strchr_pointer+1, NULL, 10); }
|
|
|
-static inline int16_t code_value_short() { return int16_t(strtol(strchr_pointer+1, NULL, 10)); };
|
|
|
-static inline uint8_t code_value_uint8() { return uint8_t(strtol(strchr_pointer+1, NULL, 10)); };
|
|
|
-
|
|
|
-static inline float code_value_float() {
|
|
|
- char* e = strchr(strchr_pointer, 'E');
|
|
|
- if (!e) return strtod(strchr_pointer + 1, NULL);
|
|
|
- *e = 0;
|
|
|
- float ret = strtod(strchr_pointer + 1, NULL);
|
|
|
- *e = 'E';
|
|
|
- return ret;
|
|
|
+#endif //TMC2130
|
|
|
}
|
|
|
|
|
|
#define DEFINE_PGM_READ_ANY(type, reader) \
|
|
@@ -1985,55 +1386,76 @@ inline void gcode_M900() {
|
|
|
}
|
|
|
#endif // LIN_ADVANCE
|
|
|
|
|
|
-void homeaxis(int axis) {
|
|
|
+#ifdef TMC2130
|
|
|
+bool calibrate_z_auto()
|
|
|
+{
|
|
|
+ lcd_display_message_fullscreen_P(MSG_CALIBRATE_Z_AUTO);
|
|
|
+ bool endstops_enabled = enable_endstops(true);
|
|
|
+ int axis_up_dir = -home_dir(Z_AXIS);
|
|
|
+ tmc2130_home_enter(Z_AXIS_MASK);
|
|
|
+ current_position[Z_AXIS] = 0;
|
|
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
+ set_destination_to_current();
|
|
|
+ destination[Z_AXIS] += (1.1 * max_length(Z_AXIS) * axis_up_dir);
|
|
|
+ feedrate = homing_feedrate[Z_AXIS];
|
|
|
+ plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
+ tmc2130_home_restart(Z_AXIS);
|
|
|
+ st_synchronize();
|
|
|
+// current_position[axis] = 0;
|
|
|
+// plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
+ tmc2130_home_exit();
|
|
|
+ enable_endstops(false);
|
|
|
+ current_position[Z_AXIS] = 0;
|
|
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
+ set_destination_to_current();
|
|
|
+ destination[Z_AXIS] += 10 * axis_up_dir; //10mm up
|
|
|
+ feedrate = homing_feedrate[Z_AXIS] / 2;
|
|
|
+ plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
+ st_synchronize();
|
|
|
+ enable_endstops(endstops_enabled);
|
|
|
+ current_position[Z_AXIS] = Z_MAX_POS-3.f;
|
|
|
+ plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
+ return true;
|
|
|
+}
|
|
|
+#endif //TMC2130
|
|
|
+
|
|
|
+void homeaxis(int axis)
|
|
|
+{
|
|
|
+ bool endstops_enabled = enable_endstops(true); //RP: endstops should be allways enabled durring homming
|
|
|
#define HOMEAXIS_DO(LETTER) \
|
|
|
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
|
|
-
|
|
|
- if (axis==X_AXIS ? HOMEAXIS_DO(X) :
|
|
|
- axis==Y_AXIS ? HOMEAXIS_DO(Y) :
|
|
|
- 0) {
|
|
|
+ if ((axis==X_AXIS)?HOMEAXIS_DO(X):(axis==Y_AXIS)?HOMEAXIS_DO(Y):0)
|
|
|
+ {
|
|
|
int axis_home_dir = home_dir(axis);
|
|
|
-
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
+#ifdef TMC2130
|
|
|
tmc2130_home_enter(X_AXIS_MASK << axis);
|
|
|
#endif
|
|
|
-
|
|
|
current_position[axis] = 0;
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
-
|
|
|
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
|
|
feedrate = homing_feedrate[axis];
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
-
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
- sg_homing_delay = 0;
|
|
|
- tmc2130_axis_stalled[axis] = false;
|
|
|
+#ifdef TMC2130
|
|
|
+ tmc2130_home_restart(axis);
|
|
|
#endif
|
|
|
st_synchronize();
|
|
|
-
|
|
|
current_position[axis] = 0;
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
destination[axis] = -home_retract_mm(axis) * axis_home_dir;
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
-
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
- sg_homing_delay = 0;
|
|
|
- tmc2130_axis_stalled[axis] = false;
|
|
|
+#ifdef TMC2130
|
|
|
+ tmc2130_home_restart(axis);
|
|
|
#endif
|
|
|
st_synchronize();
|
|
|
-
|
|
|
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
- if (tmc2130_didLastHomingStall())
|
|
|
- feedrate = homing_feedrate[axis];
|
|
|
- else
|
|
|
-#endif
|
|
|
+#ifdef TMC2130
|
|
|
+ feedrate = homing_feedrate[axis];
|
|
|
+#else
|
|
|
feedrate = homing_feedrate[axis] / 2;
|
|
|
+#endif
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
-
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
- sg_homing_delay = 0;
|
|
|
- tmc2130_axis_stalled[axis] = false;
|
|
|
+#ifdef TMC2130
|
|
|
+ tmc2130_home_restart(axis);
|
|
|
#endif
|
|
|
st_synchronize();
|
|
|
axis_is_at_home(axis);
|
|
@@ -2041,29 +1463,27 @@ void homeaxis(int axis) {
|
|
|
feedrate = 0.0;
|
|
|
endstops_hit_on_purpose();
|
|
|
axis_known_position[axis] = true;
|
|
|
-
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
+#ifdef TMC2130
|
|
|
tmc2130_home_exit();
|
|
|
+// destination[axis] += 2;
|
|
|
+// plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], homing_feedrate[axis]/60, active_extruder);
|
|
|
+// st_synchronize();
|
|
|
#endif
|
|
|
}
|
|
|
- else if (axis==Z_AXIS ? HOMEAXIS_DO(Z) :
|
|
|
- 0) {
|
|
|
+ else if ((axis==Z_AXIS)?HOMEAXIS_DO(Z):0)
|
|
|
+ {
|
|
|
int axis_home_dir = home_dir(axis);
|
|
|
-
|
|
|
current_position[axis] = 0;
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
-
|
|
|
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
|
|
feedrate = homing_feedrate[axis];
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
st_synchronize();
|
|
|
-
|
|
|
current_position[axis] = 0;
|
|
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
|
|
destination[axis] = -home_retract_mm(axis) * axis_home_dir;
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
|
st_synchronize();
|
|
|
-
|
|
|
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
|
|
feedrate = homing_feedrate[axis]/2 ;
|
|
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
|
@@ -2074,7 +1494,9 @@ void homeaxis(int axis) {
|
|
|
endstops_hit_on_purpose();
|
|
|
axis_known_position[axis] = true;
|
|
|
}
|
|
|
+ enable_endstops(endstops_enabled);
|
|
|
}
|
|
|
+
|
|
|
/**/
|
|
|
void home_xy()
|
|
|
{
|
|
@@ -2232,7 +1654,7 @@ void process_commands()
|
|
|
|
|
|
#ifdef CMDBUFFER_DEBUG
|
|
|
SERIAL_ECHOPGM("Processing a GCODE command: ");
|
|
|
- SERIAL_ECHO(cmdbuffer+bufindr+1);
|
|
|
+ SERIAL_ECHO(cmdbuffer+bufindr+CMDHDRSIZE);
|
|
|
SERIAL_ECHOLNPGM("");
|
|
|
SERIAL_ECHOPGM("In cmdqueue: ");
|
|
|
SERIAL_ECHO(buflen);
|
|
@@ -2295,7 +1717,35 @@ void process_commands()
|
|
|
trace();
|
|
|
prusa_sd_card_upload = true;
|
|
|
card.openFile(strchr_pointer+4,false);
|
|
|
- } else if(code_seen("Fir")){
|
|
|
+ } else if (code_seen("SN")) {
|
|
|
+ if (farm_mode) {
|
|
|
+ selectedSerialPort = 0;
|
|
|
+ MSerial.write(";S");
|
|
|
+ // S/N is:CZPX0917X003XC13518
|
|
|
+ int numbersRead = 0;
|
|
|
+
|
|
|
+ while (numbersRead < 19) {
|
|
|
+ while (MSerial.available() > 0) {
|
|
|
+ uint8_t serial_char = MSerial.read();
|
|
|
+ selectedSerialPort = 1;
|
|
|
+ MSerial.write(serial_char);
|
|
|
+ numbersRead++;
|
|
|
+ selectedSerialPort = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ selectedSerialPort = 1;
|
|
|
+ MSerial.write('\n');
|
|
|
+ /*for (int b = 0; b < 3; b++) {
|
|
|
+ tone(BEEPER, 110);
|
|
|
+ delay(50);
|
|
|
+ noTone(BEEPER);
|
|
|
+ delay(50);
|
|
|
+ }*/
|
|
|
+ } else {
|
|
|
+ MYSERIAL.println("Not in farm mode.");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if(code_seen("Fir")){
|
|
|
|
|
|
SERIAL_PROTOCOLLN(FW_version);
|
|
|
|
|
@@ -3021,6 +2471,139 @@ void process_commands()
|
|
|
|
|
|
case 76: //PINDA probe temperature calibration
|
|
|
{
|
|
|
+#ifdef PINDA_THERMISTOR
|
|
|
+ if (true)
|
|
|
+ {
|
|
|
+ if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) {
|
|
|
+ // We don't know where we are! HOME!
|
|
|
+ // Push the commands to the front of the message queue in the reverse order!
|
|
|
+ // There shall be always enough space reserved for these commands.
|
|
|
+ repeatcommand_front(); // repeat G76 with all its parameters
|
|
|
+ enquecommand_front_P((PSTR("G28 W0")));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ SERIAL_ECHOLNPGM("PINDA probe calibration start");
|
|
|
+
|
|
|
+ float zero_z;
|
|
|
+ int z_shift = 0; //unit: steps
|
|
|
+ float start_temp = 5 * (int)(current_temperature_pinda / 5);
|
|
|
+ if (start_temp < 35) start_temp = 35;
|
|
|
+ if (start_temp < current_temperature_pinda) start_temp += 5;
|
|
|
+ SERIAL_ECHOPGM("start temperature: ");
|
|
|
+ MYSERIAL.println(start_temp);
|
|
|
+
|
|
|
+// setTargetHotend(200, 0);
|
|
|
+ setTargetBed(50 + 10 * (start_temp - 30) / 5);
|
|
|
+
|
|
|
+ custom_message = true;
|
|
|
+ custom_message_type = 4;
|
|
|
+ custom_message_state = 1;
|
|
|
+ custom_message = MSG_TEMP_CALIBRATION;
|
|
|
+ current_position[X_AXIS] = PINDA_PREHEAT_X;
|
|
|
+ current_position[Y_AXIS] = PINDA_PREHEAT_Y;
|
|
|
+ current_position[Z_AXIS] = PINDA_PREHEAT_Z;
|
|
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
|
|
|
+ st_synchronize();
|
|
|
+
|
|
|
+ while (current_temperature_pinda < start_temp)
|
|
|
+ {
|
|
|
+ delay_keep_alive(1000);
|
|
|
+ serialecho_temperatures();
|
|
|
+ }
|
|
|
+
|
|
|
+ eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process
|
|
|
+
|
|
|
+ current_position[Z_AXIS] = 5;
|
|
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
|
|
|
+
|
|
|
+ current_position[X_AXIS] = pgm_read_float(bed_ref_points);
|
|
|
+ current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1);
|
|
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
|
|
|
+ st_synchronize();
|
|
|
+
|
|
|
+ find_bed_induction_sensor_point_z(-1.f);
|
|
|
+ zero_z = current_position[Z_AXIS];
|
|
|
+
|
|
|
+ //current_position[Z_AXIS]
|
|
|
+ SERIAL_ECHOLNPGM("");
|
|
|
+ SERIAL_ECHOPGM("ZERO: ");
|
|
|
+ MYSERIAL.print(current_position[Z_AXIS]);
|
|
|
+ SERIAL_ECHOLNPGM("");
|
|
|
+
|
|
|
+ int i = -1; for (; i < 5; i++)
|
|
|
+ {
|
|
|
+ float temp = (40 + i * 5);
|
|
|
+ SERIAL_ECHOPGM("Step: ");
|
|
|
+ MYSERIAL.print(i + 2);
|
|
|
+ SERIAL_ECHOLNPGM("/6 (skipped)");
|
|
|
+ SERIAL_ECHOPGM("PINDA temperature: ");
|
|
|
+ MYSERIAL.print((40 + i*5));
|
|
|
+ SERIAL_ECHOPGM(" Z shift (mm):");
|
|
|
+ MYSERIAL.print(0);
|
|
|
+ SERIAL_ECHOLNPGM("");
|
|
|
+ if (i >= 0) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift);
|
|
|
+ if (start_temp <= temp) break;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (i++; i < 5; i++)
|
|
|
+ {
|
|
|
+ float temp = (40 + i * 5);
|
|
|
+ SERIAL_ECHOPGM("Step: ");
|
|
|
+ MYSERIAL.print(i + 2);
|
|
|
+ SERIAL_ECHOLNPGM("/6");
|
|
|
+ custom_message_state = i + 2;
|
|
|
+ setTargetBed(50 + 10 * (temp - 30) / 5);
|
|
|
+// setTargetHotend(255, 0);
|
|
|
+ current_position[X_AXIS] = PINDA_PREHEAT_X;
|
|
|
+ current_position[Y_AXIS] = PINDA_PREHEAT_Y;
|
|
|
+ current_position[Z_AXIS] = PINDA_PREHEAT_Z;
|
|
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
|
|
|
+ st_synchronize();
|
|
|
+ while (current_temperature_pinda < temp)
|
|
|
+ {
|
|
|
+ delay_keep_alive(1000);
|
|
|
+ serialecho_temperatures();
|
|
|
+ }
|
|
|
+ current_position[Z_AXIS] = 5;
|
|
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
|
|
|
+ current_position[X_AXIS] = pgm_read_float(bed_ref_points);
|
|
|
+ current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1);
|
|
|
+ plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
|
|
|
+ st_synchronize();
|
|
|
+ find_bed_induction_sensor_point_z(-1.f);
|
|
|
+ z_shift = (int)((current_position[Z_AXIS] - zero_z)*axis_steps_per_unit[Z_AXIS]);
|
|
|
+
|
|
|
+ SERIAL_ECHOLNPGM("");
|
|
|
+ SERIAL_ECHOPGM("PINDA temperature: ");
|
|
|
+ MYSERIAL.print(current_temperature_pinda);
|
|
|
+ SERIAL_ECHOPGM(" Z shift (mm):");
|
|
|
+ MYSERIAL.print(current_position[Z_AXIS] - zero_z);
|
|
|
+ SERIAL_ECHOLNPGM("");
|
|
|
+
|
|
|
+ EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift);
|
|
|
+
|
|
|
+ }
|
|
|
+ custom_message_type = 0;
|
|
|
+ custom_message = false;
|
|
|
+
|
|
|
+ eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1);
|
|
|
+ SERIAL_ECHOLNPGM("Temperature calibration done. Continue with pressing the knob.");
|
|
|
+ disable_x();
|
|
|
+ disable_y();
|
|
|
+ disable_z();
|
|
|
+ disable_e0();
|
|
|
+ disable_e1();
|
|
|
+ disable_e2();
|
|
|
+ lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE);
|
|
|
+ lcd_update_enable(true);
|
|
|
+ lcd_update(2);
|
|
|
+
|
|
|
+ setTargetBed(0); //set bed target temperature back to 0
|
|
|
+// setTargetHotend(0,0); //set hotend target temperature back to 0
|
|
|
+ break;
|
|
|
+ }
|
|
|
+#endif //PINDA_THERMISTOR
|
|
|
+
|
|
|
setTargetBed(PINDA_MIN_T);
|
|
|
float zero_z;
|
|
|
int z_shift = 0; //unit: steps
|
|
@@ -3209,6 +2792,13 @@ void process_commands()
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ bool temp_comp_start = true;
|
|
|
+#ifdef PINDA_THERMISTOR
|
|
|
+ temp_comp_start = false;
|
|
|
+#endif //PINDA_THERMISTOR
|
|
|
+
|
|
|
+ if (temp_comp_start)
|
|
|
if (run == false && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) {
|
|
|
if (lcd_commands_type != LCD_COMMAND_STOP_PRINT) {
|
|
|
temp_compensation_start();
|
|
@@ -3339,12 +2929,20 @@ void process_commands()
|
|
|
SERIAL_PROTOCOLPGM("\n");
|
|
|
}
|
|
|
|
|
|
+ float offset_z = 0;
|
|
|
+
|
|
|
+#ifdef PINDA_THERMISTOR
|
|
|
+ offset_z = temp_compensation_pinda_thermistor_offset();
|
|
|
+#endif //PINDA_THERMISTOR
|
|
|
+
|
|
|
if (verbosity_level >= 1) {
|
|
|
SERIAL_ECHOPGM("mesh bed leveling: ");
|
|
|
MYSERIAL.print(current_position[Z_AXIS], 5);
|
|
|
+ SERIAL_ECHOPGM(" offset: ");
|
|
|
+ MYSERIAL.print(offset_z, 5);
|
|
|
SERIAL_ECHOLNPGM("");
|
|
|
}
|
|
|
- mbl.set_z(ix, iy, current_position[Z_AXIS]); //store measured z values z_values[iy][ix] = z;
|
|
|
+ mbl.set_z(ix, iy, current_position[Z_AXIS] - offset_z); //store measured z values z_values[iy][ix] = z - offset_z;
|
|
|
|
|
|
custom_message_state--;
|
|
|
mesh_point++;
|
|
@@ -3364,6 +2962,12 @@ void process_commands()
|
|
|
}
|
|
|
clean_up_after_endstop_move();
|
|
|
SERIAL_ECHOLNPGM("clean up finished ");
|
|
|
+
|
|
|
+ bool apply_temp_comp = true;
|
|
|
+#ifdef PINDA_THERMISTOR
|
|
|
+ apply_temp_comp = false;
|
|
|
+#endif
|
|
|
+ if (apply_temp_comp)
|
|
|
if(temp_cal_active == true && calibration_status_pinda() == true) temp_compensation_apply(); //apply PINDA temperature compensation
|
|
|
babystep_apply(); // Apply Z height correction aka baby stepping before mesh bed leveing gets activated.
|
|
|
SERIAL_ECHOLNPGM("babystep applied");
|
|
@@ -3862,9 +3466,19 @@ void process_commands()
|
|
|
babystep_reset();
|
|
|
// Mark all axes as in a need for homing.
|
|
|
memset(axis_known_position, 0, sizeof(axis_known_position));
|
|
|
-
|
|
|
+
|
|
|
+ // Home in the XY plane.
|
|
|
+ //set_destination_to_current();
|
|
|
+ setup_for_endstop_move();
|
|
|
+ lcd_display_message_fullscreen_P(MSG_AUTO_HOME);
|
|
|
+ home_xy();
|
|
|
+
|
|
|
// Let the user move the Z axes up to the end stoppers.
|
|
|
+#ifdef TMC2130
|
|
|
+ if (calibrate_z_auto()) {
|
|
|
+#else //TMC2130
|
|
|
if (lcd_calibrate_z_end_stop_manual( onlyZ )) {
|
|
|
+#endif //TMC2130
|
|
|
refresh_cmd_timeout();
|
|
|
if (((degHotend(0) > MAX_HOTEND_TEMP_CALIBRATION) || (degBed() > MAX_BED_TEMP_CALIBRATION)) && (!onlyZ)) {
|
|
|
lcd_wait_for_cool_down();
|
|
@@ -3879,14 +3493,10 @@ void process_commands()
|
|
|
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], homing_feedrate[Z_AXIS]/40, active_extruder);
|
|
|
st_synchronize();
|
|
|
|
|
|
- // Home in the XY plane.
|
|
|
- set_destination_to_current();
|
|
|
- setup_for_endstop_move();
|
|
|
- home_xy();
|
|
|
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
- tmc2130_home_enter(X_AXIS_MASK | Y_AXIS_MASK);
|
|
|
-#endif
|
|
|
+//#ifdef TMC2130
|
|
|
+// tmc2130_home_enter(X_AXIS_MASK | Y_AXIS_MASK);
|
|
|
+//#endif
|
|
|
|
|
|
int8_t verbosity_level = 0;
|
|
|
if (code_seen('V')) {
|
|
@@ -3946,7 +3556,7 @@ void process_commands()
|
|
|
lcd_show_fullscreen_message_and_wait_P(MSG_BABYSTEP_Z_NOT_SET);
|
|
|
}
|
|
|
}
|
|
|
-#ifdef HAVE_TMC2130_DRIVERS
|
|
|
+#ifdef TMC2130
|
|
|
tmc2130_home_exit();
|
|
|
#endif
|
|
|
} else {
|
|
@@ -4334,6 +3944,17 @@ Sigma_Exit:
|
|
|
SERIAL_PROTOCOL(getHeaterPower(-1));
|
|
|
#endif
|
|
|
|
|
|
+#ifdef PINDA_THERMISTOR
|
|
|
+ SERIAL_PROTOCOLPGM(" P:");
|
|
|
+ SERIAL_PROTOCOL_F(current_temperature_pinda,1);
|
|
|
+#endif //PINDA_THERMISTOR
|
|
|
+
|
|
|
+#ifdef AMBIENT_THERMISTOR
|
|
|
+ SERIAL_PROTOCOLPGM(" A:");
|
|
|
+ SERIAL_PROTOCOL_F(current_temperature_ambient,1);
|
|
|
+#endif //AMBIENT_THERMISTOR
|
|
|
+
|
|
|
+
|
|
|
#ifdef SHOW_TEMP_ADC_VALUES
|
|
|
{float raw = 0.0;
|
|
|
|
|
@@ -4858,7 +4479,7 @@ Sigma_Exit:
|
|
|
SERIAL_ECHO_START;
|
|
|
SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND);
|
|
|
SERIAL_ECHO(CMDBUFFER_CURRENT_STRING);
|
|
|
- SERIAL_ECHOLNPGM("\"");
|
|
|
+ SERIAL_ECHOLNPGM("\"(1)");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5595,13 +5216,13 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
|
|
lcd_setstatuspgm(WELCOME_MSG);
|
|
|
custom_message = false;
|
|
|
custom_message_type = 0;
|
|
|
-#ifdef HAVE_PAT9125_SENSOR
|
|
|
+#ifdef PAT9125
|
|
|
if (fsensor_M600)
|
|
|
{
|
|
|
cmdqueue_pop_front(); //hack because M600 repeated 2x when enqueued to front
|
|
|
fsensor_enable();
|
|
|
}
|
|
|
-#endif //HAVE_PAT9125_SENSOR
|
|
|
+#endif //PAT9125
|
|
|
|
|
|
}
|
|
|
break;
|
|
@@ -5703,12 +5324,15 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
|
|
|
|
|
case 916: // M916 Set sg_thrs
|
|
|
{
|
|
|
- if (code_seen('X')) sg_thrs_x = code_value();
|
|
|
- if (code_seen('Y')) sg_thrs_y = code_value();
|
|
|
- MYSERIAL.print("sg_thrs_x=");
|
|
|
- MYSERIAL.print(sg_thrs_x, DEC);
|
|
|
- MYSERIAL.print(" sg_thrs_y=");
|
|
|
- MYSERIAL.println(sg_thrs_y, DEC);
|
|
|
+ if (code_seen('X')) tmc2131_axis_sg_thr[X_AXIS] = code_value();
|
|
|
+ if (code_seen('Y')) tmc2131_axis_sg_thr[Y_AXIS] = code_value();
|
|
|
+ if (code_seen('Z')) tmc2131_axis_sg_thr[Z_AXIS] = code_value();
|
|
|
+ MYSERIAL.print("tmc2131_axis_sg_thr[X]=");
|
|
|
+ MYSERIAL.print(tmc2131_axis_sg_thr[X_AXIS], DEC);
|
|
|
+ MYSERIAL.print("tmc2131_axis_sg_thr[Y]=");
|
|
|
+ MYSERIAL.print(tmc2131_axis_sg_thr[Y_AXIS], DEC);
|
|
|
+ MYSERIAL.print("tmc2131_axis_sg_thr[Z]=");
|
|
|
+ MYSERIAL.print(tmc2131_axis_sg_thr[Z_AXIS], DEC);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -5943,77 +5567,103 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
|
|
}
|
|
|
} // end if(code_seen('T')) (end of T codes)
|
|
|
|
|
|
+#ifdef DEBUG_DCODES
|
|
|
else if (code_seen('D')) // D codes (debug)
|
|
|
{
|
|
|
switch((int)code_value())
|
|
|
{
|
|
|
case 0: // D0 - Reset
|
|
|
- MYSERIAL.println("D0 - Reset");
|
|
|
- cli(); //disable interrupts
|
|
|
- wdt_reset(); //reset watchdog
|
|
|
- WDTCSR = (1<<WDCE) | (1<<WDE); //enable watchdog
|
|
|
- WDTCSR = (1<<WDE) | (1<<WDP0); //30ms prescaler
|
|
|
- while(1); //wait for reset
|
|
|
- break;
|
|
|
+ dcode_0(); break;
|
|
|
case 1: // D1 - Clear EEPROM
|
|
|
- {
|
|
|
- MYSERIAL.println("D1 - Clear EEPROM");
|
|
|
- cli();
|
|
|
- for (int i = 0; i < 4096; i++)
|
|
|
- eeprom_write_byte((unsigned char*)i, (unsigned char)0);
|
|
|
- sei();
|
|
|
- }
|
|
|
+ dcode_1(); break;
|
|
|
+ case 2: // D2 - Read/Write RAM
|
|
|
+ dcode_2(); break;
|
|
|
+ case 3: // D3 - Read/Write EEPROM
|
|
|
+ dcode_3(); break;
|
|
|
+ case 4: // D4 - Read/Write PIN
|
|
|
+ dcode_4(); break;
|
|
|
+ case 5:
|
|
|
+ MYSERIAL.println("D5 - Test");
|
|
|
+ if (code_seen('P'))
|
|
|
+ selectedSerialPort = (int)code_value();
|
|
|
+ MYSERIAL.print("selectedSerialPort = ");
|
|
|
+ MYSERIAL.println(selectedSerialPort, DEC);
|
|
|
break;
|
|
|
- case 2: // D2 - read/write PIN
|
|
|
+/* case 4:
|
|
|
{
|
|
|
- if (code_seen('P')) // Pin (0-255)
|
|
|
+ MYSERIAL.println("D4 - Test");
|
|
|
+ uint8_t data[16];
|
|
|
+ int cnt = parse_hex(strchr_pointer + 2, data, 16);
|
|
|
+ MYSERIAL.println(cnt, DEC);
|
|
|
+ for (int i = 0; i < cnt; i++)
|
|
|
{
|
|
|
- int pin = (int)code_value();
|
|
|
- if ((pin >= 0) && (pin <= 255))
|
|
|
- {
|
|
|
- if (code_seen('F')) // Function in/out (0/1)
|
|
|
- {
|
|
|
- int fnc = (int)code_value();
|
|
|
- if (fnc == 0) pinMode(pin, INPUT);
|
|
|
- else if (fnc == 1) pinMode(pin, OUTPUT);
|
|
|
- }
|
|
|
- if (code_seen('V')) // Value (0/1)
|
|
|
- {
|
|
|
- int val = (int)code_value();
|
|
|
- if (val == 0) digitalWrite(pin, LOW);
|
|
|
- else if (val == 1) digitalWrite(pin, HIGH);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- int val = (digitalRead(pin) != LOW)?1:0;
|
|
|
- MYSERIAL.print("PIN");
|
|
|
- MYSERIAL.print(pin);
|
|
|
- MYSERIAL.print("=");
|
|
|
- MYSERIAL.println(val);
|
|
|
- }
|
|
|
- }
|
|
|
+ serial_print_hex_byte(data[i]);
|
|
|
+ MYSERIAL.write(' ');
|
|
|
}
|
|
|
+ MYSERIAL.write('\n');
|
|
|
}
|
|
|
break;
|
|
|
- case 3:
|
|
|
-#ifdef HAVE_PAT9125_SENSOR
|
|
|
+/* case 3:
|
|
|
+ if (code_seen('L')) // lcd pwm (0-255)
|
|
|
+ {
|
|
|
+ lcdSoftPwm = (int)code_value();
|
|
|
+ }
|
|
|
+ if (code_seen('B')) // lcd blink delay (0-255)
|
|
|
+ {
|
|
|
+ lcdBlinkDelay = (int)code_value();
|
|
|
+ }
|
|
|
+// calibrate_z_auto();
|
|
|
+/* MYSERIAL.print("fsensor_enable()");
|
|
|
+#ifdef PAT9125
|
|
|
fsensor_enable();
|
|
|
-#endif
|
|
|
+#endif*/
|
|
|
break;
|
|
|
- case 4:
|
|
|
-#ifdef HAVE_PAT9125_SENSOR
|
|
|
+// case 4:
|
|
|
+// lcdBlinkDelay = 10;
|
|
|
+/* MYSERIAL.print("fsensor_disable()");
|
|
|
+#ifdef PAT9125
|
|
|
fsensor_disable();
|
|
|
#endif
|
|
|
+ break;*/
|
|
|
+// break;
|
|
|
+/* case 5:
|
|
|
+ {
|
|
|
+ MYSERIAL.print("tmc2130_rd_MSCNT(0)=");
|
|
|
+ int val = tmc2130_rd_MSCNT(tmc2130_cs[0]);
|
|
|
+ MYSERIAL.println(val);
|
|
|
+ homeaxis(0);
|
|
|
+ }
|
|
|
+ break;*/
|
|
|
+ case 6:
|
|
|
+ {
|
|
|
+/* MYSERIAL.print("tmc2130_rd_MSCNT(1)=");
|
|
|
+ int val = tmc2130_rd_MSCNT(tmc2130_cs[1]);
|
|
|
+ MYSERIAL.println(val);*/
|
|
|
+ homeaxis(1);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ {
|
|
|
+ MYSERIAL.print("pat9125_init=");
|
|
|
+ MYSERIAL.println(pat9125_init(200, 200));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ {
|
|
|
+ MYSERIAL.print("swi2c_check=");
|
|
|
+ MYSERIAL.println(swi2c_check(0x75));
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+#endif //DEBUG_DCODES
|
|
|
|
|
|
else
|
|
|
{
|
|
|
SERIAL_ECHO_START;
|
|
|
SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND);
|
|
|
SERIAL_ECHO(CMDBUFFER_CURRENT_STRING);
|
|
|
- SERIAL_ECHOLNPGM("\"");
|
|
|
+ SERIAL_ECHOLNPGM("\"(2)");
|
|
|
}
|
|
|
|
|
|
ClearToSend();
|
|
@@ -6085,6 +5735,9 @@ void get_arc_coordinates()
|
|
|
|
|
|
void clamp_to_software_endstops(float target[3])
|
|
|
{
|
|
|
+#ifdef DEBUG_DISABLE_SWLIMITS
|
|
|
+ return;
|
|
|
+#endif //DEBUG_DISABLE_SWLIMITS
|
|
|
world2machine_clamp(target[0], target[1]);
|
|
|
|
|
|
// Clamp the Z coordinate.
|
|
@@ -6929,7 +6582,11 @@ float temp_comp_interpolation(float inp_temperature) {
|
|
|
for (i = 0; i < n; i++) {
|
|
|
if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &shift[i]); //read shift in steps from EEPROM
|
|
|
temp_C[i] = 50 + i * 10; //temperature in C
|
|
|
-
|
|
|
+#ifdef PINDA_THERMISTOR
|
|
|
+ temp_C[i] = 35 + i * 5; //temperature in C
|
|
|
+#else
|
|
|
+ temp_C[i] = 50 + i * 10; //temperature in C
|
|
|
+#endif
|
|
|
x[i] = (float)temp_C[i];
|
|
|
f[i] = (float)shift[i];
|
|
|
}
|
|
@@ -6976,6 +6633,15 @@ float temp_comp_interpolation(float inp_temperature) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+#ifdef PINDA_THERMISTOR
|
|
|
+float temp_compensation_pinda_thermistor_offset()
|
|
|
+{
|
|
|
+ if (!temp_cal_active) return 0;
|
|
|
+ if (!calibration_status_pinda()) return 0;
|
|
|
+ return temp_comp_interpolation(current_temperature_pinda) / axis_steps_per_unit[Z_AXIS];
|
|
|
+}
|
|
|
+#endif //PINDA_THERMISTOR
|
|
|
+
|
|
|
void long_pause() //long pause print
|
|
|
{
|
|
|
st_synchronize();
|
|
@@ -7032,7 +6698,7 @@ void serialecho_temperatures() {
|
|
|
|
|
|
|
|
|
void uvlo_() {
|
|
|
- //SERIAL_ECHOLNPGM("UVLO");
|
|
|
+ SERIAL_ECHOLNPGM("UVLO");
|
|
|
save_print_to_eeprom();
|
|
|
float current_position_bckp[2];
|
|
|
int feedrate_bckp = feedrate;
|