浏览代码

Libs updates

Scott Lahteine 7 年前
父节点
当前提交
d7ee81202f

+ 50
- 29
Marlin/src/libs/hex_print_routines.cpp 查看文件

19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
  *
20
  *
21
  */
21
  */
22
-#include "Marlin.h"
23
-#include "gcode.h"
22
+
23
+#include "../inc/MarlinConfig.h"
24
 
24
 
25
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER)
25
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER)
26
 
26
 
27
-#include "hex_print_routines.h"
28
-
29
-static char _hex[7] = "0x0000";
30
-
31
-char* hex_byte(const uint8_t b) {
32
-  _hex[4] = hex_nybble(b >> 4);
33
-  _hex[5] = hex_nybble(b);
34
-  return &_hex[4];
35
-}
36
-
37
-char* hex_word(const uint16_t w) {
38
-  _hex[2] = hex_nybble(w >> 12);
39
-  _hex[3] = hex_nybble(w >> 8);
40
-  _hex[4] = hex_nybble(w >> 4);
41
-  _hex[5] = hex_nybble(w);
42
-  return &_hex[2];
43
-}
44
-
45
-char* hex_address(const void * const w) {
46
-  (void)hex_word((int)w);
47
-  return _hex;
48
-}
49
-
50
-void print_hex_nybble(const uint8_t n)       { SERIAL_CHAR(hex_nybble(n));  }
51
-void print_hex_byte(const uint8_t b)         { SERIAL_ECHO(hex_byte(b));    }
52
-void print_hex_word(const uint16_t w)        { SERIAL_ECHO(hex_word(w));    }
53
-void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
27
+  #include "hex_print_routines.h"
28
+
29
+  #ifdef CPU_32_BIT
30
+    constexpr int byte_start = 0;
31
+    static char _hex[] = "0x0000";
32
+  #else
33
+    constexpr int byte_start = 4;
34
+    static char _hex[] = "0x00000000";
35
+  #endif
36
+
37
+  char* hex_byte(const uint8_t b) {
38
+    _hex[byte_start + 4] = hex_nybble(b >> 4);
39
+    _hex[byte_start + 5] = hex_nybble(b);
40
+    return &_hex[byte_start];
41
+  }
42
+
43
+  char* hex_word(const uint16_t w) {
44
+    _hex[byte_start + 2] = hex_nybble(w >> 12);
45
+    _hex[byte_start + 3] = hex_nybble(w >> 8);
46
+    _hex[byte_start + 4] = hex_nybble(w >> 4);
47
+    _hex[byte_start + 5] = hex_nybble(w);
48
+    return &_hex[byte_start - 2];
49
+  }
50
+
51
+  #ifdef CPU_32_BIT
52
+    char* hex_long(const uint32_t w) {
53
+      _hex[byte_start - 2] = hex_nybble(w >> 28);
54
+      _hex[byte_start - 1] = hex_nybble(w >> 24);
55
+      _hex[byte_start + 0] = hex_nybble(w >> 20);
56
+      _hex[byte_start + 1] = hex_nybble(w >> 16);
57
+      (void)hex_word((uint16_t)(w & 0xFFFF));
58
+      return &_hex[byte_start - 6];
59
+    }
60
+  #endif
61
+
62
+  char* hex_address(const void * const w) {
63
+    #ifdef CPU_32_BIT
64
+      (void)hex_long((ptr_int_t)w);
65
+    #else
66
+      (void)hex_word((ptr_int_t)w);
67
+    #endif
68
+    return _hex;
69
+  }
70
+
71
+  void print_hex_nybble(const uint8_t n)       { SERIAL_CHAR(hex_nybble(n));  }
72
+  void print_hex_byte(const uint8_t b)         { SERIAL_ECHO(hex_byte(b));    }
73
+  void print_hex_word(const uint16_t w)        { SERIAL_ECHO(hex_word(w));    }
74
+  void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
54
 
75
 
55
 #endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER
76
 #endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER

+ 8
- 6
Marlin/src/libs/hex_print_routines.h 查看文件

23
 #ifndef HEX_PRINT_ROUTINES_H
23
 #ifndef HEX_PRINT_ROUTINES_H
24
 #define HEX_PRINT_ROUTINES_H
24
 #define HEX_PRINT_ROUTINES_H
25
 
25
 
26
-#include "MarlinConfig.h"
27
-#include "gcode.h"
28
-
29
-#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(M100_FREE_MEMORY_WATCHER) || ENABLED(DEBUG_GCODE_PARSER)
26
+#include <stdint.h>
30
 
