Browse Source

Moves all global enums to a central file

João Brázio 8 years ago
parent
commit
3ebad4e020

+ 2
- 29
Marlin/Marlin.h View File

@@ -50,6 +50,8 @@
50 50
 
51 51
 #include "Arduino.h"
52 52
 
53
+#include "enum.h"
54
+
53 55
 typedef unsigned long millis_t;
54 56
 
55 57
 #ifdef USBCON
@@ -230,20 +232,8 @@ void manage_inactivity(bool ignore_stepper_queue = false);
230 232
  * The axis order in all axis related arrays is X, Y, Z, E
231 233
  */
232 234
 #define NUM_AXIS 4
233
-
234
-/**
235
- * Axis indices as enumerated constants
236
- *
237
- * A_AXIS and B_AXIS are used by COREXY printers
238
- * X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship between X_AXIS and X Head movement, like CoreXY bots.
239
- */
240
-enum AxisEnum {NO_AXIS = -1, X_AXIS = 0, A_AXIS = 0, Y_AXIS = 1, B_AXIS = 1, Z_AXIS = 2, C_AXIS = 2, E_AXIS = 3, X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 5};
241
-
242 235
 #define _AXIS(AXIS) AXIS ##_AXIS
243 236
 
244
-typedef enum { LINEARUNIT_MM = 0, LINEARUNIT_INCH = 1 } LinearUnit;
245
-typedef enum { TEMPUNIT_C = 0, TEMPUNIT_K = 1, TEMPUNIT_F = 2 } TempUnit;
246
-
247 237
 void enable_all_steppers();
248 238
 void disable_all_steppers();
249 239
 
@@ -259,18 +249,6 @@ void quickstop_stepper();
259 249
   void handle_filament_runout();
260 250
 #endif
261 251
 
262
-/**
263
- * Debug flags - not yet widely applied
264
- */
265
-enum DebugFlags {
266
-  DEBUG_NONE          = 0,
267
-  DEBUG_ECHO          = _BV(0), ///< Echo commands in order as they are processed
268
-  DEBUG_INFO          = _BV(1), ///< Print messages for code that has debug output
269
-  DEBUG_ERRORS        = _BV(2), ///< Not implemented
270
-  DEBUG_DRYRUN        = _BV(3), ///< Ignore temperature setting and E movement commands
271
-  DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
272
-  DEBUG_LEVELING      = _BV(5)  ///< Print detailed output for homing and leveling
273
-};
274 252
 extern uint8_t marlin_debug_flags;
275 253
 #define DEBUGGING(F) (marlin_debug_flags & (DEBUG_## F))
276 254
 
@@ -380,11 +358,6 @@ float code_value_temp_diff();
380 358
 #endif
381 359
 
382 360
 #if ENABLED(FILAMENT_CHANGE_FEATURE)
383
-  enum FilamentChangeMenuResponse {
384
-    FILAMENT_CHANGE_RESPONSE_WAIT_FOR,
385
-    FILAMENT_CHANGE_RESPONSE_EXTRUDE_MORE,
386
-    FILAMENT_CHANGE_RESPONSE_RESUME_PRINT
387
-  };
388 361
   extern FilamentChangeMenuResponse filament_change_menu_response;
389 362
 #endif
390 363
 

+ 0
- 15
Marlin/MarlinSerial.cpp View File

@@ -455,21 +455,6 @@ MarlinSerial customizedSerial;
455 455
 
