Bladeren bron

Cleanup to emergency parser

Followup to #10516
Scott Lahteine 6 jaren geleden
bovenliggende
commit
8cc31d1b2e
2 gewijzigde bestanden met toevoegingen van 42 en 42 verwijderingen
  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 Bestand weergeven

@@ -33,7 +33,7 @@
33 33
 extern volatile bool wait_for_user, wait_for_heatup;
34 34
 void quickstop_stepper();
35 35
 
36
-EmergencyParser::State EmergencyParser::state = EmergencyParser::State::RESET;
36
+EmergencyParser::State EmergencyParser::state = EP_RESET;
37 37
 bool EmergencyParser::killed_by_M112; // = false
38 38
 
39 39
 EmergencyParser emergency_parser;
@@ -41,79 +41,79 @@ EmergencyParser emergency_parser;
41 41
 void EmergencyParser::update(const uint8_t c) {
42 42
 
43 43
   switch (state) {
44
-    case EmergencyParser::State::RESET:
44
+    case EP_RESET:
45 45
       switch (c) {
46 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 51
       break;
52 52
 
53
-    case EmergencyParser::State::N:
53
+    case EP_N:
54 54
       switch (c) {
55 55
         case '0': case '1': case '2':
56 56
         case '3': case '4': case '5':
57 57
         case '6': case '7': case '8':
58 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 62
       break;
63 63
 
64
-    case EmergencyParser::State::M:
64
+    case EP_M:
65 65
       switch (c) {
66 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 71
       break;
72 72
 
73
-    case EmergencyParser::State::M1:
73
+    case EP_M1:
74 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 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 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 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 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 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 99
       break;
100 100
 
101 101
     default:
102 102
       if (c == '\n') {
103 103
         switch (state) {
104
-          case EmergencyParser::State::M108:
104
+          case EP_M108:
105 105
             wait_for_user = wait_for_heatup = false;
106 106
             break;
107
-          case EmergencyParser::State::M112:
107
+          case EP_M112:
108 108
             killed_by_M112 = true;
109 109
             break;
110
-          case EmergencyParser::State::M410:
110
+          case EP_M410:
111 111
             quickstop_stepper();
112 112
             break;
113 113
           default:
114 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 Bestand weergeven

@@ -31,18 +31,18 @@ class EmergencyParser {
31 31
 
32 32
   // Currently looking for: M108, M112, M410
33 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 48
 public:

Laden…
Annuleren
Opslaan