Browse Source

Cleanup to emergency parser

Followup to #10516
Scott Lahteine 6 years ago
parent
commit
8cc31d1b2e
2 changed files with 42 additions and 42 deletions
  1. 30
    30
      Marlin/src/feature/emergency_parser.cpp
  2. 12
    12
      Marlin/src/feature/emergency_parser.h

+ 30
- 30
Marlin/src/feature/emergency_parser.cpp View File

33
 extern volatile bool wait_for_user, wait_for_heatup;
33
 extern volatile bool wait_for_user, wait_for_heatup;
34
 void quickstop_stepper();
34
 void quickstop_stepper();
35
 
35
 
36
-EmergencyParser::State EmergencyParser::state = EmergencyParser::State::RESET;
36
+EmergencyParser::State EmergencyParser::state = EP_RESET;
37
 bool EmergencyParser::killed_by_M112; // = false
37
 bool EmergencyParser::killed_by_M112; // = false
38
 
38
 
39
 EmergencyParser emergency_parser;
39
 EmergencyParser emergency_parser;
41
 void EmergencyParser::update(const uint8_t c) {
41
 void EmergencyParser::update(const uint8_t c) {
42
 
42
 
43
   switch (state) {
43
   switch (state) {
44
-    case EmergencyParser::State::RESET:
44
+    case EP_RESET:
45
       switch (c) {
45
       switch (c) {
46
         case ' ': break;
46
         case ' ': break;
47
-        case 'N': state = EmergencyParser::State::N;      break;
48
-        case 'M': state = EmergencyParser::State::M;      break;
49
-        default: state  = EmergencyParser::State::IGNORE;
47
+        case 'N': state = EP_N;      break;
48
+        case 'M': state = EP_M;      break;
49
+        default: state  = EP_IGNORE;
50
       }
50
       }
51
       break;
51
       break;
52
 
52
 
53
-    case EmergencyParser::State::N:
53
+    case EP_N:
54
       switch (c) {
54
       switch (c) {
55
         case '0': case '1': case '2':
55
         case '0': case '1': case '2':
56
         case '3': case '4': case '5':
56
         case '3': case '4': case '5':
57
         case '6': case '7': case '8':
57
         case '6': case '7': case '8':
58
         case '9': case '-': case ' ':   break;
58
         case '9': case '-': case ' ':   break;
59
-        case 'M': state = EmergencyParser::State::M;      break;
60
-        default:  state = EmergencyParser::State::IGNORE;
59
+        case 'M': state = EP_M;      break;
60
+        default:  state = EP_IGNORE;
61
       }
61
       }
62
       break;
62
       break;
63
 
63
 
64
-    case EmergencyParser::State::M:
64
+    case EP_M:
65
       switch (c) {
65
       switch (c) {
66
         case ' ': break;
66
         case ' ': break;
67
-        case '1': state = EmergencyParser::State::M1;     break;
68
-        case '4': state = EmergencyParser::State::M4;     break;
69
-        default: state  = EmergencyParser::State::IGNORE;
67
+        case '1': state = EP_M1;     break;
68
+        case '4': state = EP_M4;     break;
69
+        default: state  = EP_IGNORE;
70
       }
70
       }
71
       break;
71
       break;
72
 
72
 
73
-    case EmergencyParser::State::M1:
73
+    case EP_M1:
74
       switch (c) {
74
       switch (c) {
75
-        case '0': state = EmergencyParser::State::M10;    break;
76
-        case '1': state = EmergencyParser::State::M11;    break;
77
-        default: state  = EmergencyParser::State::IGNORE;
75
+        case '0': state = EP_M10;    break;
76
+        case '1': state = EP_M11;    break;
77
+        default: state  = EP_IGNORE;
78
       }
78
       }
79
       break;
79
       break;
80
 
80
 
81
-    case EmergencyParser::State::M10:
82
-      state = (c == '8') ? EmergencyParser::State::M108 : EmergencyParser::State::IGNORE;
81
+    case EP_M10:
82
+      state = (c == '8') ? EP_M108 : EP_IGNORE;
83
       break;
83
       break;
84
 
84
 
85
-    case EmergencyParser::State::M11:
86
-      state = (c == '2') ? EmergencyParser::State::M112 : EmergencyParser::State::IGNORE;
85
+    case EP_M11:
86
+      state = (c == '2') ? EP_M112 : EP_IGNORE;
87
       break;
87
       break;
88
 
88
 
89
-    case EmergencyParser::State::M4:
90
-      state = (c == '1') ? EmergencyParser::State::M41 : EmergencyParser::State::IGNORE;
89
+    case EP_M4:
90
+      state = (c == '1') ? EP_M41 : EP_IGNORE;
91
       break;
91
       break;
92
 
92
 
93
-    case EmergencyParser::State::M41:
94
-      state = (c == '0') ? EmergencyParser::State::M410 : EmergencyParser::State::IGNORE;
93
+    case EP_M41:
94
+      state = (c == '0') ? EP_M410 : EP_IGNORE;
95
       break;
95
       break;
96
 
96
 
97
-    case EmergencyParser::State::IGNORE:
98
-      if (c == '\n') state = EmergencyParser::State::RESET;
97
+    case EP_IGNORE:
98
+      if (c == '\n') state = EP_RESET;
99
       break;
99
       break;
100
 
100
 
101
     default:
101
     default:
102
       if (c == '\n') {
102
       if (c == '\n') {
103
         switch (state) {
103
         switch (state) {
104
-          case EmergencyParser::State::M108:
104
+          case EP_M108:
105
             wait_for_user = wait_for_heatup = false;
105
             wait_for_user = wait_for_heatup = false;
106
             break;
106
             break;
107
-          case EmergencyParser::State::M112:
107
+          case EP_M112:
108
             killed_by_M112 = true;
108
             killed_by_M112 = true;
109
             break;
109
             break;
110
-          case EmergencyParser::State::M410:
110
+          case EP_M410:
111
             quickstop_stepper();
111
             quickstop_stepper();
112
             break;
112
             break;
113
           default:
113
           default:
114
             break;
114
             break;
115
         }
115
         }
116
-        state = EmergencyParser::State::RESET;
116
+        state = EP_RESET;
117
       }
117
       }
118
   }
118
   }
119
 }
119
 }

+ 12
- 12
Marlin/src/feature/emergency_parser.h View File

31
 
31
 
32
   // Currently looking for: M108, M112, M410
32
   // Currently looking for: M108, M112, M410
33
   enum State : char {
33
   enum State : char {
34
-    RESET,
35
-    N,
36
-    M,
37
-    M1,
38
-    M10,
39
-    M108,
40
-    M11,
41
-    M112,
42
-    M4,
43
-    M41,
44
-    M410,
45
-    IGNORE // to '\n'
34
+    EP_RESET,
35
+    EP_N,
36
+    EP_M,
37
+    EP_M1,
38
+    EP_M10,
39
+    EP_M108,
40
+    EP_M11,
41
+    EP_M112,
42
+    EP_M4,
43
+    EP_M41,
44
+    EP_M410,
45
+    EP_IGNORE // to '\n'
46
   };
46
   };
47
 
47
 
48
 public:
48
 public:

Loading…
Cancel
Save