27
 
31
 //
28
 //
32
 // Utility functions to create and print hex strings as nybble, byte, and word.
29
 // Utility functions to create and print hex strings as nybble, byte, and word.
33
 //
30
 //
34
 
31
 
35
-inline char hex_nybble(const uint8_t n) {
32
+FORCE_INLINE char hex_nybble(const uint8_t n) {
36
   return (n & 0xF) + ((n & 0xF) < 10 ? '0' : 'A' - 10);
33
   return (n & 0xF) + ((n & 0xF) < 10 ? '0' : 'A' - 10);
37
 }
34
 }
38
 char* hex_byte(const uint8_t b);
35
 char* hex_byte(const uint8_t b);
44
 void print_hex_word(const uint16_t w);
41
 void print_hex_word(const uint16_t w);
45
 void print_hex_address(const void * const w);
42
 void print_hex_address(const void * const w);
46
 
43
 
47
-#endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER
44
+#ifdef CPU_32_BIT
45
+  typedef uint32_t ptr_int_t;
46
+#else
47
+  typedef uint16_t ptr_int_t;
48
+#endif
49
+
48
 #endif // HEX_PRINT_ROUTINES_H
50
 #endif // HEX_PRINT_ROUTINES_H

+ 3
- 4
Marlin/src/libs/least_squares_fit.cpp 查看文件

32
  *
32
  *
33
  */
33
  */
34
 
34
 
35
-#include "MarlinConfig.h"
35
+#include "../inc/MarlinConfig.h"
36
 
36
 
37
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_LINEAR)
37
 #if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_LINEAR)
38
 
38
 
39
-#include "macros.h"
40
-#include <math.h>
41
-
42
 #include "least_squares_fit.h"
39
 #include "least_squares_fit.h"
43
 
40
 
