Browse Source

Merge pull request #3923 from thinkyhead/rc_statics_endstops

Apply static to Endstops class
Scott Lahteine 8 years ago
parent
commit
c3df293fc6
2 changed files with 43 additions and 25 deletions
  1. 28
    0
      Marlin/endstops.cpp
  2. 15
    25
      Marlin/endstops.h

+ 28
- 0
Marlin/endstops.cpp View File

@@ -36,6 +36,34 @@
36 36
 
37 37
 Endstops endstops;
38 38
 
39
+// public:
40
+
41
+bool  Endstops::enabled = true,
42
+      Endstops::enabled_globally =
43
+        #if ENABLED(ENDSTOPS_ONLY_FOR_HOMING)
44
+          false
45
+        #else
46
+          true
47
+        #endif
48
+      ;
49
+volatile char Endstops::endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
50
+
51
+#if ENABLED(Z_DUAL_ENDSTOPS)
52
+  uint16_t
53
+#else
54
+  byte
55
+#endif
56
+    Endstops::current_endstop_bits = 0,
57
+    Endstops::old_endstop_bits = 0;
58
+
59
+#if HAS_BED_PROBE
60
+  volatile bool Endstops::z_probe_enabled = false;
61
+#endif
62
+
63
+/**
64
+ * Class and Instance Methods
65
+ */
66
+
39 67
 Endstops::Endstops() {
40 68
   enable_globally(
41 69
     #if ENABLED(ENDSTOPS_ONLY_FOR_HOMING)

+ 15
- 25
Marlin/endstops.h View File

@@ -33,26 +33,16 @@ class Endstops {
33 33
 
34 34
   public:
35 35
 
36
-    volatile char endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
36
+    static bool enabled, enabled_globally;
37
+    static volatile char endstop_hit_bits; // use X_MIN, Y_MIN, Z_MIN and Z_MIN_PROBE as BIT value
37 38
 
38 39
     #if ENABLED(Z_DUAL_ENDSTOPS)
39
-      uint16_t current_endstop_bits = 0,
40
-                   old_endstop_bits = 0;
40
+      static uint16_t
41 41
     #else
42
-      byte current_endstop_bits = 0,
43
-               old_endstop_bits = 0;
42
+      static byte
44 43
     #endif
44
+        current_endstop_bits, old_endstop_bits;
45 45
         
46
-
47
-    bool enabled = true;
48
-    bool enabled_globally =
49
-      #if ENABLED(ENDSTOPS_ONLY_FOR_HOMING)
50
-        false
51
-      #else
52
-        true
53
-      #endif
54
-    ;
55
-
56 46
     Endstops();
57 47
 
58 48
     /**
@@ -63,40 +53,40 @@ class Endstops {
63 53
     /**
64 54
      * Update the endstops bits from the pins
65 55
      */
66
-    void update();
56
+    static void update();
67 57
 
68 58
     /**
69 59
      * Print an error message reporting the position when the endstops were last hit.
70 60
      */
71
-    void report_state(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
61
+    static void report_state(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
72 62
 
73 63
     /**
74 64
      * Report endstop positions in response to M119
75 65
      */
76
-    void M119();
66
+    static void M119();
77 67
 
78 68
     // Enable / disable endstop checking globally
79
-    FORCE_INLINE void enable_globally(bool onoff=true) { enabled_globally = enabled = onoff; }
69
+    static FORCE_INLINE void enable_globally(bool onoff=true) { enabled_globally = enabled = onoff; }
80 70
 
81 71
     // Enable / disable endstop checking
82
-    FORCE_INLINE void enable(bool onoff=true) { enabled = onoff; }
72
+    static FORCE_INLINE void enable(bool onoff=true) { enabled = onoff; }
83 73
 
84 74
     // Disable / Enable endstops based on ENSTOPS_ONLY_FOR_HOMING and global enable
85
-    FORCE_INLINE void not_homing() { enabled = enabled_globally; }
75
+    static FORCE_INLINE void not_homing() { enabled = enabled_globally; }
86 76
 
87 77
     // Clear endstops (i.e., they were hit intentionally) to suppress the report
88
-    FORCE_INLINE void hit_on_purpose() { endstop_hit_bits = 0; }
78
+    static FORCE_INLINE void hit_on_purpose() { endstop_hit_bits = 0; }
89 79
 
90 80
     // Enable / disable endstop z-probe checking
91 81
     #if HAS_BED_PROBE
92
-      volatile bool z_probe_enabled = false;
93
-      FORCE_INLINE void enable_z_probe(bool onoff=true) { z_probe_enabled = onoff; }
82
+      static volatile bool z_probe_enabled;
83
+      static FORCE_INLINE void enable_z_probe(bool onoff=true) { z_probe_enabled = onoff; }
94 84
     #endif
95 85
 
96 86
   private:
97 87
 
98 88
     #if ENABLED(Z_DUAL_ENDSTOPS)
99
-      void test_dual_z_endstops(EndstopEnum es1, EndstopEnum es2);
89
+      static void test_dual_z_endstops(EndstopEnum es1, EndstopEnum es2);
100 90
     #endif
101 91
 };
102 92
 

Loading…
Cancel
Save