Browse Source

Merge pull request #482 from bubnikv/M221_fix

M221 fix
XPila 6 years ago
parent
commit
74e6ff67d3
4 changed files with 39 additions and 47 deletions
  1. 0 7
      Firmware/MarlinSerial.cpp
  2. 33 34
      Firmware/MarlinSerial.h
  3. 5 1
      Firmware/Marlin_main.cpp
  4. 1 5
      Firmware/planner.cpp

+ 0 - 7
Firmware/MarlinSerial.cpp

@@ -99,13 +99,6 @@ ISR(USART1_RX_vect)
 #endif
 #endif
 
-// Constructors ////////////////////////////////////////////////////////////////
-
-MarlinSerial::MarlinSerial()
-{
-
-}
-
 // Public Methods //////////////////////////////////////////////////////////////
 
 void MarlinSerial::begin(long baud)

+ 33 - 34
Firmware/MarlinSerial.h

@@ -90,14 +90,13 @@ class MarlinSerial //: public Stream
 {
 
   public:
-    MarlinSerial();
-    void begin(long);
-    void end();
-    int peek(void);
-    int read(void);
-    void flush(void);
+    static void begin(long);
+    static void end();
+    static int peek(void);
+    static int read(void);
+    static void flush(void);
     
-    FORCE_INLINE int available(void)
+    static FORCE_INLINE int available(void)
     {
       return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
     }
@@ -110,7 +109,7 @@ class MarlinSerial //: public Stream
       M_UDRx = c;
     }
     */
-	void write(uint8_t c)
+	static void write(uint8_t c)
 	{
 		if (selectedSerialPort == 0)
 		{
@@ -124,7 +123,7 @@ class MarlinSerial //: public Stream
 		}
 	}
     
-    void checkRx(void)
+    static void checkRx(void)
     {
         if (selectedSerialPort == 0) {
             if((M_UCSRxA & (1<<M_RXCx)) != 0) {
@@ -150,7 +149,7 @@ class MarlinSerial //: public Stream
 #endif //DEBUG_DUMP_TO_2ND_SERIAL
                 }
             }
-        } else if(selectedSerialPort == 1) {
+        } else { // if(selectedSerialPort == 1) {
             if((UCSR1A & (1<<RXC1)) != 0) {
                 // Test for a framing error.
                 if (UCSR1A & (1<<FE1)) {
@@ -179,54 +178,54 @@ class MarlinSerial //: public Stream
     
     
     private:
-    void printNumber(unsigned long, uint8_t);
-    void printFloat(double, uint8_t);
+    static void printNumber(unsigned long, uint8_t);
+    static void printFloat(double, uint8_t);
     
     
   public:
     
-    FORCE_INLINE void write(const char *str)
+    static FORCE_INLINE void write(const char *str)
     {
       while (*str)
         write(*str++);
     }
 
 
-    FORCE_INLINE void write(const uint8_t *buffer, size_t size)
+    static FORCE_INLINE void write(const uint8_t *buffer, size_t size)
     {
       while (size--)
         write(*buffer++);
     }
 
-    FORCE_INLINE void print(const String &s)
+    static FORCE_INLINE void print(const String &s)
     {
       for (int i = 0; i < (int)s.length(); i++) {
         write(s[i]);
       }
     }
     
-    FORCE_INLINE void print(const char *str)
+    static FORCE_INLINE void print(const char *str)
     {
       write(str);
     }
-    void print(char, int = BYTE);
-    void print(unsigned char, int = BYTE);
-    void print(int, int = DEC);
-    void print(unsigned int, int = DEC);
-    void print(long, int = DEC);
-    void print(unsigned long, int = DEC);
-    void print(double, int = 2);
-
-    void println(const String &s);
-    void println(const char[]);
-    void println(char, int = BYTE);
-    void println(unsigned char, int = BYTE);
-    void println(int, int = DEC);
-    void println(unsigned int, int = DEC);
-    void println(long, int = DEC);
-    void println(unsigned long, int = DEC);
-    void println(double, int = 2);
-    void println(void);
+    static void print(char, int = BYTE);
+    static void print(unsigned char, int = BYTE);
+    static void print(int, int = DEC);
+    static void print(unsigned int, int = DEC);
+    static void print(long, int = DEC);
+    static void print(unsigned long, int = DEC);
+    static void print(double, int = 2);
+
+    static void println(const String &s);
+    static void println(const char[]);
+    static void println(char, int = BYTE);
+    static void println(unsigned char, int = BYTE);
+    static void println(int, int = DEC);
+    static void println(unsigned int, int = DEC);
+    static void println(long, int = DEC);
+    static void println(unsigned long, int = DEC);
+    static void println(double, int = 2);
+    static void println(void);
 };
 
 extern MarlinSerial MSerial;

+ 5 - 1
Firmware/Marlin_main.cpp

@@ -6561,7 +6561,11 @@ void get_coordinates()
   for(int8_t i=0; i < NUM_AXIS; i++) {
     if(code_seen(axis_codes[i]))
     {
-      destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
+      destination[i] = (float)code_value();
+      if (i == E_AXIS && extrudemultiply != 100)
+        destination[i] *= (extrudemultiply * 0.01f);
+      if (axis_relative_modes[i] || relative_mode)
+        destination[i] += current_position[i];
       seen[i]=true;
     }
     else destination[i] = current_position[i]; //Are these else lines really needed?

+ 1 - 5
Firmware/planner.cpp

@@ -784,10 +784,6 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
   block->steps_e = labs(target[E_AXIS]-position[E_AXIS]);
   if (volumetric_multiplier[active_extruder] != 1.f)
     block->steps_e *= volumetric_multiplier[active_extruder];
-  if (extrudemultiply != 100) {
-    block->steps_e *= extrudemultiply;
-    block->steps_e /= 100;
-  }
   block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
 
   // Bail if this is a zero-length block
@@ -919,7 +915,7 @@ Having the real displacement of the head, we can calculate the total movement le
     delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[Y_AXIS];
   #endif
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
-  delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*volumetric_multiplier[active_extruder]*extrudemultiply/100.0;
+  delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*volumetric_multiplier[active_extruder];
   if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments )
   {
     block->millimeters = fabs(delta_mm[E_AXIS]);