41
+#include <math.h>
42
+
44
 int finish_incremental_LSF(struct linear_fit_data *lsf) {
43
 int finish_incremental_LSF(struct linear_fit_data *lsf) {
45
 
44
 
46
   const float N = lsf->N;
45
   const float N = lsf->N;

+ 5
- 8
Marlin/src/libs/least_squares_fit.h 查看文件

32
  *
32
  *
33
  */
33
  */
34
 
34
 
35
-#include "MarlinConfig.h"
35
+#ifndef _LEAST_SQUARES_FIT_H_
36
+#define _LEAST_SQUARES_FIT_H_
36
 
37
 
37
-#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(AUTO_BED_LEVELING_LINEAR)
38
-
39
-#include "Marlin.h"
40
-#include "macros.h"
38
+#include "../inc/MarlinConfig.h"
41
 #include <math.h>
39
 #include <math.h>
42
 
40
 
43
 struct linear_fit_data {
41
 struct linear_fit_data {
54
 
52
 
55
 void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
53
 void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
56
   // weight each accumulator by factor w, including the "number" of samples
54
   // weight each accumulator by factor w, including the "number" of samples
57
-  // (analagous to calling inc_LSF twice with same values to weight it by 2X)
55
+  // (analogous to calling inc_LSF twice with same values to weight it by 2X)
58
   lsf->xbar  += w * x;
56
   lsf->xbar  += w * x;
59
   lsf->ybar  += w * y;
57
   lsf->ybar  += w * y;
60
   lsf->zbar  += w * z;
58
   lsf->zbar  += w * z;
86
 
84
 
87
 int finish_incremental_LSF(struct linear_fit_data *);
85
 int finish_incremental_LSF(struct linear_fit_data *);
88
 
86
 
89
-#endif
90
-
87
+#endif // _LEAST_SQUARES_FIT_H_

+ 23
- 1
Marlin/src/libs/nozzle.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
1
 #include "nozzle.h"
23
 #include "nozzle.h"
2
 
24
 
3
-#include "Marlin.h"
25
+#include "../Marlin.h"
4
 #include "point_t.h"
26
 #include "point_t.h"
5
 
27
 
6
 /**
28
 /**

+ 2
- 2
Marlin/src/libs/nozzle.h 查看文件

23
 #ifndef __NOZZLE_H__
23
 #ifndef __NOZZLE_H__
24
 #define __NOZZLE_H__
24
 #define __NOZZLE_H__
25
 
25
 
26
-#include "Marlin.h"
26
+#include "../inc/MarlinConfig.h"
27
 #include "point_t.h"
27
 #include "point_t.h"
28
 
28
 
29
 #if ENABLED(NOZZLE_CLEAN_FEATURE)
29
 #if ENABLED(NOZZLE_CLEAN_FEATURE)
106
     ) _Os;
106
     ) _Os;
107
 };
107
 };
108
 
108
 
109
-#endif
109
+#endif // __NOZZLE_H__

+ 1
- 4
Marlin/src/libs/point_t.h 查看文件

34
  * @param e The e-coordinate of the point.
34
  * @param e The e-coordinate of the point.
35
  */
35
  */
36
 struct point_t {
36
 struct point_t {
37
-  float x;
38
-  float y;
39
-  float z;
40
-  float e;
37
+  float x, y, z, e;
41
 
38
 
42
   /**
39
   /**
43
    * @brief Two dimensional point constructor
40
    * @brief Two dimensional point constructor

+ 1
- 1
Marlin/src/libs/private_spi.h 查看文件

23
 #ifndef __PRIVATE_SPI_H__
23
 #ifndef __PRIVATE_SPI_H__
24
 #define __PRIVATE_SPI_H__
24
 #define __PRIVATE_SPI_H__
25
 
25
 
26
-#include <stdint.h>
27
 #include "softspi.h"
26
 #include "softspi.h"
27
+#include <stdint.h>
28
 
28
 
29
 template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin>
29
 template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin>
30
 class SPI {
30
 class SPI {

+ 0
- 2
Marlin/src/libs/softspi.h 查看文件

766
   }
766
   }
767
   //----------------------------------------------------------------------------
767
   //----------------------------------------------------------------------------
768
 };
768
 };
769
-
770
-

+ 1
- 1
Marlin/src/libs/stopwatch.cpp 查看文件

20
  *
20
  *
21
  */
21
  */
22
 
22
 
23
-#include "Marlin.h"
23
+#include "../Marlin.h"
24
 #include "stopwatch.h"
24
 #include "stopwatch.h"
25
 
25
 
26
 Stopwatch::Stopwatch() {
26
 Stopwatch::Stopwatch() {

+ 2
- 2
Marlin/src/libs/stopwatch.h 查看文件

23
 #ifndef STOPWATCH_H
23
 #ifndef STOPWATCH_H
24
 #define STOPWATCH_H
24
 #define STOPWATCH_H
25
 
25
 
26
-#include "macros.h"
26
+#include "../core/types.h"
27
 
27
 
28
 // Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM)
28
 // Print debug messages with M111 S2 (Uses 156 bytes of PROGMEM)
29
 //#define DEBUG_STOPWATCH
29
 //#define DEBUG_STOPWATCH
103
      */
103
      */
104
     millis_t duration();
104
     millis_t duration();
105
 
105
 
106
-    #if ENABLED(DEBUG_STOPWATCH)
106
+    #ifdef DEBUG_STOPWATCH
107
 
107
 
108
       /**
108
       /**
109
        * @brief Prints a debug message
109
        * @brief Prints a debug message

+ 5
- 2
Marlin/src/libs/vector_3.cpp 查看文件

38
   License along with this library; if not, write to the Free Software
38
   License along with this library; if not, write to the Free Software
39
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
39
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
40
 */
40
 */
41
-#include <math.h>
42
-#include "Marlin.h"
41
+
42
+#include "../inc/MarlinConfig.h"
43
 
43
 
44
 #if HAS_ABL
44
 #if HAS_ABL
45
+
45
 #include "vector_3.h"
46
 #include "vector_3.h"
46
 
47
 
48
+#include <math.h>
49
+
47
 vector_3::vector_3() : x(0), y(0), z(0) { }
50
 vector_3::vector_3() : x(0), y(0), z(0) { }
48
 
51
 
49
 vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }
52
 vector_3::vector_3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) { }

+ 1
- 3
Marlin/src/libs/vector_3.h 查看文件

38
   License along with this library; if not, write to the Free Software
38
   License along with this library; if not, write to the Free Software
39
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
39
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
40
 */
40
 */
41
+
41
 #ifndef VECTOR_3_H
42
 #ifndef VECTOR_3_H
42
 #define VECTOR_3_H
43
 #define VECTOR_3_H
43
 
44
 
44
-#if HAS_ABL
45
-
46
 class matrix_3x3;
45
 class matrix_3x3;
47
 
46
 
48
 struct vector_3 {
47
 struct vector_3 {
79
 
78
 
80
 void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float &y, float &z);
79
 void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float &y, float &z);
81
 
80
 
82
-#endif // HAS_ABL
83
 #endif // VECTOR_3_H
81
 #endif // VECTOR_3_H

正在加载...
取消
保存