Browse Source

Move macros, add ENABLED/DISABLED, add includes

Scott Lahteine 8 years ago
parent
commit
d85861d296

+ 1
- 0
Marlin/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 0
- 8
Marlin/Marlin.h View File

@@ -28,14 +28,6 @@
28 28
 
29 29
 #include "Arduino.h"
30 30
 
31
-#define BIT(b) (1<<(b))
32
-#define TEST(n,b) (((n)&BIT(b))!=0)
33
-#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
34
-#define RADIANS(d) ((d)*M_PI/180.0)
35
-#define DEGREES(r) ((r)*180.0/M_PI)
36
-#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
37
-#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
38
-
39 31
 typedef unsigned long millis_t;
40 32
 
41 33
 // Arduino < 1.0.0 does not define this, so we need to do it ourselves

+ 1
- 0
Marlin/configurator/config/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/Felix/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/Felix/Configuration_DUAL.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/K8200/Configuration.h View File

@@ -7,6 +7,7 @@
7 7
 #define CONFIGURATION_H
8 8
 
9 9
 #include "boards.h"
10
+#include "macros.h"
10 11
 
11 12
 //===========================================================================
12 13
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/RigidBot/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/adafruit/ST7565/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/delta/biv2.5/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

@@ -6,6 +6,7 @@
6 6
 #define CONFIGURATION_H
7 7
 
8 8
 #include "boards.h"
9
+#include "macros.h"
9 10
 
10 11
 //===========================================================================
11 12
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/makibox/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 1
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -2,6 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 #include "boards.h"
5
+#include "macros.h"
5 6
 
6 7
 //===========================================================================
7 8
 //============================= Getting Started =============================

+ 25
- 0
Marlin/macros.h View File

@@ -0,0 +1,25 @@
1
+#ifndef MACROS_H
2
+#define MACROS_H
3
+
4
+// Macros for bit masks
5
+#define BIT(b) (1<<(b))
6
+#define TEST(n,b) (((n)&BIT(b))!=0)
7
+#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
8
+
9
+// Macros for maths shortcuts
10
+#define RADIANS(d) ((d)*M_PI/180.0)
11
+#define DEGREES(r) ((r)*180.0/M_PI)
12
+
13
+// Macros to contrain values
14
+#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
15
+#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
16
+
17
+// Macros to support option testing
18
+#define _CAT(a, ...) a ## __VA_ARGS__
19
+#define SWITCH_ENABLED_0 0
20
+#define SWITCH_ENABLED_1 1
21
+#define SWITCH_ENABLED_  1
22
+#define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
23
+#define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b))
24
+
25
+#endif //__MACROS_H

+ 2
- 0
Marlin/stepper_indirection.h View File

@@ -22,6 +22,8 @@
22 22
 #ifndef STEPPER_INDIRECTION_H
23 23
 #define STEPPER_INDIRECTION_H
24 24
 
25
+#include "macros.h"
26
+
25 27
 // X motor
26 28
 #define X_STEP_INIT SET_OUTPUT(X_STEP_PIN)
27 29
 #define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)

Loading…
Cancel
Save