Browse Source

Libs updates

Scott Lahteine 7 years ago
parent
commit
d7ee81202f

+ 50
- 29
Marlin/src/libs/hex_print_routines.cpp View File

@@ -19,37 +19,58 @@
19 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 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 76
 #endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER

+ 8
- 6
Marlin/src/libs/hex_print_routines.h View File

@@ -23,16 +23,13 @@
23 23
 #ifndef HEX_PRINT_ROUTINES_H
24 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 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 33
   return (n & 0xF) + ((n & 0xF) < 10 ? '0' : 'A' - 10);
37 34
 }
38 35
 char* hex_byte(const uint8_t b);
@@ -44,5 +41,10 @@ void print_hex_byte(const uint8_t b);
44 41
 void print_hex_word(const uint16_t w);
45 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 50
 #endif // HEX_PRINT_ROUTINES_H

+ 3
- 4
Marlin/src/libs/least_squares_fit.cpp View File

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

+ 5
- 8
Marlin/src/libs/least_squares_fit.h View File

@@ -32,12 +32,10 @@
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 39
 #include <math.h>
42 40
 
43 41
 struct linear_fit_data {
@@ -54,7 +52,7 @@ void inline incremental_LSF_reset(struct linear_fit_data *lsf) {
54 52
 
55 53
 void inline incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
56 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 56
   lsf->xbar  += w * x;
59 57
   lsf->ybar  += w * y;
60 58
   lsf->zbar  += w * z;
@@ -86,5 +84,4 @@ void inline incremental_LSF(struct linear_fit_data *lsf, const float &x, const f
86 84
 
87 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 View File

@@ -1,6 +1,28 @@
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 23
 #include "nozzle.h"
2 24
 
3
-#include "Marlin.h"
25
+#include "../Marlin.h"
4 26
 #include "point_t.h"
5 27
 
6 28
 /**

+ 2
- 2
Marlin/src/libs/nozzle.h View File

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

+ 1
- 4
Marlin/src/libs/point_t.h View File

@@ -34,10 +34,7 @@
34 34
  * @param e The e-coordinate of the point.
35 35
  */
36 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 40
    * @brief Two dimensional point constructor

+ 1
- 1
Marlin/src/libs/private_spi.h View File

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

+ 0
- 2
Marlin/src/libs/softspi.h View File

@@ -766,5 +766,3 @@ class SoftSPI {
766 766
   }
767 767
   //----------------------------------------------------------------------------
768 768
 };
769
-
770
-

+ 1
- 1
Marlin/src/libs/stopwatch.cpp View File

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

+ 2
- 2
Marlin/src/libs/stopwatch.h View File

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

+ 5
- 2
Marlin/src/libs/vector_3.cpp View File

@@ -38,12 +38,15 @@
38 38
   License along with this library; if not, write to the Free Software
39 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 44
 #if HAS_ABL
45
+
45 46
 #include "vector_3.h"
46 47
 
48
+#include <math.h>
49
+
47 50
 vector_3::vector_3() : x(0), y(0), z(0) { }
48 51
 
49 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 View File

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

Loading…
Cancel
Save