456 456
   FORCE_INLINE void emergency_parser(unsigned char c) {
457 457
 
458
-    enum e_parser_state {
459
-      state_RESET,
460
-      state_N,
461
-      state_M,
462
-      state_M1,
463
-      state_M10,
464
-      state_M108,
465
-      state_M11,
466
-      state_M112,
467
-      state_M4,
468
-      state_M41,
469
-      state_M410,
470
-      state_IGNORE // to '\n'
471
-    };
472
-
473 458
     static e_parser_state state = state_RESET;
474 459
 
475 460
     switch (state) {

+ 7
- 21
Marlin/Marlin_main.cpp View File

@@ -535,17 +535,6 @@ static bool send_ok[BUFSIZE];
535 535
 #endif
536 536
 
537 537
 #if ENABLED(HOST_KEEPALIVE_FEATURE)
538
-
539
-  // States for managing Marlin and host communication
540
-  // Marlin sends messages if blocked or busy
541
-  enum MarlinBusyState {
542
-    NOT_BUSY,           // Not in a handler
543
-    IN_HANDLER,         // Processing a GCode
544
-    IN_PROCESS,         // Known to be blocking command input (as in G29)
545
-    PAUSED_FOR_USER,    // Blocking pending any input
546
-    PAUSED_FOR_INPUT    // Blocking pending text input (concept)
547
-  };
548
-
549 538
   static MarlinBusyState busy_state = NOT_BUSY;
550 539
   static millis_t next_busy_signal_ms = 0;
551 540
   uint8_t host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
@@ -3213,9 +3202,6 @@ inline void gcode_G28() {
3213 3202
 #endif
3214 3203
 
3215 3204
 #if ENABLED(MESH_BED_LEVELING)
3216
-
3217
-  enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet, MeshSetZOffset, MeshReset };
3218
-
3219 3205
   inline void _mbl_goto_xy(float x, float y) {
3220 3206
     float old_feedrate_mm_m = feedrate_mm_m;
3221 3207
     feedrate_mm_m = homing_feedrate_mm_m[X_AXIS];
@@ -6825,7 +6811,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
6825 6811
             // <0 if the new nozzle is higher, >0 if lower. A bigger raise when lower.
6826 6812
             float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
6827 6813
                   z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
6828
-          
6814
+
6829 6815
             // Always raise by some amount
6830 6816
             planner.buffer_line(
6831 6817
               current_position[X_AXIS],
@@ -6836,10 +6822,10 @@ inline void gcode_T(uint8_t tmp_extruder) {
6836 6822
               active_extruder
6837 6823
             );
6838 6824
             stepper.synchronize();
6839
-          
6825
+
6840 6826
             move_extruder_servo(active_extruder);
6841 6827
             delay(500);
6842
-          
6828
+
6843 6829
             // Move back down, if needed
6844 6830
             if (z_raise != z_diff) {
6845 6831
               planner.buffer_line(
@@ -6853,7 +6839,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
6853 6839
               stepper.synchronize();
6854 6840
             }
6855 6841
           #endif
6856
-          
6842
+
6857 6843
           /**
6858 6844
            * Set current_position to the position of the new nozzle.
6859 6845
            * Offsets are based on linear distance, so we need to get
@@ -6906,7 +6892,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
6906 6892
             current_position[Z_AXIS] += offset_vec.z;
6907 6893
 
6908 6894
           #else // !AUTO_BED_LEVELING_FEATURE
6909
-  
6895
+
6910 6896
             float xydiff[2] = {
6911 6897
               hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
6912 6898
               hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
@@ -6930,7 +6916,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
6930 6916
               }
6931 6917
 
6932 6918
             #endif // MESH_BED_LEVELING
6933
-  
6919
+
6934 6920
           #endif // !AUTO_BED_LEVELING_FEATURE
6935 6921
 
6936 6922
           #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -6993,7 +6979,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
6993 6979
         SERIAL_ECHOLNPGM("<<< gcode_T");
6994 6980
       }
6995 6981
     #endif
6996
-  
6982
+
6997 6983
     SERIAL_ECHO_START;
6998 6984
     SERIAL_ECHOPGM(MSG_ACTIVE_EXTRUDER);
6999 6985
     SERIAL_PROTOCOLLN((int)active_extruder);

+ 1
- 1
Marlin/cardreader.h View File

@@ -28,7 +28,7 @@
28 28
 #define MAX_DIR_DEPTH 10          // Maximum folder depth
29 29
 
30 30
 #include "SdFile.h"
31
-enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
31
+#include "enum.h"
32 32
 
33 33
 class CardReader {
34 34
 public:

+ 2
- 2
Marlin/endstops.h View File

@@ -27,7 +27,7 @@
27 27
 #ifndef ENDSTOPS_H
28 28
 #define ENDSTOPS_H
29 29
 
30
-enum EndstopEnum {X_MIN = 0, Y_MIN = 1, Z_MIN = 2, Z_MIN_PROBE = 3, X_MAX = 4, Y_MAX = 5, Z_MAX = 6, Z2_MIN = 7, Z2_MAX = 8};
30
+#include "enum.h"
31 31
 
32 32
 class Endstops {
33 33
 
@@ -42,7 +42,7 @@ class Endstops {
42 42
       static byte
43 43
     #endif
44 44
         current_endstop_bits, old_endstop_bits;
45
-        
45
+
46 46
     Endstops() {};
47 47
 
48 48
     /**

+ 190
- 0
Marlin/enum.h View File

@@ -0,0 +1,190 @@
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
+
23
+#ifndef __ENUM_H__
24
+#define __ENUM_H__
25
+
26
+/**
27
+ * Axis indices as enumerated constants
28
+ *
29
+ * Special axis:
30
+ *  - A_AXIS and B_AXIS are used by COREXY printers
31
+ *  - X_HEAD and Y_HEAD is used for systems that don't have a 1:1 relationship
32
+ *    between X_AXIS and X Head movement, like CoreXY bots
33
+ */
34
+enum AxisEnum {
35
+  NO_AXIS = -1,
36
+  X_AXIS  = 0,
37
+  A_AXIS  = 0,
38
+  Y_AXIS  = 1,
39
+  B_AXIS  = 1,
40
+  Z_AXIS  = 2,
41
+  C_AXIS  = 2,
42
+  E_AXIS  = 3,
43
+  X_HEAD  = 4,
44
+  Y_HEAD  = 5,
45
+  Z_HEAD  = 5
46
+};
47
+
48
+typedef enum {
49
+  LINEARUNIT_MM,
50
+  LINEARUNIT_INCH
51
+} LinearUnit;
52
+
53
+typedef enum {
54
+  TEMPUNIT_C,
55
+  TEMPUNIT_K,
56
+  TEMPUNIT_F
57
+} TempUnit;
58
+
59
+/**
60
+ * Debug flags
61
+ * Not yet widely applied
62
+ */
63
+enum DebugFlags {
64
+  DEBUG_NONE          = 0,
65
+  DEBUG_ECHO          = _BV(0), ///< Echo commands in order as they are processed
66
+  DEBUG_INFO          = _BV(1), ///< Print messages for code that has debug output
67
+  DEBUG_ERRORS        = _BV(2), ///< Not implemented
68
+  DEBUG_DRYRUN        = _BV(3), ///< Ignore temperature setting and E movement commands
69
+  DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
70
+  DEBUG_LEVELING      = _BV(5)  ///< Print detailed output for homing and leveling
71
+};
72
+
73
+enum EndstopEnum {
74
+  X_MIN,
75
+  Y_MIN,
76
+  Z_MIN,
77
+  Z_MIN_PROBE,
78
+  X_MAX,
79
+  Y_MAX,
80
+  Z_MAX,
81
+  Z2_MIN,
82
+  Z2_MAX
83
+};
84
+
85
+/**
86
+ * Temperature
87
+ * Stages in the ISR loop
88
+ */
89
+enum TempState {
90
+  PrepareTemp_0,
91
+  MeasureTemp_0,
92
+  PrepareTemp_BED,
93
+  MeasureTemp_BED,
94
+  PrepareTemp_1,
95
+  MeasureTemp_1,
96
+  PrepareTemp_2,
97
+  MeasureTemp_2,
98
+  PrepareTemp_3,
99
+  MeasureTemp_3,
100
+  Prepare_FILWIDTH,
101
+  Measure_FILWIDTH,
102
+  StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
103
+};
104
+
105
+#if ENABLED(EMERGENCY_PARSER)
106
+  enum e_parser_state {
107
+    state_RESET,
108
+    state_N,
109
+    state_M,
110
+    state_M1,
111
+    state_M10,
112
+    state_M108,
113
+    state_M11,
114
+    state_M112,
115
+    state_M4,
116
+    state_M41,
117
+    state_M410,
118
+    state_IGNORE // to '\n'
119
+  };
120
+#endif
121
+
122
+#if ENABLED(FILAMENT_CHANGE_FEATURE)
123
+  enum FilamentChangeMenuResponse {
124
+    FILAMENT_CHANGE_RESPONSE_WAIT_FOR,
125
+    FILAMENT_CHANGE_RESPONSE_EXTRUDE_MORE,
126
+    FILAMENT_CHANGE_RESPONSE_RESUME_PRINT
127
+  };
128
+
129
+  #if ENABLED(ULTIPANEL)
130
+    enum FilamentChangeMessage {
131
+      FILAMENT_CHANGE_MESSAGE_INIT,
132
+      FILAMENT_CHANGE_MESSAGE_UNLOAD,
133
+      FILAMENT_CHANGE_MESSAGE_INSERT,
134
+      FILAMENT_CHANGE_MESSAGE_LOAD,
135
+      FILAMENT_CHANGE_MESSAGE_EXTRUDE,
136
+      FILAMENT_CHANGE_MESSAGE_OPTION,
137
+      FILAMENT_CHANGE_MESSAGE_RESUME,
138
+      FILAMENT_CHANGE_MESSAGE_STATUS
139
+    };
140
+  #endif
141
+#endif
142
+
143
+/**
144
+ * States for managing Marlin and host communication
145
+ * Marlin sends messages if blocked or busy
146
+ */
147
+#if ENABLED(HOST_KEEPALIVE_FEATURE)
148
+  enum MarlinBusyState {
149
+    NOT_BUSY,           // Not in a handler
150
+    IN_HANDLER,         // Processing a GCode
151
+    IN_PROCESS,         // Known to be blocking command input (as in G29)
152
+    PAUSED_FOR_USER,    // Blocking pending any input
153
+    PAUSED_FOR_INPUT    // Blocking pending text input (concept)
154
+  };
155
+#endif
156
+
157
+#if ENABLED(MESH_BED_LEVELING)
158
+  enum MeshLevelingState {
159
+    MeshReport,
160
+    MeshStart,
161
+    MeshNext,
162
+    MeshSet,
163
+    MeshSetZOffset,
164
+    MeshReset
165
+  };
166
+
167
+  enum MBLStatus {
168
+    MBL_STATUS_NONE = 0,
169
+    MBL_STATUS_HAS_MESH_BIT = 0,
170
+    MBL_STATUS_ACTIVE_BIT = 1
171
+  };
172
+#endif
173
+
174
+/**
175
+ * SD Card
176
+ */
177
+enum LsAction { LS_SerialPrint, LS_Count, LS_GetFilename };
178
+
179
+/**
180
+ * Ultra LCD
181
+ */
182
+enum LCDViewAction {
183
+  LCDVIEW_NONE,
184
+  LCDVIEW_REDRAW_NOW,
185
+  LCDVIEW_CALL_REDRAW_NEXT,
186
+  LCDVIEW_CLEAR_CALL_REDRAW,
187
+  LCDVIEW_CALL_NO_REDRAW
188
+};
189
+
190
+#endif // __ENUM_H__

+ 0
- 3
Marlin/mesh_bed_leveling.h View File

@@ -23,9 +23,6 @@
23 23
 #include "Marlin.h"
24 24
 
25 25
 #if ENABLED(MESH_BED_LEVELING)
26
-
27
-  enum MBLStatus { MBL_STATUS_NONE = 0, MBL_STATUS_HAS_MESH_BIT = 0, MBL_STATUS_ACTIVE_BIT = 1 };
28
-
29 26
   #define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X))/(MESH_NUM_X_POINTS - 1))
30 27
   #define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y))/(MESH_NUM_Y_POINTS - 1))
31 28
 

+ 0
- 19
Marlin/temperature.cpp View File

@@ -1343,25 +1343,6 @@ void Temperature::disable_all_heaters() {
1343 1343
 #endif //HEATER_0_USES_MAX6675
1344 1344
 
1345 1345
 /**
1346
- * Stages in the ISR loop
1347
- */
1348
-enum TempState {
1349
-  PrepareTemp_0,
1350
-  MeasureTemp_0,
1351
-  PrepareTemp_BED,
1352
-  MeasureTemp_BED,
1353
-  PrepareTemp_1,
1354
-  MeasureTemp_1,
1355
-  PrepareTemp_2,
1356
-  MeasureTemp_2,
1357
-  PrepareTemp_3,
1358
-  MeasureTemp_3,
1359
-  Prepare_FILWIDTH,
1360
-  Measure_FILWIDTH,
1361
-  StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
1362
-};
1363
-
1364
-/**
1365 1346
  * Get raw temperatures
1366 1347
  */
1367 1348
 void Temperature::set_current_temp_raw() {

+ 4
- 12
Marlin/ultralcd.cpp View File

@@ -54,14 +54,6 @@ static void lcd_status_screen();
54 54
 
55 55
 millis_t next_lcd_update_ms;
56 56
 
57
-enum LCDViewAction {
58
-  LCDVIEW_NONE,
59
-  LCDVIEW_REDRAW_NOW,
60
-  LCDVIEW_CALL_REDRAW_NEXT,
61
-  LCDVIEW_CLEAR_CALL_REDRAW,
62
-  LCDVIEW_CALL_NO_REDRAW
63
-};
64
-
65 57
 uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
66 58
 
67 59
 #if ENABLED(ULTIPANEL)
@@ -133,7 +125,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
133 125
     static void lcd_filament_change_load_message();
134 126
     static void lcd_filament_change_extrude_message();
135 127
     static void lcd_filament_change_resume_message();
136
-  #endif 
128
+  #endif
137 129
 
138 130
   #if HAS_LCD_CONTRAST
139 131
     static void lcd_set_contrast();
@@ -301,7 +293,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
301 293
    *             Scroll as-needed to keep the selected line in view.
302 294
    *
303 295
    * At this point _thisItemNr equals the total number of items.
304
-   * 
296
+   *
305 297
    */
306 298
 
307 299
   // Simple-scroll by using encoderLine as encoderTopLine
@@ -2207,7 +2199,7 @@ void kill_screen(const char* lcd_msg) {
2207 2199
       #endif
2208 2200
       END_SCREEN();
2209 2201
     }
2210
-  
2202
+
2211 2203
     void lcd_filament_change_show_message(FilamentChangeMessage message) {
2212 2204
       switch (message) {
2213 2205
         case FILAMENT_CHANGE_MESSAGE_INIT:
@@ -2507,7 +2499,7 @@ int lcd_strlen_P(const char* s) {
2507 2499
   int j = 0;
2508 2500
   while (pgm_read_byte(s)) {
2509 2501
     #ifdef MAPPER_NON
2510
-      j++; 
2502
+      j++;
2511 2503
     #else
2512 2504
       if ((pgm_read_byte(s) & 0xc0) != 0x80) j++;
2513 2505
     #endif

+ 0
- 10
Marlin/ultralcd.h View File

@@ -73,16 +73,6 @@
73 73
     void lcd_ignore_click(bool b=true);
74 74
 
75 75
     #if ENABLED(FILAMENT_CHANGE_FEATURE)
76
-      enum FilamentChangeMessage {
77
-        FILAMENT_CHANGE_MESSAGE_INIT,
78
-        FILAMENT_CHANGE_MESSAGE_UNLOAD,
79
-        FILAMENT_CHANGE_MESSAGE_INSERT,
80
-        FILAMENT_CHANGE_MESSAGE_LOAD,
81
-        FILAMENT_CHANGE_MESSAGE_EXTRUDE,
82
-        FILAMENT_CHANGE_MESSAGE_OPTION,
83
-        FILAMENT_CHANGE_MESSAGE_RESUME,
84
-        FILAMENT_CHANGE_MESSAGE_STATUS
85
-      };
86 76
       void lcd_filament_change_show_message(FilamentChangeMessage message);
87 77
     #endif // FILAMENT_CHANGE_FEATURE
88 78
 

Loading…
Cancel